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

27
LINES

< > BotCompany Repo | #1008973 // ctxTestRule - test if a rule fires on input; uses current ctxContext - calls addTestResult

JavaX fragment (include)

static void ctxTestRule(S input, S ruleName) {
  ctxTestRule("", input, ruleName);
}

static void ctxTestRule(S prelude, S input, S ruleName) {
  //ruleName = addPrefix("Agent#", ruleName);
  S desc = prelude + input + " -> " + ruleName;
  print("\nTesting: " + desc);
  try {
    ctxContext().rulesFired.clear();
    ctxClearOutput();
    ctxProcessInput(input);
    ctxProcessRules();
    ctxDefaultOnEmptyOutput();
    S output = ctxGetOutput();
    bool ok1 = ctxContext().rulesFired.contains(ruleName);
    if (!ok1) desc += " was: " + struct(ctxContext().rulesFired);
    bool ok2 = nempty(output);
    if (!ok2)
      desc += " no output";
    else
      desc += " output: " + quote(output);
    addTestResult(desc, (boolToInt(ok1)+boolToInt(ok2))*50);
  } catch e {
    addTestResult(desc, e);
  }
}

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: #1008973
Snippet name: ctxTestRule - test if a rule fires on input; uses current ctxContext - calls addTestResult
Eternal ID of this version: #1008973/14
Text MD5: ea45bafe28ce8261e8a0869439052009
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-07-14 19:51:43
Source code size: 833 bytes / 27 lines
Pitched / IR pitched: No / No
Views / Downloads: 525 / 568
Version history: 13 change(s)
Referenced in: [show references]