Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

42
LINES

< > BotCompany Repo | #1002755 // Run test case on logic engine

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (3781L/25K/79K).

1  
!759
2  
3  
p {
4  
  O engine = run_overBot("#1002751");
5  
  
6  
  Lisp testCode = snlToTree(loadSnippet("#1002754"));
7  
  L<Lisp> ops = snlSplitOps(testCode);
8  
  int score = 0, total = 0;
9  
  new L<Lisp> memory;
10  
  for (int i = 0; i < l(ops); i += 2) {
11  
    Lisp on = ops.get(i);
12  
    Lisp say = ops.get(i+1);
13  
    assertEquals("on *", on.head);
14  
    assertEquals("say *", say.head);
15  
    
16  
    S sOn = snlFromTree(on.get(0));
17  
    print("> " + sOn);
18  
    Lisp out = cast restructure(call(engine, "quickrun", memory, sOn));
19  
    S sOut = snlFromTree(out);
20  
    S sSay = snlFromTree(say.get(0));
21  
    print("< " + sOut);
22  
    if (testOut(say.get(0), out)) {
23  
      print("Hmm!");
24  
      print("! " + sSay);
25  
      print("# " + out);
26  
      print("# " + say.get(0));
27  
    } else {
28  
      print("OK");
29  
      ++score;
30  
    }
31  
    ++total;
32  
  }
33  
  
34  
  print("Score: " + score + "/" + total);
35  
}
36  
37  
static boolean testOut(Lisp say, Lisp out) {
38  
  if (say.isA("* or *"))
39  
    ret eq(say.get(0), out) || eq(say.get(1), out);
40  
  else
41  
    ret eq(say, out);
42  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1002755
Snippet name: Run test case on logic engine
Eternal ID of this version: #1002755/1
Text MD5: 1cf570c383852c2fd174b901c2e2501b
Transpilation MD5: 2197ca01c250d796a2056e2157a45307
Author: stefan
Category: eleu / nl
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-02-20 05:03:56
Source code size: 1041 bytes / 42 lines
Pitched / IR pitched: No / No
Views / Downloads: 611 / 596
Referenced in: [show references]