t3hn3rd
dc67262477
feature: add comprehensive WASM test suite (374 tests)
...
Add a full test framework and 123 test files covering infrastructure,
parser sections, and VM opcodes. All 374 tests pass; exit code reflects
failure count for CI/CD integration.
Test framework (wasm.test.framework):
- Assert helpers: assert_true, assert_i32/i64/u32/u64/f32/f64/bool
- Context builders: make_test_context, setup_test_locals, setup_test_globals
- Global counters: TotalTests, PassedTests, FailedTests
Test runner (wasm.test, WASURO.lpr):
- Master runner calls all 108 test units and prints summary
- halt(FailedTests) returns exit code for pipeline consumption
- Gated behind {$IFDEF RUN_TESTS} / build.bat test
Infrastructure tests (3 units):
- Stack push/pop for i32, i64, f32, f64
- Heap read/write across all widths (8/16/32/64-bit)
- LEB128 unsigned/signed encoding/decoding
Parser tests (8 units):
- type, function, export, code, global, memory, start, data sections
Opcode tests (97 units, ~374 assertions):
- Control: nop, unreachable, drop, select, return
- Variables: local.get/set/tee, global.get/set
- Constants: i32/i64/f32/f64.const
- I32: all arithmetic, bitwise, and comparison ops (29 units)
- I64: all arithmetic, bitwise, and comparison ops (29 units)
- F32/F64: all comparison ops (12 units)
- Memory loads: i32/i64/f32/f64.load + sign/zero-extending variants (14 units)
- Memory stores: i32/i64/f32/f64.store + narrowing variants (9 units)
2026-02-24 00:34:49 +00:00
t3hn3rd
d34997aa4e
feature: implement WASM parser sections and VM opcode handlers
...
Parser implementations:
- dataSection: parse segments, evaluate i32.const offset expressions,
copy data bytes into linear memory
- globalSection: parse globals with init expression evaluation and
type/mutability handling
- memorySection: parse memory limits (initial/max pages, flags)
- startSection: parse start function index
- wasm.parser: route new section types to their handlers
VM opcode implementations:
- Control: nop, unreachable (trap), drop, select, return
- Variables: local.get/set/tee, global.get/set
- Constants: i32.const, i64.const, f32.const, f64.const
- I32 arithmetic: add, sub, mul, div_s, div_u, rem_s, rem_u,
clz, ctz, popcnt
- I32 bitwise: and, or, xor, shl, shr_s, shr_u, rotl, rotr
- I32 comparison: eqz, eq, ne, lt_s/u, gt_s/u, le_s/u, ge_s/u
- I64 arithmetic: add, sub, mul, div_s, div_u, rem_s, rem_u,
clz, ctz, popcnt
- I64 bitwise: and, or, xor, shl, shr_s, shr_u, rotl, rotr
- I64 comparison: eqz, eq, ne, lt_s/u, gt_s/u, le_s/u, ge_s/u
- F32/F64 comparison: eq, ne, lt, gt, le, ge
- Memory loads: i32/i64/f32/f64.load, i32.load8_s/u, i32.load16_s/u,
i64.load8_s/u, i64.load16_s/u, i64.load32_s/u
- Memory stores: i32/i64/f32/f64.store, i32.store8, i32.store16,
i64.store8, i64.store16, i64.store32
- Memory management: memory.size, memory.grow
Bug fixes:
- memory.grow: guard against uint32 underflow when growing 0 pages
- select: fix off-by-one stack indexing for val1/val2
- i32/i64.shr_s: use manual arithmetic shift right (logical shift +
sign-bit mask fill) instead of RTL intrinsics for bare-metal
kernel compatibility
Type additions:
- wasm.types: new records and pointer types for globals, locals,
and section structures
2026-02-24 00:31:36 +00:00