summary refs log tree commit diff stats
path: root/tests/stdlib/tstreams.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/stdlib/tstreams.nim')
-rw-r--r--tests/stdlib/tstreams.nim30
1 files changed, 25 insertions, 5 deletions
diff --git a/tests/stdlib/tstreams.nim b/tests/stdlib/tstreams.nim
index 640565a27..16dbc0e1b 100644
--- a/tests/stdlib/tstreams.nim
+++ b/tests/stdlib/tstreams.nim
@@ -1,7 +1,27 @@
 import streams
 
-var outp = newFileStream(stdout)
-var inp = newFileStream(stdin)
-write(outp, "Hello! What is your name?")
-var line = readLine(inp)
-write(outp, "Nice name: " & line)
+
+block tstreams:
+  var outp = newFileStream(stdout)
+  var inp = newFileStream(stdin)
+  write(outp, "Hello! What is your name?")
+  var line = readLine(inp)
+  write(outp, "Nice name: " & line)
+
+
+block tstreams2:
+  var
+    fs = newFileStream("amissingfile.txt")
+    line = ""
+  echo "fs is: ",repr(fs)
+  if not isNil(fs):
+    while fs.readLine(line):
+      echo line
+    fs.close()
+
+
+block tstreams3:
+  try:
+    var fs = openFileStream("shouldneverexist.txt")
+  except IoError:
+    echo "threw exception"