summaryrefslogtreecommitdiff
path: root/tests/std/io.toc
diff options
context:
space:
mode:
Diffstat (limited to 'tests/std/io.toc')
-rw-r--r--tests/std/io.toc65
1 files changed, 0 insertions, 65 deletions
diff --git a/tests/std/io.toc b/tests/std/io.toc
deleted file mode 100644
index 994cd2a..0000000
--- a/tests/std/io.toc
+++ /dev/null
@@ -1,65 +0,0 @@
-/* @TODO: use write / WriteFile */
-
-#include "std/base.toc";
-
-putchar ::= #foreign("putchar", libc) fn(#C int) #C int;
-toc_putchar ::= fn(x: char) {
- putchar(x as #C int);
-}
-
-/*
-unfortunately, we can't use fwrite because MSVC doesn't like it when you
-use a file handle that's not from the DLL. (i.e. you can't pass your stdout
-to the imported version of fwrite)
-*/
-
-writes ::= fn(x: []char) {
- for c := x {
- toc_putchar(c);
- }
-}
-
-puts ::= fn(x: []char) {
- writes(x);
- toc_putchar('\n');
-}
-
-writei ::= fn(x: int) {
- if x < 0 {
- toc_putchar('-');
- // NOTE: don't do x = -x; here to make sure I64_MIN works
- }
- if x == 0 {
- toc_putchar('0');
- } else {
- abs ::= fn(x: int) int { if x < 0 { -x } else { x } };
- scan_digit := 1000000000000000000;
- started := false;
- while scan_digit > 0 {
- digit := abs((x / scan_digit) % 10);
- if digit > 0 { started = true; }
- if started {
- toc_putchar((('0' as int) + digit) as char);
- }
- scan_digit /= 10;
- }
- }
-}
-
-puti ::= fn(x: int) {
- writei(x);
- toc_putchar('\n');
-}
-
-/* @TODO: write your own version of this */
-printf ::= #foreign("printf", libc) fn(#C &"const char", #C ..) #C int;
-writef ::= fn(x: float) {
- fmt := "%f\0";
- printf(&fmt[0], x as f64);
-};
-putf ::= fn(x: float) {
- writef(x);
- toc_putchar('\n');
-}
-
-