RegressionTests__STCCompilerTests.st
changeset 1047 c602a3472c37
parent 1046 06719286467f
child 1048 b5f4b15a3dbf
--- a/RegressionTests__STCCompilerTests.st	Tue Feb 11 13:45:04 2014 +0100
+++ b/RegressionTests__STCCompilerTests.st	Tue Feb 11 21:08:55 2014 +0100
@@ -65,6 +65,41 @@
     ^ b value:#arg1
 !
 
+inlinedBlockVariables2
+    "stc generates wrong code for inlined variables"
+
+    | b |
+
+    b := [:arg1 | 
+        |local1|
+
+        local1 := #local1.
+        1 to:3 do:[:argb_1 |
+            |localb_1 localb_2|
+
+            localb_1 := #localb_1.
+            localb_2 := #localb_2.
+            1 to:5 do:[:argbb_1 |
+                |localbb_1 localbb_2|
+
+                localbb_1 := #localbb_1.
+                localbb_2 := #localbb_2.
+                argbb_1 == 3 ifTrue:[
+                    ^ [:argbbb_1 |
+                        |localbbb_1 localbbb_2|
+
+                        localbbb_1 := #localbbb_1.
+                        localbbb_2 := #localbbb_2.
+                        argbb_1 
+                    ].
+                ].
+            ]
+        ]
+    ].
+
+    ^ b value:#arg1
+!
+
 nextLittleEndianNumber: n from:bytes
     "stc generates wrong code for the following s := assignment"
 
@@ -270,6 +305,44 @@
     "
 
     "Created: / 17-09-2011 / 10:32:18 / cg"
+!
+
+test21_localsOfInlinedBlock_bug
+    "checks for an stc compiler bug (detected Sep 2011).
+     stc generates bad code for the bitOr expression in nextLittleEndianNumber"
+
+    |blk mthd|
+
+    Class withoutUpdatingChangesDo:[
+        self class recompile:#'inlinedBlockVariables2'.
+        blk := self inlinedBlockVariables2.
+        self assert:((blk value:#argbbb_1) == 3).
+
+        mthd := self class compiledMethodAt:#'inlinedBlockVariables2'.
+        (STCCompilerInterface new)
+            compileToMachineCode:mthd source
+            forClass:self class
+            selector:#'inlinedBlockVariables2'
+            inCategory:mthd category
+            notifying:nil
+            install:true
+            skipIfSame:false
+            silent:true.
+
+        self 
+            assert:mthd ~= (self class compiledMethodAt:#'inlinedBlockVariables2')
+            description:'Could not compile with STC'.
+
+        blk := self inlinedBlockVariables2.
+        self assert:((blk value:#argbbb_1) == 3).
+    ].
+
+    "
+     self run:#test21_localsOfInlinedBlock_bug
+     self new test21_localsOfInlinedBlock_bug
+    "
+
+    "Created: / 17-09-2011 / 10:32:18 / cg"
 ! !
 
 !STCCompilerTests class methodsFor:'documentation'!