diff options
author | Sergio Queiroz <sqmedeiros@gmail.com> | 2017-01-02 11:19:58 -0300 |
---|---|---|
committer | Sergio Queiroz <sqmedeiros@gmail.com> | 2017-01-02 11:19:58 -0300 |
commit | 2e5820c37e4e6cb2a2c01863619abd19eb5a8199 (patch) | |
tree | c239f53708f00c9c588b95360608939f16bac4c5 | |
parent | b04d3e015ba3f7a660c90b3b75ed937491327efe (diff) | |
download | lpeglabel-2e5820c37e4e6cb2a2c01863619abd19eb5a8199.tar.gz lpeglabel-2e5820c37e4e6cb2a2c01863619abd19eb5a8199.tar.bz2 lpeglabel-2e5820c37e4e6cb2a2c01863619abd19eb5a8199.zip |
Adding tests to check farthest fail
-rw-r--r-- | testfarthest.lua | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/testfarthest.lua b/testfarthest.lua new file mode 100644 index 0000000..386cbbd --- /dev/null +++ b/testfarthest.lua | |||
@@ -0,0 +1,25 @@ | |||
1 | local m = require 'lpeglabel' | ||
2 | |||
3 | function matchPrint(p, s) | ||
4 | local r, l, sfail = p:match(s) | ||
5 | print("Input:", s) | ||
6 | print("Result:", r, l, sfail) | ||
7 | end | ||
8 | |||
9 | local p = m.P"a"^0 * m.P"b" + m.P"c" | ||
10 | |||
11 | p:pcode() | ||
12 | |||
13 | matchPrint(p, "aab") | ||
14 | matchPrint(p, "ck") | ||
15 | matchPrint(p, "dk") | ||
16 | matchPrint(p, "aak") | ||
17 | |||
18 | local p = m.P"a"^0 * m.P(1) * m.P(1) + m.P"a"^0 * m.P"c" | ||
19 | |||
20 | p:pcode() | ||
21 | |||
22 | matchPrint(p, "aabc") | ||
23 | matchPrint(p, "aac") | ||
24 | matchPrint(p, "aak") | ||
25 | matchPrint(p, "x") | ||