diff options
author | Ayke van Laethem <[email protected]> | 2024-07-09 17:16:32 +0200 |
---|---|---|
committer | Ayke <[email protected]> | 2024-07-13 13:26:26 +0200 |
commit | 8a357af3d81b86ada93a91fbd3b57d9c5fb34fc6 (patch) | |
tree | 08578e4fce0419eed350b33de51b0d5eef32d34e /testdata | |
parent | 7ac1ca0ae2a727329550eecf71814f08dccf0700 (diff) | |
download | tinygo-8a357af3d81b86ada93a91fbd3b57d9c5fb34fc6.tar.gz tinygo-8a357af3d81b86ada93a91fbd3b57d9c5fb34fc6.zip |
all: add testing for compiler error messages
This is needed for some improvements I'm going to make next.
This commit also refactors error handling slightly to make it more
easily testable, this should hopefully not result in any actual changes
in behavior.
Diffstat (limited to 'testdata')
-rw-r--r-- | testdata/errors/cgo.go | 15 | ||||
-rw-r--r-- | testdata/errors/syntax.go | 7 | ||||
-rw-r--r-- | testdata/errors/types.go | 12 |
3 files changed, 34 insertions, 0 deletions
diff --git a/testdata/errors/cgo.go b/testdata/errors/cgo.go new file mode 100644 index 000000000..e0853cc85 --- /dev/null +++ b/testdata/errors/cgo.go @@ -0,0 +1,15 @@ +package main + +// #error hello +// ))) +import "C" + +func main() { +} + +// TODO: this error should be relative to the current directory (so cgo.go +// instead of testdata/errors/cgo.go). + +// ERROR: # command-line-arguments +// ERROR: testdata/errors/cgo.go:3:5: error: hello +// ERROR: testdata/errors/cgo.go:4:4: error: expected identifier or '(' diff --git a/testdata/errors/syntax.go b/testdata/errors/syntax.go new file mode 100644 index 000000000..48d9e732f --- /dev/null +++ b/testdata/errors/syntax.go @@ -0,0 +1,7 @@ +package main + +func main(var) { // syntax error +} + +// ERROR: # command-line-arguments +// ERROR: syntax.go:3:11: expected ')', found 'var' diff --git a/testdata/errors/types.go b/testdata/errors/types.go new file mode 100644 index 000000000..491e2fe67 --- /dev/null +++ b/testdata/errors/types.go @@ -0,0 +1,12 @@ +package main + +func main() { + var a int + a = "foobar" + nonexisting() +} + +// ERROR: # command-line-arguments +// ERROR: types.go:5:6: cannot use "foobar" (untyped string constant) as int value in assignment +// ERROR: types.go:6:2: undefined: nonexisting +// ERROR: types.go:4:6: a declared and not used |