-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.txt
153 lines (117 loc) · 3.03 KB
/
tests.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
FUN add (INT a, INT b) => INT {:
a = a + b:)
RETURN a:)
:}
add(5, 10):) // valid function call
add(5, "a"):) // invalid function call - wrong data type error
add(5, 4, 3):) // invalid function call - num of parameters error
============================================================
// var declarations
integer_var => INT:)
double_var => DOUBLE:)
char_val => CHAR:)
bool_var => BOOL:)
str_var => STR:)
// var initializations
integer_var = 2 * 4:)
double_var = 2.0:)
char_val = 'c':)
bool_var = TRUE:) // or FALSE
str_var = "samPle12_":)
// array declarations
integer_arr => INT[10]:)
double_arr => DOUBLE[10]:)
char_arr => CHAR[10]:)
bool_arr => BOOL[10]:)
str_arr => STR[10]:)
integer_arr[0] = 0:)
integer_arr[1] = 1:)
IF (bool_var & double_var > 3.0 & integer_var >= 2) {: // false
str_arr[0] = "zero":)
PRINT(str_arr[0]):)
PRINTinteger_arr[0] + integer_arr[1]:)):)
:}
ELIF (bool_var) {: // true
str_arr[1] = "one":)
PRINTstr_arr[1]):)
:}
ELSE {:
str_arr [2] = "two":)
PRINTstr_arr[2]):)
:}
WHILE ( double_var < 10.0 ) {:
t => INT:) // not executed
:}
FUN add (INT a, INT b) => INT {: // redeclaration of function add
a = a + b:)
RETURN a:)
:}
===============================================================
x_arr => INT[2] :)
x_arr[0] = 2 :)
x_arr[1] = 3 :)
print(x_arr[0] + x_arr[1] = 3 :))
integer_arr => INT[10]:)
double_var => DOUBLE:)
double_arr => DOUBLE[10]:)
new_integer_var = integer_arr[3] :) // definition error
new_integer_var => INT :)
new_integer_var = integer_arr[3] :) // initalization error
new_integer_var[0] = 10:) // array / variable error
new_integer_var = double_var :) // wrong data type error
IF(double_var) {: // Not a logical statement !
PRINT(double_var) :)
:}
ELSE {:
new_integer_var = integer_arr[100]:) // wrong index error
:}
===============================================================
undefined_fun( 1, "a"):) // "function is not defined" error
IF ( 1 < "sample") // data type error {:
PRINT("Inside if"):)
:}
IF (TRUE < FALSE) // data type error {:
PRINT("Inside if"):)
:}
===============================================================
str_var => STR :)
str_var = "Hello" :)
IF(str == "Hello") {: // strings not allowed error
PRINT("Hi") :)
:}
=============================================================
new_integer_var => INT :)
new_integer_var = 10:)
IF(TRUE){: // Not a logical statement !
denominator => INT :)
denominator = new_integer_var - 10 :)
PRINT(denominator ):)
new_integer_var = new_integer_var / denominator :) // no division by zero
:}
============================================================
a => INT:)
b => INT:)
a = 10:)
b = a:)
a = a + b:)
PRINT(b) :)
a = a / b:)
PRINT(a) :)
b = a * b:)
PRINT(b) :)
b = a - b:)
PRINT(b) :)
============================================================
temperature => INT :)
temperature = 20 :)
is_bored => BOOL:)
is_bored = TRUE :)
IF(temperature > 25){:
PRINT("Too hot for a picnic day!") :)
:}
ELIF(temperature > 20 & is_bored) {:
PRINT("Today is the picnic day!) :)
:}
ELSE{:
PRINT("Not suitable for a picnic day!"):)
:}