summary refs log tree commit diff stats
path: root/tests/casestmt
diff options
context:
space:
mode:
authorcooldome <cdome@bk.ru>2020-02-28 09:55:06 +0000
committerGitHub <noreply@github.com>2020-02-28 09:55:06 +0000
commitc79df2fb6abb5663505de13c0ae5995d72ae71a8 (patch)
treea9b1a91550d3df1b4613d46fd743a8018577ca4d /tests/casestmt
parent25dc5f76e024de88478bc6ee3b559e731f227b69 (diff)
downloadNim-c79df2fb6abb5663505de13c0ae5995d72ae71a8.tar.gz
EndsInNoReturn in expressions extension, fixes #13490 (#13520)
* fix #13490
Diffstat (limited to 'tests/casestmt')
-rw-r--r--tests/casestmt/tcasestmt.nim37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/casestmt/tcasestmt.nim b/tests/casestmt/tcasestmt.nim
index b7454ef99..6abea53bc 100644
--- a/tests/casestmt/tcasestmt.nim
+++ b/tests/casestmt/tcasestmt.nim
@@ -250,3 +250,40 @@ proc negativeOrNot(num: int): string =
 doAssert negativeOrNot(-1) == "negative"
 doAssert negativeOrNot(10000000) == "zero or positive"
 doAssert negativeOrNot(0) == "zero or positive"
+
+########################################################
+# issue #13490
+import strutils
+func foo(input: string): int =
+  try:
+    parseInt(input)
+  except:
+    return
+
+func foo2(b, input: string): int =
+  case b:
+    of "Y":
+      for c in input:
+        result =  if c in '0'..'9': parseInt($c)
+                  else: break
+    of "N":
+      for c in input:
+        result =  if c in '0'..'9': parseInt($c)
+                  else: continue
+    else: return
+
+
+static:
+  doAssert(foo("3") == 3)
+  doAssert(foo("a") == 0)
+  doAssert(foo2("Y", "a2") == 0)
+  doAssert(foo2("Y", "2a") == 2)
+  doAssert(foo2("N", "a3") == 3)
+  doAssert(foo2("z", "2") == 0)
+
+doAssert(foo("3") == 3)
+doAssert(foo("a") == 0)
+doAssert(foo2("Y", "a2") == 0)
+doAssert(foo2("Y", "2a") == 2)
+doAssert(foo2("N", "a3") == 3)
+doAssert(foo2("z", "2") == 0)