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

35
LINES

< > BotCompany Repo | #1018314 // Test nlLogic_iterate_withOnFail

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

Download Jar. Libraryless. Click here for Pure Java version (15858L/115K).

!7

p-exp {
  assertEmpty(checkRule([[ true => o(ok) ]], true));
  
  L<Exp> l = checkRule([[ false => o(ok) ]], false);
  assertEqualsVerbose(1, l(l));
  
  l = checkRule(
[[
    true && eval(true) && eval(false) && true => o(ok)
  ]], false);
  assertEqualsVerbose(1, l(l));
  assertTrueVerbose(jmatch("eval(false) && true", str(first(l))));
}

static L<Exp> checkRule(S rule, final bool shouldSucceed) {
  print("\n" + rule);
  NLLogicChecker_v2 c = nlLogicCheckerWithRules(rule);
  new NLLogicChecker_v2.Matching m;
  m.verbose = true;
  
  final new Flag succeeded;
  final new L<Exp> remaining;
  nlLogic_iterate_withOnFail(c, first(c.rules).in, m, r {
    if (!shouldSucceed) fail("Should not succeed");
    succeeded.raise();
  }, voidfunc(Exp e) {
    remaining.add(e);
    print("Remaining expression: " + e);
  });
  if (shouldSucceed && !succeeded.isUp())
    fail("Rule failed");
  ret remaining;
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1018314
Snippet name: Test nlLogic_iterate_withOnFail
Eternal ID of this version: #1018314/13
Text MD5: 7467d94775e4c920f603030c9d086949
Transpilation MD5: 08ebfb700581ef947f73b33c1dc14c22
Author: stefan
Category: javax / a.i.
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-09-19 17:39:22
Source code size: 945 bytes / 35 lines
Pitched / IR pitched: No / No
Views / Downloads: 285 / 826
Version history: 12 change(s)
Referenced in: [show references]