Skip to content

Commit 2d19f41

Browse files
committed
Make NQP nativecall tests robust on Win32.
At least, with MSVC. If we don't find standard C symbols, fall back to explicitly looking in the C library.
1 parent 3ebb27f commit 2d19f41

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

t/nativecall/01-basic.t

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,19 @@ BEGIN {
4747
class Call is repr('NativeCall') { }
4848
class CPointer is repr('CPointer') { }
4949

50-
#my $printf := nqp::create(Call);
5150
my $printf := Call.new;
5251
$arg_hash := nqp::hash();
5352
$arg_hash<type> := 'utf8str';
5453
$arg_hash<free_str> := 1;
5554
$return_hash := nqp::hash();
5655
$return_hash<type> := 'void';
5756

58-
nqp::buildnativecall($printf, '', 'printf', '', [$arg_hash], $return_hash);
57+
try {
58+
nqp::buildnativecall($printf, '', 'printf', '', [$arg_hash], $return_hash);
59+
CATCH {
60+
nqp::buildnativecall($printf, 'msvcrt.dll', 'printf', '', [$arg_hash], $return_hash);
61+
}
62+
}
5963
nqp::nativecall(nqp::null(), $printf, ["ok - printf\n"]);
6064

6165
my $strdup := nqp::create(Call);
@@ -68,7 +72,7 @@ $return_hash<type> := 'cpointer';
6872
try {
6973
nqp::buildnativecall($strdup, '', 'strdup', '', [$arg_hash], $return_hash);
7074
CATCH {
71-
nqp::buildnativecall($strdup, '', '_strdup', '', [$arg_hash], $return_hash);
75+
nqp::buildnativecall($strdup, 'msvcrt.dll', '_strdup', '', [$arg_hash], $return_hash);
7276
}
7377
}
7478
my $dupped := nqp::nativecall(CPointer, $strdup, ["ok - passing cpointer\n"]);
@@ -80,7 +84,12 @@ $arg_hash<type> := 'cpointer';
8084
$return_hash := nqp::hash();
8185
$return_hash<type> := 'void';
8286

83-
nqp::buildnativecall($printf, '', 'printf', '', [$arg_hash], $return_hash);
87+
try {
88+
nqp::buildnativecall($printf, '', 'printf', '', [$arg_hash], $return_hash);
89+
CATCH {
90+
nqp::buildnativecall($printf, 'msvcrt.dll', 'printf', '', [$arg_hash], $return_hash);
91+
}
92+
}
8493
nqp::nativecall(nqp::null(), $printf, [$dupped]);
8594

8695
# vim: ft=perl6

0 commit comments

Comments
 (0)