RegressionTests__CompilerTests2.st
changeset 899 4375bdf77fd2
parent 871 098316a54e40
child 900 7acbd0cce153
--- a/RegressionTests__CompilerTests2.st	Tue Apr 09 22:31:51 2013 +0200
+++ b/RegressionTests__CompilerTests2.st	Fri Apr 12 22:00:08 2013 +0200
@@ -10,6 +10,324 @@
 !
 
 
+!CompilerTests2 methodsFor:'private'!
+
+currentLineNumber
+    ^thisContext sender lineNumber
+
+    "Created: / 12-04-2013 / 21:20:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+method_lineno_002
+    1 factorial. ^self currentLineNumber
+
+    "Created: / 12-04-2013 / 21:22:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+method_lineno_300
+    "DO NOT MAKE THIS METHOD SHORTER, DO NOT REMOVE BLANK LINES!!!!!!"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+    ^self currentLineNumber
+
+    "Created: / 12-04-2013 / 21:23:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !CompilerTests2 methodsFor:'setup'!
 
 tearDown
@@ -101,6 +419,75 @@
     "Modified (comment): / 12-02-2013 / 16:24:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!CompilerTests2 methodsFor:'tests - line numbers'!
+
+test_lineno_01_bci
+    | m002 m300 l |
+
+    m002 := self class >> #method_lineno_002.
+    m002 code: nil.
+    m002 checked: true.
+
+    m300 := self class >> #method_lineno_300.
+    m002 code: nil.
+    m002 checked: true.
+
+    self assert: (l := self method_lineno_002) == 2.
+    self assert: (l := self method_lineno_300) == 300.
+
+    self assert: m002 code isNil.
+    self assert: m300 code isNil.
+
+    "Created: / 12-04-2013 / 21:24:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+test_lineno_01_jit
+    | m002 m300 l |
+
+    m002 := self class >> #method_lineno_002.
+    m002 code: nil.
+    m002 checked: false.
+    self method_lineno_002; method_lineno_002.
+
+    m300 := self class >> #method_lineno_300.
+    m002 code: nil.
+    m002 checked: false.
+    self method_lineno_300;method_lineno_300.
+
+    self assert: (l := self method_lineno_002) == 2.
+    self assert: (l := self method_lineno_300) == 300.
+
+    self assert: m002 code notNil.
+    self assert: m300 code notNil.
+
+    "Created: / 12-04-2013 / 21:41:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+test_lineno_01_stc
+    | m002 m300 l |
+
+    m002 := self class >> #method_lineno_002.
+    ParserFlags withSTCCompilation:#always do:[
+        self class compile: 'STC_', m002 source classified: 'private - *dynamic*'
+    ].
+
+    m300 := self class >> #method_lineno_300.
+    ParserFlags withSTCCompilation:#always do:[
+        self class compile: 'STC_', m300 source classified: 'private - *dynamic*'
+    ].
+
+    [
+        self assert: (l := self STC_method_lineno_002) == 2.
+        self assert: (l := self STC_method_lineno_300) == 300.
+    ] ensure:[
+        self class
+            removeSelector:#STC_method_lineno_002;
+            removeSelector:#STC_method_lineno_300
+    ]
+
+    "Created: / 12-04-2013 / 21:50:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !CompilerTests2 class methodsFor:'documentation'!
 
 version