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).

!759

p {
  O engine = run_overBot("#1002751");
  
  Lisp testCode = snlToTree(loadSnippet("#1002754"));
  L<Lisp> ops = snlSplitOps(testCode);
  int score = 0, total = 0;
  new L<Lisp> memory;
  for (int i = 0; i < l(ops); i += 2) {
    Lisp on = ops.get(i);
    Lisp say = ops.get(i+1);
    assertEquals("on *", on.head);
    assertEquals("say *", say.head);
    
    S sOn = snlFromTree(on.get(0));
    print("> " + sOn);
    Lisp out = cast restructure(call(engine, "quickrun", memory, sOn));
    S sOut = snlFromTree(out);
    S sSay = snlFromTree(say.get(0));
    print("< " + sOut);
    if (testOut(say.get(0), out)) {
      print("Hmm!");
      print("! " + sSay);
      print("# " + out);
      print("# " + say.get(0));
    } else {
      print("OK");
      ++score;
    }
    ++total;
  }
  
  print("Score: " + score + "/" + total);
}

static boolean testOut(Lisp say, Lisp out) {
  if (say.isA("* or *"))
    ret eq(say.get(0), out) || eq(say.get(1), out);
  else
    ret eq(say, out);
}

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: 749 / 722
Referenced in: #3000238 - Answer for stefanreich (>> t power bot)
#3000382 - Answer for ferdie (>> t = 1, f = 0)
#3000383 - Answer for funkoverflow (>> t=1, f=0 okay)