summary refs log tree commit diff stats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/captures.nim24
-rw-r--r--test/find.nim4
-rw-r--r--test/init.nim18
-rw-r--r--test/split.nim8
4 files changed, 27 insertions, 27 deletions
diff --git a/test/captures.nim b/test/captures.nim
index bccbc0993..31bf1c6a2 100644
--- a/test/captures.nim
+++ b/test/captures.nim
@@ -3,57 +3,57 @@ include nre
 
 suite "captures":
   test "map capture names to numbers":
-    check(getNameToNumberTable(initRegex("(?<v1>1(?<v2>2(?<v3>3))(?'v4'4))()")) == 
+    check(getNameToNumberTable(re("(?<v1>1(?<v2>2(?<v3>3))(?'v4'4))()")) == 
       { "v1" : 0, "v2" : 1, "v3" : 2, "v4" : 3 }.toTable())
 
   test "capture bounds are correct":
-    let ex1 = initRegex("([0-9])")
+    let ex1 = re("([0-9])")
     check("1 23".find(ex1).matchBounds == 0 .. 1)
     check("1 23".find(ex1).captureBounds[0].get == 0 .. 1)
     check("1 23".find(ex1, 1).matchBounds == 2 .. 3)
     check("1 23".find(ex1, 3).matchBounds == 3 .. 4)
 
-    let ex2 = initRegex("()()()()()()()()()()([0-9])")
+    let ex2 = re("()()()()()()()()()()([0-9])")
     check("824".find(ex2).captureBounds[0].get == 0 .. 0)
     check("824".find(ex2).captureBounds[10].get == 0 .. 1)
 
-    let ex3 = initRegex("([0-9]+)")
+    let ex3 = re("([0-9]+)")
     check("824".find(ex3).captureBounds[0].get == 0 .. 3)
 
   test "named captures":
-    let ex1 = "foobar".find(initRegex("(?<foo>foo)(?<bar>bar)"))
+    let ex1 = "foobar".find(re("(?<foo>foo)(?<bar>bar)"))
     check(ex1.captures["foo"] == "foo")
     check(ex1.captures["bar"] == "bar")
 
-    let ex2 = "foo".find(initRegex("(?<foo>foo)(?<bar>bar)?"))
+    let ex2 = "foo".find(re("(?<foo>foo)(?<bar>bar)?"))
     check(ex2.captures["foo"] == "foo")
     check(ex2.captures["bar"] == nil)
 
   test "named capture bounds":
-    let ex1 = "foo".find(initRegex("(?<foo>foo)(?<bar>bar)?"))
+    let ex1 = "foo".find(re("(?<foo>foo)(?<bar>bar)?"))
     check(ex1.captureBounds["foo"] == Some(0..3))
     check(ex1.captureBounds["bar"] == None[Slice[int]]())
 
   test "capture count":
-    let ex1 = initRegex("(?<foo>foo)(?<bar>bar)?")
+    let ex1 = re("(?<foo>foo)(?<bar>bar)?")
     check(ex1.captureCount == 2)
     check(ex1.captureNameId == {"foo" : 0, "bar" : 1}.toTable())
 
   test "named capture table":
-    let ex1 = "foo".find(initRegex("(?<foo>foo)(?<bar>bar)?"))
+    let ex1 = "foo".find(re("(?<foo>foo)(?<bar>bar)?"))
     check(ex1.captures.toTable == {"foo" : "foo", "bar" : nil}.toTable())
     check(ex1.captureBounds.toTable == {"foo" : Some(0..3), "bar" : None[Slice[int]]()}.toTable())
     check(ex1.captures.toTable("") == {"foo" : "foo", "bar" : ""}.toTable())
 
-    let ex2 = "foobar".find(initRegex("(?<foo>foo)(?<bar>bar)?"))
+    let ex2 = "foobar".find(re("(?<foo>foo)(?<bar>bar)?"))
     check(ex2.captures.toTable == {"foo" : "foo", "bar" : "bar"}.toTable())
 
   test "capture sequence":
-    let ex1 = "foo".find(initRegex("(?<foo>foo)(?<bar>bar)?"))
+    let ex1 = "foo".find(re("(?<foo>foo)(?<bar>bar)?"))
     check(ex1.captures.toSeq == @["foo", nil])
     check(ex1.captureBounds.toSeq == @[Some(0..3), None[Slice[int]]()])
     check(ex1.captures.toSeq("") == @["foo", ""])
 
-    let ex2 = "foobar".find(initRegex("(?<foo>foo)(?<bar>bar)?"))
+    let ex2 = "foobar".find(re("(?<foo>foo)(?<bar>bar)?"))
     check(ex2.captures.toSeq == @["foo", "bar"])
 
diff --git a/test/find.nim b/test/find.nim
index 06f4d22cc..ddbfcdfdb 100644
--- a/test/find.nim
+++ b/test/find.nim
@@ -3,13 +3,13 @@ include nre
 
 suite "find":
   test "find text":
-    check("3213a".find(initRegex(r"[a-z]")).match == "a")
+    check("3213a".find(re"[a-z]").match == "a")
     check("1 2 3 4 5 6 7 8 ".findAll(re" ").map(
       proc (a: RegexMatch): string = a.match
     ) == @[" ", " ", " ", " ", " ", " ", " ", " "])
 
   test "find bounds":
-    check("1 2 3 4 5 ".findAll(re" ")).map(
+    check("1 2 3 4 5 ".findAll(re" ").map(
       proc (a: RegexMatch): Slice[int] = a.matchBounds
     ) == @[1..2, 3..4, 5..6, 7..8, 9..10])
 
diff --git a/test/init.nim b/test/init.nim
index 9bf7c3c42..105e6a19e 100644
--- a/test/init.nim
+++ b/test/init.nim
@@ -1,24 +1,24 @@
 import unittest
-include nre
+import nre
 
 suite "Test NRE initialization":
   test "correct intialization":
-    check(initRegex("[0-9]+") != nil)
-    check(initRegex("[0-9]+", "iS") != nil)
+    check(re("[0-9]+") != nil)
+    check(re("[0-9]+", "i") != nil)
 
   test "correct options":
     expect(SyntaxError):  # ValueError would be bad
-      discard initRegex("[0-9]+",
-        "89AEfimNsUWXxY<any><anycrlf><cr><crlf><lf><bsr_anycrlf><bsr_unicode><js>")
+      discard re("[0-9]+",
+        "89AEfimNsUWXxY<any><anycrlf><cr><crlf><lf><bsr_anycrlf><bsr_unicode><js><no_study>")
 
   test "incorrect options":
-    expect(KeyError): discard initRegex("[0-9]+", "a")
-    expect(KeyError): discard initRegex("[0-9]+", "<does_not_exist>")
+    expect(KeyError): discard re("[0-9]+", "a")
+    expect(KeyError): discard re("[0-9]+", "<does_not_exist>")
 
   test "invalid regex":
-    expect(SyntaxError): discard initRegex("[0-9")
+    expect(SyntaxError): discard re("[0-9")
     try:
-      discard initRegex("[0-9")
+      discard re("[0-9")
     except SyntaxError:
       let ex = SyntaxError(getCurrentException())
       check(ex.pos == 4)
diff --git a/test/split.nim b/test/split.nim
index 2dbb835d2..184b5f9e2 100644
--- a/test/split.nim
+++ b/test/split.nim
@@ -3,11 +3,11 @@ include nre
 
 suite "string splitting":
   test "splitting strings":
-    check("12345".split(initRegex("")) == @["1", "2", "3", "4", "5"])
+    check("12345".split(re("")) == @["1", "2", "3", "4", "5"])
     check("1 2 3 4 5 6 ".split(re" ") == @["1", "2", "3", "4", "5", "6", ""])
-    check("1  2  ".split(initRegex(" ")) == @["1", "", "2", "", ""])
-    check("1 2".split(initRegex(" ")) == @["1", "2"])
-    check("foo".split(initRegex("foo")) == @["", ""])
+    check("1  2  ".split(re(" ")) == @["1", "", "2", "", ""])
+    check("1 2".split(re(" ")) == @["1", "2"])
+    check("foo".split(re("foo")) == @["", ""])
 
   test "captured patterns":
     check("12".split(re"(\d)") == @["", "1", "", "2", ""])