summary refs log tree commit diff stats
path: root/tests/discard
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2014-01-13 02:10:03 +0100
committerAraq <rumpf_a@web.de>2014-01-13 02:10:03 +0100
commit20b5f31c03fb556ec0aa2428a40adbac004d8987 (patch)
tree58086941e7d6bb8f480ca1173a95722ada9435b2 /tests/discard
parent51ee524109cf7e3e86c676bc1676063a01bfd979 (diff)
downloadNim-20b5f31c03fb556ec0aa2428a40adbac004d8987.tar.gz
new tester; all tests categorized
Diffstat (limited to 'tests/discard')
-rw-r--r--tests/discard/tdiscardable.nim13
-rw-r--r--tests/discard/tneedsdiscard.nim12
2 files changed, 25 insertions, 0 deletions
diff --git a/tests/discard/tdiscardable.nim b/tests/discard/tdiscardable.nim
new file mode 100644
index 000000000..c0551ba2f
--- /dev/null
+++ b/tests/discard/tdiscardable.nim
@@ -0,0 +1,13 @@
+# Test the discardable pragma
+
+proc p(x, y: int): int {.discardable.} = 
+  return x + y
+
+# test that it is inherited from generic procs too:
+proc q[T](x, y: T): T {.discardable.} = 
+  return x + y
+
+
+p(8, 2)
+q[float](0.8, 0.2)
+
diff --git a/tests/discard/tneedsdiscard.nim b/tests/discard/tneedsdiscard.nim
new file mode 100644
index 000000000..24f5b2eee
--- /dev/null
+++ b/tests/discard/tneedsdiscard.nim
@@ -0,0 +1,12 @@
+discard """
+  line: 10
+  errormsg: "value returned by statement has to be discarded"
+"""
+
+proc p =
+  var f: TFile
+  echo "hi"
+  
+  open(f, "arg.txt")
+  
+p()