mirror of
https://github.com/ganelson/inform.git
synced 2024-07-08 01:54:21 +03:00
178 lines
4.1 KiB
INI
Executable file
178 lines
4.1 KiB
INI
Executable file
Constant Story "IndivPropTest";
|
|
Constant Headline "Not a game.^";
|
|
|
|
Release 1;
|
|
|
|
! This is a compiler unit test for "Property individual" declarations.
|
|
|
|
#ifdef TARGET_ZCODE;
|
|
Constant HDR_GAMERELEASE = $02; ! word
|
|
Constant HDR_GAMESERIAL = $12; ! six ASCII characters
|
|
#ifnot;
|
|
Global gg_mainwin;
|
|
Constant HDR_GLULXVERSION $04; ! long word
|
|
Constant ROM_GAMERELEASE $34; ! short word
|
|
Constant ROM_GAMESERIAL $36; ! six ASCII characters
|
|
#endif; ! TARGET_GLULX
|
|
|
|
Global failures;
|
|
|
|
[ Main;
|
|
#ifdef TARGET_GLULX;
|
|
@setiosys 2 0;
|
|
@push 201; @push 3; @push 0; @push 0; @push 0;
|
|
@glk $0023 5 gg_mainwin;
|
|
|
|
@push gg_mainwin;
|
|
@glk $002F 1 0;
|
|
#endif; ! TARGET_GLULX
|
|
|
|
Banner();
|
|
new_line;
|
|
RunTest();
|
|
];
|
|
|
|
[ Banner ix;
|
|
if (Story ~= 0) {
|
|
#ifdef TARGET_ZCODE;
|
|
#ifV5; style bold; #Endif;
|
|
print (string) Story;
|
|
#ifV5; style roman; #Endif;
|
|
#ifnot; ! TARGET_GLULX;
|
|
glk($0086, 3); ! set header style
|
|
print (string) Story;
|
|
glk($0086, 0); ! set normal style
|
|
#Endif; ! TARGET_
|
|
}
|
|
if (Headline ~= 0) print ": ", (string) Headline;
|
|
#ifdef TARGET_ZCODE;
|
|
print "Release ", (HDR_GAMERELEASE-->0) & $03ff, " / Serial number ";
|
|
for (ix=0 : ix<6 : ix++) print (char) HDR_GAMESERIAL->ix;
|
|
#ifnot; ! TARGET_GLULX;
|
|
print "Release ";
|
|
@aloads ROM_GAMERELEASE 0 ix;
|
|
print ix;
|
|
print " / Serial number ";
|
|
for (ix=0 : ix<6 : ix++) print (char) ROM_GAMESERIAL->ix;
|
|
#Endif; ! TARGET_
|
|
print " / Inform v"; inversion;
|
|
print ", compiler options ";
|
|
ix = false;
|
|
#ifdef STRICT_MODE;
|
|
print "S"; ix++;
|
|
#Endif; ! STRICT_MODE
|
|
#ifdef INFIX;
|
|
print "X"; ix++;
|
|
#ifnot;
|
|
#ifdef DEBUG;
|
|
print "D"; ix++;
|
|
#Endif; ! DEBUG
|
|
#Endif; ! INFIX
|
|
if (~~ix) print "(none)";
|
|
new_line;
|
|
|
|
#ifdef TARGET_GLULX;
|
|
@gestalt 1 0 ix;
|
|
print "Interpreter version ", ix / $10000, ".", (ix & $FF00) / $100,
|
|
".", ix & $FF, " / ";
|
|
@gestalt 0 0 ix;
|
|
print "VM ", ix / $10000, ".", (ix & $FF00) / $100, ".", ix & $FF, " / ";
|
|
ix = HDR_GLULXVERSION-->0;
|
|
print "game file format ", ix / $10000, ".", (ix & $FF00) / $100, ".", ix & $FF, "^";
|
|
#Endif; ! TARGET_GLULX
|
|
];
|
|
|
|
[ check_value val1 val2;
|
|
print val1;
|
|
if (val1 ~= val2) {
|
|
failures++;
|
|
print " (ERROR, should be ", val2, ")";
|
|
}
|
|
];
|
|
|
|
Property common1;
|
|
Property common2 2;
|
|
|
|
! Defining DEF_INDIV1 does not change the compiled game, because indiv1 gets implicitly declared by obj1 whether or not it's declared here.
|
|
|
|
#ifdef DEF_INDIV1;
|
|
Property individual indiv1;
|
|
#endif;
|
|
|
|
! Defining DEF_INDIV2 *does* change the compiled game, because obj1 declares indivextra before obj declares indiv2. So if we declare indiv2 here, it changes the order that the properties appear in. However, the *behavior* of the compiled game is the same!
|
|
|
|
#ifdef DEF_INDIV2;
|
|
Property individual indiv2;
|
|
#endif;
|
|
|
|
Object obj1
|
|
with common1 11,
|
|
with indiv1 111,
|
|
with indivextra 37;
|
|
|
|
Object obj2
|
|
with indiv1 112,
|
|
with indiv2 223;
|
|
|
|
[ RunTest;
|
|
|
|
print "obj1 provides common1: ";
|
|
check_value(obj1 provides common1, true);
|
|
print ".^";
|
|
|
|
print "obj1 provides common2: ";
|
|
check_value(obj1 provides common2, false);
|
|
print ".^";
|
|
|
|
print "obj1 provides indiv1: ";
|
|
check_value(obj1 provides indiv1, true);
|
|
print ".^";
|
|
|
|
print "obj1 provides indivextra: ";
|
|
check_value(obj1 provides indivextra, true);
|
|
print ".^";
|
|
|
|
print "obj1.common1: ";
|
|
check_value(obj1.common1, 11);
|
|
print ".^";
|
|
|
|
print "obj1.common2: ";
|
|
check_value(obj1.common2, 2);
|
|
print ".^";
|
|
|
|
print "obj1.indiv1: ";
|
|
check_value(obj1.indiv1, 111);
|
|
print ".^";
|
|
|
|
print "obj1.indivextra: ";
|
|
check_value(obj1.indivextra, 37);
|
|
print ".^";
|
|
|
|
print "obj2.indiv1: ";
|
|
check_value(obj2.indiv1, 112);
|
|
print ".^";
|
|
|
|
print "obj2.indiv2: ";
|
|
check_value(obj2.indiv2, 223);
|
|
print ".^";
|
|
|
|
print "obj2 provides indiv1: ";
|
|
check_value(obj2 provides indiv1, true);
|
|
print ".^";
|
|
|
|
print "obj2 provides indiv2: ";
|
|
check_value(obj2 provides indiv2, true);
|
|
print ".^";
|
|
|
|
print "obj2 provides indivextra: ";
|
|
check_value(obj2 provides indivextra, false);
|
|
print ".^";
|
|
|
|
new_line;
|
|
if (failures == 0)
|
|
print "All passed.^";
|
|
else
|
|
print failures, " errors!^";
|
|
];
|
|
|