aboutsummaryrefslogtreecommitdiff
path: root/docs/history/15-o3/code/tests/basics.zc
diff options
context:
space:
mode:
Diffstat (limited to 'docs/history/15-o3/code/tests/basics.zc')
-rw-r--r--docs/history/15-o3/code/tests/basics.zc22
1 files changed, 22 insertions, 0 deletions
diff --git a/docs/history/15-o3/code/tests/basics.zc b/docs/history/15-o3/code/tests/basics.zc
new file mode 100644
index 0000000..c1f1faf
--- /dev/null
+++ b/docs/history/15-o3/code/tests/basics.zc
@@ -0,0 +1,22 @@
+let table[10];
+let greeting = "hey";
+const N = 10, BIG = 0x100 * 2;
+fn fib(n) { if (n < 2) return n; return fib(n - 1) + fib(n - 2); }
+fn twice(f, x) { return f(f(x)); }
+fn inc(x) { return x + 1; }
+fn main()
+{
+ let i, s = 0, a[5];
+ for (i = 0; i < N; i++) table[i] = i * i;
+ for (let j = 0; j < N; j++) s += table[j];
+ putn(s); putc(' '); putn(fib(15)); putc(' '); putn(twice(inc, 40)); putc(' '); putn(BIG); putc(10);
+ puts(greeting); putc(' '); putn('A'); putc(' '); putn(-17 / 5); putc(' '); putn(-17 % 5); putc(' '); putn(1 << 10); putc(' '); putn(-64 >> 3); putc(10);
+ i = 0; while (1) { i++; if (i == 3) continue; if (i > 6) break; putn(i); } putc(10);
+ a[0] = 5; a[1] = a[0]++; a[2] = ++a[0]; putn(a[0]); putn(a[1]); putn(a[2]); putc(10);
+ let b = { let t = 3; t * t };
+ putn(b); putc(' '); putn(3 > 2 && 2 > 1); putn(0 || 0); putn(!5); putn(~0); putn(5 != 5); putn(4 >= 4); putc(10);
+ let x = asm { 2 3 + };
+ putn(x); putc(10);
+ asm { 'o' . 'k' . 10 . }
+ return 0;
+}