RegressionTests__JavaScriptTests.st
branchjv
changeset 1500 d406a10b2965
parent 1499 26a16a04219b
parent 1447 2351db93aa5b
child 1533 94753c163f85
equal deleted inserted replaced
1499:26a16a04219b 1500:d406a10b2965
    14 documentation
    14 documentation
    15 "
    15 "
    16     documentation to be added.
    16     documentation to be added.
    17 
    17 
    18     [author:]
    18     [author:]
    19         cg (cg@FUSI)
    19 	cg (cg@FUSI)
    20 
    20 
    21     [instance variables:]
    21     [instance variables:]
    22 
    22 
    23     [class variables:]
    23     [class variables:]
    24 
    24 
    32 ! !
    32 ! !
    33 
    33 
    34 !JavaScriptTests class methodsFor:'queries'!
    34 !JavaScriptTests class methodsFor:'queries'!
    35 
    35 
    36 coveredClassNames
    36 coveredClassNames
    37     ^ #( 
    37     ^ #(
    38         JavaScriptParser 
    38 	JavaScriptParser
    39         JavaScriptScanner 
    39 	JavaScriptScanner
    40         JavaScriptCompiler 
    40 	JavaScriptCompiler
    41         )
    41 	)
    42 ! !
    42 ! !
    43 
    43 
    44 !JavaScriptTests methodsFor:'helpers'!
    44 !JavaScriptTests methodsFor:'helpers'!
    45 
    45 
    46 doTestEachFromSpec:spec 
    46 doTestEachFromSpec:spec
    47     spec do:[:triple | 
    47     spec do:[:triple |
    48         |str checkSelectorOrNil valExpected val expectError|
    48 	|str checkSelectorOrNil valExpected val expectError|
    49 
    49 
    50         str := triple first.
    50 	str := triple first.
    51         checkSelectorOrNil := triple second.
    51 	checkSelectorOrNil := triple second.
    52         expectError := false.
    52 	expectError := false.
    53         valExpected := triple third.
    53 	valExpected := triple third.
    54         valExpected isArray ifTrue:[
    54 	valExpected isArray ifTrue:[
    55             valExpected size > 0 ifTrue:[
    55 	    valExpected size > 0 ifTrue:[
    56                 valExpected first == #eval ifTrue:[
    56 		valExpected first == #eval ifTrue:[
    57                     valExpected := Parser evaluate:valExpected second
    57 		    valExpected := Parser evaluate:valExpected second
    58                 ] ifFalse:[
    58 		] ifFalse:[
    59                     valExpected first == #error ifTrue:[
    59 		    valExpected first == #error ifTrue:[
    60                         expectError := true
    60 			expectError := true
    61                     ].
    61 		    ].
    62                 ].
    62 		].
    63             ].
    63 	    ].
    64         ].
    64 	].
    65         expectError ifTrue:[
    65 	expectError ifTrue:[
    66             self 
    66 	    self
    67                 should:[ (JavaScriptParser parseExpression:str) evaluate ]
    67 		should:[ (JavaScriptParser parseExpression:str) evaluate ]
    68                 raise:Error
    68 		raise:Error
    69         ] ifFalse:[
    69 	] ifFalse:[
    70             val := (JavaScriptParser parseExpression:str) evaluate.
    70 	    val := (JavaScriptParser parseExpression:str) evaluate.
    71             checkSelectorOrNil notNil ifTrue:[
    71 	    checkSelectorOrNil notNil ifTrue:[
    72                 self assert:(val perform:checkSelectorOrNil).
    72 		self assert:(val perform:checkSelectorOrNil).
    73             ].
    73 	    ].
    74             self assert:(val = valExpected).
    74 	    self assert:(val = valExpected).
    75         ].
    75 	].
    76     ]
    76     ]
    77 !
    77 !
    78 
    78 
    79 doTestEachFunctionFromSpec:spec 
    79 doTestEachFunctionFromSpec:spec
    80     spec do:[:tuple | 
    80     spec do:[:tuple |
    81         |source expectError|
    81 	|source expectError|
    82 
    82 
    83         source := tuple first.
    83 	source := tuple first.
    84         expectError := tuple second.
    84 	expectError := tuple second.
    85 
    85 
    86         expectError ifTrue:[
    86 	expectError ifTrue:[
    87             self 
    87 	    self
    88                 should:[ JavaScriptParser parseFunction:source ]
    88 		should:[ JavaScriptParser parseFunction:source ]
    89                 raise:Error
    89 		raise:Error
    90         ] ifFalse:[
    90 	] ifFalse:[
    91             JavaScriptParser parseFunction:source.
    91 	    JavaScriptParser parseFunction:source.
    92         ].
    92 	].
    93     ]
    93     ]
    94 !
    94 !
    95 
    95 
    96 execute:code for:receiver arguments:arguments
    96 execute:code for:receiver arguments:arguments
    97     |parser f result|
    97     |parser f result|
   102     JavaScriptParseNodeValidator validate: parser tree source: code.
   102     JavaScriptParseNodeValidator validate: parser tree source: code.
   103 
   103 
   104     "/ Transcript showCR:(thisContext sender selector , '...').
   104     "/ Transcript showCR:(thisContext sender selector , '...').
   105 
   105 
   106     f := JavaScriptCompiler
   106     f := JavaScriptCompiler
   107         compile:code
   107 	compile:code
   108         forClass:(receiver class)
   108 	forClass:(receiver class)
   109         inCategory:nil
   109 	inCategory:nil
   110         notifying:nil
   110 	notifying:nil
   111         install:false.
   111 	install:false.
   112 
   112 
   113 "/ f inspect.
   113 "/ f inspect.
   114 
   114 
   115     self assert:(f ~~ #Error).
   115     self assert:(f ~~ #Error).
   116     self assert:(f notNil).
   116     self assert:(f notNil).
   117 
   117 
   118 "/    f decompileTo:Transcript.
   118 "/    f decompileTo:Transcript.
   119 
   119 
   120     result := f valueWithReceiver:receiver arguments:arguments selector:nil search:nil sender:nil.    
   120     result := f valueWithReceiver:receiver arguments:arguments selector:nil search:nil sender:nil.
   121     ^ result
   121     ^ result
   122 
   122 
   123     "Modified: / 09-10-2011 / 11:41:51 / cg"
   123     "Modified: / 09-10-2011 / 11:41:51 / cg"
   124     "Modified (format): / 20-09-2013 / 11:56:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   124     "Modified (format): / 20-09-2013 / 11:56:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   125 !
   125 !
   135     |f errorEncountered|
   135     |f errorEncountered|
   136 
   136 
   137     "/ Transcript showCR:(thisContext sender selector , '...').
   137     "/ Transcript showCR:(thisContext sender selector , '...').
   138 
   138 
   139     Parser parseErrorSignal handle:[:ex |
   139     Parser parseErrorSignal handle:[:ex |
   140         errorEncountered := true.
   140 	errorEncountered := true.
   141     ] do:[
   141     ] do:[
   142         f := JavaScriptCompiler
   142 	f := JavaScriptCompiler
   143             compile:code
   143 	    compile:code
   144             forClass:(receiver class)
   144 	    forClass:(receiver class)
   145             inCategory:nil
   145 	    inCategory:nil
   146             notifying:nil
   146 	    notifying:nil
   147             install:false.
   147 	    install:false.
   148 
   148 
   149         errorEncountered := (f == #Error).
   149 	errorEncountered := (f == #Error).
   150     ].
   150     ].
   151 
   151 
   152     expectedError == #ParseError ifTrue:[
   152     expectedError == #ParseError ifTrue:[
   153         self assert:(errorEncountered).
   153 	self assert:(errorEncountered).
   154         ^ self
   154 	^ self
   155     ].
   155     ].
   156 
   156 
   157     self assert:(errorEncountered not).
   157     self assert:(errorEncountered not).
   158     self assert:(f notNil).
   158     self assert:(f notNil).
   159 
   159 
   160 "/    f decompileTo:Transcript.
   160 "/    f decompileTo:Transcript.
   161 
   161 
   162     self 
   162     self
   163         should:[f valueWithReceiver:receiver arguments:arguments]
   163 	should:[f valueWithReceiver:receiver arguments:arguments]
   164         raise:expectedError
   164 	raise:expectedError
   165 
   165 
   166     "Modified: / 09-10-2011 / 11:41:57 / cg"
   166     "Modified: / 09-10-2011 / 11:41:57 / cg"
   167 !
   167 !
   168 
   168 
   169 outputToTranscriptOf:aBlock
   169 outputToTranscriptOf:aBlock
   176     ^ output contents
   176     ^ output contents
   177 !
   177 !
   178 
   178 
   179 setUp
   179 setUp
   180     JavaScriptCompiler isNil ifTrue:[
   180     JavaScriptCompiler isNil ifTrue:[
   181         Smalltalk loadPackage:'stx:libjavascript'.
   181 	Smalltalk loadPackage:'stx:libjavascript'.
   182         JavaScriptParseNodeValidator autoload.
   182 	JavaScriptParseNodeValidator autoload.
   183     ].
   183     ].
   184 
   184 
   185     "Created: / 09-08-2011 / 23:12:13 / cg"
   185     "Created: / 09-08-2011 / 23:12:13 / cg"
   186     "Modified: / 20-09-2013 / 11:58:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   186     "Modified: / 20-09-2013 / 11:58:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   187 !
   187 !
   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
   517 
   517 
   518                           /**/ // Tiny comment
   518                           /**/ // Tiny comment
   519                           /***/ // Also valid
   519                           /***/ // Also valid
   520 
   520 
   521                           // Need to test string literals and identifiers
   521                           // Need to test string literals and identifiers
   522                           println("All is well in Javascript");
   522 			  println("All is well in Javascript");
   523                           return null;
   523                           return null;
   524                       }
   524                       }
   525                      '
   525                      '
   526             for:JavaScriptEnvironment new
   526             for:JavaScriptEnvironment new
   527             arguments:#(  )
   527             arguments:#(  )
   528             expect:nil
   528             expect:nil
   529     ] ensure:[
   529     ] ensure:[
   530         Smalltalk at:#Transcript put:savedTranscript
   530 	Smalltalk at:#Transcript put:savedTranscript
   531     ].
   531     ].
   532 
   532 
   533     expected := String streamContents:[:s | s showCR:'All is well in Javascript'].
   533     expected := String streamContents:[:s | s showCR:'All is well in Javascript'].
   534     self assert:(collector contents = expected).
   534     self assert:(collector contents = expected).
   535     
   535     
   536     "
   536     "
   537      self run:#testComments01
   537      self run:#testComments01
   538      self new testComments01  
   538      self new testComments01
   539     "
   539     "
   540 !
   540 !
   541 
   541 
   542 testConditionalExpression01
   542 testConditionalExpression01
   543     self 
   543     self
   544         execute:'max(a, b) {
   544 	execute:'max(a, b) {
   545                     return (a > b) ? a : b;
   545 		    return (a > b) ? a : b;
   546                  }'
   546 		 }'
   547         for:nil
   547 	for:nil
   548         arguments:#(10 20)
   548 	arguments:#(10 20)
   549         expect:20
   549 	expect:20
   550 
   550 
   551     "
   551     "
   552      self run:#testConditionalExpression01
   552      self run:#testConditionalExpression01
   553      self new testConditionalExpression01
   553      self new testConditionalExpression01
   554     "
   554     "
   555 !
   555 !
   556 
   556 
   557 testConditionalExpression02
   557 testConditionalExpression02
   558     self 
   558     self
   559         execute:'max(a, b) {
   559 	execute:'max(a, b) {
   560                     return (a < b) ? a : b;
   560 		    return (a < b) ? a : b;
   561                  }'
   561 		 }'
   562         for:nil
   562 	for:nil
   563         arguments:#(10 20)
   563 	arguments:#(10 20)
   564         expect:10
   564 	expect:10
   565 
   565 
   566     "
   566     "
   567      self run:#testConditionalExpression02
   567      self run:#testConditionalExpression02
   568      self new testConditionalExpression02
   568      self new testConditionalExpression02
   569     "
   569     "
   571 
   571 
   572 testDoWhile01
   572 testDoWhile01
   573     |output|
   573     |output|
   574 
   574 
   575     output := self outputToTranscriptOf:[
   575     output := self outputToTranscriptOf:[
   576         self 
   576 	self
   577             execute:'test(arg) {
   577 	    execute:'test(arg) {
   578                         var n;
   578 			var n;
   579 
   579 
   580                         n = 1;
   580 			n = 1;
   581                         do {
   581 			do {
   582                             Transcript.showCR(n);
   582 			    Transcript.showCR(n);
   583                         } while (++n <= 3);
   583 			} while (++n <= 3);
   584                         return n;
   584 			return n;
   585                      }'
   585 		     }'
   586             for:nil
   586 	    for:nil
   587             arguments:#(5)
   587 	    arguments:#(5)
   588             expect:4
   588 	    expect:4
   589     ].
   589     ].
   590     self assert:(output asCollectionOfLinesWithReturn asArray = #( '1' '2' '3' ))
   590     self assert:(output asCollectionOfLinesWithReturn asArray = #( '1' '2' '3' ))
   591 
   591 
   592     "
   592     "
   593      self run:#testDoWhile01
   593      self run:#testDoWhile01
   597 
   597 
   598 testDoWhile02
   598 testDoWhile02
   599     |output|
   599     |output|
   600 
   600 
   601     output := self outputToTranscriptOf:[
   601     output := self outputToTranscriptOf:[
   602         self 
   602 	self
   603             execute:'test(arg) {
   603 	    execute:'test(arg) {
   604                         var n;
   604 			var n;
   605 
   605 
   606                         n = 1;
   606 			n = 1;
   607                         do {
   607 			do {
   608                             Transcript.showCR(n);
   608 			    Transcript.showCR(n);
   609                             break;
   609 			    break;
   610                         } while (true);
   610 			} while (true);
   611                         return n;
   611 			return n;
   612                      }'
   612 		     }'
   613             for:nil
   613 	    for:nil
   614             arguments:#(5)
   614 	    arguments:#(5)
   615             expect:1
   615 	    expect:1
   616     ].
   616     ].
   617     self assert:(output asCollectionOfLinesWithReturn asArray = #( '1' ))
   617     self assert:(output asCollectionOfLinesWithReturn asArray = #( '1' ))
   618 
   618 
   619     "
   619     "
   620      self run:#testDoWhile02
   620      self run:#testDoWhile02
   624 
   624 
   625 testDoWhile03
   625 testDoWhile03
   626     |output|
   626     |output|
   627 
   627 
   628     output := self outputToTranscriptOf:[
   628     output := self outputToTranscriptOf:[
   629         self 
   629 	self
   630             execute:'test(arg) {
   630 	    execute:'test(arg) {
   631                         var n;
   631 			var n;
   632 
   632 
   633                         n = 1;
   633 			n = 1;
   634                         do {
   634 			do {
   635                             break;
   635 			    break;
   636                             Transcript.showCR(n);
   636 			    Transcript.showCR(n);
   637                         } while (true);
   637 			} while (true);
   638                         return n;
   638 			return n;
   639                      }'
   639 		     }'
   640             for:nil
   640 	    for:nil
   641             arguments:#(5)
   641 	    arguments:#(5)
   642             expect:1
   642 	    expect:1
   643     ].
   643     ].
   644     self assert:(output asCollectionOfLinesWithReturn asArray = #(  ))
   644     self assert:(output asCollectionOfLinesWithReturn asArray = #(  ))
   645 
   645 
   646     "
   646     "
   647      self run:#testDoWhile03
   647      self run:#testDoWhile03
   651 
   651 
   652 testDoWhile04
   652 testDoWhile04
   653     |output|
   653     |output|
   654 
   654 
   655     output := self outputToTranscriptOf:[
   655     output := self outputToTranscriptOf:[
   656         self 
   656 	self
   657             execute:'test(arg) {
   657 	    execute:'test(arg) {
   658                         var n;
   658 			var n;
   659 
   659 
   660                         n = 1;
   660 			n = 1;
   661                         do {
   661 			do {
   662                             if (++n == 3) continue;
   662 			    if (++n == 3) continue;
   663                             Transcript.showCR(n);
   663 			    Transcript.showCR(n);
   664                         } while (n <= 4);
   664 			} while (n <= 4);
   665                         return n;
   665 			return n;
   666                      }'
   666 		     }'
   667             for:nil
   667 	    for:nil
   668             arguments:#(5)
   668 	    arguments:#(5)
   669             expect:5
   669 	    expect:5
   670     ].
   670     ].
   671     self assert:(output asCollectionOfLinesWithReturn asArray = #( '2' '4' '5' ))
   671     self assert:(output asCollectionOfLinesWithReturn asArray = #( '2' '4' '5' ))
   672 
   672 
   673     "
   673     "
   674      self run:#testDoWhile04
   674      self run:#testDoWhile04
   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"},
  1607 !
  1607 !
  1608 
  1608 
  1609 testLiterals02
  1609 testLiterals02
  1610     |t|
  1610     |t|
  1611 
  1611 
  1612     t := JavaScriptParser 
  1612     t := JavaScriptParser
  1613         evaluate:'
  1613 	evaluate:'
  1614             [ 1, 2, 3, 4, 5, 6, 7, 8 ];
  1614 	    [ 1, 2, 3, 4, 5, 6, 7, 8 ];
  1615         '.
  1615 	'.
  1616     self assert:(t isArray).
  1616     self assert:(t isArray).
  1617     self assert:(t size == 8).
  1617     self assert:(t size == 8).
  1618     self assert:(t = #(1 2 3 4 5 6 7 8)).
  1618     self assert:(t = #(1 2 3 4 5 6 7 8)).
  1619 
  1619 
  1620     "
  1620     "
  1622      self new testLiterals02
  1622      self new testLiterals02
  1623     "
  1623     "
  1624 !
  1624 !
  1625 
  1625 
  1626 testLocalFunction01
  1626 testLocalFunction01
  1627     self 
  1627     self
  1628         execute:'test(arg) {
  1628 	execute:'test(arg) {
  1629                     var x ;
  1629 		    var x ;
  1630 
  1630 
  1631                     function localFunction() {  return 10 / arg; };
  1631 		    function localFunction() {  return 10 / arg; };
  1632 
  1632 
  1633                     x = localFunction() + 1;
  1633 		    x = localFunction() + 1;
  1634                     return x;
  1634 		    return x;
  1635                  }'
  1635 		 }'
  1636         for:nil
  1636 	for:nil
  1637         arguments:#(5)
  1637 	arguments:#(5)
  1638         expect:3
  1638 	expect:3
  1639 
  1639 
  1640     "
  1640     "
  1641      self run:#testLocalFunction01
  1641      self run:#testLocalFunction01
  1642      self new testLocalFunction01
  1642      self new testLocalFunction01
  1643     "
  1643     "
  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     "
  2666 testOperators27e_postInc
  2666 testOperators27e_postInc
  2667     |arr|
  2667     |arr|
  2668 
  2668 
  2669     arr := (1 to:15) asArray.
  2669     arr := (1 to:15) asArray.
  2670 
  2670 
  2671     self 
  2671     self
  2672         execute:'expr(a) {
  2672 	execute:'expr(a) {
  2673                     return (a[10]++);
  2673 		    return (a[10]++);
  2674                  }'
  2674 		 }'
  2675         for:nil
  2675 	for:nil
  2676         arguments:{ arr }
  2676 	arguments:{ arr }
  2677         expect:10.
  2677 	expect:10.
  2678 
  2678 
  2679     self assert:(arr = #(1 2 3 4 5 6 7 8 9 11 11 12 13 14 15))
  2679     self assert:(arr = #(1 2 3 4 5 6 7 8 9 11 11 12 13 14 15))
  2680 
  2680 
  2681     "
  2681     "
  2682      self run:#testOperators27e_postInc
  2682      self run:#testOperators27e_postInc
  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     "
  3374 
  3374 
  3375 testOperators44b_logAnd
  3375 testOperators44b_logAnd
  3376     "the right part of a logical and should not be evaluated,
  3376     "the right part of a logical and should not be evaluated,
  3377      if the left is already false"
  3377      if the left is already false"
  3378 
  3378 
  3379     self 
  3379     self
  3380         execute:'expr(a, bIn) {
  3380 	execute:'expr(a, bIn) {
  3381                     var x, b;
  3381 		    var x, b;
  3382 
  3382 
  3383                     b = bIn;
  3383 		    b = bIn;
  3384                     x = (a && (b++ > 5));
  3384 		    x = (a && (b++ > 5));
  3385                     return b;
  3385 		    return b;
  3386                  }'
  3386 		 }'
  3387         for:nil
  3387 	for:nil
  3388         arguments:#(true 5)
  3388 	arguments:#(true 5)
  3389         expect:6.
  3389 	expect:6.
  3390 
  3390 
  3391     self 
  3391     self
  3392         execute:'expr(a, bIn) {
  3392 	execute:'expr(a, bIn) {
  3393                     var x, b;
  3393 		    var x, b;
  3394 
  3394 
  3395                     b = bIn;
  3395 		    b = bIn;
  3396                     x = (a && (b++ > 5));
  3396 		    x = (a && (b++ > 5));
  3397                     return b;
  3397 		    return b;
  3398                  }'
  3398 		 }'
  3399         for:nil
  3399 	for:nil
  3400         arguments:#(false 5)
  3400 	arguments:#(false 5)
  3401         expect:5
  3401 	expect:5
  3402 
  3402 
  3403     "
  3403     "
  3404      self run:#testOperators44b_logAnd
  3404      self run:#testOperators44b_logAnd
  3405      self new testOperators44b_logAnd
  3405      self new testOperators44b_logAnd
  3406     "
  3406     "
  3407 !
  3407 !
  3408 
  3408 
  3409 testOperators45a_logOr
  3409 testOperators45a_logOr
  3410     self 
  3410     self
  3411         execute:'expr(a, b) {
  3411 	execute:'expr(a, b) {
  3412                     return (a || (b > 5));
  3412 		    return (a || (b > 5));
  3413                  }'
  3413 		 }'
  3414         for:nil
  3414 	for:nil
  3415         arguments:#(true 6)
  3415 	arguments:#(true 6)
  3416         expect:true.
  3416 	expect:true.
  3417 
  3417 
  3418     self 
  3418     self
  3419         execute:'expr(a, b) {
  3419 	execute:'expr(a, b) {
  3420                     return (a || (b > 5));
  3420 		    return (a || (b > 5));
  3421                  }'
  3421 		 }'
  3422         for:nil
  3422 	for:nil
  3423         arguments:#(false 6)
  3423 	arguments:#(false 6)
  3424         expect:true.
  3424 	expect:true.
  3425 
  3425 
  3426     self 
  3426     self
  3427         execute:'expr(a, b) {
  3427 	execute:'expr(a, b) {
  3428                     return (a || (b > 5));
  3428 		    return (a || (b > 5));
  3429                  }'
  3429 		 }'
  3430         for:nil
  3430 	for:nil
  3431         arguments:#(false 5)
  3431 	arguments:#(false 5)
  3432         expect:false
  3432 	expect:false
  3433 
  3433 
  3434     "
  3434     "
  3435      self run:#testOperators45a_logOr
  3435      self run:#testOperators45a_logOr
  3436      self new testOperators45a_logOr
  3436      self new testOperators45a_logOr
  3437     "
  3437     "
  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     "
  3805 
  3805 
  3806 testPrint
  3806 testPrint
  3807     |output|
  3807     |output|
  3808 
  3808 
  3809     output := self outputToTranscriptOf:[
  3809     output := self outputToTranscriptOf:[
  3810         self 
  3810 	self
  3811             execute:'
  3811 	    execute:'
  3812                       testPrint() {
  3812 		      testPrint() {
  3813                           print("1 ");
  3813 			  print("1 ");
  3814                           print("2 ");
  3814 			  print("2 ");
  3815                           print("3 ");
  3815 			  print("3 ");
  3816                           println("4");
  3816 			  println("4");
  3817                           return null;
  3817 			  return null;
  3818                       }
  3818 		      }
  3819                      '
  3819 		     '
  3820             for:JavaScriptEnvironment new
  3820 	    for:JavaScriptEnvironment new
  3821             arguments:#(  )
  3821 	    arguments:#(  )
  3822             expect:nil.
  3822 	    expect:nil.
  3823     ].
  3823     ].
  3824     self assert:(output = '1 2 3 4\' withCRs).
  3824     self assert:(output = '1 2 3 4\' withCRs).
  3825 
  3825 
  3826     "
  3826     "
  3827      self run:#testPrint
  3827      self run:#testPrint
  3828      self new testPrint  
  3828      self new testPrint
  3829     "
  3829     "
  3830 !
  3830 !
  3831 
  3831 
  3832 testRecursion01
  3832 testRecursion01
  3833     self 
  3833     self
  3834         execute:'test(n) {
  3834 	execute:'test(n) {
  3835                      function factorial(n) {
  3835 		     function factorial(n) {
  3836                         if (n > 0) {
  3836 			if (n > 0) {
  3837                             return n * factorial(n-1);
  3837 			    return n * factorial(n-1);
  3838                         } else {
  3838 			} else {
  3839                             return 1;
  3839 			    return 1;
  3840                         }
  3840 			}
  3841                      };
  3841 		     };
  3842 
  3842 
  3843                      return factorial(n);
  3843 		     return factorial(n);
  3844                  }'
  3844 		 }'
  3845         for:nil
  3845 	for:nil
  3846         arguments:#(10)
  3846 	arguments:#(10)
  3847         expect:(10 factorial)
  3847 	expect:(10 factorial)
  3848 
  3848 
  3849     "
  3849     "
  3850      self run:#testRecursion01
  3850      self run:#testRecursion01
  3851      self new testRecursion01
  3851      self new testRecursion01
  3852     "
  3852     "
  3853 
  3853 
  3854     "Modified: / 20-04-2005 / 11:55:30 / cg"
  3854     "Modified: / 20-04-2005 / 11:55:30 / cg"
  3855 !
  3855 !
  3856 
  3856 
  3857 testReturn01
  3857 testReturn01
  3858     self 
  3858     self
  3859         execute:'test(n) {
  3859 	execute:'test(n) {
  3860                      return 1;
  3860 		     return 1;
  3861                  }'
  3861 		 }'
  3862         for:nil
  3862 	for:nil
  3863         arguments:#(10)
  3863 	arguments:#(10)
  3864         expect:1
  3864 	expect:1
  3865 
  3865 
  3866     "
  3866     "
  3867      self run:#testReturn01
  3867      self run:#testReturn01
  3868      self new testReturn01
  3868      self new testReturn01
  3869     "
  3869     "
  3870 
  3870 
  3871     "Modified: / 20-04-2005 / 11:55:30 / cg"
  3871     "Modified: / 20-04-2005 / 11:55:30 / cg"
  3872 !
  3872 !
  3873 
  3873 
  3874 testReturn02
  3874 testReturn02
  3875     self 
  3875     self
  3876         execute:'test(n) {
  3876 	execute:'test(n) {
  3877                      function inner() { return 2 from test; };
  3877 		     function inner() { return 2 from test; };
  3878 
  3878 
  3879                      inner();
  3879 		     inner();
  3880                      return 1;
  3880 		     return 1;
  3881                  }'
  3881 		 }'
  3882         for:nil
  3882 	for:nil
  3883         arguments:#(10)
  3883 	arguments:#(10)
  3884         expect:2
  3884 	expect:2
  3885 
  3885 
  3886     "
  3886     "
  3887      self run:#testReturn02
  3887      self run:#testReturn02
  3888      self new testReturn02
  3888      self new testReturn02
  3889     "
  3889     "
  3890 !
  3890 !
  3891 
  3891 
  3892 testReturn03
  3892 testReturn03
  3893     self 
  3893     self
  3894         execute:'test(n) {
  3894 	execute:'test(n) {
  3895                      function inner1() { 
  3895 		     function inner1() {
  3896                         function inner2() { 
  3896 			function inner2() {
  3897                             return 2 from test; 
  3897 			    return 2 from test;
  3898                         };
  3898 			};
  3899 
  3899 
  3900                         inner2();
  3900 			inner2();
  3901                      };
  3901 		     };
  3902 
  3902 
  3903                      inner1();
  3903 		     inner1();
  3904                      return 1;
  3904 		     return 1;
  3905                  }'
  3905 		 }'
  3906         for:nil
  3906 	for:nil
  3907         arguments:#(10)
  3907 	arguments:#(10)
  3908         expect:2
  3908 	expect:2
  3909 
  3909 
  3910     "
  3910     "
  3911      self run:#testReturn03
  3911      self run:#testReturn03
  3912      self new testReturn03
  3912      self new testReturn03
  3913     "
  3913     "
  3915 
  3915 
  3916 testReturn04
  3916 testReturn04
  3917     "/ currently fails.
  3917     "/ currently fails.
  3918 ^ self.
  3918 ^ self.
  3919 
  3919 
  3920     self 
  3920     self
  3921         execute:'test(n) {
  3921 	execute:'test(n) {
  3922                      function inner1() { 
  3922 		     function inner1() {
  3923                         function inner2() { 
  3923 			function inner2() {
  3924                             return 2 from inner1; 
  3924 			    return 2 from inner1;
  3925                         };
  3925 			};
  3926 
  3926 
  3927                         inner2();
  3927 			inner2();
  3928                      };
  3928 		     };
  3929 
  3929 
  3930                      inner1();
  3930 		     inner1();
  3931                      return 1;
  3931 		     return 1;
  3932                  }'
  3932 		 }'
  3933         for:nil
  3933 	for:nil
  3934         arguments:#(10)
  3934 	arguments:#(10)
  3935         expectError:#ParseError
  3935 	expectError:#ParseError
  3936 
  3936 
  3937     "
  3937     "
  3938      self run:#testReturn04
  3938      self run:#testReturn04
  3939      self new testReturn04
  3939      self new testReturn04
  3940     "
  3940     "
  3941 
  3941 
  3942     "Modified: / 21-02-2007 / 15:08:11 / cg"
  3942     "Modified: / 21-02-2007 / 15:08:11 / cg"
  3943 !
  3943 !
  3944 
  3944 
  3945 testReturn05
  3945 testReturn05
  3946     self 
  3946     self
  3947         execute:'test(n) {
  3947 	execute:'test(n) {
  3948                      function inner() { return 2; };
  3948 		     function inner() { return 2; };
  3949 
  3949 
  3950                      return inner() + 1;
  3950 		     return inner() + 1;
  3951                  }'
  3951 		 }'
  3952         for:nil
  3952 	for:nil
  3953         arguments:#(10)
  3953 	arguments:#(10)
  3954         expect:3
  3954 	expect:3
  3955 
  3955 
  3956     "
  3956     "
  3957      self run:#testReturn05
  3957      self run:#testReturn05
  3958      self new testReturn05
  3958      self new testReturn05
  3959     "
  3959     "
  3960 
  3960 
  3961     "Created: / 21-02-2007 / 15:02:47 / cg"
  3961     "Created: / 21-02-2007 / 15:02:47 / cg"
  3962 !
  3962 !
  3963 
  3963 
  3964 testReturnNew01
  3964 testReturnNew01
  3965     self                                                         
  3965     self
  3966         execute:'test() {
  3966 	execute:'test() {
  3967                     var someString;
  3967 		    var someString;
  3968 
  3968 
  3969                     someString = "1234";
  3969 		    someString = "1234";
  3970                     return (new Point).x(someString.asInteger());
  3970 		    return (new Point).x(someString.asInteger());
  3971                  }'
  3971 		 }'
  3972         for:nil
  3972 	for:nil
  3973         arguments:#()
  3973 	arguments:#()
  3974         expect:(Point x:1234 y:nil).
  3974 	expect:(Point x:1234 y:nil).
  3975 
  3975 
  3976     "
  3976     "
  3977      self run:#testReturnNew01
  3977      self run:#testReturnNew01
  3978      self new testReturnNew01
  3978      self new testReturnNew01
  3979     "
  3979     "
  3982 !
  3982 !
  3983 
  3983 
  3984 testReturnNew02
  3984 testReturnNew02
  3985     |result|
  3985     |result|
  3986 
  3986 
  3987     result := self                                                         
  3987     result := self
  3988         execute:'test() {
  3988 	execute:'test() {
  3989                     var someString;
  3989 		    var someString;
  3990 
  3990 
  3991                     someString = "1234";
  3991 		    someString = "1234";
  3992                     return (new ValueHolder).value(someString.asInteger());
  3992 		    return (new ValueHolder).value(someString.asInteger());
  3993                  }'
  3993 		 }'
  3994         for:nil
  3994 	for:nil
  3995         arguments:#().
  3995 	arguments:#().
  3996 
  3996 
  3997     self assert:(result isKindOf:ValueHolder).
  3997     self assert:(result isKindOf:ValueHolder).
  3998     self assert:(result value = 1234).
  3998     self assert:(result value = 1234).
  3999 
  3999 
  4000     "
  4000     "
  4003 
  4003 
  4004     "Created: / 01-02-2011 / 15:35:36 / cg"
  4004     "Created: / 01-02-2011 / 15:35:36 / cg"
  4005 !
  4005 !
  4006 
  4006 
  4007 testScanner01
  4007 testScanner01
  4008     self 
  4008     self
  4009         execute:'f() { }'
  4009 	execute:'f() { }'
  4010         for:nil
  4010 	for:nil
  4011         arguments:#()
  4011 	arguments:#()
  4012         expect:nil
  4012 	expect:nil
  4013 
  4013 
  4014     "
  4014     "
  4015      self run:#testScanner01
  4015      self run:#testScanner01
  4016      self new testScanner01
  4016      self new testScanner01
  4017     "
  4017     "
  4018 !
  4018 !
  4019 
  4019 
  4020 testScanner02
  4020 testScanner02
  4021     self 
  4021     self
  4022         execute:'f(a) { }'
  4022 	execute:'f(a) { }'
  4023         for:nil
  4023 	for:nil
  4024         arguments:#(1)
  4024 	arguments:#(1)
  4025         expect:nil
  4025 	expect:nil
  4026 
  4026 
  4027     "
  4027     "
  4028      self run:#testScanner02
  4028      self run:#testScanner02
  4029      self new testScanner02
  4029      self new testScanner02
  4030     "
  4030     "
  4031 !
  4031 !
  4032 
  4032 
  4033 testScanner03
  4033 testScanner03
  4034     self 
  4034     self
  4035         execute:'f(a, b) { }'
  4035 	execute:'f(a, b) { }'
  4036         for:nil
  4036 	for:nil
  4037         arguments:#(1 2)
  4037 	arguments:#(1 2)
  4038         expect:nil
  4038 	expect:nil
  4039 
  4039 
  4040     "
  4040     "
  4041      self run:#testScanner03
  4041      self run:#testScanner03
  4042      self new testScanner03
  4042      self new testScanner03
  4043     "
  4043     "
  4044 !
  4044 !
  4045 
  4045 
  4046 testScanner04
  4046 testScanner04
  4047     self 
  4047     self
  4048         execute:'f(a, b) { return (null); }'
  4048 	execute:'f(a, b) { return (null); }'
  4049         for:nil
  4049 	for:nil
  4050         arguments:#(1 2)
  4050 	arguments:#(1 2)
  4051         expect:nil
  4051 	expect:nil
  4052 
  4052 
  4053     "
  4053     "
  4054      self run:#testScanner04
  4054      self run:#testScanner04
  4055      self new testScanner04
  4055      self new testScanner04
  4056     "
  4056     "
  4057 !
  4057 !
  4058 
  4058 
  4059 testScanner05
  4059 testScanner05
  4060     self 
  4060     self
  4061         execute:'f(a, b) { return (null); }'
  4061 	execute:'f(a, b) { return (null); }'
  4062         for:nil
  4062 	for:nil
  4063         arguments:#(1)
  4063 	arguments:#(1)
  4064         expectError:(Method wongNumberOfArgumentsSignal)
  4064 	expectError:(Method wongNumberOfArgumentsSignal)
  4065 
  4065 
  4066     "
  4066     "
  4067      self run:#testScanner05
  4067      self run:#testScanner05
  4068      self new testScanner05
  4068      self new testScanner05
  4069     "
  4069     "
  4070 
  4070 
  4071     "Modified: / 20-04-2005 / 11:53:20 / cg"
  4071     "Modified: / 20-04-2005 / 11:53:20 / cg"
  4072 !
  4072 !
  4073 
  4073 
  4074 testScanner06
  4074 testScanner06
  4075     self 
  4075     self
  4076         execute:'f() { /* a comment */ return (null); }'
  4076 	execute:'f() { /* a comment */ return (null); }'
  4077         for:nil
  4077 	for:nil
  4078         arguments:#()
  4078 	arguments:#()
  4079         expect:nil
  4079 	expect:nil
  4080 
  4080 
  4081     "
  4081     "
  4082      self run:#testScanner06
  4082      self run:#testScanner06
  4083      self new testScanner06
  4083      self new testScanner06
  4084     "
  4084     "
  4085 !
  4085 !
  4086 
  4086 
  4087 testScanner07
  4087 testScanner07
  4088     self 
  4088     self
  4089         execute:'f() { // an EOL comment
  4089 	execute:'f() { // an EOL comment
  4090  return (null); }'
  4090  return (null); }'
  4091         for:nil
  4091 	for:nil
  4092         arguments:#()
  4092 	arguments:#()
  4093         expect:nil
  4093 	expect:nil
  4094 
  4094 
  4095     "
  4095     "
  4096      self run:#testScanner07
  4096      self run:#testScanner07
  4097      self new testScanner07
  4097      self new testScanner07
  4098     "
  4098     "
  4099 !
  4099 !
  4100 
  4100 
  4101 testScanner08
  4101 testScanner08
  4102     self 
  4102     self
  4103         execute:'f() { // a comment in an /* an EOL comment
  4103 	execute:'f() { // a comment in an /* an EOL comment
  4104  return (null); }'
  4104  return (null); }'
  4105         for:nil
  4105 	for:nil
  4106         arguments:#()
  4106 	arguments:#()
  4107         expect:nil
  4107 	expect:nil
  4108 
  4108 
  4109     "
  4109     "
  4110      self run:#testScanner08
  4110      self run:#testScanner08
  4111      self new testScanner08
  4111      self new testScanner08
  4112     "
  4112     "
  4113 !
  4113 !
  4114 
  4114 
  4115 testScanner09
  4115 testScanner09
  4116     self 
  4116     self
  4117         execute:'f() { // a comment in an /* an EOL */ comment
  4117 	execute:'f() { // a comment in an /* an EOL */ comment
  4118  return (null); }'
  4118  return (null); }'
  4119         for:nil
  4119 	for:nil
  4120         arguments:#()
  4120 	arguments:#()
  4121         expect:nil
  4121 	expect:nil
  4122 
  4122 
  4123     "
  4123     "
  4124      self run:#testScanner09
  4124      self run:#testScanner09
  4125      self new testScanner09
  4125      self new testScanner09
  4126     "
  4126     "
  4127 !
  4127 !
  4128 
  4128 
  4129 testScanner10
  4129 testScanner10
  4130     self 
  4130     self
  4131         execute:'f() { /** a comment */ 
  4131 	execute:'f() { /** a comment */
  4132  return (null); }'
  4132  return (null); }'
  4133         for:nil
  4133 	for:nil
  4134         arguments:#()
  4134 	arguments:#()
  4135         expect:nil
  4135 	expect:nil
  4136 
  4136 
  4137     "
  4137     "
  4138      self run:#testScanner10
  4138      self run:#testScanner10
  4139      self new testScanner10
  4139      self new testScanner10
  4140     "
  4140     "
  4141 !
  4141 !
  4142 
  4142 
  4143 testScanner11
  4143 testScanner11
  4144     self 
  4144     self
  4145         execute:'f() { /**/ 
  4145 	execute:'f() { /**/
  4146  return (null); }'
  4146  return (null); }'
  4147         for:nil
  4147 	for:nil
  4148         arguments:#()
  4148 	arguments:#()
  4149         expect:nil
  4149 	expect:nil
  4150 
  4150 
  4151     "
  4151     "
  4152      self run:#testScanner11
  4152      self run:#testScanner11
  4153      self new testScanner11
  4153      self new testScanner11
  4154     "
  4154     "
  4156 
  4156 
  4157 testScanner12
  4157 testScanner12
  4158     "/ cg: is the comment below legal ?
  4158     "/ cg: is the comment below legal ?
  4159     ^ self. "/ assume not
  4159     ^ self. "/ assume not
  4160 
  4160 
  4161     self 
  4161     self
  4162         execute:'f() { /*/ 
  4162 	execute:'f() { /*/
  4163  return (null); }'
  4163  return (null); }'
  4164         for:nil
  4164 	for:nil
  4165         arguments:#()
  4165 	arguments:#()
  4166         expectError:#ParseError
  4166 	expectError:#ParseError
  4167 
  4167 
  4168     "
  4168     "
  4169      self run:#testScanner12
  4169      self run:#testScanner12
  4170      self new testScanner12
  4170      self new testScanner12
  4171     "
  4171     "
  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
  4944 !
  4944 !
  4945 
  4945 
  4946 testTryCatchExceptionInfo
  4946 testTryCatchExceptionInfo
  4947     |savedTranscript collector expected|
  4947     |savedTranscript collector expected|
  4948 
  4948 
  4949     savedTranscript := Smalltalk at:#Transcript.     
  4949     savedTranscript := Smalltalk at:#Transcript.
  4950     [
  4950     [
  4951         Smalltalk at:#Transcript put:(collector := '' writeStream).
  4951 	Smalltalk at:#Transcript put:(collector := '' writeStream).
  4952 
  4952 
  4953         self 
  4953         self 
  4954             execute:'
  4954 	    execute:'
  4955 test(arg) {
  4955 test(arg) {
  4956     var handlerWasCalled = false;
  4956     var handlerWasCalled = false;
  4957 
  4957 
  4958     function failingMethod() {  return 10 / arg; };
  4958     function failingMethod() {  return 10 / arg; };
  4959 
  4959 
  4965     }
  4965     }
  4966     return handlerWasCalled;    
  4966     return handlerWasCalled;    
  4967 }'
  4967 }'
  4968             for:JavaScriptEnvironment new
  4968             for:JavaScriptEnvironment new
  4969             arguments:#(0)
  4969             arguments:#(0)
  4970             expect:true.
  4970 	    expect:true.
  4971     ] ensure:[
  4971     ] ensure:[
  4972         Smalltalk at:#Transcript put:savedTranscript
  4972 	Smalltalk at:#Transcript put:savedTranscript
  4973     ].
  4973     ].
  4974 
  4974 
  4975     expected := String streamContents:[:s | s showCR:'division by zero'].
  4975     expected := String streamContents:[:s | s showCR:'division by zero'].
  4976     self assert:(collector contents = expected).
  4976     self assert:(collector contents = expected).
  4977 
  4977 
  4980      self new testTryCatchExceptionInfo
  4980      self new testTryCatchExceptionInfo
  4981     "
  4981     "
  4982 !
  4982 !
  4983 
  4983 
  4984 testTryCatchFinally01
  4984 testTryCatchFinally01
  4985     self 
  4985     self
  4986             execute:
  4986 	    execute:
  4987 'test(arg) {
  4987 'test(arg) {
  4988     var handlerWasCalled = false;
  4988     var handlerWasCalled = false;
  4989     var finallyExecuted = false;
  4989     var finallyExecuted = false;
  4990 
  4990 
  4991     function failingMethod() {  return 10 / arg; };
  4991     function failingMethod() {  return 10 / arg; };
  5000     }
  5000     }
  5001     return handlerWasCalled && finallyExecuted;    
  5001     return handlerWasCalled && finallyExecuted;    
  5002 }'
  5002 }'
  5003             for:nil
  5003             for:nil
  5004             arguments:#(0)
  5004             arguments:#(0)
  5005             expect:true.
  5005 	    expect:true.
  5006     
  5006     
  5007     "
  5007     "
  5008      self run:#testTryCatchFinally01
  5008      self run:#testTryCatchFinally01
  5009      self new testTryCatchFinally01
  5009      self new testTryCatchFinally01
  5010     "
  5010     "
  5011 !
  5011 !
  5012 
  5012 
  5013 testTryFinally01
  5013 testTryFinally01
  5014     |savedTranscript collector expected|
  5014     |savedTranscript collector expected|
  5015 
  5015 
  5016     savedTranscript := Smalltalk at:#Transcript.     
  5016     savedTranscript := Smalltalk at:#Transcript.
  5017     [
  5017     [
  5018         Smalltalk at:#Transcript put:(collector := '' writeStream).
  5018 	Smalltalk at:#Transcript put:(collector := '' writeStream).
  5019         self 
  5019         self 
  5020             execute:
  5020 	    execute:
  5021 'test(arg) {
  5021 'test(arg) {
  5022     var handlerWasCalled = false;
  5022     var handlerWasCalled = false;
  5023 
  5023 
  5024     println("1");
  5024     println("1");
  5025     try {    
  5025     try {    
  5058                     s showCR:'2c'.
  5058                     s showCR:'2c'.
  5059                     s showCR:'4'.
  5059                     s showCR:'4'.
  5060                 ].
  5060                 ].
  5061     self assert:(collector contents = expected).
  5061     self assert:(collector contents = expected).
  5062 
  5062 
       
  5063     ] ensure:[
       
  5064 	Smalltalk at:#Transcript put:savedTranscript
       
  5065     ].
       
  5066 
       
  5067     expected := String streamContents:[:s |
       
  5068 		    s showCR:'1'.
       
  5069 		    s showCR:'2'.
       
  5070 		    s showCR:'2a'.
       
  5071 		    s showCR:'2b'.
       
  5072 		    s showCR:'2c'.
       
  5073 		    s showCR:'4'.
       
  5074 		].
       
  5075     self assert:(collector contents = expected).
       
  5076 
  5063     "
  5077     "
  5064      self run:#testTryFinally01
  5078      self run:#testTryFinally01
  5065      self new testTryFinally01
  5079      self new testTryFinally01
  5066     "
  5080     "
  5067 !
  5081 !
  5068 
  5082 
  5069 testTryFinally02
  5083 testTryFinally02
  5070     |output|
  5084     |output|
  5071 
  5085 
  5072     output := self outputToTranscriptOf:[
  5086     output := self outputToTranscriptOf:[
  5073         self 
  5087 	self
  5074             execute:'test(arg) {
  5088 	    execute:'test(arg) {
  5075                         var handler1WasCalled = false;
  5089 			var handler1WasCalled = false;
  5076                         var handler2WasCalled = false;
  5090 			var handler2WasCalled = false;
  5077                         var finallyActionWasEvaluated = false;
  5091 			var finallyActionWasEvaluated = false;
  5078 
  5092 
  5079                         println("1");
  5093 			println("1");
  5080                         try {
  5094 			try {
  5081 
  5095 
  5082                             function dummy () {
  5096 			    function dummy () {
  5083                                 println("2a");
  5097 				println("2a");
  5084                                 try {
  5098 				try {
  5085                                     println("2b");
  5099 				    println("2b");
  5086                                     return 10 / arg;
  5100 				    return 10 / arg;
  5087                                 } finally {
  5101 				} finally {
  5088                                     println("2c");
  5102 				    println("2c");
  5089                                     handler1WasCalled = true;
  5103 				    handler1WasCalled = true;
  5090                                 }
  5104 				}
  5091                             };
  5105 			    };
  5092 
  5106 
  5093                             println("2");
  5107 			    println("2");
  5094                             dummy();
  5108 			    dummy();
  5095                             println("3");
  5109 			    println("3");
  5096                         } catch(Error e) {  
  5110 			} catch(Error e) {
  5097                             println("e");
  5111 			    println("e");
  5098                             handler2WasCalled =  true; 
  5112 			    handler2WasCalled =  true;
  5099                         } finally {
  5113 			} finally {
  5100                             println("f");
  5114 			    println("f");
  5101                             finallyActionWasEvaluated = true;
  5115 			    finallyActionWasEvaluated = true;
  5102                         };
  5116 			};
  5103 
  5117 
  5104                         println("4");
  5118 			println("4");
  5105                         return handler1WasCalled && handler2WasCalled && finallyActionWasEvaluated;
  5119 			return handler1WasCalled && handler2WasCalled && finallyActionWasEvaluated;
  5106                      }'
  5120 		     }'
  5107             for:JavaScriptEnvironment new
  5121 	    for:JavaScriptEnvironment new
  5108             arguments:#(0)
  5122 	    arguments:#(0)
  5109             expect:true
  5123 	    expect:true
  5110     ].
  5124     ].
  5111     self assert:(output asCollectionOfLinesWithReturn asArray = #( '1' '2' '2a' '2b' 'e' '2c' 'f' '4'))
  5125     self assert:(output asCollectionOfLinesWithReturn asArray = #( '1' '2' '2a' '2b' 'e' '2c' 'f' '4'))
  5112 
  5126 
  5113     "
  5127     "
  5114      self run:#testTryFinally02
  5128      self run:#testTryFinally02
  5118 
  5132 
  5119 testTryFinally03
  5133 testTryFinally03
  5120     |output|
  5134     |output|
  5121 
  5135 
  5122     output := self outputToTranscriptOf:[
  5136     output := self outputToTranscriptOf:[
  5123         self 
  5137 	self
  5124             execute:'test(arg) {
  5138 	    execute:'test(arg) {
  5125                         var handlerWasCalled = false;
  5139 			var handlerWasCalled = false;
  5126                         var finallyActionWasEvaluated = false;
  5140 			var finallyActionWasEvaluated = false;
  5127 
  5141 
  5128                         println("1");
  5142 			println("1");
  5129                         try {
  5143 			try {
  5130                             function dummy() {};
  5144 			    function dummy() {};
  5131 
  5145 
  5132                             println("2");
  5146 			    println("2");
  5133                             dummy();
  5147 			    dummy();
  5134                             println("3");
  5148 			    println("3");
  5135                         } catch(Error e) {  
  5149 			} catch(Error e) {
  5136                             println("e");
  5150 			    println("e");
  5137                             handlerWasCalled =  true; 
  5151 			    handlerWasCalled =  true;
  5138                         } finally {
  5152 			} finally {
  5139                             println("f");
  5153 			    println("f");
  5140                             finallyActionWasEvaluated = true;
  5154 			    finallyActionWasEvaluated = true;
  5141                         };
  5155 			};
  5142 
  5156 
  5143                         println("4");
  5157 			println("4");
  5144                         return !!handlerWasCalled && finallyActionWasEvaluated;
  5158 			return !!handlerWasCalled && finallyActionWasEvaluated;
  5145                      }'
  5159 		     }'
  5146             for:JavaScriptEnvironment new
  5160 	    for:JavaScriptEnvironment new
  5147             arguments:#(0)
  5161 	    arguments:#(0)
  5148             expect:true
  5162 	    expect:true
  5149     ].
  5163     ].
  5150     self assert:(output asCollectionOfLinesWithReturn asArray = #( '1' '2' '3' 'f' '4'))
  5164     self assert:(output asCollectionOfLinesWithReturn asArray = #( '1' '2' '3' 'f' '4'))
  5151 
  5165 
  5152     "
  5166     "
  5153      self run:#testTryFinally03
  5167      self run:#testTryFinally03
  5154      self new testTryFinally03
  5168      self new testTryFinally03
  5155     "
  5169     "
  5156 !
  5170 !
  5157 
  5171 
  5158 testTypeof01
  5172 testTypeof01
  5159     self 
  5173     self
  5160         execute:'test(arg) {
  5174 	execute:'test(arg) {
  5161                     return typeof(arg);
  5175 		    return typeof(arg);
  5162                  }'
  5176 		 }'
  5163         for:nil
  5177 	for:nil
  5164         arguments:#(0)
  5178 	arguments:#(0)
  5165         expect:'number'.
  5179 	expect:'number'.
  5166 
  5180 
  5167     self 
  5181     self
  5168         execute:'test(arg) {
  5182 	execute:'test(arg) {
  5169                     return typeof(arg);
  5183 		    return typeof(arg);
  5170                  }'
  5184 		 }'
  5171         for:nil
  5185 	for:nil
  5172         arguments:#('foo')
  5186 	arguments:#('foo')
  5173         expect:'string'.
  5187 	expect:'string'.
  5174 
  5188 
  5175     self 
  5189     self
  5176         execute:'test(arg) {
  5190 	execute:'test(arg) {
  5177                     return typeof(arg);
  5191 		    return typeof(arg);
  5178                  }'
  5192 		 }'
  5179         for:nil
  5193 	for:nil
  5180         arguments:#(true)
  5194 	arguments:#(true)
  5181         expect:'boolean'.
  5195 	expect:'boolean'.
  5182 
  5196 
  5183     self 
  5197     self
  5184         execute:'test(arg) {
  5198 	execute:'test(arg) {
  5185                     return typeof(arg);
  5199 		    return typeof(arg);
  5186                  }'
  5200 		 }'
  5187         for:nil
  5201 	for:nil
  5188         arguments:#(false)
  5202 	arguments:#(false)
  5189         expect:'boolean'.
  5203 	expect:'boolean'.
  5190 
  5204 
  5191     self 
  5205     self
  5192         execute:'test(arg) {
  5206 	execute:'test(arg) {
  5193                     return typeof(arg);
  5207 		    return typeof(arg);
  5194                  }'
  5208 		 }'
  5195         for:nil
  5209 	for:nil
  5196         arguments:#(nil)
  5210 	arguments:#(nil)
  5197         expect:'undefined'.
  5211 	expect:'undefined'.
  5198 
  5212 
  5199     self 
  5213     self
  5200         execute:'test(arg) {
  5214 	execute:'test(arg) {
  5201                     return typeof(arg);
  5215 		    return typeof(arg);
  5202                  }'
  5216 		 }'
  5203         for:nil
  5217 	for:nil
  5204         arguments:#( #[1 2 3] )
  5218 	arguments:#( #[1 2 3] )
  5205         expect:'object'.
  5219 	expect:'object'.
  5206 
  5220 
  5207     self 
  5221     self
  5208         execute:'test(arg) {
  5222 	execute:'test(arg) {
  5209                     return typeof(arg);
  5223 		    return typeof(arg);
  5210                  }'
  5224 		 }'
  5211         for:nil
  5225 	for:nil
  5212         arguments:#( #(1 2 3) )
  5226 	arguments:#( #(1 2 3) )
  5213         expect:'object'.
  5227 	expect:'object'.
  5214 
  5228 
  5215     self 
  5229     self
  5216         execute:'test(arg) {
  5230 	execute:'test(arg) {
  5217                     return typeof(arg);
  5231 		    return typeof(arg);
  5218                  }'
  5232 		 }'
  5219         for:nil
  5233 	for:nil
  5220         arguments:(Array with:(Point new))
  5234 	arguments:(Array with:(Point new))
  5221         expect:'object'.
  5235 	expect:'object'.
  5222 
  5236 
  5223     self 
  5237     self
  5224         execute:'test(arg) {
  5238 	execute:'test(arg) {
  5225                     return typeof(arg);
  5239 		    return typeof(arg);
  5226                  }'
  5240 		 }'
  5227         for:nil
  5241 	for:nil
  5228         arguments:(Array with:Integer)
  5242 	arguments:(Array with:Integer)
  5229         expect:'object'.
  5243 	expect:'object'.
  5230 
  5244 
  5231     "
  5245     "
  5232      self run:#testTypeof01
  5246      self run:#testTypeof01
  5233      self new testTypeof01
  5247      self new testTypeof01
  5234     "
  5248     "
  5235 !
  5249 !
  5236 
  5250 
  5237 testVarDeclaration01
  5251 testVarDeclaration01
  5238     self 
  5252     self
  5239         execute:'expr(a, b) {
  5253 	execute:'expr(a, b) {
  5240                     var x = 10;
  5254 		    var x = 10;
  5241 
  5255 
  5242                     return x;
  5256 		    return x;
  5243                  }'
  5257 		 }'
  5244         for:nil
  5258 	for:nil
  5245         arguments:#(10 20)
  5259 	arguments:#(10 20)
  5246         expect:10
  5260 	expect:10
  5247 
  5261 
  5248     "
  5262     "
  5249      self run:#testVarDeclaration01
  5263      self run:#testVarDeclaration01
  5250      self new testVarDeclaration01
  5264      self new testVarDeclaration01
  5251     "
  5265     "
  5252 !
  5266 !
  5253 
  5267 
  5254 testVarDeclaration02
  5268 testVarDeclaration02
  5255     self 
  5269     self
  5256         execute:'expr(a, b) {
  5270 	execute:'expr(a, b) {
  5257                     var x = 10;
  5271 		    var x = 10;
  5258 
  5272 
  5259                     return (a + x);
  5273 		    return (a + x);
  5260                  }'
  5274 		 }'
  5261         for:nil
  5275 	for:nil
  5262         arguments:#(10 20)
  5276 	arguments:#(10 20)
  5263         expect:20
  5277 	expect:20
  5264 
  5278 
  5265     "
  5279     "
  5266      self run:#testVarDeclaration02
  5280      self run:#testVarDeclaration02
  5267      self new testVarDeclaration02
  5281      self new testVarDeclaration02
  5268     "
  5282     "
  5269 !
  5283 !
  5270 
  5284 
  5271 testVarDeclaration03
  5285 testVarDeclaration03
  5272     self 
  5286     self
  5273         execute:'expr(a, b) {
  5287 	execute:'expr(a, b) {
  5274                     var x = 10;
  5288 		    var x = 10;
  5275                     var y = x+10;
  5289 		    var y = x+10;
  5276 
  5290 
  5277                     return (y);
  5291 		    return (y);
  5278                  }'
  5292 		 }'
  5279         for:nil
  5293 	for:nil
  5280         arguments:#(10 20)
  5294 	arguments:#(10 20)
  5281         expect:20
  5295 	expect:20
  5282 
  5296 
  5283     "
  5297     "
  5284      self run:#testVarDeclaration03
  5298      self run:#testVarDeclaration03
  5285      self new testVarDeclaration03
  5299      self new testVarDeclaration03
  5286     "
  5300     "
  5287 !
  5301 !
  5288 
  5302 
  5289 testVarDeclaration04
  5303 testVarDeclaration04
  5290     self 
  5304     self
  5291         execute:'expr(a, b) {
  5305 	execute:'expr(a, b) {
  5292                     var y = x+10;
  5306 		    var y = x+10;
  5293                     var x = 10;
  5307 		    var x = 10;
  5294 
  5308 
  5295                     return (y);
  5309 		    return (y);
  5296                  }'
  5310 		 }'
  5297         for:nil
  5311 	for:nil
  5298         arguments:#(10 20)
  5312 	arguments:#(10 20)
  5299         expectError:#ParseError
  5313 	expectError:#ParseError
  5300 
  5314 
  5301     "
  5315     "
  5302      self run:#testVarDeclaration04
  5316      self run:#testVarDeclaration04
  5303      self new testVarDeclaration04
  5317      self new testVarDeclaration04
  5304     "
  5318     "
  5307 !
  5321 !
  5308 
  5322 
  5309 testVarDeclaration05
  5323 testVarDeclaration05
  5310     "our JS only allows variables declarations at a blocks top"
  5324     "our JS only allows variables declarations at a blocks top"
  5311 
  5325 
  5312     self 
  5326     self
  5313         execute:'expr(a, b) {
  5327 	execute:'expr(a, b) {
  5314                     var y = 10;
  5328 		    var y = 10;
  5315 
  5329 
  5316                     y = y + 10;
  5330 		    y = y + 10;
  5317 
  5331 
  5318                     var x = 10;
  5332 		    var x = 10;
  5319 
  5333 
  5320                     return (y);
  5334 		    return (y);
  5321                  }'
  5335 		 }'
  5322         for:nil
  5336 	for:nil
  5323         arguments:#(10 20)
  5337 	arguments:#(10 20)
  5324         expect:20
  5338 	expect:20
  5325 
  5339 
  5326     "
  5340     "
  5327      self run:#testVarDeclaration05
  5341      self run:#testVarDeclaration05
  5328      self new testVarDeclaration05
  5342      self new testVarDeclaration05
  5329     "
  5343     "
  5331     "Modified: / 23-02-2007 / 16:25:07 / cg"
  5345     "Modified: / 23-02-2007 / 16:25:07 / cg"
  5332 !
  5346 !
  5333 
  5347 
  5334 testVarDeclaration06
  5348 testVarDeclaration06
  5335 
  5349 
  5336     self 
  5350     self
  5337         execute:'expr(x) {
  5351 	execute:'expr(x) {
  5338                     var y = x + 20;
  5352 		    var y = x + 20;
  5339 
  5353 
  5340                     return (y);
  5354 		    return (y);
  5341                  }'
  5355 		 }'
  5342         for:nil
  5356 	for:nil
  5343         arguments:#(10)
  5357 	arguments:#(10)
  5344         expect:30
  5358 	expect:30
  5345 
  5359 
  5346     "
  5360     "
  5347      self run:#testVarDeclaration06
  5361      self run:#testVarDeclaration06
  5348      self new testVarDeclaration06
  5362      self new testVarDeclaration06
  5349     "
  5363     "
  5350 !
  5364 !
  5351 
  5365 
  5352 testVarDeclaration07
  5366 testVarDeclaration07
  5353 
  5367 
  5354     self 
  5368     self
  5355         execute:'expr(x) {
  5369 	execute:'expr(x) {
  5356                     var x = x + 20;
  5370 		    var x = x + 20;
  5357 
  5371 
  5358                     return (x);
  5372 		    return (x);
  5359                  }'
  5373 		 }'
  5360         for:nil
  5374 	for:nil
  5361         arguments:#(10)
  5375 	arguments:#(10)
  5362         expectError:Error
  5376 	expectError:Error
  5363 
  5377 
  5364     "
  5378     "
  5365      self run:#testVarDeclaration07
  5379      self run:#testVarDeclaration07
  5366      self new testVarDeclaration07
  5380      self new testVarDeclaration07
  5367     "
  5381     "
  5368 !
  5382 !
  5369 
  5383 
  5370 testVarDeclaration08
  5384 testVarDeclaration08
  5371 
  5385 
  5372     self 
  5386     self
  5373         execute:'expr(aIn, bIn, cIn) {
  5387 	execute:'expr(aIn, bIn, cIn) {
  5374                     var a = aIn, b = bIn, c = cIn;
  5388 		    var a = aIn, b = bIn, c = cIn;
  5375 
  5389 
  5376                     return (a);
  5390 		    return (a);
  5377                  }'
  5391 		 }'
  5378         for:nil
  5392 	for:nil
  5379         arguments:#(1 2 3)
  5393 	arguments:#(1 2 3)
  5380         expect:1
  5394 	expect:1
  5381 
  5395 
  5382     "
  5396     "
  5383      self run:#testVarDeclaration08
  5397      self run:#testVarDeclaration08
  5384      self new testVarDeclaration08
  5398      self new testVarDeclaration08
  5385     "
  5399     "
  5387 
  5401 
  5388 testWhile01
  5402 testWhile01
  5389     |output|
  5403     |output|
  5390 
  5404 
  5391     output := self outputToTranscriptOf:[
  5405     output := self outputToTranscriptOf:[
  5392         self 
  5406 	self
  5393             execute:'test(arg) {
  5407 	    execute:'test(arg) {
  5394                         var n;
  5408 			var n;
  5395 
  5409 
  5396                         n = arg;
  5410 			n = arg;
  5397                         while (n > 0) {
  5411 			while (n > 0) {
  5398                             n--;
  5412 			    n--;
  5399                             Transcript.showCR("hello");
  5413 			    Transcript.showCR("hello");
  5400                         }
  5414 			}
  5401                      }'
  5415 		     }'
  5402             for:nil
  5416 	    for:nil
  5403             arguments:#(5)
  5417 	    arguments:#(5)
  5404             expect:nil
  5418 	    expect:nil
  5405     ].
  5419     ].
  5406     self assert:(output asCollectionOfLinesWithReturn asArray = #( 'hello' 'hello' 'hello' 'hello' 'hello' ))
  5420     self assert:(output asCollectionOfLinesWithReturn asArray = #( 'hello' 'hello' 'hello' 'hello' 'hello' ))
  5407 
  5421 
  5408     "
  5422     "
  5409      self run:#testWhile01
  5423      self run:#testWhile01
  5410      self new testWhile01  
  5424      self new testWhile01
  5411     "
  5425     "
  5412 !
  5426 !
  5413 
  5427 
  5414 testWhile02
  5428 testWhile02
  5415     |output|
  5429     |output|
  5416 
  5430 
  5417     output := self outputToTranscriptOf:[
  5431     output := self outputToTranscriptOf:[
  5418         self 
  5432 	self
  5419             execute:'test(arg) {
  5433 	    execute:'test(arg) {
  5420                         var n;
  5434 			var n;
  5421 
  5435 
  5422                         n = 1;
  5436 			n = 1;
  5423                         while (n <= arg) {
  5437 			while (n <= arg) {
  5424                             n++;
  5438 			    n++;
  5425                             Transcript.showCR("hello");
  5439 			    Transcript.showCR("hello");
  5426                         }
  5440 			}
  5427                      }'
  5441 		     }'
  5428             for:nil
  5442 	    for:nil
  5429             arguments:#(5)
  5443 	    arguments:#(5)
  5430             expect:nil
  5444 	    expect:nil
  5431     ].
  5445     ].
  5432     self assert:(output asCollectionOfLinesWithReturn asArray = #( 'hello' 'hello' 'hello' 'hello' 'hello' ))
  5446     self assert:(output asCollectionOfLinesWithReturn asArray = #( 'hello' 'hello' 'hello' 'hello' 'hello' ))
  5433 
  5447 
  5434     "
  5448     "
  5435      self run:#testWhile02
  5449      self run:#testWhile02
  5439 
  5453 
  5440 testWhile03
  5454 testWhile03
  5441     |output|
  5455     |output|
  5442 
  5456 
  5443     output := self outputToTranscriptOf:[
  5457     output := self outputToTranscriptOf:[
  5444         self 
  5458 	self
  5445             execute:'test(arg) {
  5459 	    execute:'test(arg) {
  5446                         var n;
  5460 			var n;
  5447 
  5461 
  5448                         n = 1;
  5462 			n = 1;
  5449                         while (n <= arg) {
  5463 			while (n <= arg) {
  5450                             Transcript.showCR(n++);
  5464 			    Transcript.showCR(n++);
  5451                         }
  5465 			}
  5452                      }'
  5466 		     }'
  5453             for:nil
  5467 	    for:nil
  5454             arguments:#(5)
  5468 	    arguments:#(5)
  5455             expect:nil
  5469 	    expect:nil
  5456     ].
  5470     ].
  5457     self assert:(output asCollectionOfLinesWithReturn asArray = #( '1' '2' '3' '4' '5' ))
  5471     self assert:(output asCollectionOfLinesWithReturn asArray = #( '1' '2' '3' '4' '5' ))
  5458 
  5472 
  5459     "
  5473     "
  5460      self run:#testWhile03
  5474      self run:#testWhile03
  5464 
  5478 
  5465 testWhile04
  5479 testWhile04
  5466     |output|
  5480     |output|
  5467 
  5481 
  5468     output := self outputToTranscriptOf:[
  5482     output := self outputToTranscriptOf:[
  5469         self 
  5483 	self
  5470             execute:'test(arg) {
  5484 	    execute:'test(arg) {
  5471                         var n;
  5485 			var n;
  5472 
  5486 
  5473                         n = 1;
  5487 			n = 1;
  5474                         while (n++ <= arg) {
  5488 			while (n++ <= arg) {
  5475                             Transcript.showCR(n);
  5489 			    Transcript.showCR(n);
  5476                         }
  5490 			}
  5477                      }'
  5491 		     }'
  5478             for:nil
  5492 	    for:nil
  5479             arguments:#(5)
  5493 	    arguments:#(5)
  5480             expect:nil
  5494 	    expect:nil
  5481     ].
  5495     ].
  5482     self assert:(output asCollectionOfLinesWithReturn asArray = #( '2' '3' '4' '5' '6'))
  5496     self assert:(output asCollectionOfLinesWithReturn asArray = #( '2' '3' '4' '5' '6'))
  5483 
  5497 
  5484     "
  5498     "
  5485      self run:#testWhile04
  5499      self run:#testWhile04
  5489 
  5503 
  5490 testWhile04b
  5504 testWhile04b
  5491     |output|
  5505     |output|
  5492 
  5506 
  5493     output := self outputToTranscriptOf:[
  5507     output := self outputToTranscriptOf:[
  5494         self 
  5508 	self
  5495             execute:'test(arg) {
  5509 	    execute:'test(arg) {
  5496                         var n;
  5510 			var n;
  5497 
  5511 
  5498                         n = 1;
  5512 			n = 1;
  5499                         while (n++ <= arg) {
  5513 			while (n++ <= arg) {
  5500                             Transcript.showCR(n);
  5514 			    Transcript.showCR(n);
  5501                         }
  5515 			}
  5502                      }'
  5516 		     }'
  5503             for:nil
  5517 	    for:nil
  5504             arguments:#(5)
  5518 	    arguments:#(5)
  5505             expect:nil
  5519 	    expect:nil
  5506     ].
  5520     ].
  5507     self assert:(output asCollectionOfLinesWithReturn asArray = #( '2' '3' '4' '5' '6'))
  5521     self assert:(output asCollectionOfLinesWithReturn asArray = #( '2' '3' '4' '5' '6'))
  5508 
  5522 
  5509     "
  5523     "
  5510      self run:#testWhile04b
  5524      self run:#testWhile04b
  5514 
  5528 
  5515 testWhile05
  5529 testWhile05
  5516     |output|
  5530     |output|
  5517 
  5531 
  5518     output := self outputToTranscriptOf:[
  5532     output := self outputToTranscriptOf:[
  5519         self 
  5533 	self
  5520             execute:'test(arg) {
  5534 	    execute:'test(arg) {
  5521                         var n;
  5535 			var n;
  5522 
  5536 
  5523                         n = 1;
  5537 			n = 1;
  5524                         while (n++ <= arg) {
  5538 			while (n++ <= arg) {
  5525                             if (n == 3) continue;
  5539 			    if (n == 3) continue;
  5526                             Transcript.showCR(n);
  5540 			    Transcript.showCR(n);
  5527                         }
  5541 			}
  5528                      }'
  5542 		     }'
  5529             for:nil
  5543 	    for:nil
  5530             arguments:#(5)
  5544 	    arguments:#(5)
  5531             expect:nil
  5545 	    expect:nil
  5532     ].
  5546     ].
  5533     self assert:(output asCollectionOfLinesWithReturn asArray = #( '2' '4' '5' '6'))
  5547     self assert:(output asCollectionOfLinesWithReturn asArray = #( '2' '4' '5' '6'))
  5534 
  5548 
  5535     "
  5549     "
  5536      self run:#testWhile05
  5550      self run:#testWhile05
  5543     Tests parsing of a while-loop with no body
  5557     Tests parsing of a while-loop with no body
  5544     "
  5558     "
  5545     |output|
  5559     |output|
  5546 
  5560 
  5547     output := self outputToTranscriptOf:[
  5561     output := self outputToTranscriptOf:[
  5548         self 
  5562 	self
  5549             execute:'test(arg) {
  5563 	    execute:'test(arg) {
  5550                         var n;
  5564 			var n;
  5551 
  5565 
  5552                         n = 1;
  5566 			n = 1;
  5553                         while (n++ < arg) {
  5567 			while (n++ < arg) {
  5554                         }
  5568 			}
  5555                         Transcript.showCR(n);
  5569 			Transcript.showCR(n);
  5556                      }'
  5570 		     }'
  5557             for:nil
  5571 	    for:nil
  5558             arguments:#(5)
  5572 	    arguments:#(5)
  5559             expect:nil
  5573 	    expect:nil
  5560     ].
  5574     ].
  5561     self assert:(output asCollectionOfLinesWithReturn asArray = #( '6'))
  5575     self assert:(output asCollectionOfLinesWithReturn asArray = #( '6'))
  5562 
  5576 
  5563     "
  5577     "
  5564      self run:#testWhile05
  5578      self run:#testWhile05
  5570 
  5584 
  5571 test_01_parse_literals
  5585 test_01_parse_literals
  5572     |spec|
  5586     |spec|
  5573 
  5587 
  5574     spec := #(
  5588     spec := #(
  5575                         ('1'                    #isInteger       1)
  5589 			('1'                    #isInteger       1)
  5576                         ('0'                    #isInteger       0)
  5590 			('0'                    #isInteger       0)
  5577                         ('-1'                   #isInteger       -1)
  5591 			('-1'                   #isInteger       -1)
  5578                         ('12345678901234567890' #isInteger       12345678901234567890)
  5592 			('12345678901234567890' #isInteger       12345678901234567890)
  5579                         ('0x0'                  #isInteger       0)
  5593 			('0x0'                  #isInteger       0)
  5580                         ('0x1'                  #isInteger       1)
  5594 			('0x1'                  #isInteger       1)
  5581                         ('0xFFFF'               #isInteger       16rFFFF)
  5595 			('0xFFFF'               #isInteger       16rFFFF)
  5582                         ('0xffff'               #isInteger       16rFFFF)
  5596 			('0xffff'               #isInteger       16rFFFF)
  5583                         ('0xFFFFFFFFFFFFFFFF'   #isInteger       16rFFFFFFFFFFFFFFFF)
  5597 			('0xFFFFFFFFFFFFFFFF'   #isInteger       16rFFFFFFFFFFFFFFFF)
  5584                         ('0777'                 #isInteger       8r777)
  5598 			('0777'                 #isInteger       8r777)
  5585 
  5599 
  5586                         ('1.2345'               #isFloat         1.2345)
  5600 			('1.2345'               #isFloat         1.2345)
  5587                         ('-1.2345'              #isFloat         -1.2345)
  5601 			('-1.2345'              #isFloat         -1.2345)
  5588 
  5602 
  5589                         ('nil'                  #isNil           nil)
  5603 			('nil'                  #isNil           nil)
  5590                         ('null'                 #isNil           nil)
  5604 			('null'                 #isNil           nil)
  5591                         ('true'                 nil              true)
  5605 			('true'                 nil              true)
  5592                         ('false'                nil              false)
  5606 			('false'                nil              false)
  5593 
  5607 
  5594                         ('"aString"'            #isString        'aString' )
  5608 			('"aString"'            #isString        'aString' )
  5595                         ('''anotherString'''    #isString        'anotherString' )
  5609 			('''anotherString'''    #isString        'anotherString' )
  5596                         ('''anoth"er"String'''  #isString        'anoth"er"String' )
  5610 			('''anoth"er"String'''  #isString        'anoth"er"String' )
  5597                         ('"anoth''er''String"'  #isString        'anoth''er''String' )
  5611 			('"anoth''er''String"'  #isString        'anoth''er''String' )
  5598                         ('"hello"'              #isString        'hello' )
  5612 			('"hello"'              #isString        'hello' )
  5599                         ('"\b"'                 #isString        (#eval 'Character backspace asString') )
  5613 			('"\b"'                 #isString        (#eval 'Character backspace asString') )
  5600                         ('"\f"'                 #isString        (#eval 'Character ff asString') )
  5614 			('"\f"'                 #isString        (#eval 'Character ff asString') )
  5601                         ('"\t"'                 #isString        (#eval 'Character tab asString') )
  5615 			('"\t"'                 #isString        (#eval 'Character tab asString') )
  5602                         ('"\r"'                 #isString        (#eval 'Character return asString') )
  5616 			('"\r"'                 #isString        (#eval 'Character return asString') )
  5603                         ('"\n"'                 #isString        (#eval 'Character nl asString') )
  5617 			('"\n"'                 #isString        (#eval 'Character nl asString') )
  5604                         ('"\''"'                #isString        '''' )
  5618 			('"\''"'                #isString        '''' )
  5605                         ('"\""'                #isString         '"' )
  5619 			('"\""'                #isString         '"' )
  5606 
  5620 
  5607                         ('[ 1 , 2 , 3]'         #isArray         #(1 2 3) )
  5621 			('[ 1 , 2 , 3]'         #isArray         #(1 2 3) )
  5608                         ('[1,2,3]'              #isArray         #(1 2 3) )
  5622 			('[1,2,3]'              #isArray         #(1 2 3) )
  5609                         ('[1,2,3]'              #isArray         #(1 2 3) )
  5623 			('[1,2,3]'              #isArray         #(1 2 3) )
  5610                         ('["a","b","c"]'        #isArray         #('a' 'b' 'c') )
  5624 			('["a","b","c"]'        #isArray         #('a' 'b' 'c') )
  5611                         ('[]'                   #isArray         #() )
  5625 			('[]'                   #isArray         #() )
  5612                         ('[null]'               #isArray         #( nil ) )
  5626 			('[null]'               #isArray         #( nil ) )
  5613 
  5627 
  5614                         ('[1,[2,[3]]]'          #isArray         #(1 (2 (3))) )
  5628 			('[1,[2,[3]]]'          #isArray         #(1 (2 (3))) )
  5615 
  5629 
  5616                ).
  5630 	       ).
  5617 
  5631 
  5618     self doTestEachFromSpec:spec.
  5632     self doTestEachFromSpec:spec.
  5619 
  5633 
  5620     "
  5634     "
  5621      self run:#test_01_parse_literals
  5635      self run:#test_01_parse_literals
  5625 
  5639 
  5626 test_02_parse_literals2
  5640 test_02_parse_literals2
  5627     |spec|
  5641     |spec|
  5628 
  5642 
  5629     spec := #(
  5643     spec := #(
  5630                         ('"\x00"'               #isString        (#eval '(Character value:0) asString') )
  5644 			('"\x00"'               #isString        (#eval '(Character value:0) asString') )
  5631                         ('"\x01"'               #isString        (#eval '(Character value:1) asString') )
  5645 			('"\x01"'               #isString        (#eval '(Character value:1) asString') )
  5632                         ('"\x1a"'               #isString        (#eval '(Character value:16r1a) asString') )
  5646 			('"\x1a"'               #isString        (#eval '(Character value:16r1a) asString') )
  5633                         ('"\x000"'              #isString        (#eval '(Character value:0) asString , ''0'' ') )
  5647 			('"\x000"'              #isString        (#eval '(Character value:0) asString , ''0'' ') )
  5634                         ('"\xgg"'               #isString        (#error ) )
  5648 			('"\xgg"'               #isString        (#error ) )
  5635                         ('"\xg"'                #isString        (#error ) )
  5649 			('"\xg"'                #isString        (#error ) )
  5636                         ('"\x"'                 #isString        (#error ) )
  5650 			('"\x"'                 #isString        (#error ) )
  5637                         ('"\x0g"'               #isString        (#error ) )
  5651 			('"\x0g"'               #isString        (#error ) )
  5638                         ('"\u1234"'             #isString        (#eval '(Character value:16r1234) asString ') )
  5652 			('"\u1234"'             #isString        (#eval '(Character value:16r1234) asString ') )
  5639                         ('"\uFFFF"'             #isString        (#eval '(Character value:16rFFFF) asString ') )
  5653 			('"\uFFFF"'             #isString        (#eval '(Character value:16rFFFF) asString ') )
  5640                ).
  5654 	       ).
  5641 
  5655 
  5642     self doTestEachFromSpec:spec.
  5656     self doTestEachFromSpec:spec.
  5643 
  5657 
  5644     "
  5658     "
  5645      self run:#test_02_parse_literals2
  5659      self run:#test_02_parse_literals2
  5649 
  5663 
  5650 test_03_parse_comments
  5664 test_03_parse_comments
  5651     |spec|
  5665     |spec|
  5652 
  5666 
  5653     spec := #(
  5667     spec := #(
  5654                         ('// ignored
  5668 			('// ignored
  5655                           1'                    #isInteger        1 )
  5669 			  1'                    #isInteger        1 )
  5656                         ('/* ignored */ 2'      #isInteger        2 )
  5670 			('/* ignored */ 2'      #isInteger        2 )
  5657                         ('/* ign//ored */ 3'    #isInteger        3 )
  5671 			('/* ign//ored */ 3'    #isInteger        3 )
  5658                ).
  5672 	       ).
  5659 
  5673 
  5660     self doTestEachFromSpec:spec.
  5674     self doTestEachFromSpec:spec.
  5661 
  5675 
  5662     "
  5676     "
  5663      self run:#test_03_parse_comments
  5677      self run:#test_03_parse_comments
  5669     "character syntax extension"
  5683     "character syntax extension"
  5670 
  5684 
  5671     |spec|
  5685     |spec|
  5672 
  5686 
  5673     spec := #(
  5687     spec := #(
  5674                         ('$''a'''                  #isCharacter     (#eval '$a ') )
  5688 			('$''a'''                  #isCharacter     (#eval '$a ') )
  5675                         ('$''\n'''                 #isCharacter     (#eval '(Character nl)') )
  5689 			('$''\n'''                 #isCharacter     (#eval '(Character nl)') )
  5676                         ('$''\r'''                 #isCharacter     (#eval '(Character return)') )
  5690 			('$''\r'''                 #isCharacter     (#eval '(Character return)') )
  5677                         ('$''\b'''                 #isCharacter     (#eval '(Character backspace)') )
  5691 			('$''\b'''                 #isCharacter     (#eval '(Character backspace)') )
  5678                         ('$''\x00'''               #isCharacter     (#eval '(Character value:0)') )
  5692 			('$''\x00'''               #isCharacter     (#eval '(Character value:0)') )
  5679                         ('$''\x01'''               #isCharacter     (#eval '(Character value:1)') )
  5693 			('$''\x01'''               #isCharacter     (#eval '(Character value:1)') )
  5680                         ('$''\x1a'''               #isCharacter     (#eval '(Character value:16r1a)') )
  5694 			('$''\x1a'''               #isCharacter     (#eval '(Character value:16r1a)') )
  5681                         ('$''\x000'''              #isCharacter     (#error ) )
  5695 			('$''\x000'''              #isCharacter     (#error ) )
  5682                         ('$''\xgg'''               #isCharacter     (#error ) )
  5696 			('$''\xgg'''               #isCharacter     (#error ) )
  5683                         ('$''\xg'''                #isCharacter     (#error ) )
  5697 			('$''\xg'''                #isCharacter     (#error ) )
  5684                         ('$''\x'''                 #isCharacter     (#error ) )
  5698 			('$''\x'''                 #isCharacter     (#error ) )
  5685                         ('$''\x0g'''               #isCharacter     (#error ) )
  5699 			('$''\x0g'''               #isCharacter     (#error ) )
  5686                         ('$''\u1234'''             #isCharacter     (#eval '(Character value:16r1234) ') )
  5700 			('$''\u1234'''             #isCharacter     (#eval '(Character value:16r1234) ') )
  5687                         ('$''\uFFFF'''             #isCharacter     (#eval '(Character value:16rFFFF) ') )
  5701 			('$''\uFFFF'''             #isCharacter     (#eval '(Character value:16rFFFF) ') )
  5688                ).
  5702 	       ).
  5689 
  5703 
  5690     self doTestEachFromSpec:spec.
  5704     self doTestEachFromSpec:spec.
  5691 
  5705 
  5692     "
  5706     "
  5693      self run:#test_03_parse_literals3
  5707      self run:#test_03_parse_literals3
  5696 !
  5710 !
  5697 
  5711 
  5698 test_10_parse_expression1
  5712 test_10_parse_expression1
  5699     |spec|
  5713     |spec|
  5700 
  5714 
  5701     spec := #( 
  5715     spec := #(
  5702              ('1+1'                     nil                2 )
  5716 	     ('1+1'                     nil                2 )
  5703              ('1-1'                     nil                0 )
  5717 	     ('1-1'                     nil                0 )
  5704              ('2*2'                     nil                4 )
  5718 	     ('2*2'                     nil                4 )
  5705              ('4/2'                     nil                2 )
  5719 	     ('4/2'                     nil                2 )
  5706              ('5%3'                     nil                2 )
  5720 	     ('5%3'                     nil                2 )
  5707              ('1234567890*1234567890'   nil                1524157875019052100 )
  5721 	     ('1234567890*1234567890'   nil                1524157875019052100 )
  5708              ('1234567890/1234567890'   nil                1 )
  5722 	     ('1234567890/1234567890'   nil                1 )
  5709              ('1234567890/1234567890.0' nil                1.0 )
  5723 	     ('1234567890/1234567890.0' nil                1.0 )
  5710 
  5724 
  5711              ('1>0'                     nil                true )
  5725 	     ('1>0'                     nil                true )
  5712              ('1<0'                     nil                false )
  5726 	     ('1<0'                     nil                false )
  5713              ('1<=0'                    nil                false )
  5727 	     ('1<=0'                    nil                false )
  5714              ('1>=0'                    nil                true )
  5728 	     ('1>=0'                    nil                true )
  5715              ('1==0'                    nil                false )
  5729 	     ('1==0'                    nil                false )
  5716              ('1!!=0'                    nil                true )
  5730 	     ('1!!=0'                    nil                true )
  5717              ('1!!=1'                    nil                false )
  5731 	     ('1!!=1'                    nil                false )
  5718 
  5732 
  5719              ('3&5'                     nil                1 )
  5733 	     ('3&5'                     nil                1 )
  5720              ('3|5'                     nil                7 )
  5734 	     ('3|5'                     nil                7 )
  5721              ('5^1'                     nil                4 )
  5735 	     ('5^1'                     nil                4 )
  5722            ).
  5736 	   ).
  5723     self doTestEachFromSpec:spec.
  5737     self doTestEachFromSpec:spec.
  5724 
  5738 
  5725     "
  5739     "
  5726      self run:#test_10_parse_expression1
  5740      self run:#test_10_parse_expression1
  5727      self new test_10_parse_expression1
  5741      self new test_10_parse_expression1
  5731 !
  5745 !
  5732 
  5746 
  5733 test_11_parse_expression2
  5747 test_11_parse_expression2
  5734     |spec|
  5748     |spec|
  5735 
  5749 
  5736     spec := #( 
  5750     spec := #(
  5737                 ('1=0'               nil                ( #error ) )
  5751 		('1=0'               nil                ( #error ) )
  5738                 ('"abc"[0]'          nil                ( #error ) ) 
  5752 		('"abc"[0]'          nil                ( #error ) )
  5739                 ('"abc"[1]'          nil                $a ) 
  5753 		('"abc"[1]'          nil                $a )
  5740              ).
  5754 	     ).
  5741     self doTestEachFromSpec:spec.
  5755     self doTestEachFromSpec:spec.
  5742 
  5756 
  5743     "
  5757     "
  5744      self run:#test_11_parse_expression2
  5758      self run:#test_11_parse_expression2
  5745      self new test_11_parse_expression2
  5759      self new test_11_parse_expression2
  5748 
  5762 
  5749 test_30_parse_methods1
  5763 test_30_parse_methods1
  5750     |spec|
  5764     |spec|
  5751 
  5765 
  5752     "/ spec is { source shouldErrBoolean }
  5766     "/ spec is { source shouldErrBoolean }
  5753     spec := #( 
  5767     spec := #(
  5754                 ('
  5768 		('
  5755 execute(in1) {
  5769 execute(in1) {
  5756     var t;
  5770     var t;
  5757 
  5771 
  5758     Dialog.information((t = in1.value()) == nil ? "nil" : t);
  5772     Dialog.information((t = in1.value()) == nil ? "nil" : t);
  5759 }'   
  5773 }'
  5760 false
  5774 false
  5761                 )
  5775 		)
  5762 
  5776 
  5763              ).
  5777 	     ).
  5764     self doTestEachFunctionFromSpec:spec.
  5778     self doTestEachFunctionFromSpec:spec.
  5765 
  5779 
  5766     "
  5780     "
  5767      self run:#test_30_parse_methods1
  5781      self run:#test_30_parse_methods1
  5768      self new test_30_parse_methods1
  5782      self new test_30_parse_methods1
  5770 !
  5784 !
  5771 
  5785 
  5772 test_40_parse_function
  5786 test_40_parse_function
  5773     | tree |
  5787     | tree |
  5774 
  5788 
  5775     tree := JavaScriptParser parseExpression:'this.bar("arg1", 1)'. 
  5789     tree := JavaScriptParser parseExpression:'this.bar("arg1", 1)'.
  5776     self assert: tree selectorPosition = (6 to: 8)
  5790     self assert: tree selectorPosition = (6 to: 8)
  5777 
  5791 
  5778     "Created: / 17-11-2014 / 13:28:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  5792     "Created: / 17-11-2014 / 13:28:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  5779 !
  5793 !
  5780 
  5794 
  5781 test_41_parse_function
  5795 test_41_parse_function
  5782     | tree |
  5796     | tree |
  5783 
  5797 
  5784     tree := JavaScriptParser parseExpression:'this.bar'. 
  5798     tree := JavaScriptParser parseExpression:'this.bar'.
  5785     self assert: tree selectorPosition = (6 to: 8)
  5799     self assert: tree selectorPosition = (6 to: 8)
  5786 
  5800 
  5787     "Created: / 17-11-2014 / 13:31:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  5801     "Created: / 17-11-2014 / 13:31:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  5788 !
  5802 !
  5789 
  5803 
  5790 xtestInnerFunctionWithInitializedLocals
  5804 xtestInnerFunctionWithInitializedLocals
  5791 
  5805 
  5792     self 
  5806     self
  5793         execute:'
  5807 	execute:'
  5794 execute() {
  5808 execute() {
  5795     function foo() {}
  5809     function foo() {}
  5796     function bar() {}
  5810     function bar() {}
  5797 
  5811 
  5798     function test()
  5812     function test()
  5799     {
  5813     {
  5800 
  5814 
  5801         foo();
  5815 	foo();
  5802         bar();
  5816 	bar();
  5803         var a;
  5817 	var a;
  5804         var b;
  5818 	var b;
  5805         var c = Array.new(15);
  5819 	var c = Array.new(15);
  5806         var d = 20;
  5820 	var d = 20;
  5807 
  5821 
  5808         return [ a , b , c , d ];
  5822 	return [ a , b , c , d ];
  5809     }
  5823     }
  5810 
  5824 
  5811     test();
  5825     test();
  5812 }
  5826 }
  5813 '
  5827 '
  5814         for:nil
  5828 	for:nil
  5815         arguments:#()
  5829 	arguments:#()
  5816         expect:{ nil . nil . (Array new:15) . 20 }
  5830 	expect:{ nil . nil . (Array new:15) . 20 }
  5817 
  5831 
  5818     "
  5832     "
  5819      self run:#testInnerFunctionWithInitializedLocals
  5833      self run:#testInnerFunctionWithInitializedLocals
  5820      self new testInnerFunctionWithInitializedLocals
  5834      self new testInnerFunctionWithInitializedLocals
  5821     "
  5835     "
  5822 !
  5836 !
  5823 
  5837 
  5824 xtestNew04
  5838 xtestNew04
  5825     self 
  5839     self
  5826         execute:'test() {
  5840 	execute:'test() {
  5827                     var days;
  5841 		    var days;
  5828 
  5842 
  5829                     days = new Array(7,2);
  5843 		    days = new Array(7,2);
  5830                     days[1,1] = "Monday";
  5844 		    days[1,1] = "Monday";
  5831                     days[2,1] = "Tuesday";
  5845 		    days[2,1] = "Tuesday";
  5832                     days[3,1] = "Wednesday";
  5846 		    days[3,1] = "Wednesday";
  5833                     days[4,1] = "Thursday";
  5847 		    days[4,1] = "Thursday";
  5834                     days[5,1] = "Friday";
  5848 		    days[5,1] = "Friday";
  5835                     days[6,1] = "Saturday";
  5849 		    days[6,1] = "Saturday";
  5836                     days[7,1] = "Sunday";
  5850 		    days[7,1] = "Sunday";
  5837 
  5851 
  5838                     return days;
  5852 		    return days;
  5839                  }'
  5853 		 }'
  5840         for:nil
  5854 	for:nil
  5841         arguments:#()
  5855 	arguments:#()
  5842         expect:#('Monday' 'Tuesday' 'Wednesday' 'Thursday' 'Friday' 'Saturday' 'Sunday')
  5856 	expect:#('Monday' 'Tuesday' 'Wednesday' 'Thursday' 'Friday' 'Saturday' 'Sunday')
  5843 
  5857 
  5844     "
  5858     "
  5845      self run:#testNew04
  5859      self run:#testNew04
  5846      self new testNew04  
  5860      self new testNew04
  5847     "
  5861     "
  5848 
  5862 
  5849     "Created: / 23-02-2007 / 12:24:50 / cg"
  5863     "Created: / 23-02-2007 / 12:24:50 / cg"
  5850 ! !
  5864 ! !
  5851 
  5865