9
9
"go/parser"
10
10
"go/token"
11
11
"go/types"
12
+ "regexp"
12
13
"strings"
13
14
"testing"
14
15
@@ -36,7 +37,7 @@ func TestNormalTerms(t *testing.T) {
36
37
{"package emptyintersection; type T[P interface{ ~int; string }] int" , "" , "empty type set" },
37
38
38
39
{"package embedded0; type T[P interface{ I }] int; type I interface { int }" , "int" , "" },
39
- {"package embedded1; type T[P interface{ I | string }] int; type I interface{ int | ~string }" , "int| ~string" , "" },
40
+ {"package embedded1; type T[P interface{ I | string }] int; type I interface{ int | ~string }" , "int ? \\ | ? ~string" , "" },
40
41
{"package embedded2; type T[P interface{ I; string }] int; type I interface{ int | ~string }" , "string" , "" },
41
42
42
43
{"package named; type T[P C] int; type C interface{ ~int|int }" , "~int" , "" },
@@ -50,7 +51,7 @@ type B interface{ int|string }
50
51
type C interface { ~string|~int }
51
52
52
53
type T[P interface{ A|B; C }] int
53
- ` , "~string| int" , "" },
54
+ ` , "~string ? \\ | ? int" , "" },
54
55
}
55
56
56
57
for _ , test := range tests {
@@ -94,8 +95,9 @@ type T[P interface{ A|B; C }] int
94
95
qf := types .RelativeTo (pkg )
95
96
got = types .TypeString (NewUnion (terms ), qf )
96
97
}
97
- if got != test .want {
98
- t .Errorf ("StructuralTerms(%s) = %q, want %q" , T , got , test .want )
98
+ want := regexp .MustCompile (test .want )
99
+ if ! want .MatchString (got ) {
100
+ t .Errorf ("NormalTerms(%s) = %q, want matching %q" , T , got , test .want )
99
101
}
100
102
})
101
103
}
0 commit comments