aboutsummaryrefslogtreecommitdiff
path: root/tests/programs/stdio.zc
diff options
context:
space:
mode:
Diffstat (limited to 'tests/programs/stdio.zc')
-rw-r--r--tests/programs/stdio.zc18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/programs/stdio.zc b/tests/programs/stdio.zc
new file mode 100644
index 0000000..5a79262
--- /dev/null
+++ b/tests/programs/stdio.zc
@@ -0,0 +1,18 @@
+include rt, std;
+
+// std.Io: the writers, a capture of them, and the line reader over program input.
+fn main() {
+ std.Io.print("hi "); std.Io.put_n(-42); std.Io.put_c(32); std.Io.put_f(2.5); std.Io.nl();
+ std.Io.println("line"); std.Io.put_bs(b"bytes"); std.Io.put_c(32); std.Io.put_hex(255);
+ std.Io.put_c(32); std.Io.put_s("s"); std.Io.nl();
+ let cap = std.capture.start();
+ std.Io.print("caught "); std.Io.put_n(7);
+ std.capture.end(cap);
+ std.Io.put_n(std.Text.len(cap)); std.Io.put_c(32); std.Io.println(cap);
+ char[32] buf; int n = std.Io.getline(buf, 32);
+ std.Io.put_n(n); std.Io.print(":"); std.Io.println(buf);
+ n = std.Io.getline(buf, 4); std.Io.put_n(n); std.Io.print(":"); std.Io.println(buf);
+ n = std.Io.read(buf, 32); std.Io.put_n(n); std.Io.put_c(32); std.Io.put_n(buf[0]); std.Io.nl();
+ n = std.Io.getline(buf, 32); std.Io.put_n(n); std.Io.put_c(32); std.Io.put_n(std.Io.eof()); std.Io.nl();
+ return 0;
+}