primitive support of variadic arguments
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-05-02 22:36:50 +09:00
parent 4fbbe049ba
commit e28faca54e
9 changed files with 238 additions and 23 deletions

View File

@ -641,6 +641,10 @@ function main()
tap_ensure (str::match(b @b"what is this", /10/, 1, a), 5, @SCRIPTNAME, @SCRIPTLINE);
tap_ensure (RSTART, 5, @SCRIPTNAME, @SCRIPTLINE);
tap_ensure (RLENGTH, 2, @SCRIPTNAME, @SCRIPTLINE);
tap_ensure (test5(10, 20, 30), 10, @SCRIPTNAME, @SCRIPTLINE);
tap_ensure (test6(1, 2, 3, 4, 5, 6, 7, 8, 9, 10), 54, @SCRIPTNAME, @SCRIPTLINE);
tap_ensure (test7(1, 2, 3, 4, 5, 6, 7, 8, 9, 10), 55, @SCRIPTNAME, @SCRIPTLINE);
}
tap_end ();
}
@ -649,3 +653,21 @@ function test1(&foo) { test2(foo) }
function test2(&bar) { bar[1] = 1 }
function test3(foo) { test2(foo) }
function test4(bar) { bar[1] = 1 }
function test5(a, b, ...) {
return a;
}
function test6(a, ...) {
@local i, x
x = 0
for (i = 0; i < @argc(); i++) x += @argv(i);
return x - a;
}
function test7(...) {
@local i, x
x = 0
for (i = 0; i < @argc(); i++) x += @argv(i);
return x;
}