-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-physical-laws.ts
67 lines (51 loc) · 2.42 KB
/
test-physical-laws.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
///<reference path="lib/node.d.ts"/>
import {TextWorld} from "./TextWorld";
import {ExampleWorlds} from "./ExampleWorlds";
import {ShrdliteResult} from "./Types";
import {parse} from "./Parser";
import {interpret} from "./Interpreter";
import {TestCase, testCases} from "./InterpreterTestCases";
import {physical_laws} from "./Interpreter"
import {SimpleObject} from "./Types"
/********************************************************************************
** test-interpreter
This is the main file for testing the interpreter implementation in Interpreter.ts.
It tests against several test cases that are defined in InterpreterTestCases.ts
You should not edit this file.
********************************************************************************/
function runTest(testcase : TestCase) : boolean {
console.log('/// \n');
var obj1 : SimpleObject = new SimpleObject("small", "blue", "ball");
var string_action : string = "ontop";
var obj2 : SimpleObject = new SimpleObject("large", "blue", "floor");
var string_test : string = physical_laws(string_action, obj1, obj2);
console.log("Checking instruction :", obj1.toStringAdv(), string_action, obj2.toStringAdv(), ":");
console.log(string_test);
// obj1 = new SimpleObject("large", "blue", "plank");
// string_action = "inside";
// obj2 = new SimpleObject("small", "blue", "ball");
// string_test = physical_laws(string_action, obj1, obj2);
// console.log("Checking instruction :", obj1.toStringAdv(), string_action, obj2.toStringAdv(), ":");
// console.log(string_test);
// obj1 = new SimpleObject("small", "blue", "ball");
// string_action = "ontop";
// obj2 = new SimpleObject("large", "blue", "table");
// string_test = physical_laws(string_action, obj1, obj2);
// console.log("Checking instruction :", obj1.toStringAdv(), string_action, obj2.toStringAdv(), ":");
// console.log(string_test);
return false;
}
function runAllTests(argv : string[]) {
var result = runTest(testCases[0]);
}
try {
runAllTests(process.argv.slice(2));
} catch(err) {
console.log();
console.log("ERROR: " + err);
console.log();
console.log("Please give at least one argument:");
console.log("- either a number (0.." + (testCases.length-1) + ") for each test you want to run,");
console.log("- or 'all' for running all tests.");
console.log();
}