diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2020-06-27 10:47:41 -0400 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2020-06-27 10:47:41 -0400 |
commit | 7e47f52a21fb73dde9e59fe1f0b5957ec119ccfd (patch) | |
tree | 8954c988a19882f7c537f27d450b72ed10829a6f /tests | |
parent | 8080bfbe4a757d7a7d895654da6424d789e6d33c (diff) |
#init
Diffstat (limited to 'tests')
-rw-r--r-- | tests/init.toc | 25 | ||||
-rw-r--r-- | tests/init_expected | 18 | ||||
-rw-r--r-- | tests/std/base.toc | 3 |
3 files changed, 46 insertions, 0 deletions
diff --git a/tests/init.toc b/tests/init.toc new file mode 100644 index 0000000..ac85058 --- /dev/null +++ b/tests/init.toc @@ -0,0 +1,25 @@ +#init(-10) init(10); +#init(44) init(44); +#init(22) init(22); +#init(88) init(88); +#init(1002389) for i := 89..100 {init(i);} +#init(-20) init(0); + + +#include "std/io.toc"; + +total : int; + +init ::= fn(x: int) { + if #builtin("compiling") { return; } + writes("Initializing... "); + writei(x); + puts("% complete"); + total += x; +} + + +main ::= fn() { + writes("hello from main. total is "); + puti(total); +} diff --git a/tests/init_expected b/tests/init_expected new file mode 100644 index 0000000..23c8267 --- /dev/null +++ b/tests/init_expected @@ -0,0 +1,18 @@ +Initializing... 0% complete +Initializing... 10% complete +Initializing... 22% complete +Initializing... 44% complete +Initializing... 88% complete +Initializing... 89% complete +Initializing... 90% complete +Initializing... 91% complete +Initializing... 92% complete +Initializing... 93% complete +Initializing... 94% complete +Initializing... 95% complete +Initializing... 96% complete +Initializing... 97% complete +Initializing... 98% complete +Initializing... 99% complete +Initializing... 100% complete +hello from main. total is 1298 diff --git a/tests/std/base.toc b/tests/std/base.toc index bdb91e0..54d64d6 100644 --- a/tests/std/base.toc +++ b/tests/std/base.toc @@ -20,4 +20,7 @@ PLATFORM ::= #builtin("platform"); libc ::= "libc.so.6"; } +PLATFORM_IS_UNIX :: bool = PLATFORM == PLATFORM_LINUX || PLATFORM == PLATFORM_OSX || PLATFORM == PLATFORM_FREEBSD + || PLATFORM == PLATFORM_OPENBSD || PLATFORM == PLATFORM_MISC_UNIX; + |