summaryrefslogtreecommitdiff
path: root/libregex/test/testmatch.myr
diff options
context:
space:
mode:
Diffstat (limited to 'libregex/test/testmatch.myr')
-rw-r--r--libregex/test/testmatch.myr58
1 files changed, 0 insertions, 58 deletions
diff --git a/libregex/test/testmatch.myr b/libregex/test/testmatch.myr
deleted file mode 100644
index 4600410..0000000
--- a/libregex/test/testmatch.myr
+++ /dev/null
@@ -1,58 +0,0 @@
-use std
-use regex
-
-pkg =
- const testmatch : (pat : byte[:], text : byte[:], expected : std.option(byte[:][:]) -> void)
- const dbgmatch : (pat : byte[:], text : byte[:], expected : std.option(byte[:][:]) -> void)
-;;
-
-const testmatch = {pat, text, expected
- run(regex.compile(pat), pat, text, expected)
-}
-
-const dbgmatch = {pat, text, expected
- run(regex.dbgcompile(pat), pat, text, expected)
-}
-
-const run = {regex, pat, text, expected
- var i, re
-
- re = std.try(regex)
- match regex.exec(re, text)
- | `std.Some res:
- match expected
- | `std.None:
- std.fatal("expected no match, got:")
- for i = 0; i < res.len; i++
- std.put("\t{}: {}\n", i, res[i])
- ;;
- | `std.Some exp:
- if !std.sleq(res[0], text)
- std.put("whole match does not match text!\n")
- std.fatal("failed matching {} over {}\n", pat, text)
- ;;
- res = res[1:]
- if res.len != exp.len
- std.put("mismatch: expected {} matches, got {}\n", exp.len, res.len)
- std.fatal("failed matching {} over {}\n", pat, text)
- ;;
- for i = 0; i < exp.len; i++
- if !std.sleq(res[i], exp[i])
- std.put("mismatch on {}: expected {}, got {}\n", i, exp[i], res[i])
- std.fatal("failed matching {} over {}\n", pat, text)
- ;;
- ;;
- ;;
- | `std.None:
- match expected
- | `std.None: /* : expected failure */
- | `std.Some matches:
- std.put("expected matches:\n")
- for i = 0; i < matches.len; i++
- std.put("\t{}: {}\n", i, matches[i])
- ;;
- std.fatal("no match found\n")
- ;;
- ;;
- regex.free(re)
-}