class: RegressionTests::STCCompilerTests
authorJan Vrany <jan.vrany@fit.cvut.cz>
Wed, 04 Sep 2013 10:40:52 +0200
changeset 994 914cf744f89e
parent 993 8cc7201dbfda
child 995 676127617c9e
class: RegressionTests::STCCompilerTests added: #test03_compilation
RegressionTests__STCCompilerTests.st
--- a/RegressionTests__STCCompilerTests.st	Tue Aug 27 11:32:51 2013 +0200
+++ b/RegressionTests__STCCompilerTests.st	Wed Sep 04 10:40:52 2013 +0200
@@ -27,6 +27,7 @@
 "
 ! !
 
+
 !STCCompilerTests methodsFor:'code templates'!
 
 nextLittleEndianNumber: n from:bytes
@@ -108,6 +109,51 @@
     "Created: / 17-09-2011 / 10:32:18 / cg"
 !
 
+test03_compilation
+    "As of 2013-09-04, instance variables of Class are not visible
+     in class methods of ordinary classes. For bytecode-compiled method
+     they are.
+
+     This tests checks for this bug.
+    "
+
+    |val|
+
+    Class withoutUpdatingChangesDo:[
+        "/ Check bytecode version first...
+        self class class compile:'returnMyName
+    ^ name
+'.
+        val := self class returnMyName.
+        self assert:(val == self class name).
+        self class removeSelector:#returnMyName.
+
+        "/ Now, compile the same source using stc and check...
+        (STCCompilerInterface new)
+            compileToMachineCode:'returnMyName
+    ^ name
+'
+            forClass:self class class
+            selector:#'returnMyName'
+            inCategory:'tests'
+            notifying:nil
+            install:true
+            skipIfSame:false
+            silent:true.
+
+        val := self class returnMyName.
+        self assert:(val == self class name).
+        self class removeSelector:#returnMyName.
+    ].
+
+    "
+     self run:#test02_compilation
+     self new test02_compilation
+    "
+
+    "Created: / 04-09-2013 / 09:35:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 test10_bitor_bug
     "checks for an stc compiler bug (detected Sep 2011).
      stc generates bad code for the bitOr expression in nextLittleEndianNumber"