Download Jar. Libraryless. Click here for Pure Java version (15858L/115K).
1 | !7 |
2 | |
3 | p-exp { |
4 | assertEmpty(checkRule([[ true => o(ok) ]], true)); |
5 | |
6 | L<Exp> l = checkRule([[ false => o(ok) ]], false); |
7 | assertEqualsVerbose(1, l(l)); |
8 | |
9 | l = checkRule( |
10 | [[ |
11 | true && eval(true) && eval(false) && true => o(ok) |
12 | ]], false); |
13 | assertEqualsVerbose(1, l(l)); |
14 | assertTrueVerbose(jmatch("eval(false) && true", str(first(l)))); |
15 | } |
16 | |
17 | static L<Exp> checkRule(S rule, final bool shouldSucceed) { |
18 | print("\n" + rule); |
19 | NLLogicChecker_v2 c = nlLogicCheckerWithRules(rule); |
20 | new NLLogicChecker_v2.Matching m; |
21 | m.verbose = true; |
22 | |
23 | final new Flag succeeded; |
24 | final new L<Exp> remaining; |
25 | nlLogic_iterate_withOnFail(c, first(c.rules).in, m, r { |
26 | if (!shouldSucceed) fail("Should not succeed"); |
27 | succeeded.raise(); |
28 | }, voidfunc(Exp e) { |
29 | remaining.add(e); |
30 | print("Remaining expression: " + e); |
31 | }); |
32 | if (shouldSucceed && !succeeded.isUp()) |
33 | fail("Rule failed"); |
34 | ret remaining; |
35 | } |
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: | 414 / 1159 |
Version history: | 12 change(s) |
Referenced in: | [show references] |