RegressionTests__STCCompilerTests.st
changeset 1046 06719286467f
parent 995 676127617c9e
child 1047 c602a3472c37
equal deleted inserted replaced
1045:a64026853a4b 1046:06719286467f
    26 
    26 
    27 "
    27 "
    28 ! !
    28 ! !
    29 
    29 
    30 !STCCompilerTests methodsFor:'code templates'!
    30 !STCCompilerTests methodsFor:'code templates'!
       
    31 
       
    32 inlinedBlockVariables1
       
    33     "stc generates wrong code for inlined variables"
       
    34 
       
    35     | b |
       
    36 
       
    37     b := [:arg1 | 
       
    38         |local1|
       
    39 
       
    40         local1 := #local1.
       
    41         1 to:3 do:[:argb_1 |
       
    42             |localb_1 localb_2|
       
    43 
       
    44             localb_1 := #localb_1.
       
    45             localb_2 := #localb_2.
       
    46             1 to:5 do:[:argbb_1 |
       
    47                 |localbb_1 localbb_2|
       
    48 
       
    49                 localbb_1 := #localbb_1.
       
    50                 localbb_2 := #localbb_2.
       
    51                 argbb_1 == 3 ifTrue:[
       
    52                     ^ [:argbbb_1 |
       
    53                         |localbbb_1 localbbb_2|
       
    54 
       
    55                         localbbb_1 := #localbbb_1.
       
    56                         localbbb_2 := #localbbb_2.
       
    57 
       
    58                         localb_1 "/ here, in old stc versions, localb_2 is returned
       
    59                     ].
       
    60                 ].
       
    61             ]
       
    62         ]
       
    63     ].
       
    64 
       
    65     ^ b value:#arg1
       
    66 !
    31 
    67 
    32 nextLittleEndianNumber: n from:bytes
    68 nextLittleEndianNumber: n from:bytes
    33     "stc generates wrong code for the following s := assignment"
    69     "stc generates wrong code for the following s := assignment"
    34 
    70 
    35     | s |
    71     | s |
   194      self run:#test10_bitor_bug
   230      self run:#test10_bitor_bug
   195      self new test10_bitor_bug
   231      self new test10_bitor_bug
   196     "
   232     "
   197 
   233 
   198     "Created: / 17-09-2011 / 10:32:18 / cg"
   234     "Created: / 17-09-2011 / 10:32:18 / cg"
       
   235 !
       
   236 
       
   237 test20_localsOfInlinedBlock_bug
       
   238     "checks for an stc compiler bug (detected Sep 2011).
       
   239      stc generates bad code for the bitOr expression in nextLittleEndianNumber"
       
   240 
       
   241     |blk mthd|
       
   242 
       
   243     Class withoutUpdatingChangesDo:[
       
   244         self class recompile:#'inlinedBlockVariables1'.
       
   245         blk := self inlinedBlockVariables1.
       
   246         self assert:((blk value:#argbbb_1) == #localb_1).
       
   247 
       
   248         mthd := self class compiledMethodAt:#'inlinedBlockVariables1'.
       
   249         (STCCompilerInterface new)
       
   250             compileToMachineCode:mthd source
       
   251             forClass:self class
       
   252             selector:#'inlinedBlockVariables1'
       
   253             inCategory:mthd category
       
   254             notifying:nil
       
   255             install:true
       
   256             skipIfSame:false
       
   257             silent:true.
       
   258 
       
   259         self 
       
   260             assert:mthd ~= (self class compiledMethodAt:#'inlinedBlockVariables1')
       
   261             description:'Could not compile with STC'.
       
   262 
       
   263         blk := self inlinedBlockVariables1.
       
   264         self assert:((blk value:#argbbb_1) == #localb_1).
       
   265     ].
       
   266 
       
   267     "
       
   268      self run:#test20_localsOfInlinedBlock_bug
       
   269      self new test20_localsOfInlinedBlock_bug
       
   270     "
       
   271 
       
   272     "Created: / 17-09-2011 / 10:32:18 / cg"
   199 ! !
   273 ! !
   200 
   274 
   201 !STCCompilerTests class methodsFor:'documentation'!
   275 !STCCompilerTests class methodsFor:'documentation'!
   202 
   276 
   203 version
   277 version