Files
hawk/t/h-004.hawk

55 lines
1.3 KiB
Plaintext
Raw Normal View History

2024-04-23 00:39:01 +09:00
@pragma entry main
@pragma implicit off
@include "tap.inc";
function run_getline_test()
{
@local x, b;
b = "stale ...";
## getlbine must return -1 if the file is not found and reset the variable blank.
x = (getbline b < "/non-existent-dir/non-existent-file.dat");
tap_ensure(x, -1, @SCRIPTNAME, @SCRIPTLINE);
tap_ensure(b, "", @SCRIPTNAME, @SCRIPTLINE);
## getline must return -1 if the file is not found and reset the variable blank.
x = (getline b < "/non-existent-dir/non-existent-file.dat");
tap_ensure(x, -1, @SCRIPTNAME, @SCRIPTLINE);
tap_ensure(b, "", @SCRIPTNAME, @SCRIPTLINE);
}
2024-04-23 00:39:01 +09:00
function run_gc_test ()
{
@local i, a, b, ts, pr, cpr;
tap_ensure (hawk::GC_NUM_GENS, 3, @SCRIPTNAME, @SCRIPTLINE);
hawk::gc_set_threshold(0, 30);
ts = hawk::gc_get_threshold(0);
tap_ensure (ts, 30, @SCRIPTNAME, @SCRIPTLINE);
pr = hawk::gc_get_pressure(0);
for (i = 0; i < 50; i++)
{
a[1] = 999; ## there is only 1 allocation that's concerting GC in the current implementation
b = a;
b = @nil;
a = @nil;
cpr = hawk::gc_get_pressure(0);
if (pr + i + 1 <= ts)
tap_ensure (cpr, pr + i + 1, @SCRIPTNAME, @SCRIPTLINE);
else ## gc kicks in when the pressure reaches the threshold, the pressure drops...
tap_ensure (cpr, (pr + i + 1) - ts, @SCRIPTNAME, @SCRIPTLINE);
}
}
function main()
{
run_getline_test();
2024-04-23 00:39:01 +09:00
run_gc_test();
tap_end ();
}