From 2e5820c37e4e6cb2a2c01863619abd19eb5a8199 Mon Sep 17 00:00:00 2001 From: Sergio Queiroz Date: Mon, 2 Jan 2017 11:19:58 -0300 Subject: Adding tests to check farthest fail --- testfarthest.lua | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 testfarthest.lua diff --git a/testfarthest.lua b/testfarthest.lua new file mode 100644 index 0000000..386cbbd --- /dev/null +++ b/testfarthest.lua @@ -0,0 +1,25 @@ +local m = require 'lpeglabel' + +function matchPrint(p, s) + local r, l, sfail = p:match(s) + print("Input:", s) + print("Result:", r, l, sfail) +end + +local p = m.P"a"^0 * m.P"b" + m.P"c" + +p:pcode() + +matchPrint(p, "aab") +matchPrint(p, "ck") +matchPrint(p, "dk") +matchPrint(p, "aak") + +local p = m.P"a"^0 * m.P(1) * m.P(1) + m.P"a"^0 * m.P"c" + +p:pcode() + +matchPrint(p, "aabc") +matchPrint(p, "aac") +matchPrint(p, "aak") +matchPrint(p, "x") -- cgit v1.2.3-55-g6feb