Skip to content

Commit

Permalink
add tests for "Pointer is rw", bump nqp/moar
Browse files Browse the repository at this point in the history
  • Loading branch information
FROGGS committed Dec 1, 2015
1 parent 88a8a00 commit 2b5c41e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
10 changes: 10 additions & 0 deletions t/04-nativecall/15-rw-args.c
@@ -1,3 +1,4 @@
#include <stdlib.h>
#ifdef _WIN32
#define DLLEXPORT __declspec(dllexport)
#else
Expand Down Expand Up @@ -43,3 +44,12 @@ DLLEXPORT void SetULong(unsigned long *lng) {
DLLEXPORT void SetULongLong(unsigned long long *llg) {
*llg = 15324;
}

DLLEXPORT int SetPtrToPtr(int **ptr) {
if (ptr == NULL) {
return 0;
}

*ptr = (int *)42;
return 1;
}
7 changes: 6 additions & 1 deletion t/04-nativecall/15-rw-args.t
Expand Up @@ -4,7 +4,7 @@ use lib 'lib';
use NativeCall;
use Test;

plan 10;
plan 12;

compile_test_lib('15-rw-args');

Expand All @@ -18,6 +18,7 @@ sub SetUChar(uint8 is rw) is native('./15-rw-args') { * }
sub SetUShort(uint16 is rw) is native('./15-rw-args') { * }
sub SetULong(ulong is rw) is native('./15-rw-args') { * }
sub SetULongLong(ulonglong is rw) is native('./15-rw-args') { * }
sub SetPtrToPtr(Pointer is rw) returns int32 is native('./15-rw-args') { * }

my int8 $c; SetChar($c);
is $c, 97, 'Perl\'s rw variable was set by C (char)';
Expand Down Expand Up @@ -50,4 +51,8 @@ is $ul, 777, 'Perl\'s rw variable was set by C (unsigned long)';
my ulonglong $ull; SetULongLong($ull);
is $ull, 15324, 'Perl\'s rw variable was set by C (unsigned long long)';

my Pointer $ptr .= new;
ok SetPtrToPtr($ptr), 'Can pass an instantiated pointer with rw-trait to C';
is +$ptr, 42, 'Perl\'s rw variable was set by C (pointer)';

# vim:ft=perl6
2 changes: 1 addition & 1 deletion tools/build/NQP_REVISION
@@ -1 +1 @@
2015.11-21-g9559a26
2015.11-22-g9baf227

0 comments on commit 2b5c41e

Please sign in to comment.