RegressionTests__CompilerTests2.st
changeset 922 7c65bb0a73f5
parent 921 cb5e99d58aab
child 929 5c6f8d37f9ce
--- a/RegressionTests__CompilerTests2.st	Thu Apr 25 16:26:14 2013 +0200
+++ b/RegressionTests__CompilerTests2.st	Thu Apr 25 16:40:51 2013 +0200
@@ -12,6 +12,28 @@
 
 !CompilerTests2 methodsFor:'private'!
 
+assertSendersMethodIsIdenticalTo: sendersMethod
+    "Do not assert here, pass down to have some immediate, possibly lazy contexts
+     in between"
+
+    self assertSendersSendersMethodIsIdenticalTo: sendersMethod
+
+    "Created: / 25-04-2013 / 15:28:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+assertSendersSendersMethodIsIdenticalTo: thisMethod
+    | ctx m |
+
+    ctx := thisContext sender sender.
+    "/ Now, DO NOT USE Context>>method as it searches for the method
+    "/ if it is not set!!
+
+    m := ctx instVarAt: (Context instVarIndexFor: #method).
+    self assert: m == thisMethod
+
+    "Created: / 25-04-2013 / 15:30:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 compile: source mode: mode
     "Compile given source and returns the new method.
      The from the source is prepended the mode + underscore
@@ -51,7 +73,9 @@
 
     "Created: / 12-04-2013 / 21:20:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     "Modified: / 13-04-2013 / 10:12:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
+! !
+
+!CompilerTests2 methodsFor:'private-mock methods'!
 
 method_lineno_002
     1 factorial. ^self currentLineNumber
@@ -361,6 +385,34 @@
     ^self currentLineNumber
 
     "Created: / 12-04-2013 / 21:23:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+method_methodslot_01: thisMethod
+    self assertSendersMethodIsIdenticalTo: thisMethod
+
+    "Created: / 25-04-2013 / 15:28:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+method_methodslot_02: thisMethod
+     [ self assertSendersMethodIsIdenticalTo: thisMethod ]
+        valueWithArguments:#() "/ don't use #value, it gets optimized!!
+
+    "Created: / 25-04-2013 / 15:36:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+method_methodslot_03: thisMethod
+    "Deep block nesting...."
+    [
+        [
+            [
+                [ 
+                    self assertSendersMethodIsIdenticalTo: thisMethod 
+                ] valueWithArguments:#() "/ don't use #value, it gets optimized!!
+            ] valueWithArguments:#() "/ don't use #value, it gets optimized!!
+        ] valueWithArguments:#() "/ don't use #value, it gets optimized!!
+    ] valueWithArguments:#() "/ don't use #value, it gets optimized!!
+
+    "Created: / 25-04-2013 / 15:38:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !CompilerTests2 methodsFor:'setup'!
@@ -517,6 +569,98 @@
     "Modified: / 25-04-2013 / 15:22:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!CompilerTests2 methodsFor:'tests - method slot'!
+
+test_methodslot_01_bci
+    | m |
+
+    m := self compile: (self class >> #method_methodslot_01:) source mode: #bc.
+    self bc_method_methodslot_01: m.
+    self assert: m code isNil.
+
+    "Created: / 25-04-2013 / 15:33:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+test_methodslot_01_jit
+    | m |
+
+    m := self compile: (self class >> #method_methodslot_01:) source mode: #jit.
+    self jit_method_methodslot_01: m.
+    self assert: m code notNil.
+
+    "Created: / 25-04-2013 / 15:34:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+test_methodslot_01_stc
+    | m |
+
+    m := self compile: (self class >> #method_methodslot_01:) source mode: #stc.
+    self stc_method_methodslot_01: m.
+    self assert: m code notNil.
+
+    "Created: / 25-04-2013 / 15:34:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+test_methodslot_02_bci
+    | m |
+
+    m := self compile: (self class >> #method_methodslot_02:) source mode: #bc.
+    self bc_method_methodslot_02: m.
+    self assert: m code isNil.
+
+    "Created: / 25-04-2013 / 15:36:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+test_methodslot_02_jit
+    | m |
+
+    m := self compile: (self class >> #method_methodslot_02:) source mode: #jit.
+    self jit_method_methodslot_02: m.
+    self assert: m code notNil.
+
+    "Created: / 25-04-2013 / 15:37:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+test_methodslot_02_stc
+    | m |
+
+    m := self compile: (self class >> #method_methodslot_02:) source mode: #stc.
+    self stc_method_methodslot_02: m.
+    self assert: m code notNil.
+
+    "Created: / 25-04-2013 / 15:37:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+test_methodslot_03_bci
+    | m |
+
+    m := self compile: (self class >> #method_methodslot_03:) source mode: #bc.
+    self bc_method_methodslot_03: m.
+    self assert: m code isNil.
+
+    "Created: / 25-04-2013 / 15:39:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+test_methodslot_03_jit
+    | m |
+
+    m := self compile: (self class >> #method_methodslot_03:) source mode: #jit.
+    self jit_method_methodslot_03: m.
+    self assert: m code notNil.
+
+    "Created: / 25-04-2013 / 15:39:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+test_methodslot_03_stc
+    | m |
+
+    m := self compile: (self class >> #method_methodslot_03:) source mode: #stc.
+    self stc_method_methodslot_03: m.
+    self assert: m code notNil.
+
+    "Created: / 25-04-2013 / 15:39:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !CompilerTests2 class methodsFor:'documentation'!
 
 version