191 |
191 |
192 |savedTranscript| |
192 |savedTranscript| |
193 |
193 |
194 savedTranscript := Transcript. |
194 savedTranscript := Transcript. |
195 [ |
195 [ |
196 Transcript := aStream. |
196 Transcript := aStream. |
197 aBlock value. |
197 aBlock value. |
198 ] ensure:[ |
198 ] ensure:[ |
199 Transcript := savedTranscript |
199 Transcript := savedTranscript |
200 ]. |
200 ]. |
201 ! ! |
201 ! ! |
202 |
202 |
203 !JavaScriptTests methodsFor:'tests'! |
203 !JavaScriptTests methodsFor:'tests'! |
204 |
204 |
205 testArray01 |
205 testArray01 |
206 self |
206 self |
207 execute:'test(arr) { |
207 execute:'test(arr) { |
208 return arr[1]; |
208 return arr[1]; |
209 }' |
209 }' |
210 for:nil |
210 for:nil |
211 arguments:#( #(10 20 30) ) |
211 arguments:#( #(10 20 30) ) |
212 expect:10 |
212 expect:10 |
213 |
213 |
214 " |
214 " |
215 self run:#testArray01 |
215 self run:#testArray01 |
216 self new testArray01 |
216 self new testArray01 |
217 " |
217 " |
218 ! |
218 ! |
219 |
219 |
220 testArray02 |
220 testArray02 |
221 self |
221 self |
222 execute:'test(arr) { |
222 execute:'test(arr) { |
223 arr[1]; |
223 arr[1]; |
224 }' |
224 }' |
225 for:nil |
225 for:nil |
226 arguments:#( #(10 20 30) ) |
226 arguments:#( #(10 20 30) ) |
227 expect:nil |
227 expect:nil |
228 |
228 |
229 " |
229 " |
230 self run:#testArray02 |
230 self run:#testArray02 |
231 self new testArray02 |
231 self new testArray02 |
232 " |
232 " |
233 |
233 |
234 "Modified: / 21-02-2007 / 13:02:39 / cg" |
234 "Modified: / 21-02-2007 / 13:02:39 / cg" |
235 ! |
235 ! |
236 |
236 |
237 testArray03 |
237 testArray03 |
238 self |
238 self |
239 execute:'test(arr, val) { |
239 execute:'test(arr, val) { |
240 arr[1] = val; |
240 arr[1] = val; |
241 return arr; |
241 return arr; |
242 }' |
242 }' |
243 for:nil |
243 for:nil |
244 arguments:#( #(10 20 30) 99 ) deepCopy "deepCopy - this is immutable" |
244 arguments:#( #(10 20 30) 99 ) deepCopy "deepCopy - this is immutable" |
245 expect:#(99 20 30) |
245 expect:#(99 20 30) |
246 |
246 |
247 " |
247 " |
248 self run:#testArray03 |
248 self run:#testArray03 |
249 self new testArray03 |
249 self new testArray03 |
250 " |
250 " |
251 ! |
251 ! |
252 |
252 |
253 testArray04 |
253 testArray04 |
254 self |
254 self |
255 execute:'test() { |
255 execute:'test() { |
256 var arr = new Array; |
256 var arr = new Array; |
257 return arr; |
257 return arr; |
258 }' |
258 }' |
259 for:nil |
259 for:nil |
260 arguments:#( ) |
260 arguments:#( ) |
261 expect:#() |
261 expect:#() |
262 |
262 |
263 " |
263 " |
264 self run:#testArray04 |
264 self run:#testArray04 |
265 self new testArray04 |
265 self new testArray04 |
266 " |
266 " |
267 |
267 |
268 "Modified: / 21-02-2007 / 13:03:22 / cg" |
268 "Modified: / 21-02-2007 / 13:03:22 / cg" |
269 ! |
269 ! |
270 |
270 |
271 testArray04a |
271 testArray04a |
272 self |
272 self |
273 execute:'test() { |
273 execute:'test() { |
274 var arr = new Array; |
274 var arr = new Array; |
275 return arr; |
275 return arr; |
276 }' |
276 }' |
277 for:nil |
277 for:nil |
278 arguments:#( ) |
278 arguments:#( ) |
279 expect:#() |
279 expect:#() |
280 |
280 |
281 " |
281 " |
282 self run:#testArray04a |
282 self run:#testArray04a |
283 self new testArray04a |
283 self new testArray04a |
284 " |
284 " |
285 |
285 |
286 "Created: / 21-02-2007 / 13:03:39 / cg" |
286 "Created: / 21-02-2007 / 13:03:39 / cg" |
287 ! |
287 ! |
288 |
288 |
289 testArray04b |
289 testArray04b |
290 self |
290 self |
291 execute:'test() { |
291 execute:'test() { |
292 var arr = Array.new; |
292 var arr = Array.new; |
293 return arr; |
293 return arr; |
294 }' |
294 }' |
295 for:nil |
295 for:nil |
296 arguments:#( ) |
296 arguments:#( ) |
297 expect:#() |
297 expect:#() |
298 |
298 |
299 " |
299 " |
300 self run:#testArray04b |
300 self run:#testArray04b |
301 self new testArray04b |
301 self new testArray04b |
302 " |
302 " |
303 |
303 |
304 "Created: / 21-02-2007 / 13:03:48 / cg" |
304 "Created: / 21-02-2007 / 13:03:48 / cg" |
305 ! |
305 ! |
306 |
306 |
307 testArray04c |
307 testArray04c |
308 self |
308 self |
309 execute:'test() { |
309 execute:'test() { |
310 var arr = Array.new(); |
310 var arr = Array.new(); |
311 return arr; |
311 return arr; |
312 }' |
312 }' |
313 for:nil |
313 for:nil |
314 arguments:#( ) |
314 arguments:#( ) |
315 expect:#() |
315 expect:#() |
316 |
316 |
317 " |
317 " |
318 self run:#testArray04c |
318 self run:#testArray04c |
319 self new testArray04c |
319 self new testArray04c |
320 " |
320 " |
321 |
321 |
322 "Created: / 21-02-2007 / 13:04:00 / cg" |
322 "Created: / 21-02-2007 / 13:04:00 / cg" |
323 ! |
323 ! |
324 |
324 |
325 testArray04d |
325 testArray04d |
326 self |
326 self |
327 execute:'test() { |
327 execute:'test() { |
328 var arr = new Array(); |
328 var arr = new Array(); |
329 return arr; |
329 return arr; |
330 }' |
330 }' |
331 for:nil |
331 for:nil |
332 arguments:#( ) |
332 arguments:#( ) |
333 expect:#() |
333 expect:#() |
334 |
334 |
335 " |
335 " |
336 self run:#testArray04d |
336 self run:#testArray04d |
337 self new testArray04d |
337 self new testArray04d |
338 " |
338 " |
339 |
339 |
340 "Created: / 21-02-2007 / 13:04:25 / cg" |
340 "Created: / 21-02-2007 / 13:04:25 / cg" |
341 ! |
341 ! |
342 |
342 |
343 testArray06a |
343 testArray06a |
344 self |
344 self |
345 execute:'test() { |
345 execute:'test() { |
346 var arr = new Array(5); |
346 var arr = new Array(5); |
347 return arr; |
347 return arr; |
348 }' |
348 }' |
349 for:nil |
349 for:nil |
350 arguments:#( ) |
350 arguments:#( ) |
351 expect:#( nil nil nil nil nil ) |
351 expect:#( nil nil nil nil nil ) |
352 |
352 |
353 " |
353 " |
354 self run:#testArray06a |
354 self run:#testArray06a |
355 self new testArray06a |
355 self new testArray06a |
356 " |
356 " |
357 |
357 |
358 "Created: / 21-02-2007 / 13:04:52 / cg" |
358 "Created: / 21-02-2007 / 13:04:52 / cg" |
359 ! |
359 ! |
360 |
360 |
361 testArray06b |
361 testArray06b |
362 self |
362 self |
363 execute:'test() { |
363 execute:'test() { |
364 var arr = Array.new(5); |
364 var arr = Array.new(5); |
365 return arr; |
365 return arr; |
366 }' |
366 }' |
367 for:nil |
367 for:nil |
368 arguments:#( ) |
368 arguments:#( ) |
369 expect:#( nil nil nil nil nil ) |
369 expect:#( nil nil nil nil nil ) |
370 |
370 |
371 " |
371 " |
372 self run:#testArray06b |
372 self run:#testArray06b |
373 self new testArray06b |
373 self new testArray06b |
374 " |
374 " |
375 |
375 |
376 "Created: / 21-02-2007 / 13:05:08 / cg" |
376 "Created: / 21-02-2007 / 13:05:08 / cg" |
377 ! |
377 ! |
378 |
378 |
379 testArray07 |
379 testArray07 |
380 self |
380 self |
381 execute:'test() { |
381 execute:'test() { |
382 var arr = new Array(3); |
382 var arr = new Array(3); |
383 arr[1] = 41; |
383 arr[1] = 41; |
384 arr[2] = -5; |
384 arr[2] = -5; |
385 arr[3] = 20; |
385 arr[3] = 20; |
386 return arr; |
386 return arr; |
387 }' |
387 }' |
388 for:nil |
388 for:nil |
389 arguments:#() |
389 arguments:#() |
390 expect:#( 41 -5 20 ). |
390 expect:#( 41 -5 20 ). |
391 |
391 |
392 " |
392 " |
393 self run:#testArray07 |
393 self run:#testArray07 |
394 self new testArray07 |
394 self new testArray07 |
395 " |
395 " |
396 ! |
396 ! |
397 |
397 |
398 testArray08 |
398 testArray08 |
399 self |
399 self |
400 execute:'test() { |
400 execute:'test() { |
401 var arr = new Array(3); |
401 var arr = new Array(3); |
402 arr[1] = 41; |
402 arr[1] = 41; |
403 arr[2] = -5; |
403 arr[2] = -5; |
404 arr[3] = 20; |
404 arr[3] = 20; |
405 return arr; |
405 return arr; |
406 }' |
406 }' |
407 for:nil |
407 for:nil |
408 arguments:#( ) |
408 arguments:#( ) |
409 expect:#( 41 -5 20 ) |
409 expect:#( 41 -5 20 ) |
410 |
410 |
411 " |
411 " |
412 self run:#testArray08 |
412 self run:#testArray08 |
413 self new testArray08 |
413 self new testArray08 |
414 " |
414 " |
415 ! |
415 ! |
416 |
416 |
417 testArray09 |
417 testArray09 |
418 self |
418 self |
419 execute:'test() { |
419 execute:'test() { |
420 var arr = [1,2,3]; |
420 var arr = [1,2,3]; |
421 return arr; |
421 return arr; |
422 }' |
422 }' |
423 for:nil |
423 for:nil |
424 arguments:#( ) |
424 arguments:#( ) |
425 expect:#( 1 2 3 ) |
425 expect:#( 1 2 3 ) |
426 |
426 |
427 " |
427 " |
428 self run:#testArray09 |
428 self run:#testArray09 |
429 self new testArray09 |
429 self new testArray09 |
430 " |
430 " |
431 |
431 |
432 "Created: / 21-02-2007 / 13:05:48 / cg" |
432 "Created: / 21-02-2007 / 13:05:48 / cg" |
433 ! |
433 ! |
434 |
434 |
435 testAssignmentExpression01 |
435 testAssignmentExpression01 |
436 self |
436 self |
437 execute:'assign(a, b) { |
437 execute:'assign(a, b) { |
438 var x, y; |
438 var x, y; |
439 |
439 |
440 x = y = 0; |
440 x = y = 0; |
441 x = y = a; |
441 x = y = a; |
442 x = y = b; |
442 x = y = b; |
443 return (x + y); |
443 return (x + y); |
444 }' |
444 }' |
445 for:nil |
445 for:nil |
446 arguments:#(10 20) |
446 arguments:#(10 20) |
447 expect:40 |
447 expect:40 |
448 |
448 |
449 " |
449 " |
450 self run:#testAssignmentExpression01 |
450 self run:#testAssignmentExpression01 |
451 self new testAssignmentExpression01 |
451 self new testAssignmentExpression01 |
452 " |
452 " |
453 ! |
453 ! |
454 |
454 |
455 testAssignmentExpression02 |
455 testAssignmentExpression02 |
456 "yes, in JS you can change an argument variable" |
456 "yes, in JS you can change an argument variable" |
457 |
457 |
458 self |
458 self |
459 execute:'assign(a, b) { |
459 execute:'assign(a, b) { |
460 var x, y; |
460 var x, y; |
461 |
461 |
462 a = x = y = 0; |
462 a = x = y = 0; |
463 return (a + b); |
463 return (a + b); |
464 }' |
464 }' |
465 for:nil |
465 for:nil |
466 arguments:#(10 20) |
466 arguments:#(10 20) |
467 expect:20 |
467 expect:20 |
468 |
468 |
469 " |
469 " |
470 self run:#testAssignmentExpression02 |
470 self run:#testAssignmentExpression02 |
471 self new testAssignmentExpression02 |
471 self new testAssignmentExpression02 |
472 " |
472 " |
473 ! |
473 ! |
474 |
474 |
475 testCommaExpression01 |
475 testCommaExpression01 |
476 self |
476 self |
477 execute:'comma(a, b, c) { |
477 execute:'comma(a, b, c) { |
478 return (a , b , c); |
478 return (a , b , c); |
479 }' |
479 }' |
480 for:nil |
480 for:nil |
481 arguments:#(10 20 30) |
481 arguments:#(10 20 30) |
482 expect:30 |
482 expect:30 |
483 |
483 |
484 " |
484 " |
485 self run:#testCommaExpression01 |
485 self run:#testCommaExpression01 |
486 self new testCommaExpression01 |
486 self new testCommaExpression01 |
487 " |
487 " |
488 ! |
488 ! |
489 |
489 |
490 testCommaExpression02 |
490 testCommaExpression02 |
491 self |
491 self |
492 execute:'comma(a, b, c) { |
492 execute:'comma(a, b, c) { |
493 return (a+10 , b+10 , c+10); |
493 return (a+10 , b+10 , c+10); |
494 }' |
494 }' |
495 for:nil |
495 for:nil |
496 arguments:#(10 20 30) |
496 arguments:#(10 20 30) |
497 expect:40 |
497 expect:40 |
498 |
498 |
499 " |
499 " |
500 self run:#testCommaExpression02 |
500 self run:#testCommaExpression02 |
501 self new testCommaExpression02 |
501 self new testCommaExpression02 |
502 " |
502 " |
503 ! |
503 ! |
504 |
504 |
505 testComments01 |
505 testComments01 |
506 |savedTranscript collector expected| |
506 |savedTranscript collector expected| |
507 |
507 |
508 savedTranscript := Smalltalk at:#Transcript. |
508 savedTranscript := Smalltalk at:#Transcript. |
509 [ |
509 [ |
510 Smalltalk at:#Transcript put:(collector := '' writeStream). |
510 Smalltalk at:#Transcript put:(collector := '' writeStream). |
511 self |
511 self |
512 execute:' |
512 execute:' |
513 testComments() { |
513 testComments() { |
514 // Unicode is allowed in comments |
514 // Unicode is allowed in comments |
515 // This is a comment \u0410\u0406\u0414\u0419 |
515 // This is a comment \u0410\u0406\u0414\u0419 |
678 |
678 |
679 testDoWhile05 |
679 testDoWhile05 |
680 |output| |
680 |output| |
681 |
681 |
682 output := self outputToTranscriptOf:[ |
682 output := self outputToTranscriptOf:[ |
683 self |
683 self |
684 execute:'test(arg) { |
684 execute:'test(arg) { |
685 var n; |
685 var n; |
686 |
686 |
687 n = 1; |
687 n = 1; |
688 do { |
688 do { |
689 if (++n == 3) break; |
689 if (++n == 3) break; |
690 Transcript.showCR(n); |
690 Transcript.showCR(n); |
691 } while (n <= 4); |
691 } while (n <= 4); |
692 return n; |
692 return n; |
693 }' |
693 }' |
694 for:nil |
694 for:nil |
695 arguments:#(5) |
695 arguments:#(5) |
696 expect:3 |
696 expect:3 |
697 ]. |
697 ]. |
698 self assert:(output asCollectionOfLinesWithReturn asArray = #( '2' )) |
698 self assert:(output asCollectionOfLinesWithReturn asArray = #( '2' )) |
699 |
699 |
700 " |
700 " |
701 self run:#testDoWhile05 |
701 self run:#testDoWhile05 |
702 self new testDoWhile05 |
702 self new testDoWhile05 |
703 " |
703 " |
704 ! |
704 ! |
705 |
705 |
706 testDoWhile06 |
706 testDoWhile06 |
707 self |
707 self |
708 execute:'test(arg) { |
708 execute:'test(arg) { |
709 var n; |
709 var n; |
710 |
710 |
711 n = 1; |
711 n = 1; |
712 do |
712 do |
713 n += 1; |
713 n += 1; |
714 while (n < 4); |
714 while (n < 4); |
715 return n; |
715 return n; |
716 }' |
716 }' |
717 for:nil |
717 for:nil |
718 arguments:#(5) |
718 arguments:#(5) |
719 expect:4 |
719 expect:4 |
720 |
720 |
721 " |
721 " |
722 self run:#testDoWhile06 |
722 self run:#testDoWhile06 |
723 self new testDoWhile06 |
723 self new testDoWhile06 |
724 " |
724 " |
725 ! |
725 ! |
726 |
726 |
727 testException01 |
727 testException01 |
728 self |
728 self |
729 execute:'test() { |
729 execute:'test() { |
730 try { |
730 try { |
731 return 10; |
731 return 10; |
732 } catch(Error); |
732 } catch(Error); |
733 return nil; |
733 return nil; |
734 }' |
734 }' |
735 for:nil |
735 for:nil |
736 arguments:#( ) |
736 arguments:#( ) |
737 expect:10 |
737 expect:10 |
738 |
738 |
739 " |
739 " |
740 self run:#testException01 |
740 self run:#testException01 |
741 self new testException01 |
741 self new testException01 |
742 " |
742 " |
743 |
743 |
744 "Modified: / 21-02-2007 / 10:28:50 / cg" |
744 "Modified: / 21-02-2007 / 10:28:50 / cg" |
745 ! |
745 ! |
746 |
746 |
747 testException02 |
747 testException02 |
748 self |
748 self |
749 execute:'test() { |
749 execute:'test() { |
750 try { |
750 try { |
751 Error.raise(); |
751 Error.raise(); |
752 return 10; |
752 return 10; |
753 } catch(Error); |
753 } catch(Error); |
754 return nil; |
754 return nil; |
755 }' |
755 }' |
756 for:nil |
756 for:nil |
757 arguments:#( ) |
757 arguments:#( ) |
758 expect:nil |
758 expect:nil |
759 |
759 |
760 " |
760 " |
761 self run:#testException02 |
761 self run:#testException02 |
762 self new testException02 |
762 self new testException02 |
763 " |
763 " |
764 ! |
764 ! |
765 |
765 |
766 testFor01 |
766 testFor01 |
767 |output| |
767 |output| |
768 |
768 |
769 output := self outputToTranscriptOf:[ |
769 output := self outputToTranscriptOf:[ |
770 self |
770 self |
771 execute:'test(arg) { |
771 execute:'test(arg) { |
772 var n; |
772 var n; |
773 |
773 |
774 for (n = 0; n < 10; n++) { |
774 for (n = 0; n < 10; n++) { |
775 Transcript.show("hello "); |
775 Transcript.show("hello "); |
776 Transcript.showCR(n); |
776 Transcript.showCR(n); |
777 } |
777 } |
778 }' |
778 }' |
779 for:nil |
779 for:nil |
780 arguments:#(5) |
780 arguments:#(5) |
781 expect:nil |
781 expect:nil |
782 ]. |
782 ]. |
783 self assert:(output asCollectionOfLinesWithReturn asArray = #( |
783 self assert:(output asCollectionOfLinesWithReturn asArray = #( |
784 'hello 0' |
784 'hello 0' |
785 'hello 1' |
785 'hello 1' |
786 'hello 2' |
786 'hello 2' |
787 'hello 3' |
787 'hello 3' |
788 'hello 4' |
788 'hello 4' |
789 'hello 5' |
789 'hello 5' |
790 'hello 6' |
790 'hello 6' |
791 'hello 7' |
791 'hello 7' |
792 'hello 8' |
792 'hello 8' |
793 'hello 9' )) |
793 'hello 9' )) |
794 |
794 |
795 " |
795 " |
796 self run:#testFor01 |
796 self run:#testFor01 |
797 self new testFor01 |
797 self new testFor01 |
798 " |
798 " |
799 ! |
799 ! |
800 |
800 |
801 testFor01b |
801 testFor01b |
802 |outStream output| |
802 |outStream output| |
803 |
803 |
804 outStream := '' writeStream. |
804 outStream := '' writeStream. |
805 |
805 |
806 self |
806 self |
807 execute:'test(arg, out) { |
807 execute:'test(arg, out) { |
808 var n; |
808 var n; |
809 |
809 |
810 for (n = 0; n < arg; n++) { |
810 for (n = 0; n < arg; n++) { |
811 out.show("hello "); |
811 out.show("hello "); |
812 out.showCR(n); |
812 out.showCR(n); |
813 } |
813 } |
814 }' |
814 }' |
815 for:nil |
815 for:nil |
816 arguments:(Array with:4 with:outStream) |
816 arguments:(Array with:4 with:outStream) |
817 expect:nil. |
817 expect:nil. |
818 |
818 |
819 output := outStream contents. |
819 output := outStream contents. |
820 self assert:(output = 'hello 0 |
820 self assert:(output = 'hello 0 |
821 hello 1 |
821 hello 1 |
822 hello 2 |
822 hello 2 |
823 hello 3 |
823 hello 3 |
824 '). |
824 '). |
825 |
825 |
826 " |
826 " |
827 self run:#testFor01b |
827 self run:#testFor01b |
828 self new testFor01b |
828 self new testFor01b |
829 " |
829 " |
830 ! |
830 ! |
831 |
831 |
832 testFor01c |
832 testFor01c |
833 self |
833 self |
834 execute:'test(arg) { |
834 execute:'test(arg) { |
835 var n, m; |
835 var n, m; |
836 |
836 |
837 for (n = 0, m = 10; n < 10; n++, m--) { |
837 for (n = 0, m = 10; n < 10; n++, m--) { |
838 Transcript.show(n); |
838 Transcript.show(n); |
839 Transcript.show(" -> "); |
839 Transcript.show(" -> "); |
840 Transcript.showCR(m); |
840 Transcript.showCR(m); |
841 } |
841 } |
842 }' |
842 }' |
843 for:nil |
843 for:nil |
844 arguments:#(5) |
844 arguments:#(5) |
845 expect:nil |
845 expect:nil |
846 |
846 |
847 " |
847 " |
848 self run:#testFor01c |
848 self run:#testFor01c |
849 self new testFor01c |
849 self new testFor01c |
850 " |
850 " |
851 ! |
851 ! |
852 |
852 |
853 testFor02 |
853 testFor02 |
854 |outStream output| |
854 |outStream output| |
855 |
855 |
856 outStream := '' writeStream. |
856 outStream := '' writeStream. |
857 |
857 |
858 self |
858 self |
859 execute:'test(arg, out) { |
859 execute:'test(arg, out) { |
860 var n; |
860 var n; |
861 |
861 |
862 for (n = 0; n < arg; n++) { |
862 for (n = 0; n < arg; n++) { |
863 out.show("hello "); |
863 out.show("hello "); |
864 out.showCR(n); |
864 out.showCR(n); |
865 } |
865 } |
866 }' |
866 }' |
867 for:nil |
867 for:nil |
868 arguments:(Array with:4 with:outStream) |
868 arguments:(Array with:4 with:outStream) |
869 expect:nil. |
869 expect:nil. |
870 |
870 |
871 output := outStream contents. |
871 output := outStream contents. |
872 self assert:(output = 'hello 0 |
872 self assert:(output = 'hello 0 |
873 hello 1 |
873 hello 1 |
874 hello 2 |
874 hello 2 |
875 hello 3 |
875 hello 3 |
876 '). |
876 '). |
877 |
877 |
878 " |
878 " |
879 self run:#testFor02 |
879 self run:#testFor02 |
880 self new testFor02 |
880 self new testFor02 |
881 " |
881 " |
882 ! |
882 ! |
883 |
883 |
884 testFor02b |
884 testFor02b |
885 |outStream output| |
885 |outStream output| |
886 |
886 |
887 outStream := '' writeStream. |
887 outStream := '' writeStream. |
888 |
888 |
889 self |
889 self |
890 execute:'test(arg, out) { |
890 execute:'test(arg, out) { |
891 var n; |
891 var n; |
892 |
892 |
893 for (n = 0; n < arg; ) { |
893 for (n = 0; n < arg; ) { |
894 out.show("hello "); |
894 out.show("hello "); |
895 out.showCR(n++); |
895 out.showCR(n++); |
896 } |
896 } |
897 }' |
897 }' |
898 for:nil |
898 for:nil |
899 arguments:(Array with:4 with:outStream) |
899 arguments:(Array with:4 with:outStream) |
900 expect:nil. |
900 expect:nil. |
901 |
901 |
902 output := outStream contents. |
902 output := outStream contents. |
903 self assert:(output = 'hello 0 |
903 self assert:(output = 'hello 0 |
904 hello 1 |
904 hello 1 |
905 hello 2 |
905 hello 2 |
906 hello 3 |
906 hello 3 |
907 '). |
907 '). |
908 |
908 |
909 " |
909 " |
910 self run:#testFor02b |
910 self run:#testFor02b |
911 self new testFor02b |
911 self new testFor02b |
912 " |
912 " |
913 ! |
913 ! |
914 |
914 |
915 testFor03b |
915 testFor03b |
916 |outStream output| |
916 |outStream output| |
917 |
917 |
918 outStream := '' writeStream. |
918 outStream := '' writeStream. |
919 |
919 |
920 self |
920 self |
921 execute:'test(arg, out) { |
921 execute:'test(arg, out) { |
922 var n = 0; |
922 var n = 0; |
923 |
923 |
924 for (; n < arg; ) { |
924 for (; n < arg; ) { |
925 out.show("hello "); |
925 out.show("hello "); |
926 out.showCR(n++); |
926 out.showCR(n++); |
927 } |
927 } |
928 }' |
928 }' |
929 for:nil |
929 for:nil |
930 arguments:(Array with:4 with:outStream) |
930 arguments:(Array with:4 with:outStream) |
931 expect:nil. |
931 expect:nil. |
932 |
932 |
933 output := outStream contents. |
933 output := outStream contents. |
934 self assert:(output = 'hello 0 |
934 self assert:(output = 'hello 0 |
935 hello 1 |
935 hello 1 |
936 hello 2 |
936 hello 2 |
937 hello 3 |
937 hello 3 |
938 '). |
938 '). |
939 |
939 |
940 " |
940 " |
941 self run:#testFor03b |
941 self run:#testFor03b |
942 self new testFor03b |
942 self new testFor03b |
943 " |
943 " |
944 ! |
944 ! |
945 |
945 |
946 testFor04b |
946 testFor04b |
947 |outStream output| |
947 |outStream output| |
948 |
948 |
949 outStream := '' writeStream. |
949 outStream := '' writeStream. |
950 |
950 |
951 self |
951 self |
952 execute:'test(arg, out) { |
952 execute:'test(arg, out) { |
953 var n = 0; |
953 var n = 0; |
954 |
954 |
955 for (; ; ) { |
955 for (; ; ) { |
956 if (n >= arg) return; |
956 if (n >= arg) return; |
957 out.show("hello "); |
957 out.show("hello "); |
958 out.showCR(n++); |
958 out.showCR(n++); |
959 } |
959 } |
960 }' |
960 }' |
961 for:nil |
961 for:nil |
962 arguments:(Array with:4 with:outStream) |
962 arguments:(Array with:4 with:outStream) |
963 expect:nil. |
963 expect:nil. |
964 |
964 |
965 output := outStream contents. |
965 output := outStream contents. |
966 self assert:(output = 'hello 0 |
966 self assert:(output = 'hello 0 |
967 hello 1 |
967 hello 1 |
968 hello 2 |
968 hello 2 |
969 hello 3 |
969 hello 3 |
970 '). |
970 '). |
971 |
971 |
972 " |
972 " |
973 self run:#testFor04b |
973 self run:#testFor04b |
974 self new testFor04b |
974 self new testFor04b |
975 " |
975 " |
976 ! |
976 ! |
977 |
977 |
978 testFor05 |
978 testFor05 |
979 |savedTranscript collector expected| |
979 |savedTranscript collector expected| |
980 |
980 |
981 savedTranscript := Smalltalk at:#Transcript. |
981 savedTranscript := Smalltalk at:#Transcript. |
982 [ |
982 [ |
983 Smalltalk at:#Transcript put:(collector := '' writeStream). |
983 Smalltalk at:#Transcript put:(collector := '' writeStream). |
984 self |
984 self |
985 execute:'test(arg) { |
985 execute:'test(arg) { |
986 for (var n = 0; n < arg; n++) { |
986 for (var n = 0; n < arg; n++) { |
987 Transcript.showCR(n); |
987 Transcript.showCR(n); |
988 } |
988 } |
989 }' |
989 }' |
990 for:nil |
990 for:nil |
991 arguments:#(5) |
991 arguments:#(5) |
992 expect:nil |
992 expect:nil |
993 ] ensure:[ |
993 ] ensure:[ |
994 Smalltalk at:#Transcript put:savedTranscript |
994 Smalltalk at:#Transcript put:savedTranscript |
995 ]. |
995 ]. |
996 |
996 |
997 expected := String streamContents:[:s | 0 to:4 do:[:n | s showCR:n]]. |
997 expected := String streamContents:[:s | 0 to:4 do:[:n | s showCR:n]]. |
998 self assert:(collector contents = expected). |
998 self assert:(collector contents = expected). |
999 |
999 |
1000 " |
1000 " |
1001 self run:#testFor05 |
1001 self run:#testFor05 |
1002 self new testFor05 |
1002 self new testFor05 |
1003 " |
1003 " |
1004 ! |
1004 ! |
1005 |
1005 |
1006 testFor05b |
1006 testFor05b |
1007 |outStream output| |
1007 |outStream output| |
1008 |
1008 |
1009 outStream := '' writeStream. |
1009 outStream := '' writeStream. |
1010 |
1010 |
1011 self |
1011 self |
1012 execute:'test(arg, out) { |
1012 execute:'test(arg, out) { |
1013 var n = 0; |
1013 var n = 0; |
1014 |
1014 |
1015 for (; ; ) { |
1015 for (; ; ) { |
1016 if (n >= arg) break; |
1016 if (n >= arg) break; |
1017 out.show("hello "); |
1017 out.show("hello "); |
1018 out.showCR(n++); |
1018 out.showCR(n++); |
1019 } |
1019 } |
1020 }' |
1020 }' |
1021 for:nil |
1021 for:nil |
1022 arguments:(Array with:4 with:outStream) |
1022 arguments:(Array with:4 with:outStream) |
1023 expect:nil. |
1023 expect:nil. |
1024 |
1024 |
1025 output := outStream contents. |
1025 output := outStream contents. |
1026 self assert:(output = 'hello 0 |
1026 self assert:(output = 'hello 0 |
1027 hello 1 |
1027 hello 1 |
1028 hello 2 |
1028 hello 2 |
1029 hello 3 |
1029 hello 3 |
1030 '). |
1030 '). |
1031 |
1031 |
1032 " |
1032 " |
1033 self run:#testFor05b |
1033 self run:#testFor05b |
1034 self new testFor05b |
1034 self new testFor05b |
1035 " |
1035 " |
1036 ! |
1036 ! |
1037 |
1037 |
1038 testFor05c |
1038 testFor05c |
1039 |output| |
1039 |output| |
1040 |
1040 |
1041 output := '' writeStream. |
1041 output := '' writeStream. |
1042 self |
1042 self |
1043 execute:'test(arg, out) { |
1043 execute:'test(arg, out) { |
1044 var n = 0; |
1044 var n = 0; |
1045 |
1045 |
1046 for (; ; ) { |
1046 for (; ; ) { |
1047 if (n >= arg) break; |
1047 if (n >= arg) break; |
1048 out.show("hello "); |
1048 out.show("hello "); |
1049 out.showCR(n++); |
1049 out.showCR(n++); |
1050 } |
1050 } |
1051 }' |
1051 }' |
1052 for:nil |
1052 for:nil |
1053 arguments:(Array with:4 with:output) |
1053 arguments:(Array with:4 with:output) |
1054 expect:nil. |
1054 expect:nil. |
1055 |
1055 |
1056 self assert:(output contents asCollectionOfLinesWithReturn asArray = #( |
1056 self assert:(output contents asCollectionOfLinesWithReturn asArray = #( |
1057 'hello 0' |
1057 'hello 0' |
1058 'hello 1' |
1058 'hello 1' |
1059 'hello 2' |
1059 'hello 2' |
1060 'hello 3')) |
1060 'hello 3')) |
1061 |
1061 |
1062 " |
1062 " |
1063 self run:#testFor05c |
1063 self run:#testFor05c |
1064 self new testFor05c |
1064 self new testFor05c |
1065 " |
1065 " |
1066 ! |
1066 ! |
1067 |
1067 |
1068 testFor05d |
1068 testFor05d |
1069 |output| |
1069 |output| |
1070 |
1070 |
1071 output := '' writeStream. |
1071 output := '' writeStream. |
1072 self |
1072 self |
1073 execute:'test(arg, out) { |
1073 execute:'test(arg, out) { |
1074 var n = 0; |
1074 var n = 0; |
1075 |
1075 |
1076 for (; ; ) { |
1076 for (; ; ) { |
1077 n++; |
1077 n++; |
1078 if (n >= arg) break; |
1078 if (n >= arg) break; |
1079 if (n == 2) continue; |
1079 if (n == 2) continue; |
1080 out.show("hello "); |
1080 out.show("hello "); |
1081 out.showCR(n); |
1081 out.showCR(n); |
1082 } |
1082 } |
1083 }' |
1083 }' |
1084 for:nil |
1084 for:nil |
1085 arguments:(Array with:5 with:output) |
1085 arguments:(Array with:5 with:output) |
1086 expect:nil. |
1086 expect:nil. |
1087 |
1087 |
1088 self assert:(output contents asCollectionOfLinesWithReturn asArray = #( |
1088 self assert:(output contents asCollectionOfLinesWithReturn asArray = #( |
1089 'hello 1' |
1089 'hello 1' |
1090 'hello 3' |
1090 'hello 3' |
1091 'hello 4' )) |
1091 'hello 4' )) |
1092 |
1092 |
1093 " |
1093 " |
1094 self run:#testFor05d |
1094 self run:#testFor05d |
1095 self new testFor05d |
1095 self new testFor05d |
1096 " |
1096 " |
1097 ! |
1097 ! |
1098 |
1098 |
1099 testFor06 |
1099 testFor06 |
1100 |output| |
1100 |output| |
1101 |
1101 |
1102 output := '' writeStream. |
1102 output := '' writeStream. |
1103 self |
1103 self |
1104 execute:'test(arg, out) { |
1104 execute:'test(arg, out) { |
1105 for (var n = 0, var m = 10; n < 10; n++, m--) { |
1105 for (var n = 0, var m = 10; n < 10; n++, m--) { |
1106 out.show(n); |
1106 out.show(n); |
1107 out.show(" -> "); |
1107 out.show(" -> "); |
1108 out.showCR(m); |
1108 out.showCR(m); |
1109 } |
1109 } |
1110 }' |
1110 }' |
1111 for:nil |
1111 for:nil |
1112 arguments:(Array with:5 with:output) |
1112 arguments:(Array with:5 with:output) |
1113 expect:nil. |
1113 expect:nil. |
1114 |
1114 |
1115 self assert:(output contents asCollectionOfLinesWithReturn asArray = #( |
1115 self assert:(output contents asCollectionOfLinesWithReturn asArray = #( |
1116 '0 -> 10' |
1116 '0 -> 10' |
1117 '1 -> 9' |
1117 '1 -> 9' |
1118 '2 -> 8' |
1118 '2 -> 8' |
1119 '3 -> 7' |
1119 '3 -> 7' |
1120 '4 -> 6' |
1120 '4 -> 6' |
1121 '5 -> 5' |
1121 '5 -> 5' |
1122 '6 -> 4' |
1122 '6 -> 4' |
1123 '7 -> 3' |
1123 '7 -> 3' |
1124 '8 -> 2' |
1124 '8 -> 2' |
1125 '9 -> 1' |
1125 '9 -> 1' |
1126 )) |
1126 )) |
1127 |
1127 |
1128 " |
1128 " |
1129 self run:#testFor06 |
1129 self run:#testFor06 |
1130 self new testFor06 |
1130 self new testFor06 |
1131 " |
1131 " |
1132 ! |
1132 ! |
1133 |
1133 |
1134 testFor07 |
1134 testFor07 |
1135 |output| |
1135 |output| |
1136 |
1136 |
1137 output := '' writeStream. |
1137 output := '' writeStream. |
1138 self |
1138 self |
1139 execute:'test(arg, out) { |
1139 execute:'test(arg, out) { |
1140 for (var n = 0, var m = 10; n < 10; n++, m--) { |
1140 for (var n = 0, var m = 10; n < 10; n++, m--) { |
1141 if ((n >= 3) && (n <= 6)) { |
1141 if ((n >= 3) && (n <= 6)) { |
1142 out.show(n); |
1142 out.show(n); |
1143 out.show(" -> "); |
1143 out.show(" -> "); |
1144 out.showCR(m); |
1144 out.showCR(m); |
1145 } |
1145 } |
1146 } |
1146 } |
1147 }' |
1147 }' |
1148 for:nil |
1148 for:nil |
1149 arguments:(Array with:5 with:output) |
1149 arguments:(Array with:5 with:output) |
1150 expect:nil. |
1150 expect:nil. |
1151 |
1151 |
1152 self assert:(output contents asCollectionOfLinesWithReturn asArray = #( |
1152 self assert:(output contents asCollectionOfLinesWithReturn asArray = #( |
1153 '3 -> 7' |
1153 '3 -> 7' |
1154 '4 -> 6' |
1154 '4 -> 6' |
1155 '5 -> 5' |
1155 '5 -> 5' |
1156 '6 -> 4' |
1156 '6 -> 4' |
1157 )) |
1157 )) |
1158 |
1158 |
1159 " |
1159 " |
1160 self run:#testFor06 |
1160 self run:#testFor06 |
1161 self new testFor06 |
1161 self new testFor06 |
1162 " |
1162 " |
1163 ! |
1163 ! |
1164 |
1164 |
1165 testFor08 |
1165 testFor08 |
1166 |output| |
1166 |output| |
1167 |
1167 |
1168 output := '' writeStream. |
1168 output := '' writeStream. |
1169 self |
1169 self |
1170 execute:'test(arg, out) { |
1170 execute:'test(arg, out) { |
1171 var x = 10; |
1171 var x = 10; |
1172 |
1172 |
1173 for (var n = 0, var m = 10; n < 10; n++, m--) { |
1173 for (var n = 0, var m = 10; n < 10; n++, m--) { |
1174 if ((n >= 3) && (n <= 6)) { |
1174 if ((n >= 3) && (n <= 6)) { |
1175 if ((n >= 4) && (n <= 5)) { |
1175 if ((n >= 4) && (n <= 5)) { |
1176 out.show(n); |
1176 out.show(n); |
1177 out.show(" -> "); |
1177 out.show(" -> "); |
1178 out.showCR(m); |
1178 out.showCR(m); |
1179 } |
1179 } |
1180 } |
1180 } |
1181 } |
1181 } |
1182 }' |
1182 }' |
1183 for:nil |
1183 for:nil |
1184 arguments:(Array with:5 with:output) |
1184 arguments:(Array with:5 with:output) |
1185 expect:nil. |
1185 expect:nil. |
1186 |
1186 |
1187 self assert:(output contents asCollectionOfLinesWithReturn asArray = #( |
1187 self assert:(output contents asCollectionOfLinesWithReturn asArray = #( |
1188 '4 -> 6' |
1188 '4 -> 6' |
1189 '5 -> 5' |
1189 '5 -> 5' |
1190 )) |
1190 )) |
1191 |
1191 |
1192 " |
1192 " |
1193 self run:#testFor06 |
1193 self run:#testFor06 |
1194 self new testFor06 |
1194 self new testFor06 |
1195 " |
1195 " |
1196 ! |
1196 ! |
1197 |
1197 |
1198 testForIn01 |
1198 testForIn01 |
1199 |output| |
1199 |output| |
1200 |
1200 |
1201 JavaScriptParser forInAllowed ifFalse:[^ self]. |
1201 JavaScriptParser forInAllowed ifFalse:[^ self]. |
1202 |
1202 |
1203 output := self outputToTranscriptOf:[ |
1203 output := self outputToTranscriptOf:[ |
1204 self |
1204 self |
1205 execute:'test(arg) { |
1205 execute:'test(arg) { |
1206 var arr = [ "one", "two", "three" ]; |
1206 var arr = [ "one", "two", "three" ]; |
1207 |
1207 |
1208 for (var el in arr) { |
1208 for (var el in arr) { |
1209 Transcript.showCR(el); |
1209 Transcript.showCR(el); |
1210 } |
1210 } |
1211 }' |
1211 }' |
1212 for:nil |
1212 for:nil |
1213 arguments:#(5) |
1213 arguments:#(5) |
1214 expect:nil |
1214 expect:nil |
1215 ]. |
1215 ]. |
1216 |
1216 |
1217 self assert:(output asCollectionOfLinesWithReturn asArray = #( 'one' 'two' 'three' )) |
1217 self assert:(output asCollectionOfLinesWithReturn asArray = #( 'one' 'two' 'three' )) |
1218 |
1218 |
1219 " |
1219 " |
1220 self run:#testForIn01 |
1220 self run:#testForIn01 |
1221 self new testForIn01 |
1221 self new testForIn01 |
1222 " |
1222 " |
1223 ! |
1223 ! |
1224 |
1224 |
1225 testForIn02 |
1225 testForIn02 |
1226 |output| |
1226 |output| |
1227 |
1227 |
1228 JavaScriptParser forInAllowed ifFalse:[^ self]. |
1228 JavaScriptParser forInAllowed ifFalse:[^ self]. |
1229 |
1229 |
1230 output := '' writeStream. |
1230 output := '' writeStream. |
1231 self |
1231 self |
1232 execute:'test(arg, output) { |
1232 execute:'test(arg, output) { |
1233 var sum = 0; |
1233 var sum = 0; |
1234 |
1234 |
1235 for (var el in arg) { |
1235 for (var el in arg) { |
1236 var last = el; |
1236 var last = el; |
1237 output.showCR(el*el); |
1237 output.showCR(el*el); |
1238 sum += el; |
1238 sum += el; |
1239 last = sum; |
1239 last = sum; |
1240 } |
1240 } |
1241 return last; |
1241 return last; |
1242 }' |
1242 }' |
1243 for:nil |
1243 for:nil |
1244 arguments:( Array with:#(1 2 3) with:output) |
1244 arguments:( Array with:#(1 2 3) with:output) |
1245 expect:6. |
1245 expect:6. |
1246 |
1246 |
1247 self assert:(output contents asCollectionOfLinesWithReturn asArray = #( |
1247 self assert:(output contents asCollectionOfLinesWithReturn asArray = #( |
1248 '1' |
1248 '1' |
1249 '4' |
1249 '4' |
1250 '9' |
1250 '9' |
1251 )) |
1251 )) |
1252 |
1252 |
1253 " |
1253 " |
1254 self run:#testForIn01 |
1254 self run:#testForIn01 |
1255 self new testForIn01 |
1255 self new testForIn01 |
1256 " |
1256 " |
1257 ! |
1257 ! |
1258 |
1258 |
1259 testForIn03 |
1259 testForIn03 |
1260 |output| |
1260 |output| |
1261 |
1261 |
1262 JavaScriptParser forInAllowed ifFalse:[^ self]. |
1262 JavaScriptParser forInAllowed ifFalse:[^ self]. |
1263 |
1263 |
1264 output := '' writeStream. |
1264 output := '' writeStream. |
1265 self |
1265 self |
1266 execute:'test(arg, output) { |
1266 execute:'test(arg, output) { |
1267 var sum = 0; |
1267 var sum = 0; |
1268 |
1268 |
1269 for (var el in arg) { |
1269 for (var el in arg) { |
1270 output.showCR(el*el); |
1270 output.showCR(el*el); |
1271 if (el == 1) continue; |
1271 if (el == 1) continue; |
1272 sum += el; |
1272 sum += el; |
1273 if (el == 2) break; |
1273 if (el == 2) break; |
1274 } |
1274 } |
1275 return sum; |
1275 return sum; |
1276 }' |
1276 }' |
1277 for:nil |
1277 for:nil |
1278 arguments:( Array with:#(1 2 3) with:output) |
1278 arguments:( Array with:#(1 2 3) with:output) |
1279 expect:2. |
1279 expect:2. |
1280 |
1280 |
1281 self assert:(output contents asCollectionOfLinesWithReturn asArray = #( |
1281 self assert:(output contents asCollectionOfLinesWithReturn asArray = #( |
1282 '1' |
1282 '1' |
1283 '4' |
1283 '4' |
1284 )) |
1284 )) |
1285 |
1285 |
1286 " |
1286 " |
1287 self run:#testForIn01 |
1287 self run:#testForIn01 |
1288 self new testForIn01 |
1288 self new testForIn01 |
1289 " |
1289 " |
1290 ! |
1290 ! |
1291 |
1291 |
1292 testForIn04 |
1292 testForIn04 |
1293 |output| |
1293 |output| |
1294 |
1294 |
1295 JavaScriptParser forInAllowed ifFalse:[^ self]. |
1295 JavaScriptParser forInAllowed ifFalse:[^ self]. |
1296 |
1296 |
1297 output := '' writeStream. |
1297 output := '' writeStream. |
1298 self |
1298 self |
1299 execute:'test(arg, output) { |
1299 execute:'test(arg, output) { |
1300 var sum = 0; |
1300 var sum = 0; |
1301 |
1301 |
1302 for (var el in arg) { |
1302 for (var el in arg) { |
1303 output.showCR(el*el); |
1303 output.showCR(el*el); |
1304 for (var i in ["a", "b", "c"]) { |
1304 for (var i in ["a", "b", "c"]) { |
1305 output.showCR(i); |
1305 output.showCR(i); |
1306 if (i == "b") break; |
1306 if (i == "b") break; |
1307 } |
1307 } |
1308 if (el == 1) continue; |
1308 if (el == 1) continue; |
1309 sum += el; |
1309 sum += el; |
1310 if (el == 2) break; |
1310 if (el == 2) break; |
1311 } |
1311 } |
1312 return sum; |
1312 return sum; |
1313 }' |
1313 }' |
1314 for:nil |
1314 for:nil |
1315 arguments:( Array with:#(1 2 3) with:output) |
1315 arguments:( Array with:#(1 2 3) with:output) |
1316 expect:2. |
1316 expect:2. |
1317 |
1317 |
1318 self assert:(output contents asCollectionOfLinesWithReturn asArray = #( |
1318 self assert:(output contents asCollectionOfLinesWithReturn asArray = #( |
1319 '1' |
1319 '1' |
1320 'a' |
1320 'a' |
1321 'b' |
1321 'b' |
1322 '4' |
1322 '4' |
1323 'a' |
1323 'a' |
1324 'b' |
1324 'b' |
1325 )) |
1325 )) |
1326 |
1326 |
1327 " |
1327 " |
1328 self run:#testForIn01 |
1328 self run:#testForIn01 |
1329 self new testForIn01 |
1329 self new testForIn01 |
1330 " |
1330 " |
1331 ! |
1331 ! |
1332 |
1332 |
1333 testIf01 |
1333 testIf01 |
1334 self |
1334 self |
1335 execute:'max(a, b) { |
1335 execute:'max(a, b) { |
1336 if (a > b) return a; |
1336 if (a > b) return a; |
1337 return b; |
1337 return b; |
1338 }' |
1338 }' |
1339 for:nil |
1339 for:nil |
1340 arguments:#(10 20) |
1340 arguments:#(10 20) |
1341 expect:20 |
1341 expect:20 |
1342 |
1342 |
1343 " |
1343 " |
1344 self run:#testIf01 |
1344 self run:#testIf01 |
1345 self new testIf01 |
1345 self new testIf01 |
1346 " |
1346 " |
1347 ! |
1347 ! |
1348 |
1348 |
1349 testIf02 |
1349 testIf02 |
1350 self |
1350 self |
1351 execute:'max(a, b) { |
1351 execute:'max(a, b) { |
1352 if (a > b) ; |
1352 if (a > b) ; |
1353 else return b; |
1353 else return b; |
1354 return a; |
1354 return a; |
1355 }' |
1355 }' |
1356 for:nil |
1356 for:nil |
1357 arguments:#(10 20) |
1357 arguments:#(10 20) |
1358 expect:20 |
1358 expect:20 |
1359 |
1359 |
1360 " |
1360 " |
1361 self run:#testIf02 |
1361 self run:#testIf02 |
1362 self new testIf02 |
1362 self new testIf02 |
1363 " |
1363 " |
1364 ! |
1364 ! |
1365 |
1365 |
1366 testIf03 |
1366 testIf03 |
1367 self |
1367 self |
1368 execute:'max(a, b) { |
1368 execute:'max(a, b) { |
1369 if (a > b) return a; |
1369 if (a > b) return a; |
1370 else return b; |
1370 else return b; |
1371 }' |
1371 }' |
1372 for:nil |
1372 for:nil |
1373 arguments:#(10 20) |
1373 arguments:#(10 20) |
1374 expect:20 |
1374 expect:20 |
1375 |
1375 |
1376 " |
1376 " |
1377 self run:#testIf03 |
1377 self run:#testIf03 |
1378 self new testIf03 |
1378 self new testIf03 |
1379 " |
1379 " |
1381 |
1381 |
1382 testInnerFunctionWithForLoop |
1382 testInnerFunctionWithForLoop |
1383 |
1383 |
1384 |savedTranscript collector expected| |
1384 |savedTranscript collector expected| |
1385 |
1385 |
1386 savedTranscript := Smalltalk at:#Transcript. |
1386 savedTranscript := Smalltalk at:#Transcript. |
1387 [ |
1387 [ |
1388 Smalltalk at:#Transcript put:(collector := '' writeStream). |
1388 Smalltalk at:#Transcript put:(collector := '' writeStream). |
1389 |
1389 |
1390 self |
1390 self |
1391 execute:' |
1391 execute:' |
1392 execute() { |
1392 execute() { |
1393 function foo() |
1393 function foo() |
1394 { |
1394 { |
1395 Transcript.show("foo called\n"); |
1395 Transcript.show("foo called\n"); |
1396 } |
1396 } |
1397 |
1397 |
1398 function bar() |
1398 function bar() |
1399 { |
1399 { |
1400 Transcript.show("bar called\n"); |
1400 Transcript.show("bar called\n"); |
1401 } |
1401 } |
1402 |
1402 |
1403 function bla(n) |
1403 function bla(n) |
1404 { |
1404 { |
1405 Transcript.show("bla called\n"); |
1405 Transcript.show("bla called\n"); |
1406 } |
1406 } |
1407 |
1407 |
1408 function test() |
1408 function test() |
1409 { |
1409 { |
1410 |
1410 |
1411 foo(); |
1411 foo(); |
1412 bar(); |
1412 bar(); |
1413 var _fecUs; |
1413 var _fecUs; |
1414 var _fecDs; |
1414 var _fecDs; |
1415 var _cvUs = Array.new(15); |
1415 var _cvUs = Array.new(15); |
1416 var _cvDs = Array.new(15); |
1416 var _cvDs = Array.new(15); |
1417 var _headerLength = 10; |
1417 var _headerLength = 10; |
1418 var _headerLength2 = 10; |
1418 var _headerLength2 = 10; |
1419 var _raw = Array.new(20); |
1419 var _raw = Array.new(20); |
1420 |
1420 |
1421 for(var l=_headerLength+2;l<=_raw.size;l++) |
1421 for(var l=_headerLength+2;l<=_raw.size;l++) |
1422 { |
1422 { |
1423 var x = _raw[l]; |
1423 var x = _raw[l]; |
1424 if(l!!=_raw.size) |
1424 if(l!!=_raw.size) |
1425 { var y = _raw[l+1]; } |
1425 { var y = _raw[l+1]; } |
1426 |
1426 |
1427 if(_cvUs.size >10 && _cvDs.size>10) |
1427 if(_cvUs.size >10 && _cvDs.size>10) |
1428 { |
1428 { |
1429 _fecUs = 15.asInteger - 12.asInteger; |
1429 _fecUs = 15.asInteger - 12.asInteger; |
1430 _fecDs = 20.asInteger - 13.asInteger; |
1430 _fecDs = 20.asInteger - 13.asInteger; |
1431 bla(_fecUs); |
1431 bla(_fecUs); |
1432 bla(_fecDs); |
1432 bla(_fecDs); |
1433 bla(_cvUs); |
1433 bla(_cvUs); |
1434 bla(_cvDs); |
1434 bla(_cvDs); |
1435 if(_fecUs >=0 && _fecUs >=0) |
1435 if(_fecUs >=0 && _fecUs >=0) |
1436 { |
1436 { |
1437 Transcript.show("hello\n"); |
1437 Transcript.show("hello\n"); |
1438 } |
1438 } |
1439 |
1439 |
1440 } |
1440 } |
1441 if(_cvUs.size == 5) |
1441 if(_cvUs.size == 5) |
1442 { Transcript.show("end\n"); } |
1442 { Transcript.show("end\n"); } |
1443 } |
1443 } |
1444 Transcript.show("bbb\n"); |
1444 Transcript.show("bbb\n"); |
1445 } |
1445 } |
1446 |
1446 |
1447 test(); |
1447 test(); |
1448 } |
1448 } |
1449 ' |
1449 ' |
1450 for:nil |
1450 for:nil |
1451 arguments:#() |
1451 arguments:#() |
1452 expect:nil |
1452 expect:nil |
1453 ] ensure:[ |
1453 ] ensure:[ |
1454 Smalltalk at:#Transcript put:savedTranscript |
1454 Smalltalk at:#Transcript put:savedTranscript |
1455 ]. |
1455 ]. |
1456 |
1456 |
1457 expected := String streamContents:[:s | |
1457 expected := String streamContents:[:s | |
1458 s showCR:'foo called'. |
1458 s showCR:'foo called'. |
1459 s showCR:'bar called'. |
1459 s showCR:'bar called'. |
1460 9 timesRepeat:[ |
1460 9 timesRepeat:[ |
1461 s showCR:'bla called'. |
1461 s showCR:'bla called'. |
1462 s showCR:'bla called'. |
1462 s showCR:'bla called'. |
1463 s showCR:'bla called'. |
1463 s showCR:'bla called'. |
1464 s showCR:'bla called'. |
1464 s showCR:'bla called'. |
1465 s showCR:'hello'. |
1465 s showCR:'hello'. |
1466 ]. |
1466 ]. |
1467 s showCR:'bbb'. |
1467 s showCR:'bbb'. |
1468 ]. |
1468 ]. |
1469 self assert:(collector contents = expected). |
1469 self assert:(collector contents = expected). |
1470 |
1470 |
1471 " |
1471 " |
1472 self run:#testVarDeclaration08 |
1472 self run:#testVarDeclaration08 |
1473 self new testVarDeclaration08 |
1473 self new testVarDeclaration08 |
1474 " |
1474 " |
1475 ! |
1475 ! |
1476 |
1476 |
1477 testLiteralReturn01 |
1477 testLiteralReturn01 |
1478 self |
1478 self |
1479 execute:'function f() { return (0); }' |
1479 execute:'function f() { return (0); }' |
1480 for:nil |
1480 for:nil |
1481 arguments:#() |
1481 arguments:#() |
1482 expect:0 |
1482 expect:0 |
1483 |
1483 |
1484 " |
1484 " |
1485 self run:#testLiteralReturn01 |
1485 self run:#testLiteralReturn01 |
1486 self new testLiteralReturn01 |
1486 self new testLiteralReturn01 |
1487 " |
1487 " |
1488 ! |
1488 ! |
1489 |
1489 |
1490 testLiteralReturn02 |
1490 testLiteralReturn02 |
1491 self |
1491 self |
1492 execute:'function f() { return (0.0); }' |
1492 execute:'function f() { return (0.0); }' |
1493 for:nil |
1493 for:nil |
1494 arguments:#() |
1494 arguments:#() |
1495 expect:0.0 |
1495 expect:0.0 |
1496 |
1496 |
1497 " |
1497 " |
1498 self run:#testLiteralReturn02 |
1498 self run:#testLiteralReturn02 |
1499 self new testLiteralReturn02 |
1499 self new testLiteralReturn02 |
1500 " |
1500 " |
1501 ! |
1501 ! |
1502 |
1502 |
1503 testLiteralReturn03 |
1503 testLiteralReturn03 |
1504 self |
1504 self |
1505 execute:'function f() { return ("foo"); }' |
1505 execute:'function f() { return ("foo"); }' |
1506 for:nil |
1506 for:nil |
1507 arguments:#() |
1507 arguments:#() |
1508 expect:'foo' |
1508 expect:'foo' |
1509 |
1509 |
1510 " |
1510 " |
1511 self run:#testLiteralReturn03 |
1511 self run:#testLiteralReturn03 |
1512 self new testLiteralReturn03 |
1512 self new testLiteralReturn03 |
1513 " |
1513 " |
1514 ! |
1514 ! |
1515 |
1515 |
1516 testLiteralReturn04 |
1516 testLiteralReturn04 |
1517 self |
1517 self |
1518 execute:'function f() { return (true); }' |
1518 execute:'function f() { return (true); }' |
1519 for:nil |
1519 for:nil |
1520 arguments:#() |
1520 arguments:#() |
1521 expect:true |
1521 expect:true |
1522 |
1522 |
1523 " |
1523 " |
1524 self run:#testLiteralReturn04 |
1524 self run:#testLiteralReturn04 |
1525 self new testLiteralReturn04 |
1525 self new testLiteralReturn04 |
1526 " |
1526 " |
1527 ! |
1527 ! |
1528 |
1528 |
1529 testLiteralReturn05 |
1529 testLiteralReturn05 |
1530 self |
1530 self |
1531 execute:'function f() { return (false); }' |
1531 execute:'function f() { return (false); }' |
1532 for:nil |
1532 for:nil |
1533 arguments:#() |
1533 arguments:#() |
1534 expect:false |
1534 expect:false |
1535 |
1535 |
1536 " |
1536 " |
1537 self run:#testLiteralReturn05 |
1537 self run:#testLiteralReturn05 |
1538 self new testLiteralReturn05 |
1538 self new testLiteralReturn05 |
1539 " |
1539 " |
1540 ! |
1540 ! |
1541 |
1541 |
1542 testLiteralReturn06 |
1542 testLiteralReturn06 |
1543 self |
1543 self |
1544 execute:'function f() { return (null); }' |
1544 execute:'function f() { return (null); }' |
1545 for:nil |
1545 for:nil |
1546 arguments:#() |
1546 arguments:#() |
1547 expect:nil |
1547 expect:nil |
1548 |
1548 |
1549 " |
1549 " |
1550 self run:#testLiteralReturn06 |
1550 self run:#testLiteralReturn06 |
1551 self new testLiteralReturn06 |
1551 self new testLiteralReturn06 |
1552 " |
1552 " |
1553 ! |
1553 ! |
1554 |
1554 |
1555 testLiteralReturn07 |
1555 testLiteralReturn07 |
1556 self |
1556 self |
1557 execute:'function f() { return (nil); }' |
1557 execute:'function f() { return (nil); }' |
1558 for:nil |
1558 for:nil |
1559 arguments:#() |
1559 arguments:#() |
1560 expect:nil |
1560 expect:nil |
1561 |
1561 |
1562 " |
1562 " |
1563 self run:#testLiteralReturn07 |
1563 self run:#testLiteralReturn07 |
1564 self new testLiteralReturn07 |
1564 self new testLiteralReturn07 |
1565 " |
1565 " |
1566 ! |
1566 ! |
1567 |
1567 |
1568 testLiteralReturn08 |
1568 testLiteralReturn08 |
1569 self |
1569 self |
1570 execute:'function f() { return ("hello"); }' |
1570 execute:'function f() { return ("hello"); }' |
1571 for:nil |
1571 for:nil |
1572 arguments:#() |
1572 arguments:#() |
1573 expect:'hello' |
1573 expect:'hello' |
1574 |
1574 |
1575 " |
1575 " |
1576 self run:#testLiteralReturn08 |
1576 self run:#testLiteralReturn08 |
1577 self new testLiteralReturn08 |
1577 self new testLiteralReturn08 |
1578 " |
1578 " |
1579 ! |
1579 ! |
1580 |
1580 |
1581 testLiterals01 |
1581 testLiterals01 |
1582 |t| |
1582 |t| |
1583 |
1583 |
1584 t := JavaScriptParser |
1584 t := JavaScriptParser |
1585 evaluate:' |
1585 evaluate:' |
1586 [ |
1586 [ |
1587 {"params": {"name": "q"}, "method": "click"}, |
1587 {"params": {"name": "q"}, "method": "click"}, |
1588 {"params": {"text": "hello world", "name": "q"}, "method": "type"}, |
1588 {"params": {"text": "hello world", "name": "q"}, "method": "type"}, |
1589 {"params": {"link": "Hallo-Welt-Programm \u2013 Wikipedia"}, "method": "click"}, |
1589 {"params": {"link": "Hallo-Welt-Programm \u2013 Wikipedia"}, "method": "click"}, |
1590 {"params": {"timeout": "20000"}, "method": "waits.forPageLoad"}, |
1590 {"params": {"timeout": "20000"}, "method": "waits.forPageLoad"}, |
1645 "Created: / 20-02-2007 / 18:13:19 / cg" |
1645 "Created: / 20-02-2007 / 18:13:19 / cg" |
1646 "Modified: / 20-02-2007 / 21:35:56 / cg" |
1646 "Modified: / 20-02-2007 / 21:35:56 / cg" |
1647 ! |
1647 ! |
1648 |
1648 |
1649 testLocalFunction02 |
1649 testLocalFunction02 |
1650 self |
1650 self |
1651 execute:'test(arg) { |
1651 execute:'test(arg) { |
1652 var x ; |
1652 var x ; |
1653 |
1653 |
1654 function localFunction() { return (10 / arg) from test; }; |
1654 function localFunction() { return (10 / arg) from test; }; |
1655 |
1655 |
1656 x = localFunction() + 1; |
1656 x = localFunction() + 1; |
1657 return x; |
1657 return x; |
1658 }' |
1658 }' |
1659 for:nil |
1659 for:nil |
1660 arguments:#(5) |
1660 arguments:#(5) |
1661 expect:2 |
1661 expect:2 |
1662 |
1662 |
1663 " |
1663 " |
1664 self run:#testLocalFunction02 |
1664 self run:#testLocalFunction02 |
1665 self new testLocalFunction02 |
1665 self new testLocalFunction02 |
1666 " |
1666 " |
1667 |
1667 |
1668 "Created: / 20-02-2007 / 21:36:31 / cg" |
1668 "Created: / 20-02-2007 / 21:36:31 / cg" |
1669 ! |
1669 ! |
1670 |
1670 |
1671 testNew01 |
1671 testNew01 |
1672 self |
1672 self |
1673 execute:'test() { |
1673 execute:'test() { |
1674 var a; |
1674 var a; |
1675 |
1675 |
1676 a = Array.new(5); |
1676 a = Array.new(5); |
1677 return a; |
1677 return a; |
1678 }' |
1678 }' |
1679 for:nil |
1679 for:nil |
1680 arguments:#() |
1680 arguments:#() |
1681 expect:#(nil nil nil nil nil). |
1681 expect:#(nil nil nil nil nil). |
1682 |
1682 |
1683 " |
1683 " |
1684 self run:#testNew01 |
1684 self run:#testNew01 |
1685 self new testNew01 |
1685 self new testNew01 |
1686 " |
1686 " |
1687 ! |
1687 ! |
1688 |
1688 |
1689 testNew02 |
1689 testNew02 |
1690 self |
1690 self |
1691 execute:'test() { |
1691 execute:'test() { |
1692 var a; |
1692 var a; |
1693 |
1693 |
1694 a = new Array(5); |
1694 a = new Array(5); |
1695 return a; |
1695 return a; |
1696 }' |
1696 }' |
1697 for:nil |
1697 for:nil |
1698 arguments:#() |
1698 arguments:#() |
1699 expect:#(nil nil nil nil nil). |
1699 expect:#(nil nil nil nil nil). |
1700 |
1700 |
1701 " |
1701 " |
1702 self run:#testNew02 |
1702 self run:#testNew02 |
1703 self new testNew02 |
1703 self new testNew02 |
1704 " |
1704 " |
1705 ! |
1705 ! |
1706 |
1706 |
1707 testNew03 |
1707 testNew03 |
1708 self |
1708 self |
1709 execute:'test() { |
1709 execute:'test() { |
1710 var days; |
1710 var days; |
1711 |
1711 |
1712 days = new Array(7); |
1712 days = new Array(7); |
1713 days[1] = "Monday"; |
1713 days[1] = "Monday"; |
1714 days[2] = "Tuesday"; |
1714 days[2] = "Tuesday"; |
1715 days[3] = "Wednesday"; |
1715 days[3] = "Wednesday"; |
1716 days[4] = "Thursday"; |
1716 days[4] = "Thursday"; |
1717 days[5] = "Friday"; |
1717 days[5] = "Friday"; |
1718 days[6] = "Saturday"; |
1718 days[6] = "Saturday"; |
1719 days[7] = "Sunday"; |
1719 days[7] = "Sunday"; |
1720 |
1720 |
1721 return days; |
1721 return days; |
1722 }' |
1722 }' |
1723 for:nil |
1723 for:nil |
1724 arguments:#() |
1724 arguments:#() |
1725 expect:#('Monday' 'Tuesday' 'Wednesday' 'Thursday' 'Friday' 'Saturday' 'Sunday') |
1725 expect:#('Monday' 'Tuesday' 'Wednesday' 'Thursday' 'Friday' 'Saturday' 'Sunday') |
1726 |
1726 |
1727 " |
1727 " |
1728 self run:#testNew03 |
1728 self run:#testNew03 |
1729 self new testNew03 |
1729 self new testNew03 |
1730 " |
1730 " |
1731 ! |
1731 ! |
1732 |
1732 |
1733 testOperators01_plus |
1733 testOperators01_plus |
1734 self |
1734 self |
1735 execute:'expr(a, b) { |
1735 execute:'expr(a, b) { |
1736 return (a + 0); |
1736 return (a + 0); |
1737 }' |
1737 }' |
1738 for:nil |
1738 for:nil |
1739 arguments:#(10 20) |
1739 arguments:#(10 20) |
1740 expect:10 |
1740 expect:10 |
1741 |
1741 |
1742 " |
1742 " |
1743 self run:#testOperators01_plus |
1743 self run:#testOperators01_plus |
1744 self new testOperators01_plus |
1744 self new testOperators01_plus |
1745 " |
1745 " |
1746 ! |
1746 ! |
1747 |
1747 |
1748 testOperators02_plus |
1748 testOperators02_plus |
1749 self |
1749 self |
1750 execute:'expr(a, b) { |
1750 execute:'expr(a, b) { |
1751 return (a + 1); |
1751 return (a + 1); |
1752 }' |
1752 }' |
1753 for:nil |
1753 for:nil |
1754 arguments:#(10 20) |
1754 arguments:#(10 20) |
1755 expect:11 |
1755 expect:11 |
1756 |
1756 |
1757 " |
1757 " |
1758 self run:#testOperators02_plus |
1758 self run:#testOperators02_plus |
1759 self new testOperators02_plus |
1759 self new testOperators02_plus |
1760 " |
1760 " |
1761 ! |
1761 ! |
1762 |
1762 |
1763 testOperators03_minus |
1763 testOperators03_minus |
1764 self |
1764 self |
1765 execute:'expr(a, b) { |
1765 execute:'expr(a, b) { |
1766 return (a - 1); |
1766 return (a - 1); |
1767 }' |
1767 }' |
1768 for:nil |
1768 for:nil |
1769 arguments:#(10 20) |
1769 arguments:#(10 20) |
1770 expect:9 |
1770 expect:9 |
1771 |
1771 |
1772 " |
1772 " |
1773 self run:#testOperators03_minus |
1773 self run:#testOperators03_minus |
1774 self new testOperators03_minus |
1774 self new testOperators03_minus |
1775 " |
1775 " |
1776 ! |
1776 ! |
1777 |
1777 |
1778 testOperators04_plus |
1778 testOperators04_plus |
1779 self |
1779 self |
1780 execute:'expr(a, b) { |
1780 execute:'expr(a, b) { |
1781 return (a + a); |
1781 return (a + a); |
1782 }' |
1782 }' |
1783 for:nil |
1783 for:nil |
1784 arguments:#(10 20) |
1784 arguments:#(10 20) |
1785 expect:20 |
1785 expect:20 |
1786 |
1786 |
1787 " |
1787 " |
1788 self run:#testOperators04_plus |
1788 self run:#testOperators04_plus |
1789 self new testOperators04_plus |
1789 self new testOperators04_plus |
1790 " |
1790 " |
1791 ! |
1791 ! |
1792 |
1792 |
1793 testOperators05_mul |
1793 testOperators05_mul |
1794 self |
1794 self |
1795 execute:'expr(a, b) { |
1795 execute:'expr(a, b) { |
1796 return (a * 0); |
1796 return (a * 0); |
1797 }' |
1797 }' |
1798 for:nil |
1798 for:nil |
1799 arguments:#(10 20) |
1799 arguments:#(10 20) |
1800 expect:0 |
1800 expect:0 |
1801 |
1801 |
1802 " |
1802 " |
1803 self run:#testOperators05_mul |
1803 self run:#testOperators05_mul |
1804 self new testOperators05_mul |
1804 self new testOperators05_mul |
1805 " |
1805 " |
1806 ! |
1806 ! |
1807 |
1807 |
1808 testOperators06_mul |
1808 testOperators06_mul |
1809 self |
1809 self |
1810 execute:'expr(a, b) { |
1810 execute:'expr(a, b) { |
1811 return (a * 1); |
1811 return (a * 1); |
1812 }' |
1812 }' |
1813 for:nil |
1813 for:nil |
1814 arguments:#(10 20) |
1814 arguments:#(10 20) |
1815 expect:10 |
1815 expect:10 |
1816 |
1816 |
1817 " |
1817 " |
1818 self run:#testOperators06_mul |
1818 self run:#testOperators06_mul |
1819 self new testOperators06_mul |
1819 self new testOperators06_mul |
1820 " |
1820 " |
1821 ! |
1821 ! |
1822 |
1822 |
1823 testOperators07_mul |
1823 testOperators07_mul |
1824 self |
1824 self |
1825 execute:'expr(a, b) { |
1825 execute:'expr(a, b) { |
1826 return (a * -1); |
1826 return (a * -1); |
1827 }' |
1827 }' |
1828 for:nil |
1828 for:nil |
1829 arguments:#(10 20) |
1829 arguments:#(10 20) |
1830 expect:-10 |
1830 expect:-10 |
1831 |
1831 |
1832 " |
1832 " |
1833 self run:#testOperators07_mul |
1833 self run:#testOperators07_mul |
1834 self new testOperators07_mul |
1834 self new testOperators07_mul |
1835 " |
1835 " |
1836 ! |
1836 ! |
1837 |
1837 |
1838 testOperators08_mul |
1838 testOperators08_mul |
1839 self |
1839 self |
1840 execute:'expr(a, b) { |
1840 execute:'expr(a, b) { |
1841 return (a * 10); |
1841 return (a * 10); |
1842 }' |
1842 }' |
1843 for:nil |
1843 for:nil |
1844 arguments:#(10 20) |
1844 arguments:#(10 20) |
1845 expect:100 |
1845 expect:100 |
1846 |
1846 |
1847 " |
1847 " |
1848 self run:#testOperators08_mul |
1848 self run:#testOperators08_mul |
1849 self new testOperators08_mul |
1849 self new testOperators08_mul |
1850 " |
1850 " |
1851 ! |
1851 ! |
1852 |
1852 |
1853 testOperators09_mul |
1853 testOperators09_mul |
1854 self |
1854 self |
1855 execute:'expr(a, b) { |
1855 execute:'expr(a, b) { |
1856 return (a * a); |
1856 return (a * a); |
1857 }' |
1857 }' |
1858 for:nil |
1858 for:nil |
1859 arguments:#(10 20) |
1859 arguments:#(10 20) |
1860 expect:100 |
1860 expect:100 |
1861 |
1861 |
1862 " |
1862 " |
1863 self run:#testOperators09_mul |
1863 self run:#testOperators09_mul |
1864 self new testOperators09_mul |
1864 self new testOperators09_mul |
1865 " |
1865 " |
1866 ! |
1866 ! |
1867 |
1867 |
1868 testOperators10_mul |
1868 testOperators10_mul |
1869 self |
1869 self |
1870 execute:'expr(a, b) { |
1870 execute:'expr(a, b) { |
1871 return (a * b); |
1871 return (a * b); |
1872 }' |
1872 }' |
1873 for:nil |
1873 for:nil |
1874 arguments:#(10 20) |
1874 arguments:#(10 20) |
1875 expect:200 |
1875 expect:200 |
1876 |
1876 |
1877 " |
1877 " |
1878 self run:#testOperators10_mul |
1878 self run:#testOperators10_mul |
1879 self new testOperators10_mul |
1879 self new testOperators10_mul |
1880 " |
1880 " |
1881 ! |
1881 ! |
1882 |
1882 |
1883 testOperators11_minus |
1883 testOperators11_minus |
1884 self |
1884 self |
1885 execute:'expr(a, b) { |
1885 execute:'expr(a, b) { |
1886 return (a - b); |
1886 return (a - b); |
1887 }' |
1887 }' |
1888 for:nil |
1888 for:nil |
1889 arguments:#(10 20) |
1889 arguments:#(10 20) |
1890 expect:-10 |
1890 expect:-10 |
1891 |
1891 |
1892 " |
1892 " |
1893 self run:#testOperators11_minus |
1893 self run:#testOperators11_minus |
1894 self new testOperators11_minus |
1894 self new testOperators11_minus |
1895 " |
1895 " |
1896 ! |
1896 ! |
1897 |
1897 |
1898 testOperators12_unaryMinus |
1898 testOperators12_unaryMinus |
1899 self |
1899 self |
1900 execute:'expr(a) { |
1900 execute:'expr(a) { |
1901 return (-a); |
1901 return (-a); |
1902 }' |
1902 }' |
1903 for:nil |
1903 for:nil |
1904 arguments:#(10) |
1904 arguments:#(10) |
1905 expect:-10 |
1905 expect:-10 |
1906 |
1906 |
1907 " |
1907 " |
1908 self run:#testOperators12_unaryMinus |
1908 self run:#testOperators12_unaryMinus |
1909 self new testOperators12_unaryMinus |
1909 self new testOperators12_unaryMinus |
1910 " |
1910 " |
1911 ! |
1911 ! |
1912 |
1912 |
1913 testOperators13_minus |
1913 testOperators13_minus |
1914 self |
1914 self |
1915 execute:'expr(a, b) { |
1915 execute:'expr(a, b) { |
1916 return (a - -b); |
1916 return (a - -b); |
1917 }' |
1917 }' |
1918 for:nil |
1918 for:nil |
1919 arguments:#(10 20) |
1919 arguments:#(10 20) |
1920 expect:30 |
1920 expect:30 |
1921 |
1921 |
1922 " |
1922 " |
1923 self run:#testOperators13_minus |
1923 self run:#testOperators13_minus |
1924 self new testOperators13_minus |
1924 self new testOperators13_minus |
1925 " |
1925 " |
1926 ! |
1926 ! |
1927 |
1927 |
1928 testOperators14_unaryMinus |
1928 testOperators14_unaryMinus |
1929 self |
1929 self |
1930 execute:'expr(a, b) { |
1930 execute:'expr(a, b) { |
1931 return (a * -b); |
1931 return (a * -b); |
1932 }' |
1932 }' |
1933 for:nil |
1933 for:nil |
1934 arguments:#(10 1) |
1934 arguments:#(10 1) |
1935 expect:-10 |
1935 expect:-10 |
1936 |
1936 |
1937 " |
1937 " |
1938 self run:#testOperators14_unaryMinus |
1938 self run:#testOperators14_unaryMinus |
1939 self new testOperators14_unaryMinus |
1939 self new testOperators14_unaryMinus |
1940 " |
1940 " |
1941 ! |
1941 ! |
1942 |
1942 |
1943 testOperators15_div |
1943 testOperators15_div |
1944 self |
1944 self |
1945 execute:'expr(a, b) { |
1945 execute:'expr(a, b) { |
1946 return (a / 1.0); |
1946 return (a / 1.0); |
1947 }' |
1947 }' |
1948 for:nil |
1948 for:nil |
1949 arguments:#(10 1) |
1949 arguments:#(10 1) |
1950 expect:10.0 |
1950 expect:10.0 |
1951 |
1951 |
1952 " |
1952 " |
1953 self run:#testOperators15_div |
1953 self run:#testOperators15_div |
1954 self new testOperators15_div |
1954 self new testOperators15_div |
1955 " |
1955 " |
1956 ! |
1956 ! |
1957 |
1957 |
1958 testOperators16a_postInc |
1958 testOperators16a_postInc |
1959 self |
1959 self |
1960 execute:'expr(a, b) { |
1960 execute:'expr(a, b) { |
1961 return (a++); |
1961 return (a++); |
1962 }' |
1962 }' |
1963 for:nil |
1963 for:nil |
1964 arguments:#(10 1) |
1964 arguments:#(10 1) |
1965 expect:10 |
1965 expect:10 |
1966 |
1966 |
1967 " |
1967 " |
1968 self run:#testOperators16a_postInc |
1968 self run:#testOperators16a_postInc |
1969 self new testOperators16a_postInc |
1969 self new testOperators16a_postInc |
1970 " |
1970 " |
1971 |
1971 |
1972 "Modified: / 23-02-2007 / 13:29:51 / cg" |
1972 "Modified: / 23-02-2007 / 13:29:51 / cg" |
1973 ! |
1973 ! |
1974 |
1974 |
1975 testOperators16b_postInc |
1975 testOperators16b_postInc |
1976 self |
1976 self |
1977 execute:'expr(a, b) { |
1977 execute:'expr(a, b) { |
1978 var aa = a; |
1978 var aa = a; |
1979 |
1979 |
1980 return (aa++); |
1980 return (aa++); |
1981 }' |
1981 }' |
1982 for:nil |
1982 for:nil |
1983 arguments:#(10 1) |
1983 arguments:#(10 1) |
1984 expect:10 |
1984 expect:10 |
1985 |
1985 |
1986 " |
1986 " |
1987 self run:#testOperators16b_postInc |
1987 self run:#testOperators16b_postInc |
1988 self new testOperators16b_postInc |
1988 self new testOperators16b_postInc |
1989 " |
1989 " |
1990 ! |
1990 ! |
1991 |
1991 |
1992 testOperators16c_postInc |
1992 testOperators16c_postInc |
1993 self |
1993 self |
1994 execute:'expr(a, b) { |
1994 execute:'expr(a, b) { |
1995 var t = a++; |
1995 var t = a++; |
1996 return (t); |
1996 return (t); |
1997 }' |
1997 }' |
1998 for:nil |
1998 for:nil |
1999 arguments:#(10 1) |
1999 arguments:#(10 1) |
2000 expect:10 |
2000 expect:10 |
2001 |
2001 |
2002 " |
2002 " |
2003 self run:#testOperators16c_postInc |
2003 self run:#testOperators16c_postInc |
2004 self new testOperators16c_postInc |
2004 self new testOperators16c_postInc |
2005 " |
2005 " |
2006 |
2006 |
2007 "Created: / 23-02-2007 / 13:30:21 / cg" |
2007 "Created: / 23-02-2007 / 13:30:21 / cg" |
2008 ! |
2008 ! |
2009 |
2009 |
2010 testOperators16d_postInc |
2010 testOperators16d_postInc |
2011 self |
2011 self |
2012 execute:'expr(a, b) { |
2012 execute:'expr(a, b) { |
2013 var t = a++; |
2013 var t = a++; |
2014 return (a); |
2014 return (a); |
2015 }' |
2015 }' |
2016 for:nil |
2016 for:nil |
2017 arguments:#(10 1) |
2017 arguments:#(10 1) |
2018 expect:11 |
2018 expect:11 |
2019 |
2019 |
2020 " |
2020 " |
2021 self run:#testOperators16d_postInc |
2021 self run:#testOperators16d_postInc |
2022 self new testOperators16d_postInc |
2022 self new testOperators16d_postInc |
2023 " |
2023 " |
2024 |
2024 |
2025 "Created: / 23-02-2007 / 13:30:32 / cg" |
2025 "Created: / 23-02-2007 / 13:30:32 / cg" |
2026 ! |
2026 ! |
2027 |
2027 |
2028 testOperators16e_postInc |
2028 testOperators16e_postInc |
2029 self |
2029 self |
2030 execute:'expr(a, b) { |
2030 execute:'expr(a, b) { |
2031 var t = a++; |
2031 var t = a++; |
2032 return (b); |
2032 return (b); |
2033 }' |
2033 }' |
2034 for:nil |
2034 for:nil |
2035 arguments:#(10 1) |
2035 arguments:#(10 1) |
2036 expect:1 |
2036 expect:1 |
2037 |
2037 |
2038 " |
2038 " |
2039 self run:#testOperators16e_postInc |
2039 self run:#testOperators16e_postInc |
2040 self new testOperators16e_postInc |
2040 self new testOperators16e_postInc |
2041 " |
2041 " |
2042 |
2042 |
2043 "Created: / 23-02-2007 / 13:31:02 / cg" |
2043 "Created: / 23-02-2007 / 13:31:02 / cg" |
2044 ! |
2044 ! |
2045 |
2045 |
2046 testOperators17a_eq |
2046 testOperators17a_eq |
2047 self |
2047 self |
2048 execute:'expr(a, b) { |
2048 execute:'expr(a, b) { |
2049 return (a == b); |
2049 return (a == b); |
2050 }' |
2050 }' |
2051 for:nil |
2051 for:nil |
2052 arguments:#(10 10) |
2052 arguments:#(10 10) |
2053 expect:true |
2053 expect:true |
2054 |
2054 |
2055 " |
2055 " |
2056 self run:#testOperators17a_eq |
2056 self run:#testOperators17a_eq |
2057 self new testOperators17a_eq |
2057 self new testOperators17a_eq |
2058 " |
2058 " |
2059 ! |
2059 ! |
2060 |
2060 |
2061 testOperators17b_eq |
2061 testOperators17b_eq |
2062 self |
2062 self |
2063 execute:'expr(a, b) { |
2063 execute:'expr(a, b) { |
2064 return (a == b); |
2064 return (a == b); |
2065 }' |
2065 }' |
2066 for:nil |
2066 for:nil |
2067 arguments:#(10 11) |
2067 arguments:#(10 11) |
2068 expect:false |
2068 expect:false |
2069 |
2069 |
2070 " |
2070 " |
2071 self run:#testOperators17b_eq |
2071 self run:#testOperators17b_eq |
2072 self new testOperators17b_eq |
2072 self new testOperators17b_eq |
2073 " |
2073 " |
2074 ! |
2074 ! |
2075 |
2075 |
2076 testOperators17c_ne |
2076 testOperators17c_ne |
2077 self |
2077 self |
2078 execute:'expr(a, b) { |
2078 execute:'expr(a, b) { |
2079 return (a !!= b); |
2079 return (a !!= b); |
2080 }' |
2080 }' |
2081 for:nil |
2081 for:nil |
2082 arguments:#(10 10) |
2082 arguments:#(10 10) |
2083 expect:false |
2083 expect:false |
2084 |
2084 |
2085 " |
2085 " |
2086 self run:#testOperators17c_ne |
2086 self run:#testOperators17c_ne |
2087 self new testOperators17c_ne |
2087 self new testOperators17c_ne |
2088 " |
2088 " |
2089 ! |
2089 ! |
2090 |
2090 |
2091 testOperators17d_ne |
2091 testOperators17d_ne |
2092 self |
2092 self |
2093 execute:'expr(a, b) { |
2093 execute:'expr(a, b) { |
2094 return (a !!= b); |
2094 return (a !!= b); |
2095 }' |
2095 }' |
2096 for:nil |
2096 for:nil |
2097 arguments:#(10 11) |
2097 arguments:#(10 11) |
2098 expect:true |
2098 expect:true |
2099 |
2099 |
2100 " |
2100 " |
2101 self run:#testOperators17d_ne |
2101 self run:#testOperators17d_ne |
2102 self new testOperators17d_ne |
2102 self new testOperators17d_ne |
2103 " |
2103 " |
2104 ! |
2104 ! |
2105 |
2105 |
2106 testOperators18a_eq |
2106 testOperators18a_eq |
2107 self |
2107 self |
2108 execute:'expr(a, b) { |
2108 execute:'expr(a, b) { |
2109 return (a == b); |
2109 return (a == b); |
2110 }' |
2110 }' |
2111 for:nil |
2111 for:nil |
2112 arguments:#(10 10.0) |
2112 arguments:#(10 10.0) |
2113 expect:true |
2113 expect:true |
2114 |
2114 |
2115 " |
2115 " |
2116 self run:#testOperators18a_eq |
2116 self run:#testOperators18a_eq |
2117 self new testOperators18a_eq |
2117 self new testOperators18a_eq |
2118 " |
2118 " |
2119 ! |
2119 ! |
2120 |
2120 |
2121 testOperators18b_ne |
2121 testOperators18b_ne |
2122 self |
2122 self |
2123 execute:'expr(a, b) { |
2123 execute:'expr(a, b) { |
2124 return (a !!= b); |
2124 return (a !!= b); |
2125 }' |
2125 }' |
2126 for:nil |
2126 for:nil |
2127 arguments:#(10 11.0) |
2127 arguments:#(10 11.0) |
2128 expect:true |
2128 expect:true |
2129 |
2129 |
2130 " |
2130 " |
2131 self run:#testOperators18b_ne |
2131 self run:#testOperators18b_ne |
2132 self new testOperators18b_ne |
2132 self new testOperators18b_ne |
2133 " |
2133 " |
2134 ! |
2134 ! |
2135 |
2135 |
2136 testOperators19a_identical |
2136 testOperators19a_identical |
2137 self |
2137 self |
2138 execute:'expr(a, b) { |
2138 execute:'expr(a, b) { |
2139 return (a === b); |
2139 return (a === b); |
2140 }' |
2140 }' |
2141 for:nil |
2141 for:nil |
2142 arguments:#(10 10) |
2142 arguments:#(10 10) |
2143 expect:true |
2143 expect:true |
2144 |
2144 |
2145 " |
2145 " |
2146 self run:#testOperators19a_identical |
2146 self run:#testOperators19a_identical |
2147 self new testOperators19a_identical |
2147 self new testOperators19a_identical |
2148 " |
2148 " |
2149 ! |
2149 ! |
2150 |
2150 |
2151 testOperators19b_identical |
2151 testOperators19b_identical |
2152 self |
2152 self |
2153 execute:'expr(a, b) { |
2153 execute:'expr(a, b) { |
2154 return (a === b); |
2154 return (a === b); |
2155 }' |
2155 }' |
2156 for:nil |
2156 for:nil |
2157 arguments:#( 10 10.0 ) |
2157 arguments:#( 10 10.0 ) |
2158 expect:false |
2158 expect:false |
2159 |
2159 |
2160 " |
2160 " |
2161 self run:#testOperators19b_identical |
2161 self run:#testOperators19b_identical |
2162 self new testOperators19b_identical |
2162 self new testOperators19b_identical |
2163 " |
2163 " |
2164 ! |
2164 ! |
2165 |
2165 |
2166 testOperators19c_notIdentical |
2166 testOperators19c_notIdentical |
2167 self |
2167 self |
2168 execute:'expr(a, b) { |
2168 execute:'expr(a, b) { |
2169 return (a !!== b); |
2169 return (a !!== b); |
2170 }' |
2170 }' |
2171 for:nil |
2171 for:nil |
2172 arguments:#( 10 10 ) |
2172 arguments:#( 10 10 ) |
2173 expect:false |
2173 expect:false |
2174 |
2174 |
2175 " |
2175 " |
2176 self run:#testOperators19c_notIdentical |
2176 self run:#testOperators19c_notIdentical |
2177 self new testOperators19c_notIdentical |
2177 self new testOperators19c_notIdentical |
2178 " |
2178 " |
2179 ! |
2179 ! |
2180 |
2180 |
2181 testOperators19d_notIdentical |
2181 testOperators19d_notIdentical |
2182 self |
2182 self |
2183 execute:'expr(a, b) { |
2183 execute:'expr(a, b) { |
2184 return (a !!== b); |
2184 return (a !!== b); |
2185 }' |
2185 }' |
2186 for:nil |
2186 for:nil |
2187 arguments:#( 10 10.0 ) |
2187 arguments:#( 10 10.0 ) |
2188 expect:true |
2188 expect:true |
2189 |
2189 |
2190 " |
2190 " |
2191 self run:#testOperators19d_notIdentical |
2191 self run:#testOperators19d_notIdentical |
2192 self new testOperators19d_notIdentical |
2192 self new testOperators19d_notIdentical |
2193 " |
2193 " |
2194 ! |
2194 ! |
2195 |
2195 |
2196 testOperators20a_eq |
2196 testOperators20a_eq |
2197 self |
2197 self |
2198 execute:'expr(a, b) { |
2198 execute:'expr(a, b) { |
2199 return (a == b); |
2199 return (a == b); |
2200 }' |
2200 }' |
2201 for:nil |
2201 for:nil |
2202 arguments:#( 'foo' 'foo' ) |
2202 arguments:#( 'foo' 'foo' ) |
2203 expect:true |
2203 expect:true |
2204 |
2204 |
2205 " |
2205 " |
2206 self run:#testOperators20a_eq |
2206 self run:#testOperators20a_eq |
2207 self new testOperators20a_eq |
2207 self new testOperators20a_eq |
2208 " |
2208 " |
2209 ! |
2209 ! |
2210 |
2210 |
2211 testOperators20b_eq |
2211 testOperators20b_eq |
2212 self |
2212 self |
2213 execute:'expr(a, b) { |
2213 execute:'expr(a, b) { |
2214 return (a == b); |
2214 return (a == b); |
2215 }' |
2215 }' |
2216 for:nil |
2216 for:nil |
2217 arguments:#( 'foo' 'Foo' ) |
2217 arguments:#( 'foo' 'Foo' ) |
2218 expect:false |
2218 expect:false |
2219 |
2219 |
2220 " |
2220 " |
2221 self run:#testOperators20b_eq |
2221 self run:#testOperators20b_eq |
2222 self new testOperators20b_eq |
2222 self new testOperators20b_eq |
2223 " |
2223 " |
2224 ! |
2224 ! |
2225 |
2225 |
2226 testOperators20c_ne |
2226 testOperators20c_ne |
2227 self |
2227 self |
2228 execute:'expr(a, b) { |
2228 execute:'expr(a, b) { |
2229 return (a !!= b); |
2229 return (a !!= b); |
2230 }' |
2230 }' |
2231 for:nil |
2231 for:nil |
2232 arguments:#( 'foo' 'Foo' ) |
2232 arguments:#( 'foo' 'Foo' ) |
2233 expect:true |
2233 expect:true |
2234 |
2234 |
2235 " |
2235 " |
2236 self run:#testOperators20c_ne |
2236 self run:#testOperators20c_ne |
2237 self new testOperators20c_ne |
2237 self new testOperators20c_ne |
2238 " |
2238 " |
2239 ! |
2239 ! |
2240 |
2240 |
2241 testOperators20d_ne |
2241 testOperators20d_ne |
2242 self |
2242 self |
2243 execute:'expr(a, b) { |
2243 execute:'expr(a, b) { |
2244 return (a !!= b); |
2244 return (a !!= b); |
2245 }' |
2245 }' |
2246 for:nil |
2246 for:nil |
2247 arguments:#( 'foo' 'foo' ) |
2247 arguments:#( 'foo' 'foo' ) |
2248 expect:false |
2248 expect:false |
2249 |
2249 |
2250 " |
2250 " |
2251 self run:#testOperators20d_ne |
2251 self run:#testOperators20d_ne |
2252 self new testOperators20d_ne |
2252 self new testOperators20d_ne |
2253 " |
2253 " |
2254 ! |
2254 ! |
2255 |
2255 |
2256 testOperators21a_ne |
2256 testOperators21a_ne |
2257 self |
2257 self |
2258 execute:'expr(a) { |
2258 execute:'expr(a) { |
2259 return (a !!= 0); |
2259 return (a !!= 0); |
2260 }' |
2260 }' |
2261 for:nil |
2261 for:nil |
2262 arguments:#('foo') |
2262 arguments:#('foo') |
2263 expect:true |
2263 expect:true |
2264 |
2264 |
2265 " |
2265 " |
2266 self run:#testOperators21a_ne |
2266 self run:#testOperators21a_ne |
2267 self new testOperators21a_ne |
2267 self new testOperators21a_ne |
2268 " |
2268 " |
2269 ! |
2269 ! |
2270 |
2270 |
2271 testOperators21b_ne |
2271 testOperators21b_ne |
2272 self |
2272 self |
2273 execute:'expr(a) { |
2273 execute:'expr(a) { |
2274 return (a !!= 0); |
2274 return (a !!= 0); |
2275 }' |
2275 }' |
2276 for:nil |
2276 for:nil |
2277 arguments:#(0) |
2277 arguments:#(0) |
2278 expect:false |
2278 expect:false |
2279 |
2279 |
2280 " |
2280 " |
2281 self run:#testOperators21b_ne |
2281 self run:#testOperators21b_ne |
2282 self new testOperators21b_ne |
2282 self new testOperators21b_ne |
2283 " |
2283 " |
2284 ! |
2284 ! |
2285 |
2285 |
2286 testOperators22a_gt |
2286 testOperators22a_gt |
2287 self |
2287 self |
2288 execute:'expr(a) { |
2288 execute:'expr(a) { |
2289 return (a > 0); |
2289 return (a > 0); |
2290 }' |
2290 }' |
2291 for:nil |
2291 for:nil |
2292 arguments:#(0) |
2292 arguments:#(0) |
2293 expect:false |
2293 expect:false |
2294 |
2294 |
2295 " |
2295 " |
2296 self run:#testOperators22a_gt |
2296 self run:#testOperators22a_gt |
2297 self new testOperators22a_gt |
2297 self new testOperators22a_gt |
2298 " |
2298 " |
2299 ! |
2299 ! |
2300 |
2300 |
2301 testOperators22b_gt |
2301 testOperators22b_gt |
2302 self |
2302 self |
2303 execute:'expr(a) { |
2303 execute:'expr(a) { |
2304 return (a > 0); |
2304 return (a > 0); |
2305 }' |
2305 }' |
2306 for:nil |
2306 for:nil |
2307 arguments:#(1) |
2307 arguments:#(1) |
2308 expect:true |
2308 expect:true |
2309 |
2309 |
2310 " |
2310 " |
2311 self run:#testOperators22b_gt |
2311 self run:#testOperators22b_gt |
2312 self new testOperators22b_gt |
2312 self new testOperators22b_gt |
2313 " |
2313 " |
2314 ! |
2314 ! |
2315 |
2315 |
2316 testOperators23a_unaryMinus |
2316 testOperators23a_unaryMinus |
2317 self |
2317 self |
2318 execute:'expr(a) { |
2318 execute:'expr(a) { |
2319 return (-a); |
2319 return (-a); |
2320 }' |
2320 }' |
2321 for:nil |
2321 for:nil |
2322 arguments:#(1) |
2322 arguments:#(1) |
2323 expect:-1 |
2323 expect:-1 |
2324 |
2324 |
2325 " |
2325 " |
2326 self run:#testOperators23a_unaryMinus |
2326 self run:#testOperators23a_unaryMinus |
2327 self new testOperators23a_unaryMinus |
2327 self new testOperators23a_unaryMinus |
2328 " |
2328 " |
2329 ! |
2329 ! |
2330 |
2330 |
2331 testOperators23b_unaryMinus |
2331 testOperators23b_unaryMinus |
2332 self |
2332 self |
2333 execute:'expr(a) { |
2333 execute:'expr(a) { |
2334 return (0 - -a); |
2334 return (0 - -a); |
2335 }' |
2335 }' |
2336 for:nil |
2336 for:nil |
2337 arguments:#(1) |
2337 arguments:#(1) |
2338 expect:1 |
2338 expect:1 |
2339 |
2339 |
2340 " |
2340 " |
2341 self run:#testOperators23b_unaryMinus |
2341 self run:#testOperators23b_unaryMinus |
2342 self new testOperators23b_unaryMinus |
2342 self new testOperators23b_unaryMinus |
2343 " |
2343 " |
2344 ! |
2344 ! |
2345 |
2345 |
2346 testOperators24a_div |
2346 testOperators24a_div |
2347 self |
2347 self |
2348 execute:'expr(a) { |
2348 execute:'expr(a) { |
2349 return (a / 4); |
2349 return (a / 4); |
2350 }' |
2350 }' |
2351 for:nil |
2351 for:nil |
2352 arguments:#(4) |
2352 arguments:#(4) |
2353 expect:1 |
2353 expect:1 |
2354 |
2354 |
2355 " |
2355 " |
2356 self run:#testOperators24a_div |
2356 self run:#testOperators24a_div |
2357 self new testOperators24a_div |
2357 self new testOperators24a_div |
2358 " |
2358 " |
2359 ! |
2359 ! |
2360 |
2360 |
2361 testOperators24b_div |
2361 testOperators24b_div |
2362 self |
2362 self |
2363 execute:'expr(a) { |
2363 execute:'expr(a) { |
2364 return (a / 4.0); |
2364 return (a / 4.0); |
2365 }' |
2365 }' |
2366 for:nil |
2366 for:nil |
2367 arguments:#(4) |
2367 arguments:#(4) |
2368 expect:1.0 |
2368 expect:1.0 |
2369 |
2369 |
2370 " |
2370 " |
2371 self run:#testOperators24b_div |
2371 self run:#testOperators24b_div |
2372 self new testOperators24b_div |
2372 self new testOperators24b_div |
2373 " |
2373 " |
2374 ! |
2374 ! |
2375 |
2375 |
2376 testOperators24c_div |
2376 testOperators24c_div |
2377 self |
2377 self |
2378 execute:'expr(a) { |
2378 execute:'expr(a) { |
2379 return (a / 4); |
2379 return (a / 4); |
2380 }' |
2380 }' |
2381 for:nil |
2381 for:nil |
2382 arguments:#(4.0) |
2382 arguments:#(4.0) |
2383 expect:1.0 |
2383 expect:1.0 |
2384 |
2384 |
2385 " |
2385 " |
2386 self run:#testOperators24c_div |
2386 self run:#testOperators24c_div |
2387 self new testOperators24c_div |
2387 self new testOperators24c_div |
2388 " |
2388 " |
2389 ! |
2389 ! |
2390 |
2390 |
2391 testOperators24d_div |
2391 testOperators24d_div |
2392 self |
2392 self |
2393 execute:'expr(a) { |
2393 execute:'expr(a) { |
2394 return (a / 4.0); |
2394 return (a / 4.0); |
2395 }' |
2395 }' |
2396 for:nil |
2396 for:nil |
2397 arguments:#(4.0) |
2397 arguments:#(4.0) |
2398 expect:1.0 |
2398 expect:1.0 |
2399 |
2399 |
2400 " |
2400 " |
2401 self run:#testOperators24d_div |
2401 self run:#testOperators24d_div |
2402 self new testOperators24d_div |
2402 self new testOperators24d_div |
2403 " |
2403 " |
2404 ! |
2404 ! |
2405 |
2405 |
2406 testOperators25a_mod |
2406 testOperators25a_mod |
2407 self |
2407 self |
2408 execute:'expr(a) { |
2408 execute:'expr(a) { |
2409 return (a % 4); |
2409 return (a % 4); |
2410 }' |
2410 }' |
2411 for:nil |
2411 for:nil |
2412 arguments:#(4) |
2412 arguments:#(4) |
2413 expect:0 |
2413 expect:0 |
2414 |
2414 |
2415 " |
2415 " |
2416 self run:#testOperators25a_mod |
2416 self run:#testOperators25a_mod |
2417 self new testOperators25a_mod |
2417 self new testOperators25a_mod |
2418 " |
2418 " |
2419 ! |
2419 ! |
2420 |
2420 |
2421 testOperators25b_mod |
2421 testOperators25b_mod |
2422 self |
2422 self |
2423 execute:'expr(a) { |
2423 execute:'expr(a) { |
2424 return (a % 4.0); |
2424 return (a % 4.0); |
2425 }' |
2425 }' |
2426 for:nil |
2426 for:nil |
2427 arguments:#(4) |
2427 arguments:#(4) |
2428 expect:0.0 |
2428 expect:0.0 |
2429 |
2429 |
2430 " |
2430 " |
2431 self run:#testOperators25b_mod |
2431 self run:#testOperators25b_mod |
2432 self new testOperators25b_mod |
2432 self new testOperators25b_mod |
2433 " |
2433 " |
2434 ! |
2434 ! |
2435 |
2435 |
2436 testOperators25c_mod |
2436 testOperators25c_mod |
2437 self |
2437 self |
2438 execute:'expr(a) { |
2438 execute:'expr(a) { |
2439 return (a % 4); |
2439 return (a % 4); |
2440 }' |
2440 }' |
2441 for:nil |
2441 for:nil |
2442 arguments:#(4.0) |
2442 arguments:#(4.0) |
2443 expect:0.0 |
2443 expect:0.0 |
2444 |
2444 |
2445 " |
2445 " |
2446 self run:#testOperators25c_mod |
2446 self run:#testOperators25c_mod |
2447 self new testOperators25c_mod |
2447 self new testOperators25c_mod |
2448 " |
2448 " |
2449 ! |
2449 ! |
2450 |
2450 |
2451 testOperators25d_mod |
2451 testOperators25d_mod |
2452 self |
2452 self |
2453 execute:'expr(a) { |
2453 execute:'expr(a) { |
2454 return (a % 4.0); |
2454 return (a % 4.0); |
2455 }' |
2455 }' |
2456 for:nil |
2456 for:nil |
2457 arguments:#(4.0) |
2457 arguments:#(4.0) |
2458 expect:0.0 |
2458 expect:0.0 |
2459 |
2459 |
2460 " |
2460 " |
2461 self run:#testOperators25d_mod |
2461 self run:#testOperators25d_mod |
2462 self new testOperators25d_mod |
2462 self new testOperators25d_mod |
2463 " |
2463 " |
2464 ! |
2464 ! |
2465 |
2465 |
2466 testOperators25e_mod |
2466 testOperators25e_mod |
2467 self |
2467 self |
2468 execute:'expr(a) { |
2468 execute:'expr(a) { |
2469 return (a % 4); |
2469 return (a % 4); |
2470 }' |
2470 }' |
2471 for:nil |
2471 for:nil |
2472 arguments:#(-4) |
2472 arguments:#(-4) |
2473 expect:0 |
2473 expect:0 |
2474 |
2474 |
2475 " |
2475 " |
2476 self run:#testOperators25e_mod |
2476 self run:#testOperators25e_mod |
2477 self new testOperators25e_mod |
2477 self new testOperators25e_mod |
2478 " |
2478 " |
2479 ! |
2479 ! |
2480 |
2480 |
2481 testOperators25f_mod |
2481 testOperators25f_mod |
2482 self |
2482 self |
2483 execute:'expr(a) { |
2483 execute:'expr(a) { |
2484 return (a % 4.0); |
2484 return (a % 4.0); |
2485 }' |
2485 }' |
2486 for:nil |
2486 for:nil |
2487 arguments:#(-4) |
2487 arguments:#(-4) |
2488 expect:0.0 |
2488 expect:0.0 |
2489 |
2489 |
2490 " |
2490 " |
2491 self run:#testOperators25f_mod |
2491 self run:#testOperators25f_mod |
2492 self new testOperators25f_mod |
2492 self new testOperators25f_mod |
2493 " |
2493 " |
2494 ! |
2494 ! |
2495 |
2495 |
2496 testOperators25g_mod |
2496 testOperators25g_mod |
2497 self |
2497 self |
2498 execute:'expr(a) { |
2498 execute:'expr(a) { |
2499 return (a % 4); |
2499 return (a % 4); |
2500 }' |
2500 }' |
2501 for:nil |
2501 for:nil |
2502 arguments:#(-4.0) |
2502 arguments:#(-4.0) |
2503 expect:0.0 |
2503 expect:0.0 |
2504 |
2504 |
2505 " |
2505 " |
2506 self run:#testOperators25g_mod |
2506 self run:#testOperators25g_mod |
2507 self new testOperators25g_mod |
2507 self new testOperators25g_mod |
2508 " |
2508 " |
2509 ! |
2509 ! |
2510 |
2510 |
2511 testOperators25h_mod |
2511 testOperators25h_mod |
2512 self |
2512 self |
2513 execute:'expr(a) { |
2513 execute:'expr(a) { |
2514 return (a % 4.0); |
2514 return (a % 4.0); |
2515 }' |
2515 }' |
2516 for:nil |
2516 for:nil |
2517 arguments:#(-4.0) |
2517 arguments:#(-4.0) |
2518 expect:0.0 |
2518 expect:0.0 |
2519 |
2519 |
2520 " |
2520 " |
2521 self run:#testOperators25h_mod |
2521 self run:#testOperators25h_mod |
2522 self new testOperators25h_mod |
2522 self new testOperators25h_mod |
2523 " |
2523 " |
2524 ! |
2524 ! |
2525 |
2525 |
2526 testOperators26a_postInc |
2526 testOperators26a_postInc |
2527 self |
2527 self |
2528 execute:'expr(a) { |
2528 execute:'expr(a) { |
2529 var x = a; |
2529 var x = a; |
2530 |
2530 |
2531 return (x++); |
2531 return (x++); |
2532 }' |
2532 }' |
2533 for:nil |
2533 for:nil |
2534 arguments:#(1) |
2534 arguments:#(1) |
2535 expect:1 |
2535 expect:1 |
2536 |
2536 |
2537 " |
2537 " |
2538 self run:#testOperators26a_postInc |
2538 self run:#testOperators26a_postInc |
2539 self new testOperators26a_postInc |
2539 self new testOperators26a_postInc |
2540 " |
2540 " |
2541 ! |
2541 ! |
2542 |
2542 |
2543 testOperators26b_postDec |
2543 testOperators26b_postDec |
2544 self |
2544 self |
2545 execute:'expr(a) { |
2545 execute:'expr(a) { |
2546 var x = a; |
2546 var x = a; |
2547 |
2547 |
2548 return (x--); |
2548 return (x--); |
2549 }' |
2549 }' |
2550 for:nil |
2550 for:nil |
2551 arguments:#(1) |
2551 arguments:#(1) |
2552 expect:1 |
2552 expect:1 |
2553 |
2553 |
2554 " |
2554 " |
2555 self run:#testOperators26b_postDec |
2555 self run:#testOperators26b_postDec |
2556 self new testOperators26b_postDec |
2556 self new testOperators26b_postDec |
2557 " |
2557 " |
2558 ! |
2558 ! |
2559 |
2559 |
2560 testOperators26c_preInc |
2560 testOperators26c_preInc |
2561 self |
2561 self |
2562 execute:'expr(a) { |
2562 execute:'expr(a) { |
2563 var x = a; |
2563 var x = a; |
2564 |
2564 |
2565 return (++x); |
2565 return (++x); |
2566 }' |
2566 }' |
2567 for:nil |
2567 for:nil |
2568 arguments:#(1) |
2568 arguments:#(1) |
2569 expect:2 |
2569 expect:2 |
2570 |
2570 |
2571 " |
2571 " |
2572 self run:#testOperators26c_preInc |
2572 self run:#testOperators26c_preInc |
2573 self new testOperators26c_preInc |
2573 self new testOperators26c_preInc |
2574 " |
2574 " |
2575 ! |
2575 ! |
2576 |
2576 |
2577 testOperators26d_preDec |
2577 testOperators26d_preDec |
2578 self |
2578 self |
2579 execute:'expr(a) { |
2579 execute:'expr(a) { |
2580 var x = a; |
2580 var x = a; |
2581 |
2581 |
2582 return (--x); |
2582 return (--x); |
2583 }' |
2583 }' |
2584 for:nil |
2584 for:nil |
2585 arguments:#(1) |
2585 arguments:#(1) |
2586 expect:0 |
2586 expect:0 |
2587 |
2587 |
2588 " |
2588 " |
2589 self run:#testOperators26d_preDec |
2589 self run:#testOperators26d_preDec |
2590 self new testOperators26d_preDec |
2590 self new testOperators26d_preDec |
2591 " |
2591 " |
2592 ! |
2592 ! |
2593 |
2593 |
2594 testOperators27a_postInc |
2594 testOperators27a_postInc |
2595 self |
2595 self |
2596 execute:'expr(a) { |
2596 execute:'expr(a) { |
2597 var x = a; |
2597 var x = a; |
2598 |
2598 |
2599 x++; |
2599 x++; |
2600 return (x); |
2600 return (x); |
2601 }' |
2601 }' |
2602 for:nil |
2602 for:nil |
2603 arguments:#(1) |
2603 arguments:#(1) |
2604 expect:2 |
2604 expect:2 |
2605 |
2605 |
2606 " |
2606 " |
2607 self run:#testOperators27a_postInc |
2607 self run:#testOperators27a_postInc |
2608 self new testOperators27a_postInc |
2608 self new testOperators27a_postInc |
2609 " |
2609 " |
2610 ! |
2610 ! |
2611 |
2611 |
2612 testOperators27b_postDec |
2612 testOperators27b_postDec |
2613 self |
2613 self |
2614 execute:'expr(a) { |
2614 execute:'expr(a) { |
2615 var x = a; |
2615 var x = a; |
2616 |
2616 |
2617 x--; |
2617 x--; |
2618 return (x); |
2618 return (x); |
2619 }' |
2619 }' |
2620 for:nil |
2620 for:nil |
2621 arguments:#(1) |
2621 arguments:#(1) |
2622 expect:0 |
2622 expect:0 |
2623 |
2623 |
2624 " |
2624 " |
2625 self run:#testOperators27b_postDec |
2625 self run:#testOperators27b_postDec |
2626 self new testOperators27b_postDec |
2626 self new testOperators27b_postDec |
2627 " |
2627 " |
2628 ! |
2628 ! |
2629 |
2629 |
2630 testOperators27c_preInc |
2630 testOperators27c_preInc |
2631 self |
2631 self |
2632 execute:'expr(a) { |
2632 execute:'expr(a) { |
2633 var x = a; |
2633 var x = a; |
2634 |
2634 |
2635 ++x; |
2635 ++x; |
2636 return (x); |
2636 return (x); |
2637 }' |
2637 }' |
2638 for:nil |
2638 for:nil |
2639 arguments:#(1) |
2639 arguments:#(1) |
2640 expect:2 |
2640 expect:2 |
2641 |
2641 |
2642 " |
2642 " |
2643 self run:#testOperators27c_preInc |
2643 self run:#testOperators27c_preInc |
2644 self new testOperators27c_preInc |
2644 self new testOperators27c_preInc |
2645 " |
2645 " |
2646 ! |
2646 ! |
2647 |
2647 |
2648 testOperators27d_preDec |
2648 testOperators27d_preDec |
2649 self |
2649 self |
2650 execute:'expr(a) { |
2650 execute:'expr(a) { |
2651 var x = a; |
2651 var x = a; |
2652 |
2652 |
2653 --x; |
2653 --x; |
2654 return (x); |
2654 return (x); |
2655 }' |
2655 }' |
2656 for:nil |
2656 for:nil |
2657 arguments:#(1) |
2657 arguments:#(1) |
2658 expect:0 |
2658 expect:0 |
2659 |
2659 |
2660 " |
2660 " |
2661 self run:#testOperators27d_preDec |
2661 self run:#testOperators27d_preDec |
2662 self new testOperators27d_preDec |
2662 self new testOperators27d_preDec |
2663 " |
2663 " |
2687 testOperators27f_preDec |
2687 testOperators27f_preDec |
2688 |arr| |
2688 |arr| |
2689 |
2689 |
2690 arr := (1 to:15) asArray. |
2690 arr := (1 to:15) asArray. |
2691 |
2691 |
2692 self |
2692 self |
2693 execute:'expr(a) { |
2693 execute:'expr(a) { |
2694 return (--a[10]); |
2694 return (--a[10]); |
2695 }' |
2695 }' |
2696 for:nil |
2696 for:nil |
2697 arguments:{ arr } |
2697 arguments:{ arr } |
2698 expect:9. |
2698 expect:9. |
2699 |
2699 |
2700 self assert:(arr = #(1 2 3 4 5 6 7 8 9 9 11 12 13 14 15)) |
2700 self assert:(arr = #(1 2 3 4 5 6 7 8 9 9 11 12 13 14 15)) |
2701 |
2701 |
2702 " |
2702 " |
2703 self run:#testOperators27f_preDec |
2703 self run:#testOperators27f_preDec |
2704 self new testOperators27f_preDec |
2704 self new testOperators27f_preDec |
2705 " |
2705 " |
2706 ! |
2706 ! |
2707 |
2707 |
2708 testOperators28_not |
2708 testOperators28_not |
2709 self |
2709 self |
2710 execute:'expr(a) { |
2710 execute:'expr(a) { |
2711 return (!! a); |
2711 return (!! a); |
2712 }' |
2712 }' |
2713 for:nil |
2713 for:nil |
2714 arguments:#(true) |
2714 arguments:#(true) |
2715 expect:false |
2715 expect:false |
2716 |
2716 |
2717 " |
2717 " |
2718 self run:#testOperators28_not |
2718 self run:#testOperators28_not |
2719 self new testOperators28_not |
2719 self new testOperators28_not |
2720 " |
2720 " |
2721 ! |
2721 ! |
2722 |
2722 |
2723 testOperators29a_plusAssign |
2723 testOperators29a_plusAssign |
2724 self |
2724 self |
2725 execute:'expr(a, b, c, d) { |
2725 execute:'expr(a, b, c, d) { |
2726 var s = 0; |
2726 var s = 0; |
2727 s += a; |
2727 s += a; |
2728 s += b; |
2728 s += b; |
2729 s += c; |
2729 s += c; |
2730 s += d; |
2730 s += d; |
2731 s += 1; |
2731 s += 1; |
2732 return (s); |
2732 return (s); |
2733 }' |
2733 }' |
2734 for:nil |
2734 for:nil |
2735 arguments:#( 1 2 3 4 ) |
2735 arguments:#( 1 2 3 4 ) |
2736 expect:11 |
2736 expect:11 |
2737 |
2737 |
2738 " |
2738 " |
2739 self run:#testOperators29a_plusAssign |
2739 self run:#testOperators29a_plusAssign |
2740 self new testOperators29a_plusAssign |
2740 self new testOperators29a_plusAssign |
2741 " |
2741 " |
2742 ! |
2742 ! |
2743 |
2743 |
2744 testOperators29c_minusAssign |
2744 testOperators29c_minusAssign |
2745 self |
2745 self |
2746 execute:'expr(a, b, c, d) { |
2746 execute:'expr(a, b, c, d) { |
2747 var s = 0; |
2747 var s = 0; |
2748 s -= a; |
2748 s -= a; |
2749 s -= b; |
2749 s -= b; |
2750 s -= c; |
2750 s -= c; |
2751 s -= d; |
2751 s -= d; |
2752 s -= 1; |
2752 s -= 1; |
2753 return (s); |
2753 return (s); |
2754 }' |
2754 }' |
2755 for:nil |
2755 for:nil |
2756 arguments:#( 1 2 3 4 ) |
2756 arguments:#( 1 2 3 4 ) |
2757 expect:-11 |
2757 expect:-11 |
2758 |
2758 |
2759 " |
2759 " |
2760 self run:#testOperators29c_minusAssign |
2760 self run:#testOperators29c_minusAssign |
2761 self new testOperators29c_minusAssign |
2761 self new testOperators29c_minusAssign |
2762 " |
2762 " |
2763 ! |
2763 ! |
2764 |
2764 |
2765 testOperators30_timesAssign |
2765 testOperators30_timesAssign |
2766 self |
2766 self |
2767 execute:'expr(a, b, c, d) { |
2767 execute:'expr(a, b, c, d) { |
2768 var s = 1; |
2768 var s = 1; |
2769 s *= a; |
2769 s *= a; |
2770 s *= b; |
2770 s *= b; |
2771 s *= c; |
2771 s *= c; |
2772 s *= d; |
2772 s *= d; |
2773 s *= 2; |
2773 s *= 2; |
2774 return (s); |
2774 return (s); |
2775 }' |
2775 }' |
2776 for:nil |
2776 for:nil |
2777 arguments:#( 1 2 3 4 ) |
2777 arguments:#( 1 2 3 4 ) |
2778 expect:48 |
2778 expect:48 |
2779 |
2779 |
2780 " |
2780 " |
2781 self run:#testOperators30_timesAssign |
2781 self run:#testOperators30_timesAssign |
2782 self new testOperators30_timesAssign |
2782 self new testOperators30_timesAssign |
2783 " |
2783 " |
2784 ! |
2784 ! |
2785 |
2785 |
2786 testOperators31a_shiftLeft |
2786 testOperators31a_shiftLeft |
2787 self |
2787 self |
2788 execute:'expr(a) { |
2788 execute:'expr(a) { |
2789 return (a << 1); |
2789 return (a << 1); |
2790 }' |
2790 }' |
2791 for:nil |
2791 for:nil |
2792 arguments:#( 1 ) |
2792 arguments:#( 1 ) |
2793 expect:2 |
2793 expect:2 |
2794 |
2794 |
2795 " |
2795 " |
2796 self run:#testOperators31a_shiftLeft |
2796 self run:#testOperators31a_shiftLeft |
2797 self new testOperators31a_shiftLeft |
2797 self new testOperators31a_shiftLeft |
2798 " |
2798 " |
2799 ! |
2799 ! |
2800 |
2800 |
2801 testOperators31b_shiftLeft |
2801 testOperators31b_shiftLeft |
2802 self |
2802 self |
2803 execute:'expr(a) { |
2803 execute:'expr(a) { |
2804 return (a << 32); |
2804 return (a << 32); |
2805 }' |
2805 }' |
2806 for:nil |
2806 for:nil |
2807 arguments:#( 1 ) |
2807 arguments:#( 1 ) |
2808 expect:16r100000000 |
2808 expect:16r100000000 |
2809 |
2809 |
2810 " |
2810 " |
2811 self run:#testOperators31b_shiftLeft |
2811 self run:#testOperators31b_shiftLeft |
2812 self new testOperators31b_shiftLeft |
2812 self new testOperators31b_shiftLeft |
2813 " |
2813 " |
2814 ! |
2814 ! |
2815 |
2815 |
2816 testOperators31c_shiftLeftAssign |
2816 testOperators31c_shiftLeftAssign |
2817 self |
2817 self |
2818 execute:'expr(a) { |
2818 execute:'expr(a) { |
2819 var b = a; |
2819 var b = a; |
2820 |
2820 |
2821 b <<= 1; |
2821 b <<= 1; |
2822 return b; |
2822 return b; |
2823 }' |
2823 }' |
2824 for:nil |
2824 for:nil |
2825 arguments:#( 1 ) |
2825 arguments:#( 1 ) |
2826 expect:2 |
2826 expect:2 |
2827 |
2827 |
2828 " |
2828 " |
2829 self run:#testOperators31c_shiftLeftAssign |
2829 self run:#testOperators31c_shiftLeftAssign |
2830 self new testOperators31c_shiftLeftAssign |
2830 self new testOperators31c_shiftLeftAssign |
2831 " |
2831 " |
2832 ! |
2832 ! |
2833 |
2833 |
2834 testOperators32a_shiftRight |
2834 testOperators32a_shiftRight |
2835 self |
2835 self |
2836 execute:'expr(a) { |
2836 execute:'expr(a) { |
2837 return (a >> 1); |
2837 return (a >> 1); |
2838 }' |
2838 }' |
2839 for:nil |
2839 for:nil |
2840 arguments:#( 2 ) |
2840 arguments:#( 2 ) |
2841 expect:1 |
2841 expect:1 |
2842 |
2842 |
2843 " |
2843 " |
2844 self run:#testOperators32a_shiftRight |
2844 self run:#testOperators32a_shiftRight |
2845 self new testOperators32a_shiftRight |
2845 self new testOperators32a_shiftRight |
2846 " |
2846 " |
2847 ! |
2847 ! |
2848 |
2848 |
2849 testOperators32b_shiftRightAssign |
2849 testOperators32b_shiftRightAssign |
2850 self |
2850 self |
2851 execute:'expr(a) { |
2851 execute:'expr(a) { |
2852 var b = a; |
2852 var b = a; |
2853 |
2853 |
2854 b >>= 1; |
2854 b >>= 1; |
2855 return b; |
2855 return b; |
2856 }' |
2856 }' |
2857 for:nil |
2857 for:nil |
2858 arguments:#( 5 ) |
2858 arguments:#( 5 ) |
2859 expect:2 |
2859 expect:2 |
2860 |
2860 |
2861 " |
2861 " |
2862 self run:#testOperators32b_shiftRightAssign |
2862 self run:#testOperators32b_shiftRightAssign |
2863 self new testOperators32b_shiftRightAssign |
2863 self new testOperators32b_shiftRightAssign |
2864 " |
2864 " |
2865 ! |
2865 ! |
2866 |
2866 |
2867 testOperators33_bitOrAssign |
2867 testOperators33_bitOrAssign |
2868 self |
2868 self |
2869 execute:'expr(a, b) { |
2869 execute:'expr(a, b) { |
2870 var s = 0; |
2870 var s = 0; |
2871 s |= a; |
2871 s |= a; |
2872 s |= b; |
2872 s |= b; |
2873 return (s); |
2873 return (s); |
2874 }' |
2874 }' |
2875 for:nil |
2875 for:nil |
2876 arguments:#(1 4) |
2876 arguments:#(1 4) |
2877 expect:5 |
2877 expect:5 |
2878 |
2878 |
2879 " |
2879 " |
2880 self run:#testOperators33_bitOrAssign |
2880 self run:#testOperators33_bitOrAssign |
2881 self new testOperators33_bitOrAssign |
2881 self new testOperators33_bitOrAssign |
2882 " |
2882 " |
2883 ! |
2883 ! |
2884 |
2884 |
2885 testOperators34_bitAndAssign |
2885 testOperators34_bitAndAssign |
2886 self |
2886 self |
2887 execute:'expr(a, b) { |
2887 execute:'expr(a, b) { |
2888 var s = 0xFFFF; |
2888 var s = 0xFFFF; |
2889 s &= a; |
2889 s &= a; |
2890 s &= b; |
2890 s &= b; |
2891 return (s); |
2891 return (s); |
2892 }' |
2892 }' |
2893 for:nil |
2893 for:nil |
2894 arguments:#(3 5) |
2894 arguments:#(3 5) |
2895 expect:1 |
2895 expect:1 |
2896 |
2896 |
2897 " |
2897 " |
2898 self run:#testOperators34_bitAndAssign |
2898 self run:#testOperators34_bitAndAssign |
2899 self new testOperators34_bitAndAssign |
2899 self new testOperators34_bitAndAssign |
2900 " |
2900 " |
2901 ! |
2901 ! |
2902 |
2902 |
2903 testOperators35a_bitXorAssign |
2903 testOperators35a_bitXorAssign |
2904 self |
2904 self |
2905 execute:'expr(a) { |
2905 execute:'expr(a) { |
2906 var s = 0xFFFF; |
2906 var s = 0xFFFF; |
2907 s ^= a; |
2907 s ^= a; |
2908 return (s); |
2908 return (s); |
2909 }' |
2909 }' |
2910 for:nil |
2910 for:nil |
2911 arguments:#( 1 ) |
2911 arguments:#( 1 ) |
2912 expect:16rFFFE |
2912 expect:16rFFFE |
2913 |
2913 |
2914 " |
2914 " |
2915 self run:#testOperators35a_xorAssign |
2915 self run:#testOperators35a_xorAssign |
2916 self new testOperators35a_xorAssign |
2916 self new testOperators35a_xorAssign |
2917 " |
2917 " |
2918 ! |
2918 ! |
2919 |
2919 |
2920 testOperators35b_bitXor |
2920 testOperators35b_bitXor |
2921 self |
2921 self |
2922 execute:'expr(a) { |
2922 execute:'expr(a) { |
2923 var s = 0xFFFF; |
2923 var s = 0xFFFF; |
2924 s = s ^ a; |
2924 s = s ^ a; |
2925 return (s); |
2925 return (s); |
2926 }' |
2926 }' |
2927 for:nil |
2927 for:nil |
2928 arguments:#( 1 ) |
2928 arguments:#( 1 ) |
2929 expect:16rFFFE |
2929 expect:16rFFFE |
2930 |
2930 |
2931 " |
2931 " |
2932 self run:#testOperators35b_xor |
2932 self run:#testOperators35b_xor |
2933 self new testOperators35b_xor |
2933 self new testOperators35b_xor |
2934 " |
2934 " |
2935 ! |
2935 ! |
2936 |
2936 |
2937 testOperators36a_mod |
2937 testOperators36a_mod |
2938 self |
2938 self |
2939 execute:'expr(a) { |
2939 execute:'expr(a) { |
2940 return (a % 2); |
2940 return (a % 2); |
2941 }' |
2941 }' |
2942 for:nil |
2942 for:nil |
2943 arguments:#(10) |
2943 arguments:#(10) |
2944 expect:0 |
2944 expect:0 |
2945 |
2945 |
2946 " |
2946 " |
2947 self run:#testOperators36a_mod |
2947 self run:#testOperators36a_mod |
2948 self new testOperators36a_mod |
2948 self new testOperators36a_mod |
2949 " |
2949 " |
2950 ! |
2950 ! |
2951 |
2951 |
2952 testOperators36b_mod |
2952 testOperators36b_mod |
2953 self |
2953 self |
2954 execute:'expr(a) { |
2954 execute:'expr(a) { |
2955 return (a % 2); |
2955 return (a % 2); |
2956 }' |
2956 }' |
2957 for:nil |
2957 for:nil |
2958 arguments:#(9) |
2958 arguments:#(9) |
2959 expect:1 |
2959 expect:1 |
2960 |
2960 |
2961 " |
2961 " |
2962 self run:#testOperators36b_mod |
2962 self run:#testOperators36b_mod |
2963 self new testOperators36b_mod |
2963 self new testOperators36b_mod |
2964 " |
2964 " |
2965 ! |
2965 ! |
2966 |
2966 |
2967 testOperators37a_cond |
2967 testOperators37a_cond |
2968 self |
2968 self |
2969 execute:'expr(a) { |
2969 execute:'expr(a) { |
2970 return (a ? 1 : 0); |
2970 return (a ? 1 : 0); |
2971 }' |
2971 }' |
2972 for:nil |
2972 for:nil |
2973 arguments:#(true) |
2973 arguments:#(true) |
2974 expect:1 |
2974 expect:1 |
2975 |
2975 |
2976 " |
2976 " |
2977 self run:#testOperators37a_cond |
2977 self run:#testOperators37a_cond |
2978 self new testOperators37a_cond |
2978 self new testOperators37a_cond |
2979 " |
2979 " |
2980 ! |
2980 ! |
2981 |
2981 |
2982 testOperators37b_cond |
2982 testOperators37b_cond |
2983 self |
2983 self |
2984 execute:'expr(a) { |
2984 execute:'expr(a) { |
2985 return (a ? 1 : 0); |
2985 return (a ? 1 : 0); |
2986 }' |
2986 }' |
2987 for:nil |
2987 for:nil |
2988 arguments:#(false) |
2988 arguments:#(false) |
2989 expect:0 |
2989 expect:0 |
2990 |
2990 |
2991 " |
2991 " |
2992 self run:#testOperators37b_cond |
2992 self run:#testOperators37b_cond |
2993 self new testOperators37b_cond |
2993 self new testOperators37b_cond |
2994 " |
2994 " |
2995 ! |
2995 ! |
2996 |
2996 |
2997 testOperators37c_cond |
2997 testOperators37c_cond |
2998 self |
2998 self |
2999 execute:'expr(a, b) { |
2999 execute:'expr(a, b) { |
3000 return (a ? (b ? 0 : 1) : (b ? 2 : 3)); |
3000 return (a ? (b ? 0 : 1) : (b ? 2 : 3)); |
3001 }' |
3001 }' |
3002 for:nil |
3002 for:nil |
3003 arguments:#(false false) |
3003 arguments:#(false false) |
3004 expect:3 |
3004 expect:3 |
3005 |
3005 |
3006 " |
3006 " |
3007 self run:#testOperators37c_cond |
3007 self run:#testOperators37c_cond |
3008 self new testOperators37c_cond |
3008 self new testOperators37c_cond |
3009 " |
3009 " |
3010 ! |
3010 ! |
3011 |
3011 |
3012 testOperators37d_cond |
3012 testOperators37d_cond |
3013 self |
3013 self |
3014 execute:'expr(a) { |
3014 execute:'expr(a) { |
3015 return (a == 1 ? 2 : 3); |
3015 return (a == 1 ? 2 : 3); |
3016 }' |
3016 }' |
3017 for:nil |
3017 for:nil |
3018 arguments:#(1) |
3018 arguments:#(1) |
3019 expect:2 |
3019 expect:2 |
3020 |
3020 |
3021 " |
3021 " |
3022 self run:#testOperators37d_cond |
3022 self run:#testOperators37d_cond |
3023 self new testOperators37d_cond |
3023 self new testOperators37d_cond |
3024 " |
3024 " |
3025 ! |
3025 ! |
3026 |
3026 |
3027 testOperators38a_eq |
3027 testOperators38a_eq |
3028 self |
3028 self |
3029 execute:'expr(a) { |
3029 execute:'expr(a) { |
3030 return (a == 1); |
3030 return (a == 1); |
3031 }' |
3031 }' |
3032 for:nil |
3032 for:nil |
3033 arguments:#(1) |
3033 arguments:#(1) |
3034 expect:true |
3034 expect:true |
3035 |
3035 |
3036 " |
3036 " |
3037 self run:#testOperators38a_eq |
3037 self run:#testOperators38a_eq |
3038 self new testOperators38a_eq |
3038 self new testOperators38a_eq |
3039 " |
3039 " |
3040 ! |
3040 ! |
3041 |
3041 |
3042 testOperators38b_eq |
3042 testOperators38b_eq |
3043 self |
3043 self |
3044 execute:'expr(a) { |
3044 execute:'expr(a) { |
3045 return (a == 1); |
3045 return (a == 1); |
3046 }' |
3046 }' |
3047 for:nil |
3047 for:nil |
3048 arguments:#(1.0) |
3048 arguments:#(1.0) |
3049 expect:true |
3049 expect:true |
3050 |
3050 |
3051 " |
3051 " |
3052 self run:#testOperators38b_eq |
3052 self run:#testOperators38b_eq |
3053 self new testOperators38b_eq |
3053 self new testOperators38b_eq |
3054 " |
3054 " |
3055 ! |
3055 ! |
3056 |
3056 |
3057 testOperators38c_eq |
3057 testOperators38c_eq |
3058 self |
3058 self |
3059 execute:'expr(a) { |
3059 execute:'expr(a) { |
3060 return ( "hello"[1].asString == "h" ); |
3060 return ( "hello"[1].asString == "h" ); |
3061 }' |
3061 }' |
3062 for:nil |
3062 for:nil |
3063 arguments:#(1.0) |
3063 arguments:#(1.0) |
3064 expect:true |
3064 expect:true |
3065 |
3065 |
3066 " |
3066 " |
3067 self run:#testOperators38c_eq |
3067 self run:#testOperators38c_eq |
3068 self new testOperators38c_eq |
3068 self new testOperators38c_eq |
3069 " |
3069 " |
3070 |
3070 |
3071 "Modified: / 21-02-2007 / 14:12:07 / cg" |
3071 "Modified: / 21-02-2007 / 14:12:07 / cg" |
3072 ! |
3072 ! |
3073 |
3073 |
3074 testOperators38c_ne |
3074 testOperators38c_ne |
3075 self |
3075 self |
3076 execute:'expr(a) { |
3076 execute:'expr(a) { |
3077 return (a !!= 1); |
3077 return (a !!= 1); |
3078 }' |
3078 }' |
3079 for:nil |
3079 for:nil |
3080 arguments:#(1.0) |
3080 arguments:#(1.0) |
3081 expect:false |
3081 expect:false |
3082 |
3082 |
3083 " |
3083 " |
3084 self run:#testOperators38c_ne |
3084 self run:#testOperators38c_ne |
3085 self new testOperators38c_ne |
3085 self new testOperators38c_ne |
3086 " |
3086 " |
3087 ! |
3087 ! |
3088 |
3088 |
3089 testOperators38d_eq |
3089 testOperators38d_eq |
3090 self |
3090 self |
3091 execute:'expr(a) { |
3091 execute:'expr(a) { |
3092 return ("hello"[1] == $''h'' ); |
3092 return ("hello"[1] == $''h'' ); |
3093 }' |
3093 }' |
3094 for:nil |
3094 for:nil |
3095 arguments:#(1.0) |
3095 arguments:#(1.0) |
3096 expect:true |
3096 expect:true |
3097 |
3097 |
3098 " |
3098 " |
3099 self run:#testOperators38d_eq |
3099 self run:#testOperators38d_eq |
3100 self new testOperators38d_eq |
3100 self new testOperators38d_eq |
3101 " |
3101 " |
3102 ! |
3102 ! |
3103 |
3103 |
3104 testOperators38d_ne |
3104 testOperators38d_ne |
3105 self |
3105 self |
3106 execute:'expr(a) { |
3106 execute:'expr(a) { |
3107 return (a !!= 1); |
3107 return (a !!= 1); |
3108 }' |
3108 }' |
3109 for:nil |
3109 for:nil |
3110 arguments:#(2.0) |
3110 arguments:#(2.0) |
3111 expect:true |
3111 expect:true |
3112 |
3112 |
3113 " |
3113 " |
3114 self run:#testOperators38d_ne |
3114 self run:#testOperators38d_ne |
3115 self new testOperators38d_ne |
3115 self new testOperators38d_ne |
3116 " |
3116 " |
3117 ! |
3117 ! |
3118 |
3118 |
3119 testOperators38e_eq |
3119 testOperators38e_eq |
3120 self |
3120 self |
3121 execute:'expr(a) { |
3121 execute:'expr(a) { |
3122 return ( "hello"[1] == "h"[1] ); |
3122 return ( "hello"[1] == "h"[1] ); |
3123 }' |
3123 }' |
3124 for:nil |
3124 for:nil |
3125 arguments:#(1.0) |
3125 arguments:#(1.0) |
3126 expect:true |
3126 expect:true |
3127 |
3127 |
3128 " |
3128 " |
3129 self run:#testOperators38e_eq |
3129 self run:#testOperators38e_eq |
3130 self new testOperators38e_eq |
3130 self new testOperators38e_eq |
3131 " |
3131 " |
3132 |
3132 |
3133 "Created: / 21-02-2007 / 14:15:14 / cg" |
3133 "Created: / 21-02-2007 / 14:15:14 / cg" |
3134 ! |
3134 ! |
3135 |
3135 |
3136 testOperators38f_eq |
3136 testOperators38f_eq |
3137 self |
3137 self |
3138 execute:'expr(a) { |
3138 execute:'expr(a) { |
3139 return ( ("hello"[1]).asString == "h" ); |
3139 return ( ("hello"[1]).asString == "h" ); |
3140 }' |
3140 }' |
3141 for:nil |
3141 for:nil |
3142 arguments:#(1.0) |
3142 arguments:#(1.0) |
3143 expect:true |
3143 expect:true |
3144 |
3144 |
3145 " |
3145 " |
3146 self run:#testOperators38f_eq |
3146 self run:#testOperators38f_eq |
3147 self new testOperators38f_eq |
3147 self new testOperators38f_eq |
3148 " |
3148 " |
3149 |
3149 |
3150 "Created: / 21-02-2007 / 14:16:00 / cg" |
3150 "Created: / 21-02-2007 / 14:16:00 / cg" |
3151 ! |
3151 ! |
3152 |
3152 |
3153 testOperators39a_identical |
3153 testOperators39a_identical |
3154 self |
3154 self |
3155 execute:'expr(a) { |
3155 execute:'expr(a) { |
3156 return (a === 1); |
3156 return (a === 1); |
3157 }' |
3157 }' |
3158 for:nil |
3158 for:nil |
3159 arguments:#(1) |
3159 arguments:#(1) |
3160 expect:true |
3160 expect:true |
3161 |
3161 |
3162 " |
3162 " |
3163 self run:#testOperators39a_identical |
3163 self run:#testOperators39a_identical |
3164 self new testOperators39a_identical |
3164 self new testOperators39a_identical |
3165 " |
3165 " |
3166 ! |
3166 ! |
3167 |
3167 |
3168 testOperators39b_identical |
3168 testOperators39b_identical |
3169 self |
3169 self |
3170 execute:'expr(a) { |
3170 execute:'expr(a) { |
3171 return (a === 1); |
3171 return (a === 1); |
3172 }' |
3172 }' |
3173 for:nil |
3173 for:nil |
3174 arguments:#(1.0) |
3174 arguments:#(1.0) |
3175 expect:false |
3175 expect:false |
3176 |
3176 |
3177 " |
3177 " |
3178 self run:#testOperators39b_identical |
3178 self run:#testOperators39b_identical |
3179 self new testOperators39b_identical |
3179 self new testOperators39b_identical |
3180 " |
3180 " |
3181 ! |
3181 ! |
3182 |
3182 |
3183 testOperators39c_notIdentical |
3183 testOperators39c_notIdentical |
3184 self |
3184 self |
3185 execute:'expr(a) { |
3185 execute:'expr(a) { |
3186 return (a !!== 1); |
3186 return (a !!== 1); |
3187 }' |
3187 }' |
3188 for:nil |
3188 for:nil |
3189 arguments:#(1.0) |
3189 arguments:#(1.0) |
3190 expect:true |
3190 expect:true |
3191 |
3191 |
3192 " |
3192 " |
3193 self run:#testOperators39c_notIdentical |
3193 self run:#testOperators39c_notIdentical |
3194 self new testOperators39c_notIdentical |
3194 self new testOperators39c_notIdentical |
3195 " |
3195 " |
3196 ! |
3196 ! |
3197 |
3197 |
3198 testOperators39d_notIdentical |
3198 testOperators39d_notIdentical |
3199 self |
3199 self |
3200 execute:'expr(a) { |
3200 execute:'expr(a) { |
3201 return (a !!== 1); |
3201 return (a !!== 1); |
3202 }' |
3202 }' |
3203 for:nil |
3203 for:nil |
3204 arguments:#(1) |
3204 arguments:#(1) |
3205 expect:false |
3205 expect:false |
3206 |
3206 |
3207 " |
3207 " |
3208 self run:#testOperators39d_notIdentical |
3208 self run:#testOperators39d_notIdentical |
3209 self new testOperators39d_notIdentical |
3209 self new testOperators39d_notIdentical |
3210 " |
3210 " |
3211 ! |
3211 ! |
3212 |
3212 |
3213 testOperators40a_bitAnd |
3213 testOperators40a_bitAnd |
3214 self |
3214 self |
3215 execute:'expr(a) { |
3215 execute:'expr(a) { |
3216 return (a & 1); |
3216 return (a & 1); |
3217 }' |
3217 }' |
3218 for:nil |
3218 for:nil |
3219 arguments:#(1) |
3219 arguments:#(1) |
3220 expect:1 |
3220 expect:1 |
3221 |
3221 |
3222 " |
3222 " |
3223 self run:#testOperators40a_bitAnd |
3223 self run:#testOperators40a_bitAnd |
3224 self new testOperators40a_bitAnd |
3224 self new testOperators40a_bitAnd |
3225 " |
3225 " |
3226 ! |
3226 ! |
3227 |
3227 |
3228 testOperators40b_bitAnd |
3228 testOperators40b_bitAnd |
3229 self |
3229 self |
3230 execute:'expr(a) { |
3230 execute:'expr(a) { |
3231 return (a & 1); |
3231 return (a & 1); |
3232 }' |
3232 }' |
3233 for:nil |
3233 for:nil |
3234 arguments:#(7) |
3234 arguments:#(7) |
3235 expect:1 |
3235 expect:1 |
3236 |
3236 |
3237 " |
3237 " |
3238 self run:#testOperators40b_bitAnd |
3238 self run:#testOperators40b_bitAnd |
3239 self new testOperators40b_bitAnd |
3239 self new testOperators40b_bitAnd |
3240 " |
3240 " |
3241 ! |
3241 ! |
3242 |
3242 |
3243 testOperators41a_bitOr |
3243 testOperators41a_bitOr |
3244 self |
3244 self |
3245 execute:'expr(a) { |
3245 execute:'expr(a) { |
3246 return (a | 1); |
3246 return (a | 1); |
3247 }' |
3247 }' |
3248 for:nil |
3248 for:nil |
3249 arguments:#(6) |
3249 arguments:#(6) |
3250 expect:7 |
3250 expect:7 |
3251 |
3251 |
3252 " |
3252 " |
3253 self run:#testOperators41a_bitOr |
3253 self run:#testOperators41a_bitOr |
3254 self new testOperators41a_bitOr |
3254 self new testOperators41a_bitOr |
3255 " |
3255 " |
3256 ! |
3256 ! |
3257 |
3257 |
3258 testOperators42a_bitXor |
3258 testOperators42a_bitXor |
3259 self |
3259 self |
3260 execute:'expr(a) { |
3260 execute:'expr(a) { |
3261 return (a ^ 1); |
3261 return (a ^ 1); |
3262 }' |
3262 }' |
3263 for:nil |
3263 for:nil |
3264 arguments:#(7) |
3264 arguments:#(7) |
3265 expect:6 |
3265 expect:6 |
3266 |
3266 |
3267 " |
3267 " |
3268 self run:#testOperators42a_bitXor |
3268 self run:#testOperators42a_bitXor |
3269 self new testOperators42a_bitXor |
3269 self new testOperators42a_bitXor |
3270 " |
3270 " |
3271 ! |
3271 ! |
3272 |
3272 |
3273 testOperators43a_bitNot |
3273 testOperators43a_bitNot |
3274 self |
3274 self |
3275 execute:'expr(a) { |
3275 execute:'expr(a) { |
3276 return (~a); |
3276 return (~a); |
3277 }' |
3277 }' |
3278 for:nil |
3278 for:nil |
3279 arguments:#(1) |
3279 arguments:#(1) |
3280 expect:-2 |
3280 expect:-2 |
3281 |
3281 |
3282 " |
3282 " |
3283 self run:#testOperators43a_bitNot |
3283 self run:#testOperators43a_bitNot |
3284 self new testOperators43a_bitNot |
3284 self new testOperators43a_bitNot |
3285 " |
3285 " |
3286 ! |
3286 ! |
3287 |
3287 |
3288 testOperators44a_logAnd |
3288 testOperators44a_logAnd |
3289 self |
3289 self |
3290 execute:'expr(a, b) { |
3290 execute:'expr(a, b) { |
3291 return (a && (b > 5)); |
3291 return (a && (b > 5)); |
3292 }' |
3292 }' |
3293 for:nil |
3293 for:nil |
3294 arguments:#(true 6) |
3294 arguments:#(true 6) |
3295 expect:true. |
3295 expect:true. |
3296 |
3296 |
3297 self |
3297 self |
3298 execute:'expr(a, b) { |
3298 execute:'expr(a, b) { |
3299 return (a && (b > 5)); |
3299 return (a && (b > 5)); |
3300 }' |
3300 }' |
3301 for:nil |
3301 for:nil |
3302 arguments:#(true 5) |
3302 arguments:#(true 5) |
3303 expect:false. |
3303 expect:false. |
3304 |
3304 |
3305 self |
3305 self |
3306 execute:'expr(a, b) { |
3306 execute:'expr(a, b) { |
3307 return (a > 10 && (b > 5)); |
3307 return (a > 10 && (b > 5)); |
3308 }' |
3308 }' |
3309 for:nil |
3309 for:nil |
3310 arguments:#(10 5) |
3310 arguments:#(10 5) |
3311 expect:false. |
3311 expect:false. |
3312 |
3312 |
3313 self |
3313 self |
3314 execute:'expr(a, b) { |
3314 execute:'expr(a, b) { |
3315 return (a > 10 && (b > 5)); |
3315 return (a > 10 && (b > 5)); |
3316 }' |
3316 }' |
3317 for:nil |
3317 for:nil |
3318 arguments:#(11 5) |
3318 arguments:#(11 5) |
3319 expect:false. |
3319 expect:false. |
3320 |
3320 |
3321 self |
3321 self |
3322 execute:'expr(a, b) { |
3322 execute:'expr(a, b) { |
3323 return (a > 10 && (b > 5)); |
3323 return (a > 10 && (b > 5)); |
3324 }' |
3324 }' |
3325 for:nil |
3325 for:nil |
3326 arguments:#(10 6) |
3326 arguments:#(10 6) |
3327 expect:false. |
3327 expect:false. |
3328 |
3328 |
3329 self |
3329 self |
3330 execute:'expr(a, b) { |
3330 execute:'expr(a, b) { |
3331 return (a > 10 && (b > 5)); |
3331 return (a > 10 && (b > 5)); |
3332 }' |
3332 }' |
3333 for:nil |
3333 for:nil |
3334 arguments:#(11 15) |
3334 arguments:#(11 15) |
3335 expect:true. |
3335 expect:true. |
3336 |
3336 |
3337 self |
3337 self |
3338 execute:'expr(a, b) { |
3338 execute:'expr(a, b) { |
3339 return (a.size > 10 && (b.size > 5)); |
3339 return (a.size > 10 && (b.size > 5)); |
3340 }' |
3340 }' |
3341 for:nil |
3341 for:nil |
3342 arguments:{Array new:10 . Array new:5} |
3342 arguments:{Array new:10 . Array new:5} |
3343 expect:false. |
3343 expect:false. |
3344 |
3344 |
3345 self |
3345 self |
3346 execute:'expr(a, b) { |
3346 execute:'expr(a, b) { |
3347 return (a.size > 10 && (b.size > 5)); |
3347 return (a.size > 10 && (b.size > 5)); |
3348 }' |
3348 }' |
3349 for:nil |
3349 for:nil |
3350 arguments:{Array new:11 . Array new:5} |
3350 arguments:{Array new:11 . Array new:5} |
3351 expect:false. |
3351 expect:false. |
3352 |
3352 |
3353 self |
3353 self |
3354 execute:'expr(a, b) { |
3354 execute:'expr(a, b) { |
3355 return (a.size > 10 && (b.size > 5)); |
3355 return (a.size > 10 && (b.size > 5)); |
3356 }' |
3356 }' |
3357 for:nil |
3357 for:nil |
3358 arguments:{Array new:10 . Array new:6} |
3358 arguments:{Array new:10 . Array new:6} |
3359 expect:false. |
3359 expect:false. |
3360 |
3360 |
3361 self |
3361 self |
3362 execute:'expr(a, b) { |
3362 execute:'expr(a, b) { |
3363 return (a.size > 10 && (b.size > 5)); |
3363 return (a.size > 10 && (b.size > 5)); |
3364 }' |
3364 }' |
3365 for:nil |
3365 for:nil |
3366 arguments:{Array new:11 . Array new:15} |
3366 arguments:{Array new:11 . Array new:15} |
3367 expect:true. |
3367 expect:true. |
3368 |
3368 |
3369 " |
3369 " |
3370 self run:#testOperators44a_logAnd |
3370 self run:#testOperators44a_logAnd |
3371 self new testOperators44a_logAnd |
3371 self new testOperators44a_logAnd |
3372 " |
3372 " |
3439 |
3439 |
3440 testOperators45b_logOr |
3440 testOperators45b_logOr |
3441 "the right part of a logical or should not be evaluated, |
3441 "the right part of a logical or should not be evaluated, |
3442 if the left is already true" |
3442 if the left is already true" |
3443 |
3443 |
3444 self |
3444 self |
3445 execute:'expr(a, bIn) { |
3445 execute:'expr(a, bIn) { |
3446 var x, b; |
3446 var x, b; |
3447 |
3447 |
3448 b = bIn; |
3448 b = bIn; |
3449 x = (a || (b++ > 5)); |
3449 x = (a || (b++ > 5)); |
3450 return b; |
3450 return b; |
3451 }' |
3451 }' |
3452 for:nil |
3452 for:nil |
3453 arguments:#(true 5) |
3453 arguments:#(true 5) |
3454 expect:5. |
3454 expect:5. |
3455 |
3455 |
3456 self |
3456 self |
3457 execute:'expr(a, bIn) { |
3457 execute:'expr(a, bIn) { |
3458 var x, b; |
3458 var x, b; |
3459 |
3459 |
3460 b = bIn; |
3460 b = bIn; |
3461 x = (a || (b++ > 5)); |
3461 x = (a || (b++ > 5)); |
3462 return b; |
3462 return b; |
3463 }' |
3463 }' |
3464 for:nil |
3464 for:nil |
3465 arguments:#(false 5) |
3465 arguments:#(false 5) |
3466 expect:6 |
3466 expect:6 |
3467 |
3467 |
3468 " |
3468 " |
3469 self run:#testOperators45b_logOr |
3469 self run:#testOperators45b_logOr |
3470 self new testOperators45b_logOr |
3470 self new testOperators45b_logOr |
3471 " |
3471 " |
3472 ! |
3472 ! |
3473 |
3473 |
3474 testOperators46_comma |
3474 testOperators46_comma |
3475 self |
3475 self |
3476 execute:'expr(a, b, c) { |
3476 execute:'expr(a, b, c) { |
3477 var x; |
3477 var x; |
3478 |
3478 |
3479 x = a+1, b+1, c+1; |
3479 x = a+1, b+1, c+1; |
3480 return x; |
3480 return x; |
3481 }' |
3481 }' |
3482 for:nil |
3482 for:nil |
3483 arguments:#(1 2 3) |
3483 arguments:#(1 2 3) |
3484 expect:4. |
3484 expect:4. |
3485 |
3485 |
3486 self |
3486 self |
3487 execute:'expr(aIn, bIn, cIn) { |
3487 execute:'expr(aIn, bIn, cIn) { |
3488 var x; |
3488 var x; |
3489 var a = aIn; |
3489 var a = aIn; |
3490 var b = bIn; |
3490 var b = bIn; |
3491 var c = cIn; |
3491 var c = cIn; |
3492 |
3492 |
3493 x = ++a , ++b, ++c, a+b+c; |
3493 x = ++a , ++b, ++c, a+b+c; |
3494 return x; |
3494 return x; |
3495 }' |
3495 }' |
3496 for:nil |
3496 for:nil |
3497 arguments:#(1 2 3) |
3497 arguments:#(1 2 3) |
3498 expect:9. |
3498 expect:9. |
3499 |
3499 |
3500 self |
3500 self |
3501 execute:'expr(aIn, bIn, cIn) { |
3501 execute:'expr(aIn, bIn, cIn) { |
3502 var x; |
3502 var x; |
3503 var a = aIn; |
3503 var a = aIn; |
3504 var b = bIn; |
3504 var b = bIn; |
3505 var c = cIn; |
3505 var c = cIn; |
3506 |
3506 |
3507 x = a++ , b++, c++, a+b+c; |
3507 x = a++ , b++, c++, a+b+c; |
3508 return x; |
3508 return x; |
3509 }' |
3509 }' |
3510 for:nil |
3510 for:nil |
3511 arguments:#(1 2 3) |
3511 arguments:#(1 2 3) |
3512 expect:9. |
3512 expect:9. |
3513 |
3513 |
3514 self |
3514 self |
3515 execute:'expr(aIn, bIn, cIn) { |
3515 execute:'expr(aIn, bIn, cIn) { |
3516 var x; |
3516 var x; |
3517 var a = aIn; |
3517 var a = aIn; |
3518 var b = bIn; |
3518 var b = bIn; |
3519 var c = cIn; |
3519 var c = cIn; |
3520 |
3520 |
3521 x = a++ , b++, c++, ++a + ++b + ++c; |
3521 x = a++ , b++, c++, ++a + ++b + ++c; |
3522 return x; |
3522 return x; |
3523 }' |
3523 }' |
3524 for:nil |
3524 for:nil |
3525 arguments:#(1 2 3) |
3525 arguments:#(1 2 3) |
3526 expect:12. |
3526 expect:12. |
3527 |
3527 |
3528 self |
3528 self |
3529 execute:'expr(aIn, bIn, cIn) { |
3529 execute:'expr(aIn, bIn, cIn) { |
3530 var x; |
3530 var x; |
3531 var a = aIn; |
3531 var a = aIn; |
3532 var b = bIn; |
3532 var b = bIn; |
3533 var c = cIn; |
3533 var c = cIn; |
3534 |
3534 |
3535 x = a++ , b++, c++, a++ + b++ + c++; |
3535 x = a++ , b++, c++, a++ + b++ + c++; |
3536 return x; |
3536 return x; |
3537 }' |
3537 }' |
3538 for:nil |
3538 for:nil |
3539 arguments:#(1 2 3) |
3539 arguments:#(1 2 3) |
3540 expect:9. |
3540 expect:9. |
3541 " |
3541 " |
3542 self run:#testOperators46_comma |
3542 self run:#testOperators46_comma |
3543 self new testOperators46_comma |
3543 self new testOperators46_comma |
3544 " |
3544 " |
3545 ! |
3545 ! |
3546 |
3546 |
3547 testOperators47_asString |
3547 testOperators47_asString |
3548 self |
3548 self |
3549 execute:'expr() { |
3549 execute:'expr() { |
3550 return 123.asString; |
3550 return 123.asString; |
3551 }' |
3551 }' |
3552 for:nil |
3552 for:nil |
3553 arguments:#() |
3553 arguments:#() |
3554 expect:'123'. |
3554 expect:'123'. |
3555 |
3555 |
3556 self |
3556 self |
3557 execute:'expr() { |
3557 execute:'expr() { |
3558 return 1.23.asString; |
3558 return 1.23.asString; |
3559 }' |
3559 }' |
3560 for:nil |
3560 for:nil |
3561 arguments:#() |
3561 arguments:#() |
3562 expect:'1.23'. |
3562 expect:'1.23'. |
3563 |
3563 |
3564 " |
3564 " |
3565 self run:#testOperators47_toString |
3565 self run:#testOperators47_toString |
3566 self new testOperators47_toString |
3566 self new testOperators47_toString |
3567 " |
3567 " |
3568 ! |
3568 ! |
3569 |
3569 |
3570 testOperators48_isArray |
3570 testOperators48_isArray |
3571 self |
3571 self |
3572 execute:'expr(arg) { |
3572 execute:'expr(arg) { |
3573 return arg.isArray() ; |
3573 return arg.isArray() ; |
3574 }' |
3574 }' |
3575 for:nil |
3575 for:nil |
3576 arguments:#(123) |
3576 arguments:#(123) |
3577 expect:false. |
3577 expect:false. |
3578 |
3578 |
3579 self |
3579 self |
3580 execute:'expr(arg) { |
3580 execute:'expr(arg) { |
3581 return arg.isArray() ; |
3581 return arg.isArray() ; |
3582 }' |
3582 }' |
3583 for:nil |
3583 for:nil |
3584 arguments:#('hello') |
3584 arguments:#('hello') |
3585 expect:false. |
3585 expect:false. |
3586 |
3586 |
3587 self |
3587 self |
3588 execute:'expr(arg) { |
3588 execute:'expr(arg) { |
3589 return arg.isArray() ; |
3589 return arg.isArray() ; |
3590 }' |
3590 }' |
3591 for:nil |
3591 for:nil |
3592 arguments:#( (1 2 3) ) |
3592 arguments:#( (1 2 3) ) |
3593 expect:true. |
3593 expect:true. |
3594 |
3594 |
3595 " |
3595 " |
3596 self run:#testOperators48_isArray |
3596 self run:#testOperators48_isArray |
3597 self new testOperators48_isArray |
3597 self new testOperators48_isArray |
3598 " |
3598 " |
3599 ! |
3599 ! |
3600 |
3600 |
3601 testOperators49_concat |
3601 testOperators49_concat |
3602 self |
3602 self |
3603 execute:'expr(arg1) { |
3603 execute:'expr(arg1) { |
3604 return arg1.concat() ; |
3604 return arg1.concat() ; |
3605 }' |
3605 }' |
3606 for:nil |
3606 for:nil |
3607 arguments:#( 'a') |
3607 arguments:#( 'a') |
3608 expect:'a'. |
3608 expect:'a'. |
3609 |
3609 |
3610 self |
3610 self |
3611 execute:'expr(arg1, arg2) { |
3611 execute:'expr(arg1, arg2) { |
3612 return arg1.concat(arg2) ; |
3612 return arg1.concat(arg2) ; |
3613 }' |
3613 }' |
3614 for:nil |
3614 for:nil |
3615 arguments:#( 'a' 'b') |
3615 arguments:#( 'a' 'b') |
3616 expect:'ab'. |
3616 expect:'ab'. |
3617 |
3617 |
3618 self |
3618 self |
3619 execute:'expr(arg1, arg2, arg3) { |
3619 execute:'expr(arg1, arg2, arg3) { |
3620 return arg1.concat(arg2, arg3) ; |
3620 return arg1.concat(arg2, arg3) ; |
3621 }' |
3621 }' |
3622 for:nil |
3622 for:nil |
3623 arguments:#( 'a' 'b' 'c' ) |
3623 arguments:#( 'a' 'b' 'c' ) |
3624 expect:'abc'. |
3624 expect:'abc'. |
3625 |
3625 |
3626 self |
3626 self |
3627 execute:'expr() { |
3627 execute:'expr() { |
3628 return "a".concat("b", "c", "d", "e", "f") ; |
3628 return "a".concat("b", "c", "d", "e", "f") ; |
3629 }' |
3629 }' |
3630 for:nil |
3630 for:nil |
3631 arguments:nil |
3631 arguments:nil |
3632 expect:'abcdef'. |
3632 expect:'abcdef'. |
3633 |
3633 |
3634 self |
3634 self |
3635 execute:'expr() { |
3635 execute:'expr() { |
3636 return "a".concat("b", "c", "d", "e", "f", "g") ; |
3636 return "a".concat("b", "c", "d", "e", "f", "g") ; |
3637 }' |
3637 }' |
3638 for:nil |
3638 for:nil |
3639 arguments:nil |
3639 arguments:nil |
3640 expect:'abcdefg'. |
3640 expect:'abcdefg'. |
3641 |
3641 |
3642 self |
3642 self |
3643 execute:'expr() { |
3643 execute:'expr() { |
3644 return "a".concat("b", "c", "d", "e", "f", "g", "h") ; |
3644 return "a".concat("b", "c", "d", "e", "f", "g", "h") ; |
3645 }' |
3645 }' |
3646 for:nil |
3646 for:nil |
3647 arguments:nil |
3647 arguments:nil |
3648 expect:'abcdefgh'. |
3648 expect:'abcdefgh'. |
3649 |
3649 |
3650 self |
3650 self |
3651 execute:'expr(arg1, arg2, arg3) { |
3651 execute:'expr(arg1, arg2, arg3) { |
3652 return arg1.concat(arg2, arg3) ; |
3652 return arg1.concat(arg2, arg3) ; |
3653 }' |
3653 }' |
3654 for:nil |
3654 for:nil |
3655 arguments:#( (1) (2) (3) ) |
3655 arguments:#( (1) (2) (3) ) |
3656 expect:#(1 2 3). |
3656 expect:#(1 2 3). |
3657 |
3657 |
3658 " |
3658 " |
3659 self run:#testOperators49_concat |
3659 self run:#testOperators49_concat |
3660 self new testOperators49_concat |
3660 self new testOperators49_concat |
3661 " |
3661 " |
3662 ! |
3662 ! |
3663 |
3663 |
3664 testParserErrors01 |
3664 testParserErrors01 |
3665 self should:[ |
3665 self should:[ |
3666 self |
3666 self |
3667 execute:'expr(a, ) { |
3667 execute:'expr(a, ) { |
3668 return (a == b); |
3668 return (a == b); |
3669 }' |
3669 }' |
3670 for:nil |
3670 for:nil |
3671 arguments:#(10 10) |
3671 arguments:#(10 10) |
3672 expect:true |
3672 expect:true |
3673 ] raise:ParseError. |
3673 ] raise:ParseError. |
3674 |
3674 |
3675 self should:[ |
3675 self should:[ |
3676 self |
3676 self |
3677 execute:'expr(a b) { |
3677 execute:'expr(a b) { |
3678 return (a == b); |
3678 return (a == b); |
3679 }' |
3679 }' |
3680 for:nil |
3680 for:nil |
3681 arguments:#(10 10) |
3681 arguments:#(10 10) |
3682 expect:true |
3682 expect:true |
3683 ] raise:ParseError. |
3683 ] raise:ParseError. |
3684 |
3684 |
3685 self should:[ |
3685 self should:[ |
3686 self |
3686 self |
3687 execute:'expr(x) { |
3687 execute:'expr(x) { |
3688 return (x == 1 ?); |
3688 return (x == 1 ?); |
3689 }' |
3689 }' |
3690 for:nil |
3690 for:nil |
3691 arguments:#(10 10) |
3691 arguments:#(10 10) |
3692 expect:true |
3692 expect:true |
3693 ] raise:ParseError. |
3693 ] raise:ParseError. |
3694 |
3694 |
3695 self should:[ |
3695 self should:[ |
3696 self |
3696 self |
3697 execute:'expr(x) { |
3697 execute:'expr(x) { |
3698 return (x == 1 ? 1 ); |
3698 return (x == 1 ? 1 ); |
3699 }' |
3699 }' |
3700 for:nil |
3700 for:nil |
3701 arguments:#(10 10) |
3701 arguments:#(10 10) |
3702 expect:true |
3702 expect:true |
3703 ] raise:ParseError. |
3703 ] raise:ParseError. |
3704 |
3704 |
3705 self should:[ |
3705 self should:[ |
3706 self |
3706 self |
3707 execute:'expr(x) { |
3707 execute:'expr(x) { |
3708 return (x == 1 ? 1 : ); |
3708 return (x == 1 ? 1 : ); |
3709 }' |
3709 }' |
3710 for:nil |
3710 for:nil |
3711 arguments:#(10 10) |
3711 arguments:#(10 10) |
3712 expect:true |
3712 expect:true |
3713 ] raise:ParseError. |
3713 ] raise:ParseError. |
3714 |
3714 |
3715 self should:[ |
3715 self should:[ |
3716 self |
3716 self |
3717 execute:'expr(x) { |
3717 execute:'expr(x) { |
3718 return (x == 1 ? 1 : +); |
3718 return (x == 1 ? 1 : +); |
3719 }' |
3719 }' |
3720 for:nil |
3720 for:nil |
3721 arguments:#(10 10) |
3721 arguments:#(10 10) |
3722 expect:true |
3722 expect:true |
3723 ] raise:ParseError. |
3723 ] raise:ParseError. |
3724 |
3724 |
3725 " |
3725 " |
3726 self run:#testParserErrors01 |
3726 self run:#testParserErrors01 |
3727 self new testParserErrors01 |
3727 self new testParserErrors01 |
3728 " |
3728 " |
3729 ! |
3729 ! |
3730 |
3730 |
3731 testPrecidences01 |
3731 testPrecidences01 |
3732 self |
3732 self |
3733 execute:'expr(a, b) { |
3733 execute:'expr(a, b) { |
3734 return (a + 4 * 5 + b); |
3734 return (a + 4 * 5 + b); |
3735 }' |
3735 }' |
3736 for:nil |
3736 for:nil |
3737 arguments:#(10 20) |
3737 arguments:#(10 20) |
3738 expect:(10 + (4 * 5) + 20) |
3738 expect:(10 + (4 * 5) + 20) |
3739 |
3739 |
3740 " |
3740 " |
3741 self run:#testPrecidences01 |
3741 self run:#testPrecidences01 |
3742 self new testPrecidences01 |
3742 self new testPrecidences01 |
3743 " |
3743 " |
3744 ! |
3744 ! |
3745 |
3745 |
3746 testPrecidences02 |
3746 testPrecidences02 |
3747 self |
3747 self |
3748 execute:'expr(a, b) { |
3748 execute:'expr(a, b) { |
3749 return (a * 4 + b * 5); |
3749 return (a * 4 + b * 5); |
3750 }' |
3750 }' |
3751 for:nil |
3751 for:nil |
3752 arguments:#(10 20) |
3752 arguments:#(10 20) |
3753 expect:140 |
3753 expect:140 |
3754 |
3754 |
3755 " |
3755 " |
3756 self run:#testPrecidences02 |
3756 self run:#testPrecidences02 |
3757 self new testPrecidences02 |
3757 self new testPrecidences02 |
3758 " |
3758 " |
3759 ! |
3759 ! |
3760 |
3760 |
3761 testPrecidences03 |
3761 testPrecidences03 |
3762 self |
3762 self |
3763 execute:'expr(a, b) { |
3763 execute:'expr(a, b) { |
3764 return -(a + b); |
3764 return -(a + b); |
3765 }' |
3765 }' |
3766 for:nil |
3766 for:nil |
3767 arguments:#(10 20) |
3767 arguments:#(10 20) |
3768 expect:-30 |
3768 expect:-30 |
3769 |
3769 |
3770 " |
3770 " |
3771 self run:#testPrecidences03 |
3771 self run:#testPrecidences03 |
3772 self new testPrecidences03 |
3772 self new testPrecidences03 |
3773 " |
3773 " |
3774 ! |
3774 ! |
3775 |
3775 |
3776 testPrecidences04 |
3776 testPrecidences04 |
3777 self |
3777 self |
3778 execute:'expr(a, b) { |
3778 execute:'expr(a, b) { |
3779 return -a + b; |
3779 return -a + b; |
3780 }' |
3780 }' |
3781 for:nil |
3781 for:nil |
3782 arguments:#(10 20) |
3782 arguments:#(10 20) |
3783 expect:10 |
3783 expect:10 |
3784 |
3784 |
3785 " |
3785 " |
3786 self run:#testPrecidences04 |
3786 self run:#testPrecidences04 |
3787 self new testPrecidences04 |
3787 self new testPrecidences04 |
3788 " |
3788 " |
3789 ! |
3789 ! |
3790 |
3790 |
3791 testPrecidences05 |
3791 testPrecidences05 |
3792 self |
3792 self |
3793 execute:'expr(a, b) { |
3793 execute:'expr(a, b) { |
3794 return -a + -b; |
3794 return -a + -b; |
3795 }' |
3795 }' |
3796 for:nil |
3796 for:nil |
3797 arguments:#(10 20) |
3797 arguments:#(10 20) |
3798 expect:-30 |
3798 expect:-30 |
3799 |
3799 |
3800 " |
3800 " |
3801 self run:#testPrecidences05 |
3801 self run:#testPrecidences05 |
3802 self new testPrecidences05 |
3802 self new testPrecidences05 |
3803 " |
3803 " |
4173 |
4173 |
4174 testScanner13 |
4174 testScanner13 |
4175 "/ cg: is the comment below legal ? |
4175 "/ cg: is the comment below legal ? |
4176 ^ self. "/ assume not |
4176 ^ self. "/ assume not |
4177 |
4177 |
4178 self |
4178 self |
4179 execute:'f_1() { /*/ |
4179 execute:'f_1() { /*/ |
4180 return (null); }' |
4180 return (null); }' |
4181 for:nil |
4181 for:nil |
4182 arguments:#() |
4182 arguments:#() |
4183 expectError:#ParseError |
4183 expectError:#ParseError |
4184 |
4184 |
4185 " |
4185 " |
4186 self run:#testScanner13 |
4186 self run:#testScanner13 |
4187 self new testScanner13 |
4187 self new testScanner13 |
4188 " |
4188 " |
4189 ! |
4189 ! |
4190 |
4190 |
4191 testScanner20 |
4191 testScanner20 |
4192 #( |
4192 #( |
4193 |
4193 |
4194 ' = ' $= |
4194 ' = ' $= |
4195 '/* ignored */= ' $= |
4195 '/* ignored */= ' $= |
4196 '/* ignored */ = ' $= |
4196 '/* ignored */ = ' $= |
4197 ' + ' $+ |
4197 ' + ' $+ |
4198 ' - ' $- |
4198 ' - ' $- |
4199 ' * ' $* |
4199 ' * ' $* |
4200 ' / ' $/ |
4200 ' / ' $/ |
4201 ' % ' $% |
4201 ' % ' $% |
4202 ' & ' $& |
4202 ' & ' $& |
4203 ' ^ ' $^ |
4203 ' ^ ' $^ |
4204 ' | ' $| |
4204 ' | ' $| |
4205 ' !! ' $!! |
4205 ' !! ' $!! |
4206 ' < ' $< |
4206 ' < ' $< |
4207 ' > ' $> |
4207 ' > ' $> |
4208 |
4208 |
4209 ' << ' #'<<' |
4209 ' << ' #'<<' |
4210 ' >> ' #'>>' |
4210 ' >> ' #'>>' |
4211 ' == ' #'==' |
4211 ' == ' #'==' |
4212 ' <= ' #'<=' |
4212 ' <= ' #'<=' |
4213 ' >= ' #'>=' |
4213 ' >= ' #'>=' |
4214 ' !!= ' #'!!=' |
4214 ' !!= ' #'!!=' |
4215 ' || ' #'||' |
4215 ' || ' #'||' |
4216 ' && ' #'&&' |
4216 ' && ' #'&&' |
4217 ' ++ ' #'++' |
4217 ' ++ ' #'++' |
4218 ' -- ' #'--' |
4218 ' -- ' #'--' |
4219 |
4219 |
4220 ' += ' #'+=' |
4220 ' += ' #'+=' |
4221 ' -= ' #'-=' |
4221 ' -= ' #'-=' |
4222 ' *= ' #'*=' |
4222 ' *= ' #'*=' |
4223 ' /= ' #'/=' |
4223 ' /= ' #'/=' |
4224 ' %= ' #'%=' |
4224 ' %= ' #'%=' |
4225 ' &= ' #'&=' |
4225 ' &= ' #'&=' |
4226 ' ^= ' #'^=' |
4226 ' ^= ' #'^=' |
4227 ' |= ' #'|=' |
4227 ' |= ' #'|=' |
4228 |
4228 |
4229 ' >>> ' #'>>>' |
4229 ' >>> ' #'>>>' |
4230 ' >>= ' #'>>=' |
4230 ' >>= ' #'>>=' |
4231 ' <<= ' #'<<=' |
4231 ' <<= ' #'<<=' |
4232 ' === ' #'===' |
4232 ' === ' #'===' |
4233 ' !!== ' #'!!==' |
4233 ' !!== ' #'!!==' |
4234 |
4234 |
4235 ' 1 ' #Integer |
4235 ' 1 ' #Integer |
4236 ' 12345 ' #Integer |
4236 ' 12345 ' #Integer |
4237 ' 1.0 ' #Float |
4237 ' 1.0 ' #Float |
4238 ' 1e10 ' #Float |
4238 ' 1e10 ' #Float |
4239 ' 1E10 ' #Float |
4239 ' 1E10 ' #Float |
4240 ' 1E+10 ' #Float |
4240 ' 1E+10 ' #Float |
4241 ' 1E-10 ' #Float |
4241 ' 1E-10 ' #Float |
4242 ' 1.0d ' #Float |
4242 ' 1.0d ' #Float |
4243 ' 1. ' #Float |
4243 ' 1. ' #Float |
4244 "/ ' 1.' #Float |
4244 "/ ' 1.' #Float |
4245 ) pairWiseDo:[:src :expectedToken | |
4245 ) pairWiseDo:[:src :expectedToken | |
4246 |scannedToken| |
4246 |scannedToken| |
4247 |
4247 |
4248 scannedToken := (JavaScriptScanner for:src) nextToken. |
4248 scannedToken := (JavaScriptScanner for:src) nextToken. |
4249 self assert:(scannedToken == expectedToken) |
4249 self assert:(scannedToken == expectedToken) |
4250 ]. |
4250 ]. |
4251 |
4251 |
4252 " |
4252 " |
4253 self run:#testScanner20 |
4253 self run:#testScanner20 |
4254 self new testScanner20 |
4254 self new testScanner20 |
4255 " |
4255 " |
4256 ! |
4256 ! |
4257 |
4257 |
4258 testString01 |
4258 testString01 |
4259 self |
4259 self |
4260 execute:'test(str) { |
4260 execute:'test(str) { |
4261 return "foo".size; |
4261 return "foo".size; |
4262 }' |
4262 }' |
4263 for:nil |
4263 for:nil |
4264 arguments:#( nil ) |
4264 arguments:#( nil ) |
4265 expect:3 |
4265 expect:3 |
4266 |
4266 |
4267 " |
4267 " |
4268 self run:#testString01 |
4268 self run:#testString01 |
4269 self new testString01 |
4269 self new testString01 |
4270 " |
4270 " |
4271 ! |
4271 ! |
4272 |
4272 |
4273 testString02 |
4273 testString02 |
4274 self |
4274 self |
4275 execute:'test(str) { |
4275 execute:'test(str) { |
4276 return str.size(); |
4276 return str.size(); |
4277 }' |
4277 }' |
4278 for:nil |
4278 for:nil |
4279 arguments:#( 'hello' ) |
4279 arguments:#( 'hello' ) |
4280 expect:5 |
4280 expect:5 |
4281 |
4281 |
4282 " |
4282 " |
4283 self run:#testString02 |
4283 self run:#testString02 |
4284 self new testString02 |
4284 self new testString02 |
4285 " |
4285 " |
4286 ! |
4286 ! |
4287 |
4287 |
4288 testString03 |
4288 testString03 |
4289 self |
4289 self |
4290 execute:'test(str) { |
4290 execute:'test(str) { |
4291 return str.size; |
4291 return str.size; |
4292 }' |
4292 }' |
4293 for:nil |
4293 for:nil |
4294 arguments:#( 'hello' ) |
4294 arguments:#( 'hello' ) |
4295 expect:5 |
4295 expect:5 |
4296 |
4296 |
4297 " |
4297 " |
4298 self run:#testString03 |
4298 self run:#testString03 |
4299 self new testString03 |
4299 self new testString03 |
4300 " |
4300 " |
4301 ! |
4301 ! |
4302 |
4302 |
4303 testString04 |
4303 testString04 |
4304 self |
4304 self |
4305 execute:'test(str) { |
4305 execute:'test(str) { |
4306 return str[1]; |
4306 return str[1]; |
4307 }' |
4307 }' |
4308 for:nil |
4308 for:nil |
4309 arguments:#( 'hello' ) |
4309 arguments:#( 'hello' ) |
4310 expect:$h |
4310 expect:$h |
4311 |
4311 |
4312 " |
4312 " |
4313 self run:#testString04 |
4313 self run:#testString04 |
4314 self new testString04 |
4314 self new testString04 |
4315 " |
4315 " |
4316 ! |
4316 ! |
4317 |
4317 |
4318 testString05 |
4318 testString05 |
4319 self |
4319 self |
4320 execute:'test(str) { |
4320 execute:'test(str) { |
4321 return str[1] == "h"[1]; |
4321 return str[1] == "h"[1]; |
4322 }' |
4322 }' |
4323 for:nil |
4323 for:nil |
4324 arguments:#( 'hello' ) |
4324 arguments:#( 'hello' ) |
4325 expect:true |
4325 expect:true |
4326 |
4326 |
4327 " |
4327 " |
4328 self run:#testString05 |
4328 self run:#testString05 |
4329 self new testString05 |
4329 self new testString05 |
4330 " |
4330 " |
4331 ! |
4331 ! |
4332 |
4332 |
4333 testString06 |
4333 testString06 |
4334 self |
4334 self |
4335 execute:'test(str) { |
4335 execute:'test(str) { |
4336 return str[1] == $''h''; |
4336 return str[1] == $''h''; |
4337 }' |
4337 }' |
4338 for:nil |
4338 for:nil |
4339 arguments:#( 'hello' ) |
4339 arguments:#( 'hello' ) |
4340 expect:true |
4340 expect:true |
4341 |
4341 |
4342 " |
4342 " |
4343 self run:#testString06 |
4343 self run:#testString06 |
4344 self new testString06 |
4344 self new testString06 |
4345 " |
4345 " |
4346 ! |
4346 ! |
4347 |
4347 |
4348 testString07 |
4348 testString07 |
4349 self |
4349 self |
4350 execute:'test(str) { |
4350 execute:'test(str) { |
4351 return str[1].isLowercase; |
4351 return str[1].isLowercase; |
4352 }' |
4352 }' |
4353 for:nil |
4353 for:nil |
4354 arguments:#( 'hello' ) |
4354 arguments:#( 'hello' ) |
4355 expect:true |
4355 expect:true |
4356 |
4356 |
4357 " |
4357 " |
4358 self run:#testString07 |
4358 self run:#testString07 |
4359 self new testString07 |
4359 self new testString07 |
4360 " |
4360 " |
4361 ! |
4361 ! |
4362 |
4362 |
4363 testSuper01 |
4363 testSuper01 |
4364 |class1 class2| |
4364 |class1 class2| |
4365 |
4365 |
4366 Class withoutUpdatingChangesDo:[ |
4366 Class withoutUpdatingChangesDo:[ |
4367 class1 := Class name:'T1' subclassOf:Object. |
4367 class1 := Class name:'T1' subclassOf:Object. |
4368 class2 := Class name:'T2' subclassOf:class1. |
4368 class2 := Class name:'T2' subclassOf:class1. |
4369 |
4369 |
4370 JavaScriptCompiler |
4370 JavaScriptCompiler |
4371 compile:'foo() { return 1; }' |
4371 compile:'foo() { return 1; }' |
4372 forClass:class1 |
4372 forClass:class1 |
4373 inCategory:nil |
4373 inCategory:nil |
4374 notifying:nil |
4374 notifying:nil |
4375 install:true. |
4375 install:true. |
4376 |
4376 |
4377 JavaScriptCompiler |
4377 JavaScriptCompiler |
4378 compile:'foo() { return 2; }' |
4378 compile:'foo() { return 2; }' |
4379 forClass:class2 |
4379 forClass:class2 |
4380 inCategory:nil |
4380 inCategory:nil |
4381 notifying:nil |
4381 notifying:nil |
4382 install:true. |
4382 install:true. |
4383 |
4383 |
4384 JavaScriptCompiler |
4384 JavaScriptCompiler |
4385 compile:'callFoo() { return foo(); }' |
4385 compile:'callFoo() { return foo(); }' |
4386 forClass:class2 |
4386 forClass:class2 |
4387 inCategory:nil |
4387 inCategory:nil |
4388 notifying:nil |
4388 notifying:nil |
4389 install:true. |
4389 install:true. |
4390 |
4390 |
4391 JavaScriptCompiler |
4391 JavaScriptCompiler |
4392 compile:'callSuperFoo() { return super.foo(); }' |
4392 compile:'callSuperFoo() { return super.foo(); }' |
4393 forClass:class2 |
4393 forClass:class2 |
4394 inCategory:nil |
4394 inCategory:nil |
4395 notifying:nil |
4395 notifying:nil |
4396 install:true. |
4396 install:true. |
4397 ]. |
4397 ]. |
4398 |
4398 |
4399 self assert:(class2 new callFoo == 2). |
4399 self assert:(class2 new callFoo == 2). |
4400 self assert:(class2 new callSuperFoo == 1). |
4400 self assert:(class2 new callSuperFoo == 1). |
4401 |
4401 |
4404 self new testSuper01 |
4404 self new testSuper01 |
4405 " |
4405 " |
4406 ! |
4406 ! |
4407 |
4407 |
4408 testSwitch01 |
4408 testSwitch01 |
4409 self |
4409 self |
4410 execute:'test(arg) { |
4410 execute:'test(arg) { |
4411 switch (arg) { |
4411 switch (arg) { |
4412 } |
4412 } |
4413 }' |
4413 }' |
4414 for:nil |
4414 for:nil |
4415 arguments:#(5) |
4415 arguments:#(5) |
4416 expect:nil |
4416 expect:nil |
4417 |
4417 |
4418 " |
4418 " |
4419 self run:#testSwitch01 |
4419 self run:#testSwitch01 |
4420 self new testSwitch01 |
4420 self new testSwitch01 |
4421 " |
4421 " |
4422 ! |
4422 ! |
4423 |
4423 |
4424 testSwitch02 |
4424 testSwitch02 |
4425 |output| |
4425 |output| |
4426 |
4426 |
4427 output := self outputToTranscriptOf:[ |
4427 output := self outputToTranscriptOf:[ |
4428 self |
4428 self |
4429 execute:'test(arg) { |
4429 execute:'test(arg) { |
4430 switch (arg) { |
4430 switch (arg) { |
4431 Transcript.show("hello "); |
4431 Transcript.show("hello "); |
4432 return 1; |
4432 return 1; |
4433 } |
4433 } |
4434 return 0; |
4434 return 0; |
4435 }' |
4435 }' |
4436 for:nil |
4436 for:nil |
4437 arguments:#(5) |
4437 arguments:#(5) |
4438 expect:0 |
4438 expect:0 |
4439 ]. |
4439 ]. |
4440 self assert:(output asCollectionOfLinesWithReturn asArray = #( )) |
4440 self assert:(output asCollectionOfLinesWithReturn asArray = #( )) |
4441 |
4441 |
4442 " |
4442 " |
4443 self run:#testSwitch02 |
4443 self run:#testSwitch02 |
4444 self new testSwitch02 |
4444 self new testSwitch02 |
4445 " |
4445 " |
4446 ! |
4446 ! |
4447 |
4447 |
4448 testSwitch03 |
4448 testSwitch03 |
4449 |output| |
4449 |output| |
4450 |
4450 |
4451 output := self outputToTranscriptOf:[ |
4451 output := self outputToTranscriptOf:[ |
4452 self |
4452 self |
4453 execute:'test(arg) { |
4453 execute:'test(arg) { |
4454 switch (arg) { |
4454 switch (arg) { |
4455 Transcript.show("hello "); |
4455 Transcript.show("hello "); |
4456 Transcript.show("world "); |
4456 Transcript.show("world "); |
4457 Transcript.cr(); |
4457 Transcript.cr(); |
4458 return 1; |
4458 return 1; |
4459 } |
4459 } |
4460 return 0; |
4460 return 0; |
4461 }' |
4461 }' |
4462 for:nil |
4462 for:nil |
4463 arguments:#(5) |
4463 arguments:#(5) |
4464 expect:0 |
4464 expect:0 |
4465 ]. |
4465 ]. |
4466 self assert:(output asCollectionOfLinesWithReturn asArray = #() ) |
4466 self assert:(output asCollectionOfLinesWithReturn asArray = #() ) |
4467 |
4467 |
4468 " |
4468 " |
4469 self run:#testSwitch03 |
4469 self run:#testSwitch03 |
4470 self new testSwitch03 |
4470 self new testSwitch03 |
4471 " |
4471 " |
4472 ! |
4472 ! |
4473 |
4473 |
4474 testSwitch04 |
4474 testSwitch04 |
4475 |output| |
4475 |output| |
4476 |
4476 |
4477 output := self outputToTranscriptOf:[ |
4477 output := self outputToTranscriptOf:[ |
4478 self |
4478 self |
4479 execute:'test(arg) { |
4479 execute:'test(arg) { |
4480 switch (arg) { |
4480 switch (arg) { |
4481 default: |
4481 default: |
4482 Transcript.show("hello "); |
4482 Transcript.show("hello "); |
4483 Transcript.show("world "); |
4483 Transcript.show("world "); |
4484 Transcript.cr(); |
4484 Transcript.cr(); |
4485 return 1; |
4485 return 1; |
4486 } |
4486 } |
4487 return 0; |
4487 return 0; |
4488 }' |
4488 }' |
4489 for:nil |
4489 for:nil |
4490 arguments:#(5) |
4490 arguments:#(5) |
4491 expect:1 |
4491 expect:1 |
4492 ]. |
4492 ]. |
4493 self assert:(output = 'hello world \' withCRs). |
4493 self assert:(output = 'hello world \' withCRs). |
4494 |
4494 |
4495 " |
4495 " |
4496 self run:#testSwitch04 |
4496 self run:#testSwitch04 |
4497 self new testSwitch04 |
4497 self new testSwitch04 |
4498 " |
4498 " |
4499 ! |
4499 ! |
4500 |
4500 |
4501 testSwitch05 |
4501 testSwitch05 |
4502 |output| |
4502 |output| |
4503 |
4503 |
4504 output := self outputToTranscriptOf:[ |
4504 output := self outputToTranscriptOf:[ |
4505 self |
4505 self |
4506 execute:'test(arg) { |
4506 execute:'test(arg) { |
4507 switch (arg) { |
4507 switch (arg) { |
4508 default: |
4508 default: |
4509 Transcript.show("hello "); |
4509 Transcript.show("hello "); |
4510 Transcript.show("world "); |
4510 Transcript.show("world "); |
4511 return 1; |
4511 return 1; |
4512 Transcript.cr(); |
4512 Transcript.cr(); |
4513 } |
4513 } |
4514 return 0; |
4514 return 0; |
4515 }' |
4515 }' |
4516 for:nil |
4516 for:nil |
4517 arguments:#(5) |
4517 arguments:#(5) |
4518 expect:1 |
4518 expect:1 |
4519 ]. |
4519 ]. |
4520 self assert:(output = 'hello world '). |
4520 self assert:(output = 'hello world '). |
4521 |
4521 |
4522 " |
4522 " |
4523 self run:#testSwitch05 |
4523 self run:#testSwitch05 |
4524 self new testSwitch05 |
4524 self new testSwitch05 |
4525 " |
4525 " |
4526 ! |
4526 ! |
4527 |
4527 |
4528 testSwitch06a |
4528 testSwitch06a |
4529 |output| |
4529 |output| |
4530 |
4530 |
4531 output := self outputToTranscriptOf:[ |
4531 output := self outputToTranscriptOf:[ |
4532 self |
4532 self |
4533 execute:'test(arg) { |
4533 execute:'test(arg) { |
4534 switch (arg) { |
4534 switch (arg) { |
4535 case 1: |
4535 case 1: |
4536 Transcript.showCR("one"); |
4536 Transcript.showCR("one"); |
4537 return 10; |
4537 return 10; |
4538 case 2: |
4538 case 2: |
4539 Transcript.showCR("two"); |
4539 Transcript.showCR("two"); |
4540 return 20; |
4540 return 20; |
4541 } |
4541 } |
4542 return 0; |
4542 return 0; |
4543 }' |
4543 }' |
4544 for:nil |
4544 for:nil |
4545 arguments:#(5) |
4545 arguments:#(5) |
4546 expect:0 |
4546 expect:0 |
4547 ]. |
4547 ]. |
4548 self assert:(output asCollectionOfLinesWithReturn asArray = #( )) |
4548 self assert:(output asCollectionOfLinesWithReturn asArray = #( )) |
4549 |
4549 |
4550 " |
4550 " |
4551 self run:#testSwitch06a |
4551 self run:#testSwitch06a |
4552 self new testSwitch06a |
4552 self new testSwitch06a |
4553 " |
4553 " |
4554 ! |
4554 ! |
4555 |
4555 |
4556 testSwitch06b |
4556 testSwitch06b |
4557 |output| |
4557 |output| |
4558 |
4558 |
4559 output := self outputToTranscriptOf:[ |
4559 output := self outputToTranscriptOf:[ |
4560 self |
4560 self |
4561 execute:'test(arg) { |
4561 execute:'test(arg) { |
4562 switch (arg) { |
4562 switch (arg) { |
4563 case 1: |
4563 case 1: |
4564 Transcript.showCR("one"); |
4564 Transcript.showCR("one"); |
4565 return 10; |
4565 return 10; |
4566 case 2: |
4566 case 2: |
4567 Transcript.showCR("two"); |
4567 Transcript.showCR("two"); |
4568 return 20; |
4568 return 20; |
4569 } |
4569 } |
4570 return 0; |
4570 return 0; |
4571 }' |
4571 }' |
4572 for:nil |
4572 for:nil |
4573 arguments:#(1) |
4573 arguments:#(1) |
4574 expect:10 |
4574 expect:10 |
4575 ]. |
4575 ]. |
4576 self assert:(output asCollectionOfLinesWithReturn asArray = #( 'one')) |
4576 self assert:(output asCollectionOfLinesWithReturn asArray = #( 'one')) |
4577 |
4577 |
4578 " |
4578 " |
4579 self run:#testSwitch06b |
4579 self run:#testSwitch06b |
4580 self new testSwitch06b |
4580 self new testSwitch06b |
4581 " |
4581 " |
4582 ! |
4582 ! |
4583 |
4583 |
4584 testSwitch06c |
4584 testSwitch06c |
4585 |output| |
4585 |output| |
4586 |
4586 |
4587 output := self outputToTranscriptOf:[ |
4587 output := self outputToTranscriptOf:[ |
4588 self |
4588 self |
4589 execute:'test(arg) { |
4589 execute:'test(arg) { |
4590 switch (arg) { |
4590 switch (arg) { |
4591 case 1: |
4591 case 1: |
4592 Transcript.showCR("one"); |
4592 Transcript.showCR("one"); |
4593 return 10; |
4593 return 10; |
4594 case 2: |
4594 case 2: |
4595 Transcript.showCR("two"); |
4595 Transcript.showCR("two"); |
4596 return 20; |
4596 return 20; |
4597 } |
4597 } |
4598 return 0; |
4598 return 0; |
4599 }' |
4599 }' |
4600 for:nil |
4600 for:nil |
4601 arguments:#(2) |
4601 arguments:#(2) |
4602 expect:20 |
4602 expect:20 |
4603 ]. |
4603 ]. |
4604 self assert:(output asCollectionOfLinesWithReturn asArray = #( 'two')) |
4604 self assert:(output asCollectionOfLinesWithReturn asArray = #( 'two')) |
4605 |
4605 |
4606 " |
4606 " |
4607 self run:#testSwitch06c |
4607 self run:#testSwitch06c |
4608 self new testSwitch06c |
4608 self new testSwitch06c |
4609 " |
4609 " |
4610 ! |
4610 ! |
4611 |
4611 |
4612 testSwitch06d |
4612 testSwitch06d |
4613 |output| |
4613 |output| |
4614 |
4614 |
4615 output := self outputToTranscriptOf:[ |
4615 output := self outputToTranscriptOf:[ |
4616 self |
4616 self |
4617 execute:'test(arg) { |
4617 execute:'test(arg) { |
4618 switch (arg) { |
4618 switch (arg) { |
4619 case "hallo": |
4619 case "hallo": |
4620 Transcript.showCR("Hallo"); |
4620 Transcript.showCR("Hallo"); |
4621 return 10; |
4621 return 10; |
4622 case "hello": |
4622 case "hello": |
4623 Transcript.showCR("Hello"); |
4623 Transcript.showCR("Hello"); |
4624 return 20; |
4624 return 20; |
4625 } |
4625 } |
4626 return 0; |
4626 return 0; |
4627 }' |
4627 }' |
4628 for:nil |
4628 for:nil |
4629 arguments:#('hello') |
4629 arguments:#('hello') |
4630 expect:20 |
4630 expect:20 |
4631 ]. |
4631 ]. |
4632 self assert:(output asCollectionOfLinesWithReturn asArray = #( 'Hello')) |
4632 self assert:(output asCollectionOfLinesWithReturn asArray = #( 'Hello')) |
4633 |
4633 |
4634 " |
4634 " |
4635 self run:#testSwitch06d |
4635 self run:#testSwitch06d |
4636 self new testSwitch06d |
4636 self new testSwitch06d |
4637 " |
4637 " |
4638 ! |
4638 ! |
4639 |
4639 |
4640 testSwitch06e |
4640 testSwitch06e |
4641 self |
4641 self |
4642 execute:'test(arg) { |
4642 execute:'test(arg) { |
4643 switch (arg) { |
4643 switch (arg) { |
4644 case 1: |
4644 case 1: |
4645 Transcript.showCR("Hallo"); |
4645 Transcript.showCR("Hallo"); |
4646 return 10; |
4646 return 10; |
4647 case 2: |
4647 case 2: |
4648 Transcript.showCR("Hello"); |
4648 Transcript.showCR("Hello"); |
4649 return 20; |
4649 return 20; |
4650 } |
4650 } |
4651 return 0; |
4651 return 0; |
4652 }' |
4652 }' |
4653 for:nil |
4653 for:nil |
4654 arguments:#(3) |
4654 arguments:#(3) |
4655 expect:0 |
4655 expect:0 |
4656 |
4656 |
4657 " |
4657 " |
4658 self run:#testSwitch06e |
4658 self run:#testSwitch06e |
4659 self new testSwitch06e |
4659 self new testSwitch06e |
4660 " |
4660 " |
4661 ! |
4661 ! |
4662 |
4662 |
4663 testSwitch06f |
4663 testSwitch06f |
4664 self |
4664 self |
4665 execute:'test(arg) { |
4665 execute:'test(arg) { |
4666 var a = 0; |
4666 var a = 0; |
4667 switch (arg) { |
4667 switch (arg) { |
4668 case 1: |
4668 case 1: |
4669 a = 10; |
4669 a = 10; |
4670 break; |
4670 break; |
4671 case 2: |
4671 case 2: |
4672 a = 20; |
4672 a = 20; |
4673 break; |
4673 break; |
4674 } |
4674 } |
4675 return a; |
4675 return a; |
4676 }' |
4676 }' |
4677 for:nil |
4677 for:nil |
4678 arguments:#(1) |
4678 arguments:#(1) |
4679 expect:10 |
4679 expect:10 |
4680 |
4680 |
4681 " |
4681 " |
4682 self run:#testSwitch06f |
4682 self run:#testSwitch06f |
4683 self new testSwitch06f |
4683 self new testSwitch06f |
4684 " |
4684 " |
4685 ! |
4685 ! |
4686 |
4686 |
4687 testSwitch06g |
4687 testSwitch06g |
4688 self |
4688 self |
4689 execute:'test(arg) { |
4689 execute:'test(arg) { |
4690 var a = 0; |
4690 var a = 0; |
4691 switch (arg) { |
4691 switch (arg) { |
4692 case 1: |
4692 case 1: |
4693 a = 10; |
4693 a = 10; |
4694 break; |
4694 break; |
4695 case 2: |
4695 case 2: |
4696 a = 20; |
4696 a = 20; |
4697 break; |
4697 break; |
4698 } |
4698 } |
4699 return a; |
4699 return a; |
4700 }' |
4700 }' |
4701 for:nil |
4701 for:nil |
4702 arguments:#(2) |
4702 arguments:#(2) |
4703 expect:20 |
4703 expect:20 |
4704 |
4704 |
4705 " |
4705 " |
4706 self run:#testSwitch06g |
4706 self run:#testSwitch06g |
4707 self new testSwitch06g |
4707 self new testSwitch06g |
4708 " |
4708 " |
4709 ! |
4709 ! |
4710 |
4710 |
4711 testSwitch06h |
4711 testSwitch06h |
4712 self |
4712 self |
4713 execute:'test(arg) { |
4713 execute:'test(arg) { |
4714 var a = 0; |
4714 var a = 0; |
4715 switch (arg) { |
4715 switch (arg) { |
4716 case 1: |
4716 case 1: |
4717 a = 10; |
4717 a = 10; |
4718 break; |
4718 break; |
4719 case 2: |
4719 case 2: |
4720 a = 20; |
4720 a = 20; |
4721 break; |
4721 break; |
4722 } |
4722 } |
4723 return a; |
4723 return a; |
4724 }' |
4724 }' |
4725 for:nil |
4725 for:nil |
4726 arguments:#(3) |
4726 arguments:#(3) |
4727 expect:0 |
4727 expect:0 |
4728 |
4728 |
4729 " |
4729 " |
4730 self run:#testSwitch06h |
4730 self run:#testSwitch06h |
4731 self new testSwitch06h |
4731 self new testSwitch06h |
4732 " |
4732 " |
4733 ! |
4733 ! |
4734 |
4734 |
4735 testThrow01 |
4735 testThrow01 |
4736 "an exception is thrown" |
4736 "an exception is thrown" |
4737 |
4737 |
4738 self |
4738 self |
4739 execute:'test(arg) { |
4739 execute:'test(arg) { |
4740 var handlerWasCalled = false; |
4740 var handlerWasCalled = false; |
4741 |
4741 |
4742 function failingMethod() { |
4742 function failingMethod() { |
4743 throw Error; |
4743 throw Error; |
4744 }; |
4744 }; |
4745 |
4745 |
4746 try { |
4746 try { |
4747 failingMethod(); |
4747 failingMethod(); |
4748 } catch (Error e) { |
4748 } catch (Error e) { |
4749 handlerWasCalled = true; |
4749 handlerWasCalled = true; |
4750 } |
4750 } |
4751 return handlerWasCalled; |
4751 return handlerWasCalled; |
4752 }' |
4752 }' |
4753 for:nil |
4753 for:nil |
4754 arguments:#(0) |
4754 arguments:#(0) |
4755 expect:true |
4755 expect:true |
4756 |
4756 |
4757 " |
4757 " |
4758 self run:#testThrow01 |
4758 self run:#testThrow01 |
4759 self new testThrow01 |
4759 self new testThrow01 |
4760 " |
4760 " |
4761 ! |
4761 ! |
4762 |
4762 |
4763 testTryCatch01a |
4763 testTryCatch01a |
4764 "in this testcase, arg is 5, so no exception should be thrown" |
4764 "in this testcase, arg is 5, so no exception should be thrown" |
4765 |
4765 |
4766 self |
4766 self |
4767 execute:'test(arg) { |
4767 execute:'test(arg) { |
4768 var handlerWasCalled = false; |
4768 var handlerWasCalled = false; |
4769 |
4769 |
4770 function failingMethod() { |
4770 function failingMethod() { |
4771 return 10 / arg; |
4771 return 10 / arg; |
4772 }; |
4772 }; |
4773 |
4773 |
4774 try { |
4774 try { |
4775 failingMethod(); |
4775 failingMethod(); |
4776 } catch (Error e) { |
4776 } catch (Error e) { |
4777 handlerWasCalled = true; |
4777 handlerWasCalled = true; |
4778 } |
4778 } |
4779 return handlerWasCalled; |
4779 return handlerWasCalled; |
4780 }' |
4780 }' |
4781 for:nil |
4781 for:nil |
4782 arguments:#(5) |
4782 arguments:#(5) |
4783 expect:false |
4783 expect:false |
4784 |
4784 |
4785 " |
4785 " |
4786 self run:#testTryCatch01a |
4786 self run:#testTryCatch01a |
4787 self new testTryCatch01a |
4787 self new testTryCatch01a |
4788 " |
4788 " |
4789 ! |
4789 ! |
4790 |
4790 |
4791 testTryCatch01b |
4791 testTryCatch01b |
4792 "in this testcase, arg is 0, so an exception should be thrown" |
4792 "in this testcase, arg is 0, so an exception should be thrown" |
4793 |
4793 |
4794 self |
4794 self |
4795 execute:'test(arg) { |
4795 execute:'test(arg) { |
4796 var handlerWasCalled = false; |
4796 var handlerWasCalled = false; |
4797 |
4797 |
4798 function failingMethod() { return 10 / arg; }; |
4798 function failingMethod() { return 10 / arg; }; |
4799 |
4799 |
4800 try { |
4800 try { |
4801 failingMethod(); |
4801 failingMethod(); |
4802 } catch (Error e) { |
4802 } catch (Error e) { |
4803 handlerWasCalled = true; |
4803 handlerWasCalled = true; |
4804 } |
4804 } |
4805 return handlerWasCalled; |
4805 return handlerWasCalled; |
4806 }' |
4806 }' |
4807 for:nil |
4807 for:nil |
4808 arguments:#(0) |
4808 arguments:#(0) |
4809 expect:true |
4809 expect:true |
4810 |
4810 |
4811 " |
4811 " |
4812 self run:#testTryCatch01b |
4812 self run:#testTryCatch01b |
4813 self new testTryCatch01b |
4813 self new testTryCatch01b |
4814 " |
4814 " |
4815 ! |
4815 ! |
4816 |
4816 |
4817 testTryCatch02a |
4817 testTryCatch02a |
4818 self |
4818 self |
4819 execute:'test(arg) { |
4819 execute:'test(arg) { |
4820 var handlerWasCalled = false; |
4820 var handlerWasCalled = false; |
4821 |
4821 |
4822 function failingMethod() { return 10 / arg; }; |
4822 function failingMethod() { return 10 / arg; }; |
4823 function exceptionRaised() { handlerWasCalled = true; }; |
4823 function exceptionRaised() { handlerWasCalled = true; }; |
4824 |
4824 |
4825 try { |
4825 try { |
4826 failingMethod(); |
4826 failingMethod(); |
4827 } catch (Error e) { |
4827 } catch (Error e) { |
4828 exceptionRaised(); |
4828 exceptionRaised(); |
4829 } |
4829 } |
4830 return handlerWasCalled; |
4830 return handlerWasCalled; |
4831 }' |
4831 }' |
4832 for:nil |
4832 for:nil |
4833 arguments:#(5) |
4833 arguments:#(5) |
4834 expect:false |
4834 expect:false |
4835 |
4835 |
4836 " |
4836 " |
4837 self run:#testTryCatch02a |
4837 self run:#testTryCatch02a |
4838 self new testTryCatch02a |
4838 self new testTryCatch02a |
4839 " |
4839 " |
4840 ! |
4840 ! |
4841 |
4841 |
4842 testTryCatch02b |
4842 testTryCatch02b |
4843 self |
4843 self |
4844 execute:'test(arg) { |
4844 execute:'test(arg) { |
4845 var handlerWasCalled = false; |
4845 var handlerWasCalled = false; |
4846 |
4846 |
4847 function failingMethod() { return 10 / arg; }; |
4847 function failingMethod() { return 10 / arg; }; |
4848 function exceptionRaised() { handlerWasCalled = true; }; |
4848 function exceptionRaised() { handlerWasCalled = true; }; |
4849 |
4849 |
4850 try { |
4850 try { |
4851 failingMethod(); |
4851 failingMethod(); |
4852 } catch (Error e) { |
4852 } catch (Error e) { |
4853 exceptionRaised(); |
4853 exceptionRaised(); |
4854 } |
4854 } |
4855 return handlerWasCalled; |
4855 return handlerWasCalled; |
4856 }' |
4856 }' |
4857 for:nil |
4857 for:nil |
4858 arguments:#(0) |
4858 arguments:#(0) |
4859 expect:true |
4859 expect:true |
4860 |
4860 |
4861 " |
4861 " |
4862 self run:#testTryCatch02b |
4862 self run:#testTryCatch02b |
4863 self new testTryCatch02b |
4863 self new testTryCatch02b |
4864 " |
4864 " |
4865 ! |
4865 ! |
4866 |
4866 |
4867 testTryCatch03a |
4867 testTryCatch03a |
4868 self |
4868 self |
4869 execute:'test(arg) { |
4869 execute:'test(arg) { |
4870 var handlerWasCalled = false; |
4870 var handlerWasCalled = false; |
4871 |
4871 |
4872 function failingMethod() { return 10 / arg; }; |
4872 function failingMethod() { return 10 / arg; }; |
4873 function exceptionRaised(e) { handlerWasCalled = true; }; |
4873 function exceptionRaised(e) { handlerWasCalled = true; }; |
4874 |
4874 |
4875 try { |
4875 try { |
4876 failingMethod(); |
4876 failingMethod(); |
4877 } catch (Error e) { |
4877 } catch (Error e) { |
4878 exceptionRaised(e); |
4878 exceptionRaised(e); |
4879 } |
4879 } |
4880 return handlerWasCalled; |
4880 return handlerWasCalled; |
4881 }' |
4881 }' |
4882 for:nil |
4882 for:nil |
4883 arguments:#(5) |
4883 arguments:#(5) |
4884 expect:false |
4884 expect:false |
4885 |
4885 |
4886 " |
4886 " |
4887 self run:#testTryCatch03a |
4887 self run:#testTryCatch03a |
4888 self new testTryCatch03a |
4888 self new testTryCatch03a |
4889 " |
4889 " |
4890 ! |
4890 ! |
4891 |
4891 |
4892 testTryCatch03b |
4892 testTryCatch03b |
4893 self |
4893 self |
4894 execute:'test(arg) { |
4894 execute:'test(arg) { |
4895 var handlerWasCalled = false; |
4895 var handlerWasCalled = false; |
4896 |
4896 |
4897 function failingMethod() { return 10 / arg; }; |
4897 function failingMethod() { return 10 / arg; }; |
4898 function exceptionRaised(e) { handlerWasCalled = true; }; |
4898 function exceptionRaised(e) { handlerWasCalled = true; }; |
4899 |
4899 |
4900 try { |
4900 try { |
4901 failingMethod(); |
4901 failingMethod(); |
4902 } catch (Error e) { |
4902 } catch (Error e) { |
4903 exceptionRaised(e); |
4903 exceptionRaised(e); |
4904 } |
4904 } |
4905 return handlerWasCalled; |
4905 return handlerWasCalled; |
4906 }' |
4906 }' |
4907 for:nil |
4907 for:nil |
4908 arguments:#(0) |
4908 arguments:#(0) |
4909 expect:true |
4909 expect:true |
4910 |
4910 |
4911 " |
4911 " |
4912 self run:#testTryCatch03b |
4912 self run:#testTryCatch03b |
4913 self new testTryCatch03b |
4913 self new testTryCatch03b |
4914 " |
4914 " |
4915 ! |
4915 ! |
4916 |
4916 |
4917 testTryCatch04b |
4917 testTryCatch04b |
4918 self should:[ |
4918 self should:[ |
4919 |
4919 |
4920 self |
4920 self |
4921 execute:'test(arg) { |
4921 execute:'test(arg) { |
4922 var handlerWasCalled = false; |
4922 var handlerWasCalled = false; |
4923 |
4923 |
4924 function failingMethod() { return 10 / arg; }; |
4924 function failingMethod() { return 10 / arg; }; |
4925 function exceptionRaised() { handlerWasCalled = true; }; |
4925 function exceptionRaised() { handlerWasCalled = true; }; |
4926 |
4926 |
4927 try { |
4927 try { |
4928 failingMethod(); |
4928 failingMethod(); |
4929 } catch (Error e) { |
4929 } catch (Error e) { |
4930 exceptionRaised(e); |
4930 exceptionRaised(e); |
4931 } |
4931 } |
4932 return handlerWasCalled; |
4932 return handlerWasCalled; |
4933 }' |
4933 }' |
4934 for:nil |
4934 for:nil |
4935 arguments:#(0) |
4935 arguments:#(0) |
4936 expect:true |
4936 expect:true |
4937 |
4937 |
4938 ] raise: Error. |
4938 ] raise: Error. |
4939 |
4939 |
4940 " |
4940 " |
4941 self run:#testTryCatch04b |
4941 self run:#testTryCatch04b |