diff options
author | LemonBoy <thatlemon@gmail.com> | 2018-09-19 21:17:48 +0200 |
---|---|---|
committer | LemonBoy <thatlemon@gmail.com> | 2018-09-21 18:59:46 +0200 |
commit | 4d9aec1858ecd8651276a5e1d6ca939d345b4d11 (patch) | |
tree | 1130641e6c7fd2b60680df3ac8e1415fb928f7dd /tests/let | |
parent | 0951b5b73677f610fd0eb8c274fc540349138d9c (diff) | |
download | Nim-4d9aec1858ecd8651276a5e1d6ca939d345b4d11.tar.gz |
Revert #7964
Somehow the test case doesn't crash anymore and the regression in the doc generation is fixed. Fixes #9019
Diffstat (limited to 'tests/let')
-rw-r--r-- | tests/let/t7936.nim | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/let/t7936.nim b/tests/let/t7936.nim new file mode 100644 index 000000000..3819dfc02 --- /dev/null +++ b/tests/let/t7936.nim @@ -0,0 +1,27 @@ +discard """ + action: "run" +""" + +import + tables, deques, sequtils + +const + lookupTable = {'(': ')', '{': '}', '[': ']'}.toTable + +proc isPaired*(value: string): bool = + var stack = initDeque[char]() + + for item in value: + # echo "Looking at " & item + if item in lookupTable: + stack.addLast(item) + if item in toSeq(lookupTable.values): + if stack.len == 0: + return false + if lookupTable[stack.popLast()] != item: + return false + + return stack.len == 0 + +doAssert isPaired("{[()]}") == true +doAssert isPaired("a)b(c") == false |