RegressionTests__CompilerTests2.st
changeset 1928 a7e400e70e65
parent 1462 7a2b32a588ee
child 2182 abba80b6780f
equal deleted inserted replaced
1927:ac82d7231d95 1928:a7e400e70e65
       
     1 "{ Encoding: utf8 }"
       
     2 
     1 "{ Package: 'stx:goodies/regression' }"
     3 "{ Package: 'stx:goodies/regression' }"
     2 
     4 
     3 "{ NameSpace: RegressionTests }"
     5 "{ NameSpace: RegressionTests }"
     4 
     6 
     5 TestCase subclass:#CompilerTests2
     7 TestCase subclass:#CompilerTests2
     9 	classVariableNames:''
    11 	classVariableNames:''
    10 	poolDictionaries:''
    12 	poolDictionaries:''
    11 	category:'tests-Regression-Compilers'
    13 	category:'tests-Regression-Compilers'
    12 !
    14 !
    13 
    15 
       
    16 
       
    17 !CompilerTests2 class methodsFor:'settings'!
       
    18 
       
    19 libraryName
       
    20     ^ 'librun'
       
    21 
       
    22     "Created: / 11-05-2018 / 13:50:32 / stefan"
       
    23 ! !
    14 
    24 
    15 !CompilerTests2 methodsFor:'private'!
    25 !CompilerTests2 methodsFor:'private'!
    16 
    26 
    17 assertSendersMethodIsIdenticalTo: sendersMethod
    27 assertSendersMethodIsIdenticalTo: sendersMethod
    18     "Do not assert here, pass down to have some immediate, possibly lazy contexts
    28     "Do not assert here, pass down to have some immediate, possibly lazy contexts
   128     "Modified: / 26-09-2014 / 13:00:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   138     "Modified: / 26-09-2014 / 13:00:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   129 !
   139 !
   130 
   140 
   131 method_argAndVarNames_02
   141 method_argAndVarNames_02
   132     #(1 2 3 4) select:[:each |
   142     #(1 2 3 4) select:[:each |
   133 	| isEven |
   143         | isEven |
   134 
   144 
   135 	'1234' select:[:char |
   145         '1234' select:[:char |
   136 	    | someOtherLocal |
   146             | someOtherLocal |
   137 
   147 
   138 	    someOtherLocal := char == $1.
   148             someOtherLocal := char == $1.
   139 	].
   149         ].
   140 	isEven := each even.
   150         isEven := each even.
   141 	self saveContext.
   151         self saveContext.
   142     ].
   152     ].
   143 
   153 
   144     "Created: / 20-08-2013 / 09:17:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   154     "Created: / 20-08-2013 / 09:17:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   145     "Modified: / 26-09-2014 / 13:00:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   155     "Modified: / 26-09-2014 / 13:00:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   146 !
   156 !
   836 !CompilerTests2 methodsFor:'tests - FFI'!
   846 !CompilerTests2 methodsFor:'tests - FFI'!
   837 
   847 
   838 test_external_function_call_01a
   848 test_external_function_call_01a
   839     "Test for stx bug for <cdecl> specs like
   849     "Test for stx bug for <cdecl> specs like
   840 
   850 
   841 	<cdecl: Cairo::FontFace 'cairo_get_font_face' ( Cairo::GraphicsContext ) >
   851         <cdecl: Cairo::FontFace 'cairo_get_font_face' ( Cairo::GraphicsContext ) >
   842 
   852 
   843      i.e., when custom subclass of ExternalAddress is in namespace."
   853      i.e., when custom subclass of ExternalAddress is in namespace."
   844 
   854 
   845     | malloc  free |
   855     | malloc  free |
   846 
   856 
   847     malloc := 'malloc: size
   857     malloc := 'malloc: size
   848 
       
   849     <cdecl: const RegressionTests::CompilerTests2ExternalBytes "malloc" ( int ) module: ''librun.so''>
   858     <cdecl: const RegressionTests::CompilerTests2ExternalBytes "malloc" ( int ) module: ''librun.so''>
   850     self primitive failed'.
   859     self primitiveFailed'.
       
   860 
   851     free := 'free: ptr
   861     free := 'free: ptr
   852 
       
   853     <cdecl: const void "free" ( RegressionTests::CompilerTests2ExternalBytes ) module: ''librun.so''>
   862     <cdecl: const void "free" ( RegressionTests::CompilerTests2ExternalBytes ) module: ''librun.so''>
   854     self primitive failed'.
   863     self primitiveFailed'.
       
   864 
   855     #( #bc #stc ) do:[:mode |
   865     #( #bc #stc ) do:[:mode |
   856 	| ptr |
   866         | ptr |
   857 
   867 
   858 	self compile:malloc mode:mode.
   868         self compile:malloc mode:mode.
   859 	self compile:free mode:mode.
   869         self compile:free mode:mode.
   860 	ptr := self perform:(mode , '_malloc:') asSymbol with:1.
   870         ptr := self perform:(mode , '_malloc:') asSymbol with:1.
   861 	self assert:ptr class == RegressionTests::CompilerTests2ExternalBytes.
   871         self assert:ptr class == RegressionTests::CompilerTests2ExternalBytes.
   862 	self perform:(mode , '_free:') asSymbol with:ptr.
   872         self perform:(mode , '_free:') asSymbol with:ptr.
   863     ]
   873     ]
   864 
   874 
   865     "Created: / 06-01-2014 / 11:29:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   875     "Created: / 06-01-2014 / 11:29:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   866     "Modified: / 20-09-2014 / 21:51:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   876     "Modified: / 20-09-2014 / 21:51:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   877     "Modified: / 11-05-2018 / 13:45:11 / stefan"
   867 !
   878 !
   868 
   879 
   869 test_external_function_call_01b
   880 test_external_function_call_01b
   870     "Test for stx bug for <cdecl> specs like
   881     "Test for stx bug for <cdecl> specs like
   871 
   882 
   872 	<cdecl: Cairo::FontFace 'cairo_get_font_face' ( Cairo::GraphicsContext ) >
   883         <cdecl: Cairo::FontFace 'cairo_get_font_face' ( Cairo::GraphicsContext ) >
   873 
   884 
   874      i.e., when custom subclass of ExternalAddress is in namespace."
   885      i.e., when custom subclass of ExternalAddress is in namespace."
   875 
   886 
   876     | malloc  free |
   887     | malloc  free |
   877 
   888 
   878     malloc := 'malloc: size
   889     malloc := 'malloc: size
   879 
       
   880     <cdecl: const RegressionTests::CompilerTests2ExternalBytes "malloc" ( int ) module: ''librun''>
   890     <cdecl: const RegressionTests::CompilerTests2ExternalBytes "malloc" ( int ) module: ''librun''>
   881     self primitive failed'.
   891     self primitive failed'.
       
   892 
   882     free := 'free: ptr
   893     free := 'free: ptr
   883 
       
   884     <cdecl: const void "free" ( RegressionTests::CompilerTests2ExternalBytes ) module: ''librun''>
   894     <cdecl: const void "free" ( RegressionTests::CompilerTests2ExternalBytes ) module: ''librun''>
   885     self primitive failed'.
   895     self primitive failed'.
   886     #( #bc #stc ) do:[:mode |
   896     #( #bc #stc ) do:[:mode |
   887 	| ptr |
   897         | ptr |
   888 
   898 
   889 	self compile:malloc mode:mode.
   899         self compile:malloc mode:mode.
   890 	self compile:free mode:mode.
   900         self compile:free mode:mode.
   891 	ptr := self perform:(mode , '_malloc:') asSymbol with:1.
   901         ptr := self perform:(mode , '_malloc:') asSymbol with:1.
   892 	self assert:ptr class == RegressionTests::CompilerTests2ExternalBytes.
   902         self assert:ptr class == RegressionTests::CompilerTests2ExternalBytes.
   893 	self perform:(mode , '_free:') asSymbol with:ptr.
   903         self perform:(mode , '_free:') asSymbol with:ptr.
   894     ]
   904     ]
   895 
   905 
   896     "Created: / 06-01-2014 / 11:29:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   906     "Created: / 06-01-2014 / 11:29:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   897     "Modified: / 20-09-2014 / 21:51:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   907     "Modified: / 20-09-2014 / 21:51:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   908     "Modified: / 11-05-2018 / 13:44:09 / stefan"
   898 !
   909 !
   899 
   910 
   900 test_external_function_call_01c
   911 test_external_function_call_01c
   901     "Test for stx bug for <cdecl> specs like
   912     "Test for stx bug for <cdecl> specs like
   902 
   913 
   903 	<cdecl: Cairo::FontFace 'cairo_get_font_face' ( Cairo::GraphicsContext ) >
   914         <cdecl: Cairo::FontFace 'cairo_get_font_face' ( Cairo::GraphicsContext ) >
   904 
   915 
   905      i.e., when custom subclass of ExternalAddress is in namespace."
   916      i.e., when custom subclass of ExternalAddress is in namespace."
   906 
   917 
   907     | malloc  free |
   918     | malloc  free |
   908 
   919 
   909     malloc := 'malloc: size
   920     malloc := 'malloc: size
   910 
       
   911     <cdecl: const RegressionTests::CompilerTests2ExternalBytes "malloc" ( int )>
   921     <cdecl: const RegressionTests::CompilerTests2ExternalBytes "malloc" ( int )>
   912     self primitive failed'.
   922     self primitiveFailed'.
       
   923 
   913     free := 'free: ptr
   924     free := 'free: ptr
   914 
   925     <cdecl: const void "free" ( RegressionTests::CompilerTests2ExternalBytes)>
   915     <cdecl: const void "free" ( RegressionTests::CompilerTests2ExternalBytes )>
   926     self primitiveFailed'.
   916     self primitive failed'.
   927 
   917     #( #bc #stc ) do:[:mode |
   928     #( #bc #stc ) do:[:mode |
   918 	| ptr |
   929         | ptr |
   919 
   930 
   920 	self compile:malloc mode:mode.
   931         self compile:malloc mode:mode.
   921 	self compile:free mode:mode.
   932         self compile:free mode:mode.
   922 	ptr := self perform:(mode , '_malloc:') asSymbol with:1.
   933         ptr := self perform:(mode , '_malloc:') asSymbol with:1.
   923 	self assert:ptr class == RegressionTests::CompilerTests2ExternalBytes.
   934         self assert:ptr class == RegressionTests::CompilerTests2ExternalBytes.
   924 	self perform:(mode , '_free:') asSymbol with:ptr.
   935         self perform:(mode , '_free:') asSymbol with:ptr.
   925     ]
   936     ]
   926 
   937 
   927     "Created: / 06-01-2014 / 11:29:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   938     "Created: / 06-01-2014 / 11:29:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   928     "Modified: / 20-09-2014 / 21:51:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   939     "Modified: / 20-09-2014 / 21:51:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   940     "Modified: / 11-05-2018 / 13:45:47 / stefan"
   929 ! !
   941 ! !
   930 
   942 
   931 !CompilerTests2 methodsFor:'tests - arg & var names'!
   943 !CompilerTests2 methodsFor:'tests - arg & var names'!
   932 
   944 
   933 test_argAndVarNames_01
   945 test_argAndVarNames_01