1
0
Fork 0
mirror of https://github.com/ganelson/inform.git synced 2024-07-16 22:14:23 +03:00
inform7/inter/pipeline-module/Chapter 5/Tests.w

82 lines
2.9 KiB
OpenEdge ABL
Raw Normal View History

2021-05-22 11:49:04 +03:00
[SynopticTests::] Tests.
To compile the main/synoptic/tests submodule.
@ Our inventory |inv| already contains a list |inv->test_nodes| of all packages
in the tree with type |_test|.
2021-05-22 11:49:04 +03:00
=
2021-11-15 01:40:33 +02:00
void SynopticTests::compile(inter_tree *I, pipeline_step *step, tree_inventory *inv) {
2022-02-03 01:35:38 +02:00
if (InterNodeList::array_len(inv->test_nodes) > 0)
InterNodeList::array_sort(inv->test_nodes, MakeSynopticModuleStage::module_order);
2021-05-22 11:49:04 +03:00
@<Define TESTSCRIPTSUB function@>;
}
@ This is the function run when the command TEST is typed into the command parser
at runtime.
2021-05-22 11:49:04 +03:00
@<Define TESTSCRIPTSUB function@> =
2022-01-16 01:49:25 +02:00
inter_name *iname = HierarchyLocations::iname(I, TESTSCRIPTSUB_HL);
2021-05-22 11:49:04 +03:00
Synoptic::begin_function(I, iname);
2022-02-03 01:35:38 +02:00
if (InterNodeList::array_len(inv->test_nodes) == 0) {
2021-05-22 11:49:04 +03:00
Produce::inv_primitive(I, PRINT_BIP);
Produce::down(I);
Produce::val_text(I, I">--> No test scripts exist for this game.\n");
Produce::up(I);
} else {
Produce::inv_primitive(I, SWITCH_BIP);
Produce::down(I);
2022-01-16 01:49:25 +02:00
Produce::val_iname(I, K_value, HierarchyLocations::iname(I, SPECIAL_WORD_HL));
2021-05-22 11:49:04 +03:00
Produce::code(I);
Produce::down(I);
2022-02-03 01:35:38 +02:00
for (int i=0; i<InterNodeList::array_len(inv->test_nodes); i++) {
2022-03-01 02:41:22 +02:00
inter_package *pack = PackageInstruction::at_this_head(inv->test_nodes->list[i].node);
text_stream *name = Metadata::required_textual(pack, I"^name");
2021-05-22 11:49:04 +03:00
inter_ti len = Metadata::read_numeric(pack, I"^length");
inter_symbol *text_s = Synoptic::get_symbol(pack, I"script");
inter_symbol *req_s = Synoptic::get_symbol(pack, I"requirements");
Produce::inv_primitive(I, CASE_BIP);
Produce::down(I);
Produce::val_dword(I, name);
Produce::code(I);
Produce::down(I);
2022-01-16 01:49:25 +02:00
Produce::inv_call_iname(I, HierarchyLocations::iname(I, TESTSTART_HL));
2021-05-22 11:49:04 +03:00
Produce::down(I);
Produce::val_symbol(I, K_value, text_s);
Produce::val_symbol(I, K_value, req_s);
Produce::val(I, K_value, InterValuePairs::number(len));
2021-05-22 11:49:04 +03:00
Produce::up(I);
Produce::up(I);
Produce::up(I);
}
Produce::inv_primitive(I, DEFAULT_BIP);
Produce::down(I);
Produce::code(I);
Produce::down(I);
Produce::inv_primitive(I, PRINT_BIP);
Produce::down(I);
Produce::val_text(I, I">--> The following tests are available:\n");
Produce::up(I);
2022-02-03 01:35:38 +02:00
for (int i=0; i<InterNodeList::array_len(inv->test_nodes); i++) {
2021-05-22 11:49:04 +03:00
inter_package *pack =
2022-03-01 02:41:22 +02:00
PackageInstruction::at_this_head(inv->test_nodes->list[i].node);
text_stream *name = Metadata::required_textual(pack, I"^name");
2021-05-22 11:49:04 +03:00
TEMPORARY_TEXT(T)
WRITE_TO(T, "'test %S'\n", name);
Produce::inv_primitive(I, PRINT_BIP);
Produce::down(I);
Produce::val_text(I, T);
Produce::up(I);
DISCARD_TEXT(T)
}
Produce::inv_primitive(I, PRINT_BIP);
Produce::down(I);
Produce::val_text(I, I"\n");
Produce::up(I);
Produce::up(I);
Produce::up(I);
Produce::up(I);
Produce::up(I);
}
2021-11-15 01:40:33 +02:00
Synoptic::end_function(I, step, iname);