main: add interp tests

This one needed more advanced checking of the error messages, because we
don't want to hardcode things like `!dbg !10` in the output.
This commit is contained in:
Ayke van Laethem
2024-07-12 14:32:50 +02:00
committed by Ron Evans
parent e409950492
commit a5f78a3900
3 changed files with 36 additions and 0 deletions
+4
View File
@@ -417,6 +417,10 @@ func (r *runner) run(fn *function, params []value, parentMem *memoryView, indent
} else {
locals[inst.localIndex] = literalValue{uint8(0)}
}
case callFn.name == "__tinygo_interp_raise_test_error":
// Special function that will trigger an error.
// This is used to test error reporting.
return nil, mem, r.errorAt(inst, errors.New("test error"))
case strings.HasSuffix(callFn.name, ".$typeassert"):
if r.debug {
fmt.Fprintln(os.Stderr, indent+"interface assert:", operands[1:])