diff options
| author | 2026-10-15 02:40:12 +0330 | |
|---|---|---|
| committer | 2026-10-15 02:40:12 +0330 | |
| commit | 0970a68bcb9165aca8512ecd9ee9c0077abb9468 (patch) | |
| tree | 340714bee0b60a9b028924794573409b8e8b439b /tests/drivers/runtime_image_test.py | |
| parent | tests: zc0typed.zc drops the .u on a typed parameter, which zc0 rejects since... (diff) | |
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
Diffstat (limited to 'tests/drivers/runtime_image_test.py')
| -rw-r--r-- | tests/drivers/runtime_image_test.py | 8 |
1 files changed, 5 insertions, 3 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) |
