(The order of definitions in this file is significant, as
some of the tests--e.g., RoutineCalling--depend on particular
objects/properties/etc. having specific numbers.)
\!
$MAXDICTEXTEND=32
constant HUGO_VERSION "v2.5"
#switches -d
global errors
routine main
{
local r
local transcription
"Testing core functions of Hugo ";
print HUGO_VERSION; "\n"
"Save output transcription? ";
pause
print ""
if word[0] = 'y' or word[0] = 'Y'
{
r = scripton
if r: transcription = true
}
MathTests ! basic math
PropAttrTests ! property/attribute tests
RoutineCalling ! routine calling tests
InitTests ! initialization tests
Overflow ! overflow tests
DictTests ! dictionary tests
"\nTests complete: ";
if errors
print "\B"; number errors; " error(s)\b"
else
print "No errors"
"Press a key...";
pause
if transcription: r = scriptoff
return
}
!----------------------------------------------------------------------------
! BASIC MATH TESTS:
routine MathTests
{
local a = 10
local b = 20
local c = 5
local r
"\nBASIC MATH TESTS:"
"-----------------"
print "a = "; number a ; ", b = "; number b; ", c = "; number c; "\n"
"a + b * c = ";
r = a + b * c
print number r; Test(r, 110);
"b / c + a = ";
r = b / c + a
print number r; Test(r, 14);
"b / a / c = ";
r = b / a / c
print number r; Test(r, 0);
"b = 20 and a / 2 = c : ";
r = b = 20 and a / 2 = c
print IsTrue(r); Test(r, 1);
"b = 10 or a / 5 = c : ";
r = b = 10 or a / 5 = c
print IsTrue(r); Test(r, 0);
"b = 10 or a / 2 = c : ";
r = b = 10 or a / 2 = c
print IsTrue(r); Test(r, 1);
"a = 5 and b / 4 = c = 5 : ";
r = a = 5 and b / 4 = c = 5
print IsTrue(r); Test(r, 0);
"b / 4 = c = 1 : ";
r = b / 4 = c = 1
print IsTrue(r); Test(r, 1);
"c = b / 4 = 1 : ";
r = c = b / 4 = 1
print IsTrue(r); Test(r, 1);
"(a = 5 or b = 20) and (c = a / 2) : ";
r = (a = 5 or b = 20) and (c = a / 2)
print IsTrue(r); Test(r, 1);
"(a = 10) and (b = 5, 10, 15, 20, 25) : ";
if (a = 10) and (b = 5, 10, 15, 20, 25)
print "true";
else
print "false";
Test(((a = 10) and (b = 5, 10, 15, 20, 25)), 1)
"(a = 20, 10, 5) or (c = b / (2+2)) : ";
r = (a = 20, 10, 5) or (c = b / (2+2))
print IsTrue(r); Test(r, 1);
}
routine IsTrue(a)
{
if a
"true";
else
"false";
}
routine Test(a, b)
{
if a = b
" (PASSED)"
else
{
" \B(FAILED)\b"
errors++
}
}
#message "(NOTE: The following six warnings are expected)"
print "Properties: "; number o1.p1; ", "; number o1.p2; ", "; \
number o1.p3;
Test((o1.p1 = 0 and o1.p2 = 25 and o1.p3 = -25), 1)
print "Globals: "; number g1; ", "; number g2; ", "; number g3;
Test((g1 = 0 and g2 = 35 and g3 = -35), 1)
print "Constants: "; number c1; ", "; number c2;
Test((c1 = 4 and c2 = -5), 1)
print "Enumerated constants: "; number e1; ", "; number e2; ", "; \
number e3; ", "; number e4; ", "; number e5;
Test((e1 = 5 and e2 = -10 and e3 = 20 and e4 = -10 and e5 = 20), 1)
}
w = dict(apple, 5) ! w should become 30 (in dictionary table)
print "Testing dict(): "; number w; Test(w, 30);
string(apple2, w, 5)
print "Testing string(): ";
for (i=0; i<5; i++)
printchar apple2[i]
Test((apple2[0]='a' and apple2[1]='p' and apple2[2]='p' and
apple2[3]='l' and apple2[4]='e'), 1)
}
Files without descriptions:
9grtest.zip /if-archive/programming/hugo/utilities/grtest.zip
4hugofiletyper.sit /if-archive/programming/hugo/utilities/hugofiletyper.sit
5iotest.exe /if-archive/programming/hugo/utilities/iotest.exe