aboutsummaryrefslogtreecommitdiff
path: root/src/go/types/errors_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/go/types/errors_test.go')
-rw-r--r--src/go/types/errors_test.go25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/go/types/errors_test.go b/src/go/types/errors_test.go
index 942a9fdd4c..4b5dab68e4 100644
--- a/src/go/types/errors_test.go
+++ b/src/go/types/errors_test.go
@@ -4,7 +4,30 @@
package types
-import "testing"
+import (
+ "go/token"
+ "testing"
+)
+
+func TestError(t *testing.T) {
+ var err error_
+ want := "no error"
+ if got := err.String(); got != want {
+ t.Errorf("empty error: got %q, want %q", got, want)
+ }
+
+ want = "0: foo 42"
+ err.errorf(token.NoPos, "foo %d", 42)
+ if got := err.String(); got != want {
+ t.Errorf("simple error: got %q, want %q", got, want)
+ }
+
+ want = "0: foo 42\n\tbar 43"
+ err.errorf(token.NoPos, "bar %d", 43)
+ if got := err.String(); got != want {
+ t.Errorf("simple error: got %q, want %q", got, want)
+ }
+}
func TestStripAnnotations(t *testing.T) {
for _, test := range []struct {