summaryrefslogtreecommitdiff
path: root/lib/regex/test/basic.myr
diff options
context:
space:
mode:
Diffstat (limited to 'lib/regex/test/basic.myr')
-rw-r--r--lib/regex/test/basic.myr39
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/regex/test/basic.myr b/lib/regex/test/basic.myr
new file mode 100644
index 0000000..168b547
--- /dev/null
+++ b/lib/regex/test/basic.myr
@@ -0,0 +1,39 @@
+use std
+
+use "testmatch.use"
+
+const main = {
+ var s : byte[:]
+
+ s = std.strjoin([
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
+ ][:], "")
+ testmatch(".*bc", "Abc", `std.Some [][:])
+ testmatch("(a*)*", "a", `std.Some ["a"][:])
+ testmatch("(aa|aab?)*", s, `std.Some ["aa"][:])
+ /* greedy matches */
+ testmatch("(<.*>).*", "<a foo> blah <bar>", `std.Some [
+ "<a foo> blah <bar>",
+ ][:])
+ testmatch("(<.+>).*", "<a foo> blah <bar>", `std.Some [
+ "<a foo> blah <bar>",
+ ][:])
+ /* reluctant matches */
+ testmatch("(<.*?>).*", "<a foo> blah <bar>", `std.Some [
+ "<a foo>",
+ ][:])
+ testmatch("(<.+?>).*", "<a foo> blah <bar>", `std.Some [
+ "<a foo>",
+ ][:])
+}