added a small test case for gc
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
27bf77b51e
commit
9271fae745
@ -13,7 +13,7 @@ LDFLAGS_COMMON=-L$(abs_builddir)/../lib -L$(libdir)
|
||||
## for more information.
|
||||
LIBADD_COMMON = ../lib/libhawk.la $(LIBM)
|
||||
|
||||
check_SCRIPTS = h-001.hawk h-002.hawk h-003.hawk h-009.hawk
|
||||
check_SCRIPTS = h-001.hawk h-002.hawk h-003.hawk h-004.hawk h-009.hawk
|
||||
##noinst_SCRIPTS = $(check_SCRIPTS)
|
||||
EXTRA_DIST = $(check_SCRIPTS) tap.inc \
|
||||
journal-toc.hawk journal-toc.in journal-toc.out journal-toc-html.out \
|
||||
|
@ -578,7 +578,7 @@ CPPFLAGS_COMMON = \
|
||||
CFLAGS_COMMON =
|
||||
LDFLAGS_COMMON = -L$(abs_builddir)/../lib -L$(libdir)
|
||||
LIBADD_COMMON = ../lib/libhawk.la $(LIBM)
|
||||
check_SCRIPTS = h-001.hawk h-002.hawk h-003.hawk h-009.hawk
|
||||
check_SCRIPTS = h-001.hawk h-002.hawk h-003.hawk h-004.hawk h-009.hawk
|
||||
EXTRA_DIST = $(check_SCRIPTS) tap.inc \
|
||||
journal-toc.hawk journal-toc.in journal-toc.out journal-toc-html.out \
|
||||
bibtex-to-html.hawk bibtex-to-html.out
|
||||
|
@ -420,7 +420,7 @@ function do_cite(s, k,n,labels,t)
|
||||
function do_line( n,name,s)
|
||||
{
|
||||
s = protect_SGML_characters($0)
|
||||
|
||||
|
||||
if (match(s,STRING_PATTERN)) # remember name from @String{name = "value"}
|
||||
{
|
||||
name = substr(s,RSTART + STRING_OFFSET,RLENGTH - STRING_OFFSET)
|
||||
@ -520,7 +520,7 @@ function protect_SGML_characters(s)
|
||||
gsub(/</,"\\<",s)
|
||||
gsub(/>/,"\\>",s)
|
||||
|
||||
## [24-May-2016] with the change from HTML 3.2 to 4.0, we can use " again!
|
||||
## [24-May-2016] with the change from HTML 3.2 to 4.0, we can use " again!
|
||||
## gsub(/\"/,"\\"",s) # this was " in earlier HTML
|
||||
# versions, including the HTML 3.2
|
||||
# draft, but was stupidly eliminated in
|
||||
|
16
t/h-001.hawk
16
t/h-001.hawk
@ -136,7 +136,7 @@ function main()
|
||||
|
||||
x = 20;
|
||||
y = 90;
|
||||
r = call_by_ref_1(x, y, z);
|
||||
r = call_by_ref_1(x, y, z);
|
||||
tap_ensure (r, 1800, @SCRIPTNAME, @SCRIPTLINE);
|
||||
tap_ensure (x, 20, @SCRIPTNAME, @SCRIPTLINE);
|
||||
tap_ensure (y, 90, @SCRIPTNAME, @SCRIPTLINE);
|
||||
@ -179,7 +179,7 @@ function main()
|
||||
{
|
||||
@local a;
|
||||
a[1] = hawk::array();
|
||||
a[1][2]=20;
|
||||
a[1][2]=20;
|
||||
tap_ensure (a[1][2], 20, @SCRIPTNAME, @SCRIPTLINE);
|
||||
a[1][2]++;
|
||||
tap_ensure (a[1][2], 21, @SCRIPTNAME, @SCRIPTLINE);
|
||||
@ -217,22 +217,22 @@ function main()
|
||||
{
|
||||
@local a, i;
|
||||
|
||||
a = hawk::array();
|
||||
a = hawk::array();
|
||||
tap_ensure (length(a), 0, @SCRIPTNAME, @SCRIPTLINE);
|
||||
|
||||
for (i = 0; i < 10; i++) a[i*i]=i;
|
||||
|
||||
for (i = 0; i < 10; i++) a[i*i]=i;
|
||||
tap_ensure (length(a), 10, @SCRIPTNAME, @SCRIPTLINE);
|
||||
|
||||
delete a[0];
|
||||
tap_ensure (length(a), 9, @SCRIPTNAME, @SCRIPTLINE);
|
||||
|
||||
delete a[81];
|
||||
delete a[81];
|
||||
tap_ensure (length(a), 8, @SCRIPTNAME, @SCRIPTLINE);
|
||||
|
||||
delete a[36];
|
||||
delete a[36];
|
||||
tap_ensure (length(a), 7, @SCRIPTNAME, @SCRIPTLINE);
|
||||
|
||||
for (i = 0; i < 10; i++) delete a[i*i];
|
||||
for (i = 0; i < 10; i++) delete a[i*i];
|
||||
tap_ensure (length(a), 0, @SCRIPTNAME, @SCRIPTLINE);
|
||||
|
||||
delete a;
|
||||
|
10
t/h-003.hawk
10
t/h-003.hawk
@ -6,7 +6,7 @@
|
||||
function are_files_identical(a, b)
|
||||
{
|
||||
@local f1, f2, x, y, diff;
|
||||
|
||||
|
||||
f1 = sys::open(a, sys::O_RDONLY);
|
||||
if (f1 <= -1)
|
||||
{
|
||||
@ -25,7 +25,7 @@ function are_files_identical(a, b)
|
||||
diff = 0;
|
||||
while (sys::read(f1, x, 1) > 0)
|
||||
{
|
||||
if (sys::read(f2, y, 1) <= 0 || x !== y)
|
||||
if (sys::read(f2, y, 1) <= 0 || x !== y)
|
||||
{
|
||||
diff = 1;
|
||||
break;
|
||||
@ -58,12 +58,12 @@ function run_test (x, more_opts, in_name, set_out_name, out_name)
|
||||
else
|
||||
{
|
||||
cmd=sprintf("%s %s -f %s/%s.hawk --modlibdirs=%s %s > %s", ARGV[0], more_opts, TDIR, x, hawk::modlibdirs(), inf, outf);
|
||||
}
|
||||
}
|
||||
##print cmd;
|
||||
system (cmd);
|
||||
|
||||
|
||||
same = are_files_identical(expf, outf);
|
||||
if (same <= 0)
|
||||
if (same <= 0)
|
||||
{
|
||||
## don't delete the output file for review.
|
||||
tap_fail (sprintf("%s[%d] %s - %s and %s differ", @SCRIPTNAME, @SCRIPTLINE, x, expf, outf));
|
||||
|
37
t/h-004.hawk
Normal file
37
t/h-004.hawk
Normal file
@ -0,0 +1,37 @@
|
||||
@pragma entry main
|
||||
@pragma implicit off
|
||||
|
||||
@include "tap.inc";
|
||||
|
||||
|
||||
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_gc_test();
|
||||
tap_end ();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user