From 0970a68bcb9165aca8512ecd9ee9c0077abb9468 Mon Sep 17 00:00:00 2001 From: zinc Date: Thu, 15 Oct 2026 02:40:12 +0330 Subject: compiler: a //:lines marker starts a new file, so unbounded; and unchecked; of the source before it end there: a program joined to the unbounded runtime in a self-hosted run-only image is bounds-checked again (since d55b5fd its index errors went unreported); runtime_image_test expects the trap's exit status 2; spec 4.15.1, 4.x unchecked, 5.15.3 --- tests/drivers/runtime_image_test.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'tests/drivers/runtime_image_test.py') 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'', 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'', 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) -- cgit v1.2.3