-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTESTS.txt
executable file
·244 lines (216 loc) · 2.77 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
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
1. A loop that counts from 1 to 9. This incorporates both if statements and while loops
{
int a
int b
string c
c = " "
a = 1
b = 0
while(a==1)
{
b = 1 + b
if(b==9)
{
c = " done looping"
a = 0
}
print(b)
print(c)
}
}
output = 1 2 3 4 5 6 7 8 9 done looping
1b. Infinite loop and booleans. Note that b = (b==false) is the same as b = !b
{
boolean a
a = true
boolean b
b = true
while (a == true)
{
if(b==true)
{
print("flip")
}
if(b==false)
{
print("flop")
}
b = (b == false)
}
output = flipflopflipflopflip....
2. counting above 100. Shows that the OS will only handle positive numbers up to 127
{
int a
int b
a = 1
b = 1
int c
c = 0
int d
d = 0
while(b==1)
{
a = 9 + a
c = 1 + c
if(c==9)
{
if(d==1)
{
b = 0
}
d = 1
}
print(a)
}
}
3. Demonstates scope
{
int a
a = 1
print(a)
{
a = 3
{
int a
a = 5
print(a)
}
}
print(a)
}
output = 153
4. Shows that strings can be reassigned to different lengths
{
string a
a = "alan "
print(a)
a = "alana "
print(a)
a = "a long string"
print(a)
}
output = alan alana a long string
5. Shows that ints are initialized as 0, and strings as the empty string
{
int a
string b
print(a)
print(b)
}
output = 0
6. Shows that you can cascade addition
{
int a
a = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + a
print(a)
}
output = 45
7. Infinite loop!
{
string l
l = "loop"
while true
{
print(l)
}
}
output = looplooplooploop...
8. The bodies of If and While statements work like any other scope.
{
int b
b = 9
string g
g = "global "
if true
{
string b
b = "local"
print(g)
}
print(b)
}
output = global 9
9. Boolean expressions:
{
boolean a
a = (1+3 == 0+2)
print(a)
}
outputs '0'
{
boolean a
a = (1+1 == 0+2)
print(a)
}
outputs '1'
10. Print stringExpr:
{
print("stringy")
}
output = stringy
11. Also, print stringExpr's of different lengths
{
print("a ")
print("ab ")
print("abc ")
print("ab ")
print("a")
}
output = a ab abc ab a
12. Variable assignment to strings:
{
string a
a = "alan"
if (1 == 2)
{
a = "blackstone"
}
print(a)
}
output = "alan"
13. Using booleans as variables:
{
{
boolean a
a = false
print(a)
boolean b
b = true
print(b)
if (b == true)
{
print("b is true")
}
}
output = 01b is true
14. More booleans as variables:
{
boolean a
a = (true == false)
print(a)
a = (2 == 1+1)
print(a)
a = (a == a)
print(a)
}
output = 011
NOT WORKING/ISSUES WARNINGS
1. Subtraction warning:
{
int a
a = 6
a = 1 - 2
}
2. Heap and code overlap:
{
string a
a = "this string is way too long for so few bytes"
print(a)
}
3. This is the only test I couldn't get working. I store a lot of values in the accumulator and S0XX, so I suspect that some value is getting lost somewhere.
{
boolean a
a = ((1 == 1) == (2 == 2))
print(a)
}
}