Skip to content

Commit

Permalink
Test argless native functions returning strings
Browse files Browse the repository at this point in the history
  • Loading branch information
niner committed Sep 19, 2017
1 parent 5d6d69f commit 73bd7ec
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
6 changes: 6 additions & 0 deletions t/04-nativecall/01-argless.c
Expand Up @@ -33,6 +33,12 @@ DLLEXPORT int* ArglessPointer()
return &my_int;
}

char *my_str = "Just a string";
DLLEXPORT int* ArglessUTF8String()
{
return my_str;
}

DLLEXPORT int long_and_complicated_name()
{
return 3;
Expand Down
12 changes: 7 additions & 5 deletions t/04-nativecall/01-argless.t
Expand Up @@ -5,7 +5,7 @@ use CompileTestLib;
use NativeCall;
use Test;

plan 12;
plan 14;

compile_test_lib('01-argless');

Expand All @@ -14,16 +14,18 @@ sub Argless() is native('./01-argless') returns int32 { * }
sub ArglessChar() is native('./01-argless') returns int8 { * }
sub ArglessLongLong() is native('./01-argless') returns int64 { * }
sub ArglessPointer() is native('./01-argless') returns Pointer[int32] { * }
sub ArglessUTF8String() is native('./01-argless') returns Str { * }
sub short() is native('./01-argless') returns int32 is symbol('long_and_complicated_name') { * }

Nothing() for ^2;

pass 'survived the call';

is Argless(), 2, 'called argless function' for ^2;
is ArglessChar(), 2, 'called argless function' for ^2;
is ArglessLongLong(), 2, 'called argless function' for ^2;
is ArglessPointer().deref, 2, 'called argless function' for ^2;
is Argless(), 2, 'called argless function returning int32' for ^2;
is ArglessChar(), 2, 'called argless function returning char' for ^2;
is ArglessLongLong(), 2, 'called argless function returning long long' for ^2;
is ArglessPointer().deref, 2, 'called argless function returning pointer' for ^2;
is ArglessUTF8String(), 'Just a string', 'called argless function returning string' for ^2;

is short(), 3, 'called long_and_complicated_name';

Expand Down

0 comments on commit 73bd7ec

Please sign in to comment.