mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-05 11:37:46 +00:00
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.
This commit is contained in:
Vendored
+15
@@ -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 '('
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
package main
|
||||
|
||||
func main(var) { // syntax error
|
||||
}
|
||||
|
||||
// ERROR: # command-line-arguments
|
||||
// ERROR: syntax.go:3:11: expected ')', found 'var'
|
||||
Vendored
+12
@@ -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
|
||||
Reference in New Issue
Block a user