summary refs log tree commit diff stats
path: root/tests/exprs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/exprs')
-rw-r--r--tests/exprs/t22604.nim36
-rw-r--r--tests/exprs/texprstmt.nim2
-rw-r--r--tests/exprs/tifexpr_typeinference.nim8
-rw-r--r--tests/exprs/tresultwarning.nim2
-rw-r--r--tests/exprs/tstmtexp.nim3
-rw-r--r--tests/exprs/tstmtexprs.nim51
6 files changed, 90 insertions, 12 deletions
diff --git a/tests/exprs/t22604.nim b/tests/exprs/t22604.nim
new file mode 100644
index 000000000..c41cd3dfa
--- /dev/null
+++ b/tests/exprs/t22604.nim
@@ -0,0 +1,36 @@
+# if
+for i in 0..<1:
+  let x =
+    case false
+    of true:
+      42
+    of false:
+      if true:
+        continue
+      else:
+        raiseAssert "Won't get here"
+
+# nested case
+for i in 0..<1:
+  let x =
+    case false
+    of true:
+      42
+    of false:
+      case true
+      of true:
+        continue
+      of false:
+        raiseAssert "Won't get here"
+
+# try except
+for i in 0..<1:
+  let x =
+    case false
+    of true:
+      42
+    of false:
+      try:
+        continue
+      except:
+        raiseAssert "Won't get here"
\ No newline at end of file
diff --git a/tests/exprs/texprstmt.nim b/tests/exprs/texprstmt.nim
index 79323d82a..3c9704650 100644
--- a/tests/exprs/texprstmt.nim
+++ b/tests/exprs/texprstmt.nim
@@ -1,6 +1,6 @@
 discard """
+  errormsg: "expression 'result[1 .. BackwardsIndex(1)]' is of type 'string' and has to be used (or discarded)"
   line: 10
-  errormsg: "value of type 'string' has to be discarded"
 """
 
 # bug #578
diff --git a/tests/exprs/tifexpr_typeinference.nim b/tests/exprs/tifexpr_typeinference.nim
index 3ae95c571..ccaea3e80 100644
--- a/tests/exprs/tifexpr_typeinference.nim
+++ b/tests/exprs/tifexpr_typeinference.nim
@@ -1,11 +1,15 @@
+discard """
+action: compile
+"""
+
 #bug #712
 
 import tables
 
-proc test(): TTable[string, string] =
+proc test(): Table[string, string] =
   discard
 
-proc test2(): TTable[string, string] =
+proc test2(): Table[string, string] =
   discard
 
 var x = 5
diff --git a/tests/exprs/tresultwarning.nim b/tests/exprs/tresultwarning.nim
index 32934408e..28dabfdb1 100644
--- a/tests/exprs/tresultwarning.nim
+++ b/tests/exprs/tresultwarning.nim
@@ -1,5 +1,5 @@
 discard """
-  nimout: "Special variable 'result' is shadowed. [ResultShadowed]"
+  nimout: "tresultwarning.nim(6, 7) Warning: Special variable 'result' is shadowed. [ResultShadowed]"
 """
 
 proc test(): string =
diff --git a/tests/exprs/tstmtexp.nim b/tests/exprs/tstmtexp.nim
index fe60dd3ba..0ae866497 100644
--- a/tests/exprs/tstmtexp.nim
+++ b/tests/exprs/tstmtexp.nim
@@ -1,9 +1,8 @@
 discard """
+  errormsg: "expression '5' is of type 'int literal(5)' and has to be used (or discarded)"
   file: "tstmtexp.nim"
   line: 8
-  errormsg: "value of type 'int literal(5)' has to be discarded"
 """
 # Test 3
 
 1+4
-
diff --git a/tests/exprs/tstmtexprs.nim b/tests/exprs/tstmtexprs.nim
index b2d5db408..615c36024 100644
--- a/tests/exprs/tstmtexprs.nim
+++ b/tests/exprs/tstmtexprs.nim
@@ -1,11 +1,12 @@
 discard """
   output: '''24
-(bar: bar)
+(bar: "bar")
 1244
 6
 abcdefghijklmnopqrstuvwxyz
 145 23
-3'''
+3
+2'''
 """
 
 import strutils
@@ -32,7 +33,7 @@ when true:
     if (var yy = 0; yy != 0):
       echo yy
     else:
-      echo(try: parseInt("1244") except EINvalidValue: -1)
+      echo(try: parseInt("1244") except ValueError: -1)
     result = case x
              of 23: 3
              of 64:
@@ -80,13 +81,13 @@ semiProblem()
 # bug #844
 
 import json
-proc parseResponse(): PJsonNode =
+proc parseResponse(): JsonNode =
   result = % { "key1": % { "key2": % "value" } }
   for key, val in result["key1"]:
     var excMsg = key & "("
     if (var n=result["key2"]; n != nil):
       excMsg &= n.str
-    raise newException(ESynch, excMsg)
+    raise newException(CatchableError, excMsg)
 
 
 
@@ -98,7 +99,7 @@ let b = (se[1] = 1; 1)
 # bug #1161
 
 type
-  PFooBase = ref object of PObject
+  PFooBase = ref object of RootRef
     field: int
 
   PFoo[T] = ref object of PFooBase
@@ -122,3 +123,41 @@ var testTry =
     PFooBase(field: 5)
 
 echo(testTry.field)
+
+# bug #6166
+
+proc quo(op: proc (x: int): bool): int =
+  result =
+     if op(3):
+        2
+     else:
+        0
+
+echo(
+  if true:
+     quo do (a: int) -> bool:
+        a mod 2 != 0
+  else:
+     quo do (a: int) -> bool:
+        a mod 3 != 0
+)
+
+# bug #6980
+
+proc fooBool: bool {.discardable.} =
+  true
+
+if true:
+  fooBool()
+else:
+  raise newException(ValueError, "argh")
+
+# bug #5374
+
+proc test1(): int64 {.discardable.} = discard
+proc test2(): int {.discardable.} = discard
+
+if true:
+  test1()
+else:
+  test2()