fixed a bug in handling a reference value in hawk::call()

This commit is contained in:
2020-04-14 11:45:52 +00:00
parent c7961f84d2
commit ef9db73f19
3 changed files with 25 additions and 20 deletions

View File

@ -1,10 +1,11 @@
@pragma entry main
function ensure (a, b, desc)
{
if (a != b)
{
print "FAILURE", desc;
print "FAILURE in", desc;
exit (-1);
}
}
@ -18,6 +19,7 @@ function call_by_ref_1(&a, b, &c)
function call_by_ref_2(a, &b)
{
b[1] = b[1] * a;
b[2] = "perfect";
return a;
}
@ -27,12 +29,13 @@ function main()
x = 20;
y = 90;
r = call_by_ref_1(x, y, z);
ensure (r, 1800);
ensure (r, 1800, SCRIPTNAME);
ensure (x, 20);
ensure (y, 90);
ensure (z, "hello, world");
## TODO: add a new special word, @FILENAME, @FILELINE, @LINE <--- which are understood by the parser and swapped to the actual value
## SCRIPTNAME doesn't tell the main file.
{
@local b;
@ -53,7 +56,9 @@ function main()
b[1] = 1;
r = hawk::call("call_by_ref_2", 99, b);
ensure (r, 99);
ensure (b[1], 99);
ensure (length(b), 2, SCRIPTNAME);
ensure (b[1], 99, SCRIPTNAME);
ensure (b[2], "perfect", SCRIPTNAME);
}
print "SUCCESS"