From 3788b31ba52a79a1a0f832c0096e7805df6b8ee1 Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Fri, 12 Jul 2024 17:15:52 +0200 Subject: [PATCH] main: add test for error coming from the optimizer This is just one optimizer pass that's easy to test for. There are others, but I'm ignoring them for now. The one other that would be reasonable to test is when starting a goroutine with -gc=none, but I'm leaving that one for another time. --- errors_test.go | 1 + testdata/errors/optimizer.go | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 testdata/errors/optimizer.go diff --git a/errors_test.go b/errors_test.go index 1d29236ca5..7917419787 100644 --- a/errors_test.go +++ b/errors_test.go @@ -23,6 +23,7 @@ func TestErrors(t *testing.T) { "loader-invaliddep", "loader-invalidpackage", "loader-nopackage", + "optimizer", "syntax", "types", } { diff --git a/testdata/errors/optimizer.go b/testdata/errors/optimizer.go new file mode 100644 index 0000000000..4e0d71b934 --- /dev/null +++ b/testdata/errors/optimizer.go @@ -0,0 +1,18 @@ +package main + +import "runtime/interrupt" + +var num = 5 + +func main() { + // Error coming from LowerInterrupts. + interrupt.New(num, func(interrupt.Interrupt) { + }) + + // 2nd error + interrupt.New(num, func(interrupt.Interrupt) { + }) +} + +// ERROR: optimizer.go:9:15: interrupt ID is not a constant +// ERROR: optimizer.go:13:15: interrupt ID is not a constant