1
2
3
4
5 package types2
6
7 import "testing"
8
9 func TestError(t *testing.T) {
10 var err error_
11 want := "no error"
12 if got := err.msg(); got != want {
13 t.Errorf("empty error: got %q, want %q", got, want)
14 }
15
16 want = "foo 42"
17 err.addf(nopos, "foo %d", 42)
18 if got := err.msg(); got != want {
19 t.Errorf("simple error: got %q, want %q", got, want)
20 }
21
22 want = "foo 42\n\tbar 43"
23 err.addf(nopos, "bar %d", 43)
24 if got := err.msg(); got != want {
25 t.Errorf("simple error: got %q, want %q", got, want)
26 }
27 }
28
29 func TestStripAnnotations(t *testing.T) {
30 for _, test := range []struct {
31 in, want string
32 }{
33 {"", ""},
34 {" ", " "},
35 {"foo", "foo"},
36 {"foo₀", "foo"},
37 {"foo(T₀)", "foo(T)"},
38 } {
39 got := stripAnnotations(test.in)
40 if got != test.want {
41 t.Errorf("%q: got %q; want %q", test.in, got, test.want)
42 }
43 }
44 }
45
View as plain text