--- a/RegressionTests__JavaScriptTests.st Wed Apr 27 13:44:25 2005 +0200
+++ b/RegressionTests__JavaScriptTests.st Wed Apr 27 15:45:15 2005 +0200
@@ -192,6 +192,115 @@
"
!
+testDoWhile01
+ self
+ execute:'test(arg) {
+ var n;
+
+ n = 1;
+ do {
+ Transcript.showCR(n);
+ } while (++n <= 3);
+ return n;
+ }'
+ for:nil
+ arguments:#(5)
+ expect:4
+
+ "
+ self run:#testDoWhile01
+ self new testDoWhile01
+ "
+!
+
+testDoWhile02
+ self
+ execute:'test(arg) {
+ var n;
+
+ n = 1;
+ do {
+ Transcript.showCR(n);
+ break;
+ } while (true);
+ return n;
+ }'
+ for:nil
+ arguments:#(5)
+ expect:1
+
+ "
+ self run:#testDoWhile02
+ self new testDoWhile02
+ "
+!
+
+testDoWhile03
+ self
+ execute:'test(arg) {
+ var n;
+
+ n = 1;
+ do {
+ break;
+ Transcript.showCR(n);
+ } while (true);
+ return n;
+ }'
+ for:nil
+ arguments:#(5)
+ expect:1
+
+ "
+ self run:#testDoWhile03
+ self new testDoWhile03
+ "
+!
+
+testDoWhile04
+ self
+ execute:'test(arg) {
+ var n;
+
+ n = 1;
+ do {
+ if (++n == 3) continue;
+ Transcript.showCR(n);
+ } while (n <= 4);
+ return n;
+ }'
+ for:nil
+ arguments:#(5)
+ expect:5
+
+ "
+ self run:#testDoWhile04
+ self new testDoWhile04
+ "
+!
+
+testDoWhile05
+ self
+ execute:'test(arg) {
+ var n;
+
+ n = 1;
+ do {
+ if (++n == 3) break;
+ Transcript.showCR(n);
+ } while (n <= 4);
+ return n;
+ }'
+ for:nil
+ arguments:#(5)
+ expect:3
+
+ "
+ self run:#testDoWhile05
+ self new testDoWhile05
+ "
+!
+
testFor01
self
execute:'test(arg) {
@@ -742,7 +851,7 @@
"
!
-testOperators01
+testOperators01_plus
self
execute:'expr(a, b) {
return (a + 0);
@@ -752,12 +861,12 @@
expect:10
"
- self run:#testOperators01
- self new testOperators01
+ self run:#testOperators01_plus
+ self new testOperators01_plus
"
!
-testOperators02
+testOperators02_plus
self
execute:'expr(a, b) {
return (a + 1);
@@ -767,12 +876,12 @@
expect:11
"
- self run:#testOperators02
- self new testOperators02
+ self run:#testOperators02_plus
+ self new testOperators02_plus
"
!
-testOperators03
+testOperators03_minus
self
execute:'expr(a, b) {
return (a - 1);
@@ -782,12 +891,12 @@
expect:9
"
- self run:#testOperators03
- self new testOperators03
+ self run:#testOperators03_minus
+ self new testOperators03_minus
"
!
-testOperators04
+testOperators04_plus
self
execute:'expr(a, b) {
return (a + a);
@@ -797,12 +906,12 @@
expect:20
"
- self run:#testOperators04
- self new testOperators04
+ self run:#testOperators04_plus
+ self new testOperators04_plus
"
!
-testOperators05
+testOperators05_mul
self
execute:'expr(a, b) {
return (a * 0);
@@ -812,12 +921,12 @@
expect:0
"
- self run:#testOperators05
- self new testOperators05
+ self run:#testOperators05_mul
+ self new testOperators05_mul
"
!
-testOperators06
+testOperators06_mul
self
execute:'expr(a, b) {
return (a * 1);
@@ -827,12 +936,12 @@
expect:10
"
- self run:#testOperators06
- self new testOperators06
+ self run:#testOperators06_mul
+ self new testOperators06_mul
"
!
-testOperators07
+testOperators07_mul
self
execute:'expr(a, b) {
return (a * -1);
@@ -842,12 +951,12 @@
expect:-10
"
- self run:#testOperators07
- self new testOperators07
+ self run:#testOperators07_mul
+ self new testOperators07_mul
"
!
-testOperators08
+testOperators08_mul
self
execute:'expr(a, b) {
return (a * 10);
@@ -857,12 +966,12 @@
expect:100
"
- self run:#testOperators08
- self new testOperators08
+ self run:#testOperators08_mul
+ self new testOperators08_mul
"
!
-testOperators09
+testOperators09_mul
self
execute:'expr(a, b) {
return (a * a);
@@ -872,12 +981,12 @@
expect:100
"
- self run:#testOperators09
- self new testOperators09
+ self run:#testOperators09_mul
+ self new testOperators09_mul
"
!
-testOperators10
+testOperators10_mul
self
execute:'expr(a, b) {
return (a * b);
@@ -887,12 +996,12 @@
expect:200
"
- self run:#testOperators10
- self new testOperators10
+ self run:#testOperators10_mul
+ self new testOperators10_mul
"
!
-testOperators11
+testOperators11_minus
self
execute:'expr(a, b) {
return (a - b);
@@ -902,12 +1011,12 @@
expect:-10
"
- self run:#testOperators11
- self new testOperators11
+ self run:#testOperators11_minus
+ self new testOperators11_minus
"
!
-testOperators12
+testOperators12_unaryMinus
self
execute:'expr(a) {
return (-a);
@@ -917,12 +1026,12 @@
expect:-10
"
- self run:#testOperators12
- self new testOperators12
+ self run:#testOperators12_unaryMinus
+ self new testOperators12_unaryMinus
"
!
-testOperators13
+testOperators13_minus
self
execute:'expr(a, b) {
return (a - -b);
@@ -932,12 +1041,12 @@
expect:30
"
- self run:#testOperators13
- self new testOperators13
+ self run:#testOperators13_minus
+ self new testOperators13_minus
"
!
-testOperators14
+testOperators14_unaryMinus
self
execute:'expr(a, b) {
return (a * -b);
@@ -947,12 +1056,12 @@
expect:-10
"
- self run:#testOperators14
- self new testOperators14
+ self run:#testOperators14_unaryMinus
+ self new testOperators14_unaryMinus
"
!
-testOperators15
+testOperators15_div
self
execute:'expr(a, b) {
return (a / 1.0);
@@ -962,12 +1071,12 @@
expect:10.0
"
- self run:#testOperators15
- self new testOperators15
+ self run:#testOperators15_div
+ self new testOperators15_div
"
!
-testOperators16a
+testOperators16a_postInc
self
execute:'expr(a, b) {
return (a++);
@@ -977,12 +1086,12 @@
expectError:#ParseError
"
- self run:#testOperators16a
- self new testOperators16a
+ self run:#testOperators16a_postInc
+ self new testOperators16a_postInc
"
!
-testOperators16b
+testOperators16b_postInc
self
execute:'expr(a, b) {
var aa = a;
@@ -994,8 +1103,8 @@
expect:10
"
- self run:#testOperators16b
- self new testOperators16b
+ self run:#testOperators16b_postInc
+ self new testOperators16b_postInc
"
!
@@ -1209,7 +1318,7 @@
"
!
-testOperators21a
+testOperators21a_ne
self
execute:'expr(a) {
return (a !!= 0);
@@ -1219,12 +1328,12 @@
expect:true
"
- self run:#testOperators21a
- self new testOperators21a
+ self run:#testOperators21a_ne
+ self new testOperators21a_ne
"
!
-testOperators21b
+testOperators21b_ne
self
execute:'expr(a) {
return (a !!= 0);
@@ -1234,12 +1343,12 @@
expect:false
"
- self run:#testOperators21b
- self new testOperators21b
+ self run:#testOperators21b_ne
+ self new testOperators21b_ne
"
!
-testOperators22a
+testOperators22a_gt
self
execute:'expr(a) {
return (a > 0);
@@ -1249,12 +1358,12 @@
expect:false
"
- self run:#testOperators22a
- self new testOperators22a
+ self run:#testOperators22a_gt
+ self new testOperators22a_gt
"
!
-testOperators22b
+testOperators22b_gt
self
execute:'expr(a) {
return (a > 0);
@@ -1264,12 +1373,12 @@
expect:true
"
- self run:#testOperators22b
- self new testOperators22b
+ self run:#testOperators22b_gt
+ self new testOperators22b_gt
"
!
-testOperators23
+testOperators23_unaryMinus
self
execute:'expr(a) {
return (-a);
@@ -1279,12 +1388,12 @@
expect:-1
"
- self run:#testOperators23
- self new testOperators23
+ self run:#testOperators23_unaryMinus
+ self new testOperators23_unaryMinus
"
!
-testOperators24a
+testOperators24a_div
self
execute:'expr(a) {
return (a / 4);
@@ -1294,12 +1403,12 @@
expect:1
"
- self run:#testOperators24a
- self new testOperators24a
+ self run:#testOperators24a_div
+ self new testOperators24a_div
"
!
-testOperators24b
+testOperators24b_div
self
execute:'expr(a) {
return (a / 4.0);
@@ -1309,12 +1418,12 @@
expect:1.0
"
- self run:#testOperators24b
- self new testOperators24b
+ self run:#testOperators24b_div
+ self new testOperators24b_div
"
!
-testOperators24c
+testOperators24c_div
self
execute:'expr(a) {
return (a / 4);
@@ -1324,12 +1433,12 @@
expect:1.0
"
- self run:#testOperators24c
- self new testOperators24c
+ self run:#testOperators24c_div
+ self new testOperators24c_div
"
!
-testOperators24d
+testOperators24d_div
self
execute:'expr(a) {
return (a / 4.0);
@@ -1339,12 +1448,12 @@
expect:1.0
"
- self run:#testOperators24d
- self new testOperators24d
+ self run:#testOperators24d_div
+ self new testOperators24d_div
"
!
-testOperators25a
+testOperators25a_mod
self
execute:'expr(a) {
return (a % 4);
@@ -1354,12 +1463,12 @@
expect:0
"
- self run:#testOperators25a
- self new testOperators25a
+ self run:#testOperators25a_mod
+ self new testOperators25a_mod
"
!
-testOperators25b
+testOperators25b_mod
self
execute:'expr(a) {
return (a % 4.0);
@@ -1369,12 +1478,12 @@
expect:0.0
"
- self run:#testOperators25b
- self new testOperators25b
+ self run:#testOperators25b_mod
+ self new testOperators25b_mod
"
!
-testOperators25c
+testOperators25c_mod
self
execute:'expr(a) {
return (a % 4);
@@ -1384,12 +1493,12 @@
expect:0.0
"
- self run:#testOperators25c
- self new testOperators25c
+ self run:#testOperators25c_mod
+ self new testOperators25c_mod
"
!
-testOperators25d
+testOperators25d_mod
self
execute:'expr(a) {
return (a % 4.0);
@@ -1399,12 +1508,12 @@
expect:0.0
"
- self run:#testOperators25d
- self new testOperators25d
+ self run:#testOperators25d_mod
+ self new testOperators25d_mod
"
!
-testOperators25e
+testOperators25e_mod
self
execute:'expr(a) {
return (a % 4);
@@ -1414,12 +1523,12 @@
expect:0
"
- self run:#testOperators25e
- self new testOperators25e
+ self run:#testOperators25e_mod
+ self new testOperators25e_mod
"
!
-testOperators25f
+testOperators25f_mod
self
execute:'expr(a) {
return (a % 4.0);
@@ -1429,12 +1538,12 @@
expect:0.0
"
- self run:#testOperators25f
- self new testOperators25f
+ self run:#testOperators25f_mod
+ self new testOperators25f_mod
"
!
-testOperators25g
+testOperators25g_mod
self
execute:'expr(a) {
return (a % 4);
@@ -1444,12 +1553,12 @@
expect:0.0
"
- self run:#testOperators25g
- self new testOperators25g
+ self run:#testOperators25g_mod
+ self new testOperators25g_mod
"
!
-testOperators25h
+testOperators25h_mod
self
execute:'expr(a) {
return (a % 4.0);
@@ -1459,12 +1568,12 @@
expect:0.0
"
- self run:#testOperators25h
- self new testOperators25h
+ self run:#testOperators25h_mod
+ self new testOperators25h_mod
"
!
-testOperators26a
+testOperators26a_postInc
self
execute:'expr(a) {
var x = a;
@@ -1476,12 +1585,12 @@
expect:1
"
- self run:#testOperators26a
- self new testOperators26a
+ self run:#testOperators26a_postInc
+ self new testOperators26a_postInc
"
!
-testOperators26b
+testOperators26b_postDec
self
execute:'expr(a) {
var x = a;
@@ -1493,12 +1602,12 @@
expect:1
"
- self run:#testOperators26b
- self new testOperators26b
+ self run:#testOperators26b_postDec
+ self new testOperators26b_postDec
"
!
-testOperators26c
+testOperators26c_preInc
self
execute:'expr(a) {
var x = a;
@@ -1510,12 +1619,12 @@
expect:2
"
- self run:#testOperators26c
- self new testOperators26c
+ self run:#testOperators26c_preInc
+ self new testOperators26c_preInc
"
!
-testOperators26d
+testOperators26d_preDec
self
execute:'expr(a) {
var x = a;
@@ -1527,12 +1636,12 @@
expect:0
"
- self run:#testOperators26d
- self new testOperators26d
+ self run:#testOperators26d_preDec
+ self new testOperators26d_preDec
"
!
-testOperators27a
+testOperators27a_postInc
self
execute:'expr(a) {
var x = a;
@@ -1545,12 +1654,12 @@
expect:2
"
- self run:#testOperators27a
- self new testOperators27a
+ self run:#testOperators27a_postInc
+ self new testOperators27a_postInc
"
!
-testOperators27b
+testOperators27b_postDec
self
execute:'expr(a) {
var x = a;
@@ -1563,12 +1672,12 @@
expect:0
"
- self run:#testOperators27b
- self new testOperators27b
+ self run:#testOperators27b_postDec
+ self new testOperators27b_postDec
"
!
-testOperators27c
+testOperators27c_preInc
self
execute:'expr(a) {
var x = a;
@@ -1581,12 +1690,12 @@
expect:2
"
- self run:#testOperators27c
- self new testOperators27c
+ self run:#testOperators27c_preInc
+ self new testOperators27c_preInc
"
!
-testOperators27d
+testOperators27d_preDec
self
execute:'expr(a) {
var x = a;
@@ -1599,12 +1708,12 @@
expect:0
"
- self run:#testOperators27d
- self new testOperators27d
+ self run:#testOperators27d_preDec
+ self new testOperators27d_preDec
"
!
-testOperators28
+testOperators28_not
self
execute:'expr(a) {
return (!! a);
@@ -1614,12 +1723,12 @@
expect:false
"
- self run:#testOperators28
- self new testOperators28
+ self run:#testOperators28_not
+ self new testOperators28_not
"
!
-testOperators29
+testOperators29_plusAssign
self
execute:'expr(a, b, c, d) {
var s = 0;
@@ -1634,12 +1743,12 @@
expect:10
"
- self run:#testOperators29
- self new testOperators29
+ self run:#testOperators29_plusAssign
+ self new testOperators29_plusAssign
"
!
-testOperators30
+testOperators30_timesAssign
self
execute:'expr(a, b, c, d) {
var s = 1;
@@ -1654,12 +1763,12 @@
expect:24
"
- self run:#testOperators30
- self new testOperators30
+ self run:#testOperators30_timesAssign
+ self new testOperators30_timesAssign
"
!
-testOperators31a
+testOperators31a_shiftLeft
self
execute:'expr(a) {
return (a << 1);
@@ -1669,12 +1778,12 @@
expect:2
"
- self run:#testOperators31a
- self new testOperators31a
+ self run:#testOperators31a_shiftLeft
+ self new testOperators31a_shiftLeft
"
!
-testOperators31b
+testOperators31b_shiftLeft
self
execute:'expr(a) {
return (a << 32);
@@ -1684,12 +1793,12 @@
expect:16r100000000
"
- self run:#testOperators31b
- self new testOperators31b
+ self run:#testOperators31b_shiftLeft
+ self new testOperators31b_shiftLeft
"
!
-testOperators32a
+testOperators32a_shiftRight
self
execute:'expr(a) {
return (a >> 1);
@@ -1699,12 +1808,12 @@
expect:1
"
- self run:#testOperators32a
- self new testOperators32a
+ self run:#testOperators32a_shiftRight
+ self new testOperators32a_shiftRight
"
!
-testOperators33
+testOperators33_bitordAssign
self
execute:'expr(a, b) {
var s = 0;
@@ -1717,12 +1826,12 @@
expect:5
"
- self run:#testOperators33
- self new testOperators33
+ self run:#testOperators33_bitordAssign
+ self new testOperators33_bitordAssign
"
!
-testOperators34
+testOperators34_bitandAssign
self
execute:'expr(a, b) {
var s = 0xFFFF;
@@ -1735,12 +1844,12 @@
expect:1
"
- self run:#testOperators34
- self new testOperators34
+ self run:#testOperators34_bitandAssign
+ self new testOperators34_bitandAssign
"
!
-testOperators35a
+testOperators35a_xorAssign
self
execute:'expr(a) {
var s = 0xFFFF;
@@ -1752,12 +1861,12 @@
expect:16rFFFE
"
- self run:#testOperators35a
- self new testOperators35a
+ self run:#testOperators35a_xorAssign
+ self new testOperators35a_xorAssign
"
!
-testOperators35b
+testOperators35b_xor
self
execute:'expr(a) {
var s = 0xFFFF;
@@ -1769,8 +1878,98 @@
expect:16rFFFE
"
- self run:#testOperators35b
- self new testOperators35b
+ self run:#testOperators35b_xor
+ self new testOperators35b_xor
+ "
+!
+
+testOperators36a_mod
+ self
+ execute:'expr(a) {
+ return (a % 2);
+ }'
+ for:nil
+ arguments:#(10)
+ expect:0
+
+ "
+ self run:#testOperators36a_mod
+ self new testOperators36a_mod
+ "
+!
+
+testOperators36b_mod
+ self
+ execute:'expr(a) {
+ return (a % 2);
+ }'
+ for:nil
+ arguments:#(9)
+ expect:1
+
+ "
+ self run:#testOperators36b_mod
+ self new testOperators36b_mod
+ "
+!
+
+testOperators37a_cond
+ self
+ execute:'expr(a) {
+ return (a ? 1 : 0);
+ }'
+ for:nil
+ arguments:#(true)
+ expect:1
+
+ "
+ self run:#testOperators37a_cond
+ self new testOperators37a_cond
+ "
+!
+
+testOperators37b_cond
+ self
+ execute:'expr(a) {
+ return (a ? 1 : 0);
+ }'
+ for:nil
+ arguments:#(false)
+ expect:0
+
+ "
+ self run:#testOperators37b_cond
+ self new testOperators37b_cond
+ "
+!
+
+testOperators37c_cond
+ self
+ execute:'expr(a, b) {
+ return (a ? (b ? 0 : 1) : (b ? 2 : 3));
+ }'
+ for:nil
+ arguments:#(false false)
+ expect:3
+
+ "
+ self run:#testOperators37c_cond
+ self new testOperators37c_cond
+ "
+!
+
+testOperators37d_cond
+ self
+ execute:'expr(a) {
+ return (a == 1 ? 2 : 3);
+ }'
+ for:nil
+ arguments:#(1)
+ expect:2
+
+ "
+ self run:#testOperators37d_cond
+ self new testOperators37d_cond
"
!
@@ -1874,6 +2073,23 @@
"Modified: / 20-04-2005 / 11:55:30 / cg"
!
+testReturn01
+ self
+ execute:'test(n) {
+ return 1;
+ }'
+ for:nil
+ arguments:#(10)
+ expect:1
+
+ "
+ self run:#testReturn01
+ self new testReturn01
+ "
+
+ "Modified: / 20-04-2005 / 11:55:30 / cg"
+!
+
testScanner01
self
execute:'f() { }'
@@ -2197,6 +2413,193 @@
"
!
+testSwitch06a
+ self
+ execute:'test(arg) {
+ switch (arg) {
+ case 1:
+ Transcript.showCR("one");
+ return 10;
+ case 2:
+ Transcript.showCR("two");
+ return 20;
+ }
+ return 0;
+ }'
+ for:nil
+ arguments:#(5)
+ expect:0
+
+ "
+ self run:#testSwitch06a
+ self new testSwitch06a
+ "
+!
+
+testSwitch06b
+ self
+ execute:'test(arg) {
+ switch (arg) {
+ case 1:
+ Transcript.showCR("one");
+ return 10;
+ case 2:
+ Transcript.showCR("two");
+ return 20;
+ }
+ return 0;
+ }'
+ for:nil
+ arguments:#(1)
+ expect:10
+
+ "
+ self run:#testSwitch06b
+ self new testSwitch06b
+ "
+!
+
+testSwitch06c
+ self
+ execute:'test(arg) {
+ switch (arg) {
+ case 1:
+ Transcript.showCR("one");
+ return 10;
+ case 2:
+ Transcript.showCR("two");
+ return 20;
+ }
+ return 0;
+ }'
+ for:nil
+ arguments:#(2)
+ expect:20
+
+ "
+ self run:#testSwitch06c
+ self new testSwitch06c
+ "
+!
+
+testSwitch06d
+ self
+ execute:'test(arg) {
+ switch (arg) {
+ case "hallo":
+ Transcript.showCR("Hallo");
+ return 10;
+ case "hello":
+ Transcript.showCR("Hello");
+ return 20;
+ }
+ return 0;
+ }'
+ for:nil
+ arguments:#('hello')
+ expect:20
+
+ "
+ self run:#testSwitch06d
+ self new testSwitch06d
+ "
+!
+
+testSwitch06e
+ self
+ execute:'test(arg) {
+ switch (arg) {
+ case 1:
+ Transcript.showCR("Hallo");
+ return 10;
+ case 2:
+ Transcript.showCR("Hello");
+ return 20;
+ }
+ return 0;
+ }'
+ for:nil
+ arguments:#(3)
+ expect:0
+
+ "
+ self run:#testSwitch06e
+ self new testSwitch06e
+ "
+!
+
+testSwitch06f
+ self
+ execute:'test(arg) {
+ var a = 0;
+ switch (arg) {
+ case 1:
+ a = 10;
+ break;
+ case 2:
+ a = 20;
+ break;
+ }
+ return a;
+ }'
+ for:nil
+ arguments:#(1)
+ expect:10
+
+ "
+ self run:#testSwitch06f
+ self new testSwitch06f
+ "
+!
+
+testSwitch06g
+ self
+ execute:'test(arg) {
+ var a = 0;
+ switch (arg) {
+ case 1:
+ a = 10;
+ break;
+ case 2:
+ a = 20;
+ break;
+ }
+ return a;
+ }'
+ for:nil
+ arguments:#(2)
+ expect:20
+
+ "
+ self run:#testSwitch06g
+ self new testSwitch06g
+ "
+!
+
+testSwitch06h
+ self
+ execute:'test(arg) {
+ var a = 0;
+ switch (arg) {
+ case 1:
+ a = 10;
+ break;
+ case 2:
+ a = 20;
+ break;
+ }
+ return a;
+ }'
+ for:nil
+ arguments:#(3)
+ expect:0
+
+ "
+ self run:#testSwitch06h
+ self new testSwitch06h
+ "
+!
+
testVarDeclaration01
self
execute:'expr(a, b) {
@@ -2482,6 +2885,8 @@
('"\t"' #isString (#eval 'Character tab asString') )
('"\r"' #isString (#eval 'Character return asString') )
('"\n"' #isString (#eval 'Character nl asString') )
+ ('"\''"' #isString '''' )
+ ('"\""' #isString '"' )
('[ 1 , 2 , 3]' #isArray #(1 2 3) )
('[1,2,3]' #isArray #(1 2 3) )