aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/drivers/cli_help_test.py2
-rw-r--r--tests/drivers/core_lsp_test.js4
-rw-r--r--tests/drivers/hover_surface_test.js3
-rw-r--r--tests/drivers/nav_test.js5
-rw-r--r--tests/parity.known15
-rw-r--r--tests/programs/bareio.zc2
-rw-r--r--tests/programs/parity_ops.zc102
-rw-r--r--tests/programs/zc0bstr.zc96
-rw-r--r--tests/programs/zc0umd.zc58
-rwxr-xr-xtests/test.sh16
-rw-r--r--tests/test_win.ps14
11 files changed, 296 insertions, 11 deletions
diff --git a/tests/drivers/cli_help_test.py b/tests/drivers/cli_help_test.py
index 97eebea..1231f74 100644
--- a/tests/drivers/cli_help_test.py
+++ b/tests/drivers/cli_help_test.py
@@ -14,7 +14,7 @@ commands = []
if args.group in ('binaries', 'all'):
commands += [[str(Path(args.bin_dir) / name)] for name in ['zy', 'zym', 'zclsp', 'zc0', 'mkgenome', 'genmap']]
if args.group in ('scripts', 'all'):
- commands += [['bash', name] for name in ['tinyvm.sh', 'src/tools/zcc', 'src/tools/automap.sh', 'src/tools/findcc.sh', 'src/tools/bootstrap-check.sh', 'src/tools/mklsp.sh', 'src/tools/mklspwasm.sh', 'src/tools/mkvsix.sh', 'src/web/build.sh', 'src/baremetal/run.sh']]
+ commands += [['bash', name] for name in ['tinyvm.sh', 'src/tools/zcc', 'src/tools/automap.sh', 'src/tools/findcc.sh', 'src/tools/bootstrap-check.sh', 'src/tools/parity.sh', 'src/tools/mklsp.sh', 'src/tools/mklspwasm.sh', 'src/tools/mkvsix.sh', 'src/web/build.sh', 'src/baremetal/run.sh']]
if args.group in ('js', 'all'):
commands += [['node', name] for name in [str(Path(args.js_dir) / 'tinyvm.js'), 'src/js/mklayout.js', 'src/js/extract_lsp.js']]
diff --git a/tests/drivers/core_lsp_test.js b/tests/drivers/core_lsp_test.js
index c3c01aa..5123537 100644
--- a/tests/drivers/core_lsp_test.js
+++ b/tests/drivers/core_lsp_test.js
@@ -6,6 +6,8 @@ const fs = require('fs');
const cp = require('child_process');
const path = require('path');
const target = process.argv[2];
+// the compiler is the files listed in src/compiler/parts; the server checks them as the one document they make
+const compilerSource = () => fs.readFileSync('src/compiler/parts', 'utf8').split(/\r?\n/).filter(Boolean).map(n => fs.readFileSync(path.join('src/compiler', n), 'utf8')).join('');
const files = ['src/core/core.zc', 'src/runtime/rt.zc', 'src/compiler/compiler.zc', 'src/runtime/run.zc', 'src/lib/std.zc', 'src/lib/icon.zc', 'src/lsp/server.zc', 'src/tools/build.zc'];
const frame = message => {
const body = Buffer.from(JSON.stringify(message));
@@ -13,7 +15,7 @@ const frame = message => {
};
for (const file of files) {
const uri = 'file://' + path.resolve(file);
- const text = fs.readFileSync(file, 'utf8');
+ const text = file === 'src/compiler/compiler.zc' ? compilerSource() : fs.readFileSync(file, 'utf8');
const messages = [
{ jsonrpc: '2.0', id: 1, method: 'initialize', params: {} },
{ jsonrpc: '2.0', method: 'initialized', params: {} },
diff --git a/tests/drivers/hover_surface_test.js b/tests/drivers/hover_surface_test.js
index 688aca6..47056f6 100644
--- a/tests/drivers/hover_surface_test.js
+++ b/tests/drivers/hover_surface_test.js
@@ -17,7 +17,8 @@ function doc(uri, text) {
return rid;
};
}
-const compiler = fs.readFileSync('src/compiler/compiler.zc', 'utf8');
+// the compiler is the files listed in src/compiler/parts, joined: the one document the server embeds
+const compiler = fs.readFileSync('src/compiler/parts', 'utf8').split(/\r?\n/).filter(Boolean).map(n => fs.readFileSync('src/compiler/' + n, 'utf8')).join('');
const ask = doc('tinyvm:/compiler.zc', compiler);
checks.push([ask('ifrcap = NIF', 9), /const int NIF = 431/, /431/]);
checks.push([ask('capture_width = NCAP', 16), /const int NCAP = 32/, /initial capture capacity/, /32/]);
diff --git a/tests/drivers/nav_test.js b/tests/drivers/nav_test.js
index 8f0d8fd..deff6f3 100644
--- a/tests/drivers/nav_test.js
+++ b/tests/drivers/nav_test.js
@@ -68,7 +68,10 @@ assert.strictEqual(slice(source('/std.zc'), loc[0]), 'atoi', 'a method goes to i
loc = bdef('now(');
assert.strictEqual(slice(source('/std.zc'), loc[0]), 'now');
assert.strictEqual(source('/std.zc'), fs.readFileSync(path.join(root, 'src', 'lib', 'std.zc'), 'utf8'), 'the embedded std is the file');
-assert.strictEqual(source('/compiler.zc'), fs.readFileSync(path.join(root, 'src', 'compiler', 'compiler.zc'), 'utf8'), 'the embedded compiler is the file');
+const parts = fs.readFileSync(path.join(root, 'src', 'compiler', 'parts'), 'utf8').split(/\r?\n/).filter(Boolean);
+assert.strictEqual(source('/compiler.zc'), parts.map(n => fs.readFileSync(path.join(root, 'src', 'compiler', n), 'utf8')).join(''), 'the embedded compiler is its parts, joined in order');
+const embedded = [...fs.readFileSync(path.join(root, 'src', 'lsp', 'server.zc'), 'utf8').matchAll(/^embed "src\/compiler\/([^"]+)" as bstr/gm)].map(m => m[1]);
+assert.deepStrictEqual(embedded, parts, 'src/lsp/server.zc embeds the files of src/compiler/parts, in order');
assert.strictEqual(source('/server.zc'), fs.readFileSync(path.join(root, 'src', 'lsp', 'server.zc'), 'utf8'), 'the embedded server is the file');
loc = bdef('s_to_n(');
assert.ok(loc && loc.length === 1 && loc[0].uri === 'tinyvm:/rt.zc', 's_to_n opens the runtime source: ' + JSON.stringify(loc));
diff --git a/tests/parity.known b/tests/parity.known
new file mode 100644
index 0000000..0a73eb3
--- /dev/null
+++ b/tests/parity.known
@@ -0,0 +1,15 @@
+# programs where zc0 and the self-hosted compiler print different things on purpose.
+# src/tools/parity.sh still runs them and shows the difference as known, and it does
+# not fail the run; when one starts to agree it says so, and its line can go.
+# one program per line: the path, then # and the reason.
+#
+# zc0 reads types and ownership tags and throws them away. it has no ownership
+# analysis and no memdebug checks, so it neither warns about, traps on nor frees what
+# the self-hosted compiler does.
+tests/programs/doublefree.zc # memdebug on: only the self-hosted compiler emits the double free check
+tests/programs/scrub.zc # ownership: the analyzer warns about the use after free, zc0 runs it
+tests/programs/uaf.zc # ownership: the analyzer warns about the use after free; zc0 prints nothing
+tests/programs/uaf_in.zc # memdebug on: only the self-hosted compiler emits the use after free check
+examples/lists.zc # ownership: the block's owner frees at its end, zc0 never frees
+# the next program reads a local it never sets when stdin is empty, so it prints stack garbage
+tests/programs/bench_strings.zc # reads the repeat count from stdin; with none, acc is uninitialized
diff --git a/tests/programs/bareio.zc b/tests/programs/bareio.zc
index a06ef38..21d2b40 100644
--- a/tests/programs/bareio.zc
+++ b/tests/programs/bareio.zc
@@ -2,7 +2,7 @@ namespace;
include rt;
// bare-metal syscalls: clock, a RAM file, random, and the machine size.
-// zc0 subset, so a run-only image can carry it. names stay off u/m/d.
+// zc0 subset, so a run-only image can carry it.
fn main() {
let buf[16], n, t0, t1, i, fd, r, board[8];
t0 = rt.syscall(6, 0, 0, 0);
diff --git a/tests/programs/parity_ops.zc b/tests/programs/parity_ops.zc
new file mode 100644
index 0000000..1c3c760
--- /dev/null
+++ b/tests/programs/parity_ops.zc
@@ -0,0 +1,102 @@
+// operator precedence and associativity, the same in both compilers. every binary
+// operator is placed next to its neighbours in the table and between two of the same
+// kind, so a wrong binding changes a printed number. src/tools/parity.sh compiles
+// this program with zc0 and with the self-hosted compiler and compares the output.
+// it stays inside zc0's subset: no ?: (zc0 has none), no types beyond int.
+//
+// the table, tightest first: unary - ! ~ * &, then * / %, + -, << >>, < > <= >=,
+// == !=, &, ^, |, &&, ||, then the assignments, which group to the right. every
+// binary operator groups to the left. the expected output follows the c rules and
+// was checked by compiling the same expressions with a c compiler.
+namespace;
+include rt;
+
+int trace, calls;
+int seen(int v) { calls++; trace = trace * 10 + v; return v; }
+int id(int v) { return v; }
+int out(int v) { rt.put_n(v); rt.put_c(32); return v; }
+int endl() { rt.put_c(10); return 0; }
+
+int main() {
+ // operands the compilers cannot fold away
+ int a = id(2), b = id(3), c = id(4), e = id(5), z = id(0), one = id(1);
+
+ // * / % against + -, and left grouping
+ out(a + b * c); out(a * b + c); out(a - b * c); out(a * b - c); out((a + b) * c);
+ out(id(100) - 30 - 20); out(1 - 2 + 3); out(id(100) / 5 / 2); out(id(20) / 3 * 3);
+ out(a * b % c); out(id(100) % 7 % 3); out(id(100) / 10 % 4); out(id(7) % 4 * 3);
+ endl();
+
+ // + - against << >>, and left grouping
+ out(one << a + one); out(id(32) >> a - one); out(one << a << b); out(id(256) >> a >> one);
+ out(one << b * a); out(id(8) >> one << one);
+ endl();
+
+ // shifts against < > <= >=, and the relational chain
+ out(one << a < e); out(id(16) >> one > 7); out(a < b < c); out(e > c > b);
+ out(z <= e <= z); out(a >= b >= z);
+ endl();
+
+ // relations against == !=, and the equality chain
+ out(a < b == one); out(one == a > b); out(e == e == one); out(b != c != one);
+ out(id(3) > a == one < a);
+ endl();
+
+ // == against & ^ |
+ out(c & c == c); out(one | a == a); out(b ^ b == b); out(a == a & one); out(c != z | z);
+ endl();
+
+ // & ^ | against each other, and against + and <<
+ out(c | b & one); out(id(7) ^ e & b); out(one | 6 ^ b); out(id(6) & b | 8);
+ out(a + 6 & c); out(one & b << one); out(id(12) | one << a);
+ endl();
+
+ // && and || against | & and each other; the result of both is 0 or 1
+ out(one || z && z); out(z && z || one); out(z || one && one || z); out(z && one | one);
+ out(one || z & z); out(b && c); out(b & c); out(z || id(9)); out(id(7) && id(8) && z);
+ out(a < b && c < e || z); out(z == z || z && z);
+ endl();
+
+ // unary operators
+ out(-a * b); out(- -b); out(-a + e); out(!z + one); out(!a == z); out(!!id(7));
+ out(~z & 255); out(~one + one); out(~a & 7); out(-a * -b); out(a - -b); out(-id(7) % 4);
+ out(!(a < b) + one); out(*&a + one); out(-*&b);
+ endl();
+
+ // assignment groups to the right and takes the whole expression on its right
+ int x, y, w;
+ x = y = w = id(7); out(x); out(y); out(w);
+ x = id(10); x -= 3 - 1; out(x);
+ x *= a + b; out(x);
+ x <<= one + one; out(x);
+ x |= one << b; out(x);
+ x += y -= 2; out(x); out(y);
+ x = id(100); x /= a * b; out(x);
+ x %= 7 - 2; out(x);
+ x = id(6); x &= 3 | 8; out(x);
+ x ^= 1 + 2 * 3; out(x);
+ x = id(255); x >>= 2 + 2; out(x);
+ endl();
+
+ // division, remainder and shifts of negative numbers
+ out(id(0) - 7 / 2); out((id(0) - 7) / 2); out((id(0) - 7) % 3); out(id(7) % (id(0) - 3));
+ out((id(0) - 8) >> 1); out((id(0) - 8) << 1);
+ endl();
+
+ // short circuit: how many operands ran, and in what order
+ calls = 0; trace = 0; x = seen(0) && seen(1); out(x); out(calls); out(trace);
+ calls = 0; trace = 0; x = seen(1) || seen(2); out(x); out(calls); out(trace);
+ calls = 0; trace = 0; x = seen(1) || seen(2) && seen(3); out(x); out(calls); out(trace);
+ calls = 0; trace = 0; x = seen(0) || seen(2) && seen(3); out(x); out(calls); out(trace);
+ calls = 0; trace = 0; x = seen(0) && seen(2) || seen(3); out(x); out(calls); out(trace);
+ calls = 0; trace = 0; x = seen(1) && seen(0) || seen(2) && seen(3); out(x); out(calls); out(trace);
+ calls = 0; trace = 0; x = seen(1) | seen(2) && seen(0) & seen(3); out(x); out(calls); out(trace);
+ endl();
+
+ // operands run left to right whatever their binding
+ calls = 0; trace = 0; x = seen(1) + seen(2) * seen(3) - seen(4); out(x); out(calls); out(trace);
+ calls = 0; trace = 0; x = seen(1) << seen(2) < seen(3) == seen(4); out(x); out(calls); out(trace);
+ calls = 0; trace = 0; x = out(seen(1) - seen(2)) * out(seen(3)); out(x); out(calls); out(trace);
+ endl();
+ return 0;
+}
diff --git a/tests/programs/zc0bstr.zc b/tests/programs/zc0bstr.zc
new file mode 100644
index 0000000..bb4ffbc
--- /dev/null
+++ b/tests/programs/zc0bstr.zc
@@ -0,0 +1,96 @@
+namespace;
+include rt;
+
+// packed byte strings in the zc0 subset: the same program runs on the resident
+// compiler and, built into a run-only image, on stage 0 (src/tools/zc0.c). it
+// covers every b"..." escape, the packed layout, bstr locals, globals,
+// parameters and returns, + and the six comparisons, indexing, slicing, len
+// and embed. run from the repository root: the embeds read tests/data/embed.
+
+bstr greeting = b"hello";
+bstr shout;
+bstr plain = b"plain";
+embed "tests/data/embed/text.txt" as bstr text;
+embed "tests/data/embed/nul.bin" as bstr nul;
+embed "tests/data/embed/text.txt" as untyped;
+
+bstr tag(bstr s) { return b"<" + s + b">"; }
+bstr twice(bstr s);
+bstr twice(bstr s) { return s + s; }
+bstr pick(int n) {
+ bstr r;
+ if (n) r = b"yes"; else r = b"no";
+ return r;
+}
+int rank(bstr a, bstr b) { return (a < b) * 8 + (a <= b) * 4 + (a == b) * 2 + (a > b); }
+int count(bstr s, int c) {
+ int n = 0, i = 0;
+ while (i < len(s)) { if (s[i] == c) n++; i++; }
+ return n;
+}
+int num(int n) { rt.put_n(n); rt.put_c(32); return 0; }
+int nl() { rt.put_c(10); return 0; }
+int bytes(bstr s) {
+ int i = 0;
+ num(len(s));
+ while (i < len(s)) { num(s[i]); i++; }
+ nl();
+ return 0;
+}
+int words(bstr s) {
+ word* w = rt.bstr_storage(s);
+ int n = 1 + (w[0] >> 3) + 1, i = 0;
+ while (i < n) { num(w[i]); i++; }
+ nl();
+ return 0;
+}
+
+fn main() {
+ bstr a = b"abc", b, c;
+ bstr e = b"";
+ let u = b"x";
+ // every escape the lexer knows: n t r 0 e, and any other character stands for itself
+ bytes(b"\n\t\r\e\\\"\'\q\x41");
+ bytes(b"ab\0cd");
+ bytes(b"\0");
+ bytes(b"café");
+ bytes(b"caf\303\251");
+ bytes(b"quote \" inside, 'single', back\\slash");
+ // the layout: a length word, bytes packed 8 to a word, a 0 word after a full last word
+ words(e);
+ words(b"a");
+ words(b"abcdefg");
+ words(b"abcdefgh");
+ words(b"abcdefghi");
+ words(b"0123456789abcdef");
+ words(b"0123456789abcdefg");
+ words(text);
+ words(nul);
+ // declarations, assignment later, a return value, concatenation
+ b = tag(a);
+ c = twice(b) + e + u;
+ rt.put_s(a); rt.put_c(32); rt.put_s(b); rt.put_c(32); rt.put_s(c); nl();
+ shout = twice(greeting) + b"!";
+ rt.put_s(greeting); rt.put_c(32); rt.put_s(shout); rt.put_c(32); rt.put_s(plain); nl();
+ rt.put_s(tag(twice(tag(b"z")))); nl();
+ rt.put_s(pick(1) + b"/" + pick(0)); nl();
+ // comparisons: below, equal, above, a prefix, the empty string, a 9 byte string
+ num(rank(b"abc", b"abd")); num(rank(b"abc", b"abc")); num(rank(b"abd", b"abc"));
+ num(rank(b"ab", b"abc")); num(rank(b"", b"")); num(rank(b"", b"a"));
+ num(rank(b"abcdefghi", b"abcdefghi")); num(rank(b"abcdefgh", b"abcdefghi")); nl();
+ num(a == b"abc"); num(a != b"abc"); num(a == b); num(a != b);
+ num(tag(a) == b"<abc>"); num(shout > greeting); num(greeting >= shout); num(plain <= plain); nl();
+ // indexing, slicing, len
+ num(a[0]); num(a[2]); num(a[3]); num(len(a)); num(len(e)); num(len(c)); num(len(b"123456789")); nl();
+ rt.put_s(c[1:4]); rt.put_c(32); rt.put_s(a[1:2]); rt.put_c(32); rt.put_s(a[0:0]); rt.put_c('|');
+ rt.put_s(a[2:99]); rt.put_c('|'); rt.put_s(a[3:1]); rt.put_c('|'); rt.put_s((a + a)[2:4]); nl();
+ num(count(c, '<')); num(count(shout, 'l')); num(count(b"mississippi", 's')); num(count(e, 'x')); nl();
+ num(b"xyz"[1]); num(len(b"xyz")); num(len(a + a + a)); num(len(tag(e))); nl();
+ // embed: a global of the file's bytes, with or without the type, and a local
+ rt.put_s(text); num(len(text)); num(text[0]); num(text == untyped); num(len(nul)); num(nul[2]); nl();
+ embed "tests/data/embed/text.txt" as bstr here;
+ embed "tests/data/embed/answer.bin" as int answer;
+ embed "tests/data/embed/text.txt" as char* chars;
+ rt.put_s(here + b"|" + untyped); num(len(here)); num(here == text); num(answer); num(chars[6]); nl();
+ return 0;
+}
diff --git a/tests/programs/zc0umd.zc b/tests/programs/zc0umd.zc
new file mode 100644
index 0000000..9693111
--- /dev/null
+++ b/tests/programs/zc0umd.zc
@@ -0,0 +1,58 @@
+namespace;
+include rt;
+
+// u, m and d are ordinary names, and a tag is written .u, .m or .d after a type.
+// u*x, m*x and d*x with no space before the star is a recast, and u * x with a
+// space is a product. the same program runs on the resident compiler and, built
+// into a run-only image, on stage 0 (src/tools/zc0.c), which reads the tags and
+// recasts and does nothing with them.
+
+int u = 2, m = 3; // globals
+int[4] d4;
+int d(int x) { return x + 1; } // a function
+
+int mul3(int u, int m, int d) { return u * m * d; } // parameters
+int mixed(int.d u, int m, int d) { return u * m - d; }
+int tagged(int(int) f, int.m x) { return f(x); }
+
+// owned objects through locals named for their tags
+word*.u box(int v) { word* m = rt.new(2); m[0] = v; m[1] = v * 2; return u*m; }
+word*.u pair(int u, int m) {
+ word* d = rt.new(2);
+ d[0] = u; d[1] = m;
+ return u*d;
+}
+.u single(int v) { let u = rt.new(1); u[0] = v; return u*u; }
+int sum(word*.m m) { return m[0] + m[1]; }
+int eat(word*.d d) { return d[0] + d[1]; }
+int hold(.m u, .d d) { return u[0] * 100 + d[0]; }
+int dig(word*.m u) { int m = u[0], d = u[1]; return m * 10 + d; }
+
+fn main() {
+ int a = 4, b = 5;
+ int.m n = 9;
+ word*.m p = box(7);
+ .m q = single(6);
+ word* r = pair(8, 9);
+ let c = box(10), e = pair(1, 2);
+ rt.put_n(u * m); rt.put_c(32); // two globals multiplied
+ rt.put_n(u*=m); rt.put_c(32); // u *= m is not a recast either
+ rt.put_n(d(u) * d(m)); rt.put_c(32);
+ rt.put_n(mul3(2, 3, 4)); rt.put_c(32);
+ rt.put_n(mixed(7, 6, 5)); rt.put_c(32);
+ rt.put_n(tagged(d, n)); rt.put_c(10);
+ {
+ int u = 6, m = 7, d = 8; // locals shadow the globals
+ rt.put_n(u * m); rt.put_c(32);
+ rt.put_n(u * d - m); rt.put_c(32);
+ rt.put_n(m * u * d); rt.put_c(32);
+ rt.put_n(a * u + m * b); rt.put_c(10);
+ }
+ rt.put_n(sum(p)); rt.put_c(32);
+ rt.put_n(q[0]); rt.put_c(32);
+ rt.put_n(r[0] * r[1]); rt.put_c(32);
+ rt.put_n(dig(c)); rt.put_c(32);
+ rt.put_n(hold(e, single(5))); rt.put_c(32);
+ rt.put_n(eat(d*p)); rt.put_c(10);
+ return 0;
+}
diff --git a/tests/test.sh b/tests/test.sh
index 809da6e..ec93827 100755
--- a/tests/test.sh
+++ b/tests/test.sh
@@ -25,7 +25,9 @@
cd "$(dirname "$0")/.."; T=$(mktemp -d); trap 'rm -rf $T' EXIT
ok=0; bad=0
chk(){ if [ "$1" = "$2" ]; then echo "ok $3"; ok=$((ok+1)); else echo "FAIL $3: got [$1]"; bad=$((bad+1)); fi; }
-src(){ cat src/runtime/rt.zc src/core/core.zc src/compiler/compiler.zc; }
+# the compiler is the files listed in src/compiler/parts, in that order
+ccparts(){ tr -d '\r' < src/compiler/parts | sed 's|^|src/compiler/|'; }
+src(){ cat src/runtime/rt.zc src/core/core.zc $(ccparts); }
# -j N runs N sections at a time: j is how many cores to use. each section
# writes its own log, so the output still reads in the order it always did.
JOBS=1; QUICK=0; SELECT=""
@@ -65,7 +67,7 @@ mkdir -p build && $CC -shared -fPIC -w tests/data/sbv.c -o build/sbv.so || exit
selfc(){ (cat src/tools/build.zc; printf '`'; src) | $1 > $2; }
-# bootstrap: zc0 (c) -> g0, g0 compiles compiler.zc -> g1, g1 compiles it -> g2.
+# bootstrap: zc0 (c) -> g0, g0 compiles the compiler -> g1, g1 compiles it -> g2.
# each stage's core embeds the image in its own directory
mkdir $T/s0 $T/s1
src | $T/zc0 > $T/s0/g0.bin && $T/mkg < $T/s0/g0.bin > $T/s0/genome.bin || exit 1
@@ -103,6 +105,7 @@ run(){ # $1 = vm command, $2 = label
chk "$($vm < tests/programs/basics.zc | tr '\n' '/')" "285 610 42 512/hey 65 -3 -2 1024 -8/12456/757/9 100-101/5/ok/" "$l language basics"
chk "$($vm < tests/programs/umd.zc)" "100 6 0 15 99 5 5" "$l u m d lifetimes"
chk "$($vm < tests/programs/names.zc)" "12 1 8" "$l u, m and d are ordinary names"
+ chk "$($vm < tests/programs/zc0umd.zc | tr '\n' '/')" "6 6 28 24 37 10/42 41 336 59/21 6 72 120 105 21/" "$l u, m and d as names, products, recasts and tags (the zc0 subset)"
chk "$($vm < tests/programs/gc.zc)" "1000 1 900 1 199900" "$l mark-sweep collector"
chk "$($vm < tests/programs/meta.zc | tr '\n' '/')" "1024 19/unless ok/rrr/15 42/7/42/7/144/" "$l parse words, quote, eval, load, operator tables"
chk "$($vm < tests/programs/misc.zc | tr '\n' '/')" "45/54321/ok/" "$l compile-time eval, patched mnemonics, unchecked"
@@ -227,7 +230,7 @@ s_interp() {
grep -v '^ok' $T/arrays.out
chk $r 0 "native array receiver, algorithm and ownership contracts"
# actors are a library: nothing the compiler compiles or reads by default mentions them
- chk "$(grep -il actor src/compiler/compiler.zc src/runtime/rt.zc src/core/core.zc src/lib/std.zc src/lib/icon.zc src/tools/build.zc | wc -l)" "0" "no actor code in the compiler or anything it reads by default"
+ chk "$(grep -il actor $(ccparts) src/runtime/rt.zc src/core/core.zc src/lib/std.zc src/lib/icon.zc src/tools/build.zc | wc -l)" "0" "no actor code in the compiler or anything it reads by default"
python3 tests/drivers/actor_test.py $T/zy > $T/actor.out 2>&1; r=$?
grep -v '^ok' $T/actor.out
chk $r 0 "native isolated actor acceptance, rejection and regression fixtures"
@@ -359,6 +362,9 @@ s_runonly() {
runonly strings-ex examples/strings.zc
runonly share tests/programs/share.zc
runonly embed tests/programs/embed_top.zc
+ runonly zc0bstr tests/programs/zc0bstr.zc
+ runonly zc0umd tests/programs/zc0umd.zc
+ runonly wiring examples/wiring.zc
d=$T/run-echo; GENMAP=$T/genmap bash src/tools/automap.sh run $d src/runtime/run.zc examples/echo.zc >/dev/null && cp src/micro/micro.c src/micro/micro_port.h src/micro/port_linux.c src/micro/port_stub.c src/core/fops.h src/core/bops.h src/core/stack.h src/core/genome.h $d/ \
&& $CC -pthread -DZY_THREADS -O2 -w -fwrapv $d/micro.c $d/port_linux.c -o $T/zymr \
&& chk "$(printf 'abc\n' | $T/zymr | tr '\n' '/')" "$( (cat examples/echo.zc; printf '`abc\n') | $T/zy | tr '\n' '/')" "run echo" \
@@ -524,7 +530,9 @@ s_lsp() {
done
chk "$($lsp < examples/struct_closure_opt.zc | grep -c error)" "0" "lsp: methods and closures check clean"
# a file of a larger build checks on its own: its bodyless declarations are not errors in check mode
- for f in src/runtime/rt.zc src/runtime/run.zc src/compiler/compiler.zc src/lsp/server.zc; do chk "$($lsp < $f | grep -c ': error:')" "0" "lsp: $f checks alone"; done
+ for f in src/runtime/rt.zc src/runtime/run.zc src/lsp/server.zc; do chk "$($lsp < $f | grep -c ': error:')" "0" "lsp: $f checks alone"; done
+ # the compiler is several files that only make sense together: check them as one document
+ chk "$(cat $(ccparts) | $lsp | grep -c ': error:')" "0" "lsp: the compiler (src/compiler/parts) checks alone"
chk "$($lsp < tests/programs/decl_undefined.zc)" "no errors" "lsp: a bodyless declaration is not an error in check mode"
chk "$($lsp < tests/programs/undefined_call.zc | grep -c ': error:')" "1" "lsp: a call to a name nothing defines is still an error"
chk "$($lsp --annotate < tests/programs/annotate.zc | md5sum)" "$(md5sum < tests/programs/annotate.expected)" "lsp --annotate writes the types the compiler can see into a program"
diff --git a/tests/test_win.ps1 b/tests/test_win.ps1
index 953e875..cb64f0b 100644
--- a/tests/test_win.ps1
+++ b/tests/test_win.ps1
@@ -57,14 +57,14 @@ try {
& $cc -fwrapv -O1 -w src\tools\zc0.c -Isrc/core "-I$map" -o "$tempDir\zc0.exe"
& $cc -fwrapv -O1 -w src\tools\mkgenome.c "-I$map" -o "$tempDir\mkgenome.exe"
- cmd.exe /c "(type src\runtime\rt.zc & type src\core\core.zc & type src\compiler\compiler.zc) | `"$tempDir\zc0.exe`" > `"$tempDir\s0\g0.bin`""
+ cmd.exe /c "(type src\runtime\rt.zc & type src\core\core.zc & for /f %f in (src\compiler\parts) do @type src\compiler\%f) | `"$tempDir\zc0.exe`" > `"$tempDir\s0\g0.bin`""
cmd.exe /c "`"$tempDir\mkgenome.exe`" < `"$tempDir\s0\g0.bin`" > `"$tempDir\s0\genome.bin`""
& $cc -fwrapv -O2 -w -DJTYPE=int src\core\core.c src\core\io_win.c -Isrc/core "-I$map" "--embed-dir=$tempDir\s0" -o "$tempDir\zy0.exe"
$bzc = [IO.File]::ReadAllText("src\tools\build.zc")
$rt = [IO.File]::ReadAllText("src\runtime\rt.zc")
$core = [IO.File]::ReadAllText("src\core\core.zc")
- $cp = [IO.File]::ReadAllText("src\compiler\compiler.zc")
+ $cp = (Get-Content "src\compiler\parts" | Where-Object { $_.Trim() } | ForEach-Object { [IO.File]::ReadAllText("src\compiler\$($_.Trim())") }) -join ""
$combined = $bzc + [char]96 + $rt + $core + $cp
[IO.File]::WriteAllBytes("$tempDir\in.tmp", [Text.Encoding]::ASCII.GetBytes($combined))