aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/drivers/runtime_image_test.py8
-rw-r--r--tests/programs/zc0typed.zc2
-rw-r--r--tests/xref.baseline4
3 files changed, 8 insertions, 6 deletions
diff --git a/tests/drivers/runtime_image_test.py b/tests/drivers/runtime_image_test.py
index 64aa353..e408dca 100644
--- a/tests/drivers/runtime_image_test.py
+++ b/tests/drivers/runtime_image_test.py
@@ -17,13 +17,15 @@ args = parser.parse_args()
cases = [
('enhancements', 'include rt; fn main() { rt.put_n(17 % 5); rt.put_c(32); rt.put_n(17 / 5); }', b'2 3'),
('array algorithms', Path('examples/learn/31-array-algorithms.zc').read_text(), Path('examples/learn/31-array-algorithms.out').read_bytes()),
- ('line tables', '\n//:lines trace.zc\n' + Path('tests/programs/trace.zc').read_text(), Path('tests/programs/trace.expected').read_bytes().replace(b'<stdin>', b'trace.zc')),
+ # the index error traps: exit status 2, like zy (and the program is checked although run.zc is unbounded)
+ ('line tables', '\n//:lines trace.zc\n' + Path('tests/programs/trace.zc').read_text(), Path('tests/programs/trace.expected').read_bytes().replace(b'<stdin>', b'trace.zc'), 2),
('owned pop', 'include rt; int*.u take() { int*[?] a = rt.new(int*[?]); int* p = rt.new(int); *p = 8; a.push(p); return a.pop(); } fn main() { let p = take(); rt.put_n(rt.isobj(p)); rt.put_c(32); rt.put_n(*p); }', b'1 8'),
# main may be void: run.zc's prototype of main must not fix its type (docs/SPEC.md 5.2.5)
('void main', Path('tests/programs/void_main.zc').read_text(), b'void main\n'),
]
prefix = b''.join(Path(f).read_bytes() + b'\n' for f in ['src/runtime/rt.zc', 'src/core/core.zc', 'src/runtime/run.zc'])
-for name, source, expected in cases:
+for name, source, expected, *status in cases:
+ status = status[0] if status else 0
if args.case and args.case not in name:
continue
with tempfile.TemporaryDirectory(prefix='tinyvm-image-') as work:
@@ -34,5 +36,5 @@ for name, source, expected in cases:
assert image.returncode == 0, (name, image.stderr)
binary = micro_image(directory, image.stdout, args.map)
r = subprocess.run([str(binary)], capture_output=True, timeout=10)
- assert r.returncode == 0 and r.stdout == expected, (name, r.returncode, r.stdout, r.stderr, expected)
+ assert r.returncode == status and r.stdout == expected, (name, r.returncode, r.stdout, r.stderr, expected)
print('ok self-hosted run-only image: ' + name)
diff --git a/tests/programs/zc0typed.zc b/tests/programs/zc0typed.zc
index 81209bf..48488d5 100644
--- a/tests/programs/zc0typed.zc
+++ b/tests/programs/zc0typed.zc
@@ -11,7 +11,7 @@ const int LIMIT = 10;
int add(int a, int b) { return a + b; }
.u grow(word[?] v, int n) { return v; }
bool keep(int.d x, .m y) { return x != y; }
-int apply(int(int) f, int* p, vec<vec<int>>*.u q) { return f(*p); }
+int apply(int(int) f, int* p, vec<vec<int>>* q) { return f(*p); }
int sq(int x) { return x * x; }
fn start() {
diff --git a/tests/xref.baseline b/tests/xref.baseline
index 8731091..b8b1e1f 100644
--- a/tests/xref.baseline
+++ b/tests/xref.baseline
@@ -41,7 +41,7 @@ borrow_entry borrow_prologue ctx_pop fn_begin
borrow_jump borrow_prologue ctx_pop fn_begin
borrow_pending ctx_pop emit_borrow_hold fn_begin
borrow_slots ctx_pop emit_borrow_hold fn_begin
-bound_on chk_reset topitem1
+bound_on chk_reset lt_apply_marks topitem1
bprec add_binop reserve_binary
bs_pk body_scan bs_adv
bs_pk2 body_scan bs_adv
@@ -55,7 +55,7 @@ capture_enabled capture_prepare ctx_pop fn_begin
capture_width reserve_captures
ch chk_reset nextch src_pop
chbase src_pop src_push
-check_on chk_reset topitem1
+check_on chk_reset lt_apply_marks topitem1
chk_heap chk_unit start
chk_hook
chkabort block body chk_begin errend fatal giveup hl_begin primary probe_member probe_stmt replace_function unit_top