From a5f78a390065204d161fa80d0cfa83f9d0268d85 Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Fri, 12 Jul 2024 14:32:50 +0200 Subject: 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. --- interp/interpreter.go | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'interp/interpreter.go') 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:]) -- cgit v1.2.3