RegressionTests__STCCompilerTests.st
changeset 809 63b232026107
parent 667 bcaab8eb0617
child 894 fd92a3529be3
--- a/RegressionTests__STCCompilerTests.st	Thu Feb 21 13:49:32 2013 +0100
+++ b/RegressionTests__STCCompilerTests.st	Thu Feb 21 15:24:42 2013 +0100
@@ -79,6 +79,109 @@
     "
 
     "Created: / 17-09-2011 / 10:32:18 / cg"
+!
+
+test01_compilation
+    "checks for an stc compiler bug (detected Sep 2011).
+     stc generates bad code for the bitOr expression in nextLittleEndianNumber"
+
+    Class withoutUpdatingChangesDo:[
+        (STCCompilerInterface new)
+            compileToMachineCode:'hello
+%{
+    console_printf("hello world\n");
+%}
+'
+            forClass:self class
+            selector:#'hello'
+            inCategory:'tests'
+            notifying:nil
+            install:true
+            skipIfSame:false
+            silent:true.
+
+        self hello.
+        self class removeSelector:#hello.
+    ].
+
+    "
+     self run:#test01_compilation
+     self new test01_compilation
+    "
+
+    "Created: / 17-09-2011 / 10:32:18 / cg"
+!
+
+test02_compilation
+    "checks for an stc compiler bug (detected Sep 2011).
+     stc generates bad code for the bitOr expression in nextLittleEndianNumber"
+
+    |val|
+
+    Class withoutUpdatingChangesDo:[
+        (STCCompilerInterface new)
+            compileToMachineCode:'x123
+%{
+    RETURN(__MKSMALLINT(123));
+%}
+'
+            forClass:self class
+            selector:#'x123'
+            inCategory:'tests'
+            notifying:nil
+            install:true
+            skipIfSame:false
+            silent:true.
+
+        val := self x123.
+        self assert:(val == 123).
+        self class removeSelector:#x123.
+    ].
+
+    "
+     self run:#test02_compilation
+     self new test02_compilation
+    "
+
+    "Created: / 17-09-2011 / 10:32:18 / cg"
+!
+
+test10_bitor_bug
+    "checks for an stc compiler bug (detected Sep 2011).
+     stc generates bad code for the bitOr expression in nextLittleEndianNumber"
+
+    |val mthd|
+
+    Class withoutUpdatingChangesDo:[
+        self class recompile:#'nextLittleEndianNumber:from:'.
+        val := self nextLittleEndianNumber:4 from:#[1 2 3 4].
+        self assert:(val = 16r04030201).
+        val := self nextLittleEndianNumber:8 from:#[1 2 3 4 5 6 7 8].
+        self assert:(val = 16r0807060504030201).
+
+        mthd := (self class compiledMethodAt:#'nextLittleEndianNumber:from:').
+        (STCCompilerInterface new)
+            compileToMachineCode:mthd source
+            forClass:self class
+            selector:#'nextLittleEndianNumber:from:'
+            inCategory:mthd category
+            notifying:nil
+            install:true
+            skipIfSame:false
+            silent:true.
+
+        val := self nextLittleEndianNumber:4 from:#[1 2 3 4].
+        self assert:(val = 16r04030201).
+        val := self nextLittleEndianNumber:8 from:#[1 2 3 4 5 6 7 8].
+        self assert:(val = 16r0807060504030201).
+    ].
+
+    "
+     self run:#test10_bitor_bug
+     self new test10_bitor_bug
+    "
+
+    "Created: / 17-09-2011 / 10:32:18 / cg"
 ! !
 
 !STCCompilerTests class methodsFor:'documentation'!
@@ -90,3 +193,4 @@
 version_CVS
     ^ '$Header$'
 ! !
+