以不同顺序执行时测试失败

Fer*_*ata 4 testing raku

当我执行此程序时:

use Test;
use NativeCall;

constant LIB  = ('gsl', v23);

sub gsl_sf_airy_Ai(num64 $x, uint32 $mode --> num64) is native(LIB) is export { * }
sub Ai(Numeric $x, UInt $mode --> Num) is export { gsl_sf_airy_Ai($x.Num, $mode) }

ok Ai(0, 0) == 0.3550280538878172, 'Ai 1';
ok gsl_sf_airy_Ai(0e0, 0) == 0.3550280538878172, 'Ai 2';
Run Code Online (Sandbox Code Playgroud)

即使我以这种方式交换两个“确定”的测试,测试也可以正常工作:

ok gsl_sf_airy_Ai(0e0, 0) == 0.3550280538878172, 'Ai 2';
ok Ai(0, 0) == 0.3550280538878172, 'Ai 1';
Run Code Online (Sandbox Code Playgroud)

如果我将声明移至模块:

unit module mymodule;
use NativeCall;

constant LIB  = ('gsl', v23);

sub gsl_sf_airy_Ai(num64 $x, uint32 $mode --> num64) is native(LIB) is export { * }
sub Ai(Numeric $x, UInt $mode --> Num) is export { gsl_sf_airy_Ai($x.Num, $mode) }
Run Code Online (Sandbox Code Playgroud)

并编写一个测试程序:

use Test;
use lib '.';
use mymodule;

ok Ai(0, 0) == 0.3550280538878172, 'Ai 1';
ok gsl_sf_airy_Ai(0e0, 0) == 0.3550280538878172, 'Ai 2';
Run Code Online (Sandbox Code Playgroud)

再次执行两个测试,没有错误,但是如果我交换最后两行:

ok gsl_sf_airy_Ai(0e0, 0) == 0.3550280538878172, 'Ai 2';
ok Ai(0, 0) == 0.3550280538878172, 'Ai 1';
Run Code Online (Sandbox Code Playgroud)

我收到此错误: Type check failed for return value; expected Num but got Whatever (*)我不明白为什么。我什至怀疑可能存在内存损坏,因此我使用valgrind执行了测试程序,但显然该部门没有错。有什么提示吗?

小智 5

Please re-test on the recently released rakudo 2019.11. There's a high chance that I already fixed this when I refactored the NativeCall setup code.