summary refs log tree commit diff stats
path: root/tests/stdlib/tregex.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/stdlib/tregex.nim')
-rw-r--r--tests/stdlib/tregex.nim29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/stdlib/tregex.nim b/tests/stdlib/tregex.nim
new file mode 100644
index 000000000..9dd66cd60
--- /dev/null
+++ b/tests/stdlib/tregex.nim
@@ -0,0 +1,29 @@
+discard """
+  output: "key: keyAYes!"
+  matrix: "--mm:refc; --mm:orc"
+"""
+# Test the new regular expression module
+# which is based on the PCRE library
+
+when defined(powerpc64):
+  # cheat as our powerpc test machine has no PCRE installed:
+  echo "key: keyAYes!"
+
+else:
+  import
+    re
+  import std/syncio
+  if "keyA = valueA" =~ re"\s*(\w+)\s*\=\s*(\w+)":
+    write(stdout, "key: ", matches[0])
+  elif "# comment!" =~ re.re"\s*(\#.*)":
+    # test re.re"" syntax
+    echo("comment: ", matches[0])
+  else:
+    echo("Bug!")
+
+  if "Username".match(re"[A-Za-z]+"):
+    echo("Yes!")
+  else:
+    echo("Bug!")
+
+  #OUT key: keyAYes!