Fixed CompilerTests2>>test_external_function_call_* jv
authorJan Vrany <jan.vrany@fit.cvut.cz>
Wed, 13 Jul 2016 00:31:45 +0100
branchjv
changeset 1510 6fb7e9d33c4d
parent 1509 a8a0373fd7d1
child 1530 b21a5e9a6c26
Fixed CompilerTests2>>test_external_function_call_*
RegressionTests__CompilerTests2.st
--- a/RegressionTests__CompilerTests2.st	Wed Jul 13 09:34:00 2016 +0100
+++ b/RegressionTests__CompilerTests2.st	Wed Jul 13 00:31:45 2016 +0100
@@ -12,6 +12,19 @@
 !
 
 
+!CompilerTests2 class methodsFor:'accessing'!
+
+libraryName
+
+    OperatingSystem isUNIXlike ifTrue:[^'librun.so'].
+
+    OperatingSystem isMSWINDOWSlike ifTrue:[^'kernel32.dll'].
+
+    self error:'Library name for host OS is not known'
+
+    "Created: / 14-07-2016 / 10:10:56 / jv"
+! !
+
 !CompilerTests2 methodsFor:'private'!
 
 assertSendersMethodIsIdenticalTo: sendersMethod
@@ -855,7 +868,7 @@
 
 !CompilerTests2 methodsFor:'tests - FFI'!
 
-test_external_function_call_01a
+test_external_function_call_01a_u
     "Test for stx bug for <cdecl> specs like
 
         <cdecl: Cairo::FontFace 'cairo_get_font_face' ( Cairo::GraphicsContext ) >
@@ -864,6 +877,8 @@
     
     | malloc  free |
 
+    self skipIf: OperatingSystem isUNIXlike not description: 'This test is UNIX specific, see _w variant for Windows'.
+
     malloc := 'malloc: size
 
     <cdecl: const RegressionTests::CompilerTests2ExternalBytes "malloc" ( int ) module: ''librun.so''>
@@ -882,11 +897,37 @@
         self perform:(mode , '_free:') asSymbol with:ptr.
     ]
 
-    "Created: / 06-01-2014 / 11:29:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 20-09-2014 / 21:51:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Created: / 12-07-2016 / 23:54:54 / jv"
 !
 
-test_external_function_call_01b
+test_external_function_call_01a_w
+    "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."
+    
+    | getProcessHeap |
+
+    self skipIf: OperatingSystem isMSWINDOWSlike not description: 'This test is Windows specific, see _u variant for UNIX'.
+
+    getProcessHeap := 'getProcessHeap
+    <apicall: RegressionTests::CompilerTests2ExternalBytes "GetProcessHeap" (  ) module: "kernel32.dll">
+    self primitive failed'.
+
+    #( #bc #stc ) do:[:mode | 
+        | heap |
+
+        self compile:getProcessHeap mode:mode.
+        heap := self perform: (mode , '_getProcessHeap') asSymbol.
+        self assert:heap class == RegressionTests::CompilerTests2ExternalBytes.
+
+    ]
+
+    "Created: / 12-07-2016 / 23:57:56 / jv"
+!
+
+test_external_function_call_01b_u
     "Test for stx bug for <cdecl> specs like
 
         <cdecl: Cairo::FontFace 'cairo_get_font_face' ( Cairo::GraphicsContext ) >
@@ -895,6 +936,8 @@
     
     | malloc  free |
 
+    self skipIf: OperatingSystem isUNIXlike not description: 'This test is UNIX specific, see _w variant for Windows'.
+
     malloc := 'malloc: size
 
     <cdecl: const RegressionTests::CompilerTests2ExternalBytes "malloc" ( int ) module: ''librun''>
@@ -913,11 +956,37 @@
         self perform:(mode , '_free:') asSymbol with:ptr.
     ]
 
-    "Created: / 06-01-2014 / 11:29:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 20-09-2014 / 21:51:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Created: / 12-07-2016 / 23:55:01 / jv"
 !
 
-test_external_function_call_01c
+test_external_function_call_01b_w
+    "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."
+    
+    | getProcessHeap |
+
+    self skipIf: OperatingSystem isMSWINDOWSlike not description: 'This test is Windows specific, see _u variant for UNIX'.
+
+    getProcessHeap := 'getProcessHeap
+    <apicall: RegressionTests::CompilerTests2ExternalBytes "GetProcessHeap" (  ) module: "kernel32">
+    self primitive failed'.
+
+    #( #bc #stc ) do:[:mode | 
+        | heap |
+
+        self compile:getProcessHeap mode:mode.
+        heap := self perform: (mode , '_getProcessHeap') asSymbol.
+        self assert:heap class == RegressionTests::CompilerTests2ExternalBytes.
+
+    ]
+
+    "Created: / 14-07-2016 / 10:07:40 / jv"
+!
+
+test_external_function_call_01c_u
     "Test for stx bug for <cdecl> specs like
 
         <cdecl: Cairo::FontFace 'cairo_get_font_face' ( Cairo::GraphicsContext ) >
@@ -926,6 +995,8 @@
     
     | malloc  free |
 
+    self skipIf: OperatingSystem isUNIXlike not description: 'This test is UNIX specific, see _w variant for Windows'.
+
     malloc := 'malloc: size
 
     <cdecl: const RegressionTests::CompilerTests2ExternalBytes "malloc" ( int )>
@@ -944,8 +1015,34 @@
         self perform:(mode , '_free:') asSymbol with:ptr.
     ]
 
-    "Created: / 06-01-2014 / 11:29:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 20-09-2014 / 21:51:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Created: / 12-07-2016 / 23:55:06 / jv"
+!
+
+test_external_function_call_01c_w
+    "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."
+    
+    | getProcessHeap |
+
+    self skipIf: OperatingSystem isMSWINDOWSlike not description: 'This test is Windows specific, see _u variant for UNIX'.
+
+    getProcessHeap := 'getProcessHeap
+    <apicall: RegressionTests::CompilerTests2ExternalBytes "GetProcessHeap" (  )>
+    self primitive failed'.
+
+    #( #bc #stc ) do:[:mode | 
+        | heap |
+
+        self compile:getProcessHeap mode:mode.
+        heap := self perform: (mode , '_getProcessHeap') asSymbol.
+        self assert:heap class == RegressionTests::CompilerTests2ExternalBytes.
+
+    ]
+
+    "Created: / 14-07-2016 / 10:08:04 / jv"
 ! !
 
 !CompilerTests2 methodsFor:'tests - arg & var names'!