aboutsummaryrefslogtreecommitdiffhomepage
path: root/interp/interpreter.go
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2024-07-12 14:32:50 +0200
committerRon Evans <[email protected]>2024-07-20 14:30:34 +0200
commita5f78a390065204d161fa80d0cfa83f9d0268d85 (patch)
treecefe0c5ee753c46f88d0df7368fde2dce5d95e80 /interp/interpreter.go
parente409950492340d0e74db681de25f4a2a0dc84b37 (diff)
downloadtinygo-a5f78a390065204d161fa80d0cfa83f9d0268d85.tar.gz
tinygo-a5f78a390065204d161fa80d0cfa83f9d0268d85.zip
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.
Diffstat (limited to 'interp/interpreter.go')
-rw-r--r--interp/interpreter.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/interp/interpreter.go b/interp/interpreter.go
index ea5eeaa12..b35129b81 100644
--- a/interp/interpreter.go
+++ b/interp/interpreter.go
@@ -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:])