diff options
author | flywind <43030857+xflywind@users.noreply.github.com> | 2020-11-25 14:48:27 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-25 07:48:27 +0100 |
commit | 57bd64582ceee697dc4f079baf6a4e6137ff45b4 (patch) | |
tree | 77adcc362cb3cd2c0939f291bacb999673b8b922 /tests/compiler/tprefixmatches.nim | |
parent | b7809cc9921421ea0e8326a24d66861748e3136b (diff) | |
download | Nim-57bd64582ceee697dc4f079baf6a4e6137ff45b4.tar.gz |
move tests under the compiler directory to testament (#16096)
Diffstat (limited to 'tests/compiler/tprefixmatches.nim')
-rw-r--r-- | tests/compiler/tprefixmatches.nim | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/compiler/tprefixmatches.nim b/tests/compiler/tprefixmatches.nim new file mode 100644 index 000000000..a89a6f613 --- /dev/null +++ b/tests/compiler/tprefixmatches.nim @@ -0,0 +1,32 @@ +import compiler/prefixmatches +import macros + +macro check(val, body: untyped): untyped = + result = newStmtList() + expectKind body, nnkStmtList + for b in body: + expectKind b, nnkPar + expectLen b, 2 + let p = b[0] + let s = b[1] + result.add quote do: + doAssert prefixMatch(`p`, `s`) == `val` + +check PrefixMatch.Prefix: + ("abc", "abc") + ("a", "abc") + ("xyz", "X_yzzzZe") + +check PrefixMatch.Substr: + ("b", "abc") + ("abc", "fooabcabc") + ("abC", "foo_AB_c") + +check PrefixMatch.Abbrev: + ("abc", "AxxxBxxxCxxx") + ("xyz", "X_yabcZe") + +check PrefixMatch.None: + ("foobar", "afkslfjd_as") + ("xyz", "X_yuuZuuZe") + ("ru", "remotes") |