2
* Top-level parsing test - input for test_prs_top
12
for (iter = 0 ; iter < 5 ; ++iter)
17
tadsSay('iter[' + iter + ']: ' + i + '! = ' + j + '\n');
33
function test_unref_locals(x, y, z)
38
if (x = y) // note that this should get a warning about the assignment
40
if ((x = z) != 0) // should get no warning here
45
/* the outer 'i' should still be unreferenced */
48
/* the inner 'j' should be unreferenced, too */
56
return x * factorial(x-1);
61
function test_for_locals()
66
for (local i = 1, x = 'bye', local j = 'hello' ; i < 5 ; ++i, x += '!')
67
tadsSay('i = ' + i + ', j = ' + j + ', x = ' + x + '\n');
69
tadsSay('at outer scope: i = ' + i + '\n');
72
function test_break_cont()
74
for (local i = 1 ; i < 10 ; ++i)
76
tadsSay('test break - i = ' + i + '\n');
81
for (local i = 1 ; i < 10 ; ++i)
83
tadsSay('test continue - i = ' + i + '\n');
87
tadsSay('...not continuing this time!\n');
98
tadsSay('this is while loop iteration #' + i + '\n');
104
tadsSay('this is while loop 2 - iteration #' + i + '\n');
110
tadsSay('this is while loop 3 - iteration #' + i + '\n');
118
function test_do_while()
125
tadsSay('this is do loop - iteration #' + i + '\n');
130
tadsSay('this is do loop 2 - iteration #' + i + '\n');
139
tadsSay('this is do loop 3 - iteration #' + i + '\n');
147
function test_switch()
152
tadsSay('no breaks - i = ' + i + '\n');
171
tadsSay('default 1\n');
175
tadsSay('with breaks - i = ' + i + '\n');
202
/* this loop never terminates... */
207
/* ...so this statement is unreachable - we should get a warning */
215
* This function only returns with a value, because the end of the
216
* "for" is unreachable - we should NOT get a warning about
217
* returning with and without a value
228
* this function implicitly returns both with and without a value -
229
* we should get a warning about this
231
for (local i = 1, local j = 2 ; i < 100 ; ++i)
240
function test_label_break()
242
tadsSay('\bLabeled Break Test\b');
244
tadsSay('starting stm1:\n');
248
tadsSay('we\'re now in stm1...\n');
249
tadsSay('preparing to break...\n');
252
tadsSay('after the break???\n');
255
tadsSay('here we are after stm1\n');
257
tadsSay('starting stm2:\n');
260
for (local i = 1 ; i < 5 ; ++i)
262
tadsSay('\t- loop: i = ' + i + '\n');
267
/* this label is unreferenced - we should get a warning about it */
269
tadsSay('done with loop\n');
271
tadsSay('after stm2\n');
275
* required entrypoint function
279
tadsSay('... this is _main() ...\n');
281
tadsSay('... _main() exiting ...\n');