remove some noises in tests (#16448)
This commit is contained in:
parent
357729639f
commit
271f68259b
17 changed files with 140 additions and 181 deletions
|
|
@ -1,12 +1,12 @@
|
|||
import unittest, optional_nonstrict
|
||||
include nre
|
||||
|
||||
suite "captures":
|
||||
test "map capture names to numbers":
|
||||
block: # captures
|
||||
block: # map capture names to numbers
|
||||
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":
|
||||
block: # capture bounds are correct
|
||||
let ex1 = re("([0-9])")
|
||||
check("1 23".find(ex1).matchBounds == 0 .. 0)
|
||||
check("1 23".find(ex1).captureBounds[0] == 0 .. 0)
|
||||
|
|
@ -20,7 +20,7 @@ suite "captures":
|
|||
let ex3 = re("([0-9]+)")
|
||||
check("824".find(ex3).captureBounds[0] == 0 .. 2)
|
||||
|
||||
test "named captures":
|
||||
block: # named captures
|
||||
let ex1 = "foobar".find(re("(?<foo>foo)(?<bar>bar)"))
|
||||
check(ex1.captures["foo"] == "foo")
|
||||
check(ex1.captures["bar"] == "bar")
|
||||
|
|
@ -32,7 +32,7 @@ suite "captures":
|
|||
expect KeyError:
|
||||
discard ex2.captures["bar"]
|
||||
|
||||
test "named capture bounds":
|
||||
block: # named capture bounds
|
||||
let ex1 = "foo".find(re("(?<foo>foo)(?<bar>bar)?"))
|
||||
check("foo" in ex1.captureBounds)
|
||||
check(ex1.captureBounds["foo"] == 0..2)
|
||||
|
|
@ -40,12 +40,12 @@ suite "captures":
|
|||
expect KeyError:
|
||||
discard ex1.captures["bar"]
|
||||
|
||||
test "capture count":
|
||||
block: # capture count
|
||||
let ex1 = re("(?<foo>foo)(?<bar>bar)?")
|
||||
check(ex1.captureCount == 2)
|
||||
check(ex1.captureNameId == {"foo" : 0, "bar" : 1}.toTable())
|
||||
|
||||
test "named capture table":
|
||||
block: # named capture table
|
||||
let ex1 = "foo".find(re("(?<foo>foo)(?<bar>bar)?"))
|
||||
check(ex1.captures.toTable == {"foo" : "foo"}.toTable())
|
||||
check(ex1.captureBounds.toTable == {"foo" : 0..2}.toTable())
|
||||
|
|
@ -53,7 +53,7 @@ suite "captures":
|
|||
let ex2 = "foobar".find(re("(?<foo>foo)(?<bar>bar)?"))
|
||||
check(ex2.captures.toTable == {"foo" : "foo", "bar" : "bar"}.toTable())
|
||||
|
||||
test "capture sequence":
|
||||
block: # capture sequence
|
||||
let ex1 = "foo".find(re("(?<foo>foo)(?<bar>bar)?"))
|
||||
check(ex1.captures.toSeq == @[some("foo"), none(string)])
|
||||
check(ex1.captureBounds.toSeq == @[some(0..2), none(Slice[int])])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue