Uses 911K of libraries. Click here for Pure Java version (11778L/66K).
1 | !7 |
2 | |
3 | cmodule TestPhilosophyEngine > DynPrintLog { |
4 | sS program = [[ |
5 | program ( |
6 | count |
7 | |
8 | count => proc { |
9 | while (i < 100): |
10 | inc i |
11 | } |
12 | ) with declarations (static int i;) |
13 | and init code ( |
14 | bot.addNativePredicate("i < 100", |
15 | () -> i < 100); |
16 | bot.addNativePredicate("inc i", |
17 | () -> { |
18 | ++i; |
19 | print("Incremented i to " + i); |
20 | true; |
21 | }); |
22 | ) should end with (i == 100) |
23 | ]]; |
24 | |
25 | start-thread { |
26 | new PhilosophyBot1 main; |
27 | main.program = program; |
28 | main.run(); |
29 | pnl(main.facts); |
30 | |
31 | for (SS map : main.matchFacts( |
32 | [[ program var_p |
33 | with declarations var_d |
34 | and init code var_i |
35 | should end with var_c |
36 | ]])) { |
37 | S program = map.get("var_p"), declarations = map.get("var_d"), |
38 | initCode = map.get("var_i"), endCondition = map.get("var_c"); |
39 | printVars(+program, +endCondition); |
40 | |
41 | // Now build some JavaX code! |
42 | |
43 | S javax = joinWithEmptyLines( |
44 | declarations, |
45 | "static new PhilosophyBot1 bot;", |
46 | "p {", |
47 | "bot.program = " + quote(program) + ";", |
48 | initCode, |
49 | "bot.run();", |
50 | "assertTrueVerbose(" + endCondition + ");", |
51 | "}"); |
52 | |
53 | printWithIndent("JAVAX> ", javax); |
54 | |
55 | // do the JavaX super-magic |
56 | |
57 | Class c = veryQuickJava(javax); |
58 | |
59 | // now we can call the function we just made |
60 | |
61 | callMain(c); |
62 | |
63 | // assert succeeded, so we're good |
64 | |
65 | print("Test succeeded!"); |
66 | } |
67 | } |
68 | } |
download show line numbers debug dex old transpilations
Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1025616 |
Snippet name: | Auto-Test philosophy engine with counter example [broken?] |
Eternal ID of this version: | #1025616/19 |
Text MD5: | efc444cf4af5a6007179ce9abbf3ca6a |
Transpilation MD5: | 11ed1d84e1cfb3acd4dc0f451c56e9d3 |
Author: | stefan |
Category: | |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-10-17 14:49:05 |
Source code size: | 1594 bytes / 68 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 303 / 1000 |
Version history: | 18 change(s) |
Referenced in: | [show references] |