-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestAll.pyi
184 lines (147 loc) · 4.12 KB
/
testAll.pyi
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
print "\nTEST SCRIPT"
print "============"
print "\nBasic print"
print "-------------"
print "Print succesfull"
print f"Print formatting {'succesfull'}"
print "\nCore commands"
print "--------------"
var a 1
print f"{'OK ' if 1==a else 'FAIL'} var assignment"
if 2*3==6 skip
print "FAIL oneline branch (IF-command)"
label skip
print "OK oneline branch (IF-command)"
goto skip2
print "FAIL goto"
label skip2
print "OK goto"
gosub subproc1
print "OK return from sub"
print "NOT TESTED exit"
print "\nAssignements (var-command)"
print "-------------"
var a 1
var b 1+2
var c a+1
var d 2+a
var e a+b
var f "abc"
var g "def"+f
var h f+g
var t True
var s False
var u t&s
var v t|s
print f"{'OK ' if 1==a else 'FAIL'} var a 1 = {a} expected 1"
print f"{'OK ' if 3==b else 'FAIL'} var b 1+2 = {b} expected 3"
print f"{'OK ' if 2==c else 'FAIL'} var c a+1 = {c} expected 2"
print f"{'OK ' if 3==d else 'FAIL'} var d 2+a = {d} expected 3"
print f"{'OK ' if 4==e else 'FAIL'} var e a+b = {e} expected 4"
print f"{'OK ' if f=='abc' else 'FAIL'} var f \"abc\" = {f} expected 'abc':"
print f"{'OK ' if g=='defabc' else 'FAIL'} var g \"def\"+f = {g} expected 'defabc':"
print f"{'OK ' if h=='abcdefabc' else 'FAIL'} var h f+g = {h} expected 'abcdefabc':"
print f"{'OK ' if t==True else 'FAIL'} var t True = {t} expected True"
print f"{'OK ' if s==False else 'FAIL'} var s False = {s} expected False"
print f"{'OK ' if u==False else 'FAIL'} var u t&S = {u} expected False"
print f"{'OK ' if v==True else 'FAIL'} var v t|s = {v} expected True"
print "\nArithmetics"
print "------------"
print f"{'OK ' if 8==4*(1+2)/3+2**2 else 'FAIL'} 4*(1+2)/3+2**2 = {4*(1+2)/3+2**2} expected 8"
print f"{'OK ' if 8==e*(a+c)/b+c**c else 'FAIL'} e*(a+c)/b+c**c = {e*(a+c)/b+c**c} expected 8"
print f"{'OK ' if True==(2<3) else 'FAIL'} (2<3) = {(2<3)} expected True"
print f"{'OK ' if False==(2>3) else 'FAIL'} (2>3) = {(2>3)} expected False"
print f"{'OK ' if math.sin(3.1415)<0.001 else 'FAIL'} math.sin(3.1415) = {math.sin(3.1415)} expected <0.001"
print "\nSystem commands"
print "-----------"
print "\nMacros (if-command)"
print "-----------"
if False {
goto skip3
}
print ("OK if-multiline")
goto skip4
label skip3
print ("FAIL if-multiline)")
label skip4
a 0
if True {
a 1
}else{
a a+2
}
print f"{'OK ' if a==1 else 'FAIL'} if/else-multiline part if"
a 0
if False {
a 1
}else{
a a+2
}
print f"{'OK ' if a==2 else 'FAIL'} if/else-multiline part else"
var i 0
while (i<4) {
i i+1
}
print f"{'OK ' if (i==4) else 'FAIL'} while loop"
i 0
for x 0 9 3 {
i i+1
}
print f"{'OK ' if (i==3) else 'FAIL'} for loop"
i 0
for x 0 3 {
for y 0 3 {
i i+1
}
}
print f"{'OK ' if (i==9) else 'FAIL'} for nested loop"
print "\nSyntax"
print "------------"
var a (2+3)
print f"{'OK ' if a==5 else 'FAIL'} calc enclosed in ()"
var b (f"{'OK ' if a==5 else 'FAIL'} string enclosed in ()")
print b
if True skip5
print "FAIL multiple spaces between tokens"
goto skip6
label skip5
print "OK multiple spaces between tokens"
label skip6
print "\nOptional formatting"
print "------------"
var b = 1
print f"{'OK ' if b==1 else 'FAIL'} 'var b = 1'"
b = 2
print f"{'OK ' if b==2 else 'FAIL'} 'b = 2'"
var b = 1
for a = 1...3 : 2 {
b = b+1
}
print f"{'OK ' if b==2 else 'FAIL'} 'for a = 1...3 : 2 {'{'}'"
print "\nSystem Vars"
print "------------"
var p pi
print f"{'OK ' if (p-3.1415)<0.001 else 'FAIL'} calling system var with 'var p pi'"
sleep (1)
print "OK system (python) function sleep (and print) with statement 'sleep (1)'"
var m millis()
print "OK custom coded function with statement 'var m millis()'"
gosub subproc1
print "\n-----------------"
print f"Version: {version}"
print "\nEND SCRIPT"
print "============"
#print "\nError handling"
#print "------------"
#print "Unclosed loop
#if True {
#print "Unclosed string...
exit
#======================================
label subproc1
print ("OK gosub label")
gosub subproc2
return
sub subproc2
print ("OK gosub sub")
return