Added tests covering symbol parsing inconsistency in array literals.
authorJan Vrany <jan.vrany@fit.cvut.cz>
Mon, 20 Jan 2014 14:48:00 +0100
changeset 1037 4bba0706b9ae
parent 1036 c42c54df984e
child 1038 5443ea4b780e
Added tests covering symbol parsing inconsistency in array literals.
RegressionTests__CompilerTests2.st
--- a/RegressionTests__CompilerTests2.st	Mon Dec 02 20:10:04 2013 +0100
+++ b/RegressionTests__CompilerTests2.st	Mon Jan 20 14:48:00 2014 +0100
@@ -500,6 +500,28 @@
     "Created: / 12-04-2013 / 21:23:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
+method_literals_array_01
+    | literal |
+
+    literal := #(
+        _XXX:_:
+        YYY
+        _XXX:_:
+    ).
+    ^ literal
+
+    "Created: / 20-01-2014 / 13:39:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+method_literals_symbol_01
+    | literal |
+
+    literal := #_XXX:_:.
+    ^ literal.
+
+    "Created: / 20-01-2014 / 13:43:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 method_methodslot_01: thisMethod
     self assertSendersMethodIsIdenticalTo: thisMethod
 
@@ -675,6 +697,38 @@
     "Modified: / 27-08-2013 / 10:32:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!CompilerTests2 methodsFor:'tests - FFI'!
+
+test_external_function_call_01
+    "Test for stx bug for <cdecl> specs like
+
+        <cdecl: Cairo::FontFace 'cairo_get_font_face' ( Cairo::GraphicsContext ) >
+
+     i.e., when custom subclass of ExternalAddress is in namespace."
+    
+    | malloc  free |
+
+    malloc := 'malloc: size
+
+    <cdecl: RegressionTests::CompilerTests2ExternalBytes "malloc" ( int ) module: ''librun.so''>
+    self primitive failed'.
+    free := 'free: ptr
+
+    <cdecl: void "free" ( RegressionTests::CompilerTests2ExternalBytes ) module: ''librun.so''>
+    self primitive failed'.
+    #( #bc #stc ) do:[:mode | 
+        | ptr |
+
+        self compile:malloc mode:mode.
+        self compile:free mode:mode.
+        ptr := self perform:(mode , '_malloc:') asSymbol with:1.
+        self assert:ptr class == RegressionTests::CompilerTests2ExternalBytes.
+        self perform:(mode , 'free:') asSymbol with:ptr.
+    ]
+
+    "Created: / 06-01-2014 / 11:29:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !CompilerTests2 methodsFor:'tests - arg & var names'!
 
 test_argAndVarNames_01
@@ -799,6 +853,84 @@
     "Modified: / 25-04-2013 / 15:22:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!CompilerTests2 methodsFor:'tests - literals'!
+
+test_literals_array_01
+    | m l_stc l_bc |
+
+    m := self class >> #method_literals_array_01.
+
+    self compile: m source mode: #stc.
+    self compile: m source mode: #bc.
+
+    l_stc := self stc_method_literals_array_01.
+    l_bc :=  self bc_method_literals_array_01.
+
+    self assert: l_stc = l_bc.
+
+    "Created: / 20-01-2014 / 13:46:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+test_literals_array_01_bc
+    | m l |
+
+    m := self class >> #method_literals_array_01.
+
+    self compile: m source mode: #bc.
+
+    l := self bc_method_literals_array_01.
+
+    self assert: l size == 3.
+    self assert: l first == #'_XXX:_:'.
+    self assert: l first == #'YYY'.
+    self assert: l third == #'_XXX:_:'.
+
+    "Created: / 20-01-2014 / 13:42:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+test_literals_array_01_stc
+    | m l |
+
+    m := self class >> #method_literals_array_01.
+
+    self compile: m source mode: #stc.
+
+    l := self stc_method_literals_array_01.
+
+    self assert: l size == 3.
+    self assert: l first == #'_XXX:_:'.
+    self assert: l first == #'YYY'.
+    self assert: l third == #'_XXX:_:'.
+
+    "Created: / 20-01-2014 / 13:40:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+test_literals_symbol_01_bc
+    | m l |
+
+    m := self class >> #method_literals_symbol_01.
+
+    self compile: m source mode: #bc.
+
+    l := self bc_method_literals_symbol_01.
+    self assert: l == #'_XXX:_:'.
+
+    "Created: / 20-01-2014 / 13:44:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+test_literals_symbol_01_stc
+    | m l |
+
+    m := self class >> #method_literals_symbol_01.
+
+    self compile: m source mode: #stc.
+
+    l := self stc_method_literals_symbol_01.
+    self assert: l == #'_XXX:_:'.
+
+    "Created: / 20-01-2014 / 13:44:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !CompilerTests2 methodsFor:'tests - method slot'!
 
 test_methodslot_01_bci