mirror of https://github.com/golang/go.git
go/types, types2: use | rather than ∪ when printing term lists
With this change, the termlist String() function prints termlists in the usual Go notation and thus we can use it in error reporting. Preparation for fixing #40350. For #40350. Change-Id: Ia28318841305de234a71af3146ce0c59f5e601a5 Reviewed-on: https://go-review.googlesource.com/c/go/+/410894 Reviewed-by: Robert Griesemer <gri@google.com> Reviewed-by: Robert Findley <rfindley@google.com>
This commit is contained in:
parent
346698eea7
commit
d4fb93be87
|
|
@ -25,7 +25,7 @@ func (xl termlist) String() string {
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
for i, x := range xl {
|
for i, x := range xl {
|
||||||
if i > 0 {
|
if i > 0 {
|
||||||
buf.WriteString(" ∪ ")
|
buf.WriteString(" | ")
|
||||||
}
|
}
|
||||||
buf.WriteString(x.String())
|
buf.WriteString(x.String())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ import (
|
||||||
// maketl makes a term list from a string of the term list.
|
// maketl makes a term list from a string of the term list.
|
||||||
func maketl(s string) termlist {
|
func maketl(s string) termlist {
|
||||||
s = strings.ReplaceAll(s, " ", "")
|
s = strings.ReplaceAll(s, " ", "")
|
||||||
names := strings.Split(s, "∪")
|
names := strings.Split(s, "|")
|
||||||
r := make(termlist, len(names))
|
r := make(termlist, len(names))
|
||||||
for i, n := range names {
|
for i, n := range names {
|
||||||
r[i] = testTerm(n)
|
r[i] = testTerm(n)
|
||||||
|
|
@ -33,10 +33,10 @@ func TestTermlistString(t *testing.T) {
|
||||||
"int",
|
"int",
|
||||||
"~int",
|
"~int",
|
||||||
"myInt",
|
"myInt",
|
||||||
"∅ ∪ ∅",
|
"∅ | ∅",
|
||||||
"𝓤 ∪ 𝓤",
|
"𝓤 | 𝓤",
|
||||||
"∅ ∪ 𝓤 ∪ int",
|
"∅ | 𝓤 | int",
|
||||||
"∅ ∪ 𝓤 ∪ int ∪ myInt",
|
"∅ | 𝓤 | int | myInt",
|
||||||
} {
|
} {
|
||||||
if got := maketl(want).String(); got != want {
|
if got := maketl(want).String(); got != want {
|
||||||
t.Errorf("(%v).String() == %v", want, got)
|
t.Errorf("(%v).String() == %v", want, got)
|
||||||
|
|
@ -47,12 +47,12 @@ func TestTermlistString(t *testing.T) {
|
||||||
func TestTermlistIsEmpty(t *testing.T) {
|
func TestTermlistIsEmpty(t *testing.T) {
|
||||||
for test, want := range map[string]bool{
|
for test, want := range map[string]bool{
|
||||||
"∅": true,
|
"∅": true,
|
||||||
"∅ ∪ ∅": true,
|
"∅ | ∅": true,
|
||||||
"∅ ∪ ∅ ∪ 𝓤": false,
|
"∅ | ∅ | 𝓤": false,
|
||||||
"∅ ∪ ∅ ∪ myInt": false,
|
"∅ | ∅ | myInt": false,
|
||||||
"𝓤": false,
|
"𝓤": false,
|
||||||
"𝓤 ∪ int": false,
|
"𝓤 | int": false,
|
||||||
"𝓤 ∪ myInt ∪ ∅": false,
|
"𝓤 | myInt | ∅": false,
|
||||||
} {
|
} {
|
||||||
xl := maketl(test)
|
xl := maketl(test)
|
||||||
got := xl.isEmpty()
|
got := xl.isEmpty()
|
||||||
|
|
@ -65,13 +65,13 @@ func TestTermlistIsEmpty(t *testing.T) {
|
||||||
func TestTermlistIsAll(t *testing.T) {
|
func TestTermlistIsAll(t *testing.T) {
|
||||||
for test, want := range map[string]bool{
|
for test, want := range map[string]bool{
|
||||||
"∅": false,
|
"∅": false,
|
||||||
"∅ ∪ ∅": false,
|
"∅ | ∅": false,
|
||||||
"int ∪ ~string": false,
|
"int | ~string": false,
|
||||||
"~int ∪ myInt": false,
|
"~int | myInt": false,
|
||||||
"∅ ∪ ∅ ∪ 𝓤": true,
|
"∅ | ∅ | 𝓤": true,
|
||||||
"𝓤": true,
|
"𝓤": true,
|
||||||
"𝓤 ∪ int": true,
|
"𝓤 | int": true,
|
||||||
"myInt ∪ 𝓤": true,
|
"myInt | 𝓤": true,
|
||||||
} {
|
} {
|
||||||
xl := maketl(test)
|
xl := maketl(test)
|
||||||
got := xl.isAll()
|
got := xl.isAll()
|
||||||
|
|
@ -86,17 +86,17 @@ func TestTermlistNorm(t *testing.T) {
|
||||||
xl, want string
|
xl, want string
|
||||||
}{
|
}{
|
||||||
{"∅", "∅"},
|
{"∅", "∅"},
|
||||||
{"∅ ∪ ∅", "∅"},
|
{"∅ | ∅", "∅"},
|
||||||
{"∅ ∪ int", "int"},
|
{"∅ | int", "int"},
|
||||||
{"∅ ∪ myInt", "myInt"},
|
{"∅ | myInt", "myInt"},
|
||||||
{"𝓤 ∪ int", "𝓤"},
|
{"𝓤 | int", "𝓤"},
|
||||||
{"𝓤 ∪ myInt", "𝓤"},
|
{"𝓤 | myInt", "𝓤"},
|
||||||
{"int ∪ myInt", "int ∪ myInt"},
|
{"int | myInt", "int | myInt"},
|
||||||
{"~int ∪ int", "~int"},
|
{"~int | int", "~int"},
|
||||||
{"~int ∪ myInt", "~int"},
|
{"~int | myInt", "~int"},
|
||||||
{"int ∪ ~string ∪ int", "int ∪ ~string"},
|
{"int | ~string | int", "int | ~string"},
|
||||||
{"~int ∪ string ∪ 𝓤 ∪ ~string ∪ int", "𝓤"},
|
{"~int | string | 𝓤 | ~string | int", "𝓤"},
|
||||||
{"~int ∪ string ∪ myInt ∪ ~string ∪ int", "~int ∪ ~string"},
|
{"~int | string | myInt | ~string | int", "~int | ~string"},
|
||||||
} {
|
} {
|
||||||
xl := maketl(test.xl)
|
xl := maketl(test.xl)
|
||||||
got := maketl(test.xl).norm()
|
got := maketl(test.xl).norm()
|
||||||
|
|
@ -116,15 +116,15 @@ func TestTermlistUnion(t *testing.T) {
|
||||||
{"∅", "int", "int"},
|
{"∅", "int", "int"},
|
||||||
{"𝓤", "~int", "𝓤"},
|
{"𝓤", "~int", "𝓤"},
|
||||||
{"int", "~int", "~int"},
|
{"int", "~int", "~int"},
|
||||||
{"int", "string", "int ∪ string"},
|
{"int", "string", "int | string"},
|
||||||
{"int", "myInt", "int ∪ myInt"},
|
{"int", "myInt", "int | myInt"},
|
||||||
{"~int", "myInt", "~int"},
|
{"~int", "myInt", "~int"},
|
||||||
{"int ∪ string", "~string", "int ∪ ~string"},
|
{"int | string", "~string", "int | ~string"},
|
||||||
{"~int ∪ string", "~string ∪ int", "~int ∪ ~string"},
|
{"~int | string", "~string | int", "~int | ~string"},
|
||||||
{"~int ∪ string ∪ ∅", "~string ∪ int", "~int ∪ ~string"},
|
{"~int | string | ∅", "~string | int", "~int | ~string"},
|
||||||
{"~int ∪ myInt ∪ ∅", "~string ∪ int", "~int ∪ ~string"},
|
{"~int | myInt | ∅", "~string | int", "~int | ~string"},
|
||||||
{"~int ∪ string ∪ 𝓤", "~string ∪ int", "𝓤"},
|
{"~int | string | 𝓤", "~string | int", "𝓤"},
|
||||||
{"~int ∪ string ∪ myInt", "~string ∪ int", "~int ∪ ~string"},
|
{"~int | string | myInt", "~string | int", "~int | ~string"},
|
||||||
} {
|
} {
|
||||||
xl := maketl(test.xl)
|
xl := maketl(test.xl)
|
||||||
yl := maketl(test.yl)
|
yl := maketl(test.yl)
|
||||||
|
|
@ -150,12 +150,12 @@ func TestTermlistIntersect(t *testing.T) {
|
||||||
{"int", "string", "∅"},
|
{"int", "string", "∅"},
|
||||||
{"int", "myInt", "∅"},
|
{"int", "myInt", "∅"},
|
||||||
{"~int", "myInt", "myInt"},
|
{"~int", "myInt", "myInt"},
|
||||||
{"int ∪ string", "~string", "string"},
|
{"int | string", "~string", "string"},
|
||||||
{"~int ∪ string", "~string ∪ int", "int ∪ string"},
|
{"~int | string", "~string | int", "int | string"},
|
||||||
{"~int ∪ string ∪ ∅", "~string ∪ int", "int ∪ string"},
|
{"~int | string | ∅", "~string | int", "int | string"},
|
||||||
{"~int ∪ myInt ∪ ∅", "~string ∪ int", "int"},
|
{"~int | myInt | ∅", "~string | int", "int"},
|
||||||
{"~int ∪ string ∪ 𝓤", "~string ∪ int", "int ∪ ~string"},
|
{"~int | string | 𝓤", "~string | int", "int | ~string"},
|
||||||
{"~int ∪ string ∪ myInt", "~string ∪ int", "int ∪ string"},
|
{"~int | string | myInt", "~string | int", "int | string"},
|
||||||
} {
|
} {
|
||||||
xl := maketl(test.xl)
|
xl := maketl(test.xl)
|
||||||
yl := maketl(test.yl)
|
yl := maketl(test.yl)
|
||||||
|
|
@ -174,12 +174,12 @@ func TestTermlistEqual(t *testing.T) {
|
||||||
{"∅", "∅", true},
|
{"∅", "∅", true},
|
||||||
{"∅", "𝓤", false},
|
{"∅", "𝓤", false},
|
||||||
{"𝓤", "𝓤", true},
|
{"𝓤", "𝓤", true},
|
||||||
{"𝓤 ∪ int", "𝓤", true},
|
{"𝓤 | int", "𝓤", true},
|
||||||
{"𝓤 ∪ int", "string ∪ 𝓤", true},
|
{"𝓤 | int", "string | 𝓤", true},
|
||||||
{"𝓤 ∪ myInt", "string ∪ 𝓤", true},
|
{"𝓤 | myInt", "string | 𝓤", true},
|
||||||
{"int ∪ ~string", "string ∪ int", false},
|
{"int | ~string", "string | int", false},
|
||||||
{"~int ∪ string", "string ∪ myInt", false},
|
{"~int | string", "string | myInt", false},
|
||||||
{"int ∪ ~string ∪ ∅", "string ∪ int ∪ ~string", true},
|
{"int | ~string | ∅", "string | int | ~string", true},
|
||||||
} {
|
} {
|
||||||
xl := maketl(test.xl)
|
xl := maketl(test.xl)
|
||||||
yl := maketl(test.yl)
|
yl := maketl(test.yl)
|
||||||
|
|
@ -201,11 +201,11 @@ func TestTermlistIncludes(t *testing.T) {
|
||||||
{"int", "string", false},
|
{"int", "string", false},
|
||||||
{"~int", "string", false},
|
{"~int", "string", false},
|
||||||
{"~int", "myInt", true},
|
{"~int", "myInt", true},
|
||||||
{"int ∪ string", "string", true},
|
{"int | string", "string", true},
|
||||||
{"~int ∪ string", "int", true},
|
{"~int | string", "int", true},
|
||||||
{"~int ∪ string", "myInt", true},
|
{"~int | string", "myInt", true},
|
||||||
{"~int ∪ myInt ∪ ∅", "myInt", true},
|
{"~int | myInt | ∅", "myInt", true},
|
||||||
{"myInt ∪ ∅ ∪ 𝓤", "int", true},
|
{"myInt | ∅ | 𝓤", "int", true},
|
||||||
} {
|
} {
|
||||||
xl := maketl(test.xl)
|
xl := maketl(test.xl)
|
||||||
yl := testTerm(test.typ).typ
|
yl := testTerm(test.typ).typ
|
||||||
|
|
@ -236,12 +236,12 @@ func TestTermlistSupersetOf(t *testing.T) {
|
||||||
{"myInt", "~int", false},
|
{"myInt", "~int", false},
|
||||||
{"int", "string", false},
|
{"int", "string", false},
|
||||||
{"~int", "string", false},
|
{"~int", "string", false},
|
||||||
{"int ∪ string", "string", true},
|
{"int | string", "string", true},
|
||||||
{"int ∪ string", "~string", false},
|
{"int | string", "~string", false},
|
||||||
{"~int ∪ string", "int", true},
|
{"~int | string", "int", true},
|
||||||
{"~int ∪ string", "myInt", true},
|
{"~int | string", "myInt", true},
|
||||||
{"~int ∪ string ∪ ∅", "string", true},
|
{"~int | string | ∅", "string", true},
|
||||||
{"~string ∪ ∅ ∪ 𝓤", "myInt", true},
|
{"~string | ∅ | 𝓤", "myInt", true},
|
||||||
} {
|
} {
|
||||||
xl := maketl(test.xl)
|
xl := maketl(test.xl)
|
||||||
y := testTerm(test.typ)
|
y := testTerm(test.typ)
|
||||||
|
|
@ -261,18 +261,18 @@ func TestTermlistSubsetOf(t *testing.T) {
|
||||||
{"∅", "𝓤", true},
|
{"∅", "𝓤", true},
|
||||||
{"𝓤", "∅", false},
|
{"𝓤", "∅", false},
|
||||||
{"𝓤", "𝓤", true},
|
{"𝓤", "𝓤", true},
|
||||||
{"int", "int ∪ string", true},
|
{"int", "int | string", true},
|
||||||
{"~int", "int ∪ string", false},
|
{"~int", "int | string", false},
|
||||||
{"~int", "myInt ∪ string", false},
|
{"~int", "myInt | string", false},
|
||||||
{"myInt", "~int ∪ string", true},
|
{"myInt", "~int | string", true},
|
||||||
{"~int", "string ∪ string ∪ int ∪ ~int", true},
|
{"~int", "string | string | int | ~int", true},
|
||||||
{"myInt", "string ∪ string ∪ ~int", true},
|
{"myInt", "string | string | ~int", true},
|
||||||
{"int ∪ string", "string", false},
|
{"int | string", "string", false},
|
||||||
{"int ∪ string", "string ∪ int", true},
|
{"int | string", "string | int", true},
|
||||||
{"int ∪ ~string", "string ∪ int", false},
|
{"int | ~string", "string | int", false},
|
||||||
{"myInt ∪ ~string", "string ∪ int ∪ 𝓤", true},
|
{"myInt | ~string", "string | int | 𝓤", true},
|
||||||
{"int ∪ ~string", "string ∪ int ∪ ∅ ∪ string", false},
|
{"int | ~string", "string | int | ∅ | string", false},
|
||||||
{"int ∪ myInt", "string ∪ ~int ∪ ∅ ∪ string", true},
|
{"int | myInt", "string | ~int | ∅ | string", true},
|
||||||
} {
|
} {
|
||||||
xl := maketl(test.xl)
|
xl := maketl(test.xl)
|
||||||
yl := maketl(test.yl)
|
yl := maketl(test.yl)
|
||||||
|
|
|
||||||
|
|
@ -21,13 +21,13 @@ func TestTypeSetString(t *testing.T) {
|
||||||
"{}": "𝓤",
|
"{}": "𝓤",
|
||||||
"{int}": "{int}",
|
"{int}": "{int}",
|
||||||
"{~int}": "{~int}",
|
"{~int}": "{~int}",
|
||||||
"{int|string}": "{int ∪ string}",
|
"{int|string}": "{int | string}",
|
||||||
"{int; string}": "∅",
|
"{int; string}": "∅",
|
||||||
|
|
||||||
"{comparable}": "{comparable}",
|
"{comparable}": "{comparable}",
|
||||||
"{comparable; int}": "{int}",
|
"{comparable; int}": "{int}",
|
||||||
"{~int; comparable}": "{~int}",
|
"{~int; comparable}": "{~int}",
|
||||||
"{int|string; comparable}": "{int ∪ string}",
|
"{int|string; comparable}": "{int | string}",
|
||||||
"{comparable; int; string}": "∅",
|
"{comparable; int; string}": "∅",
|
||||||
|
|
||||||
"{m()}": "{func (p.T).m()}",
|
"{m()}": "{func (p.T).m()}",
|
||||||
|
|
@ -37,7 +37,7 @@ func TestTypeSetString(t *testing.T) {
|
||||||
"{m1(); comparable; m2() int }": "{comparable; func (p.T).m1(); func (p.T).m2() int}",
|
"{m1(); comparable; m2() int }": "{comparable; func (p.T).m1(); func (p.T).m2() int}",
|
||||||
"{comparable; error}": "{comparable; func (error).Error() string}",
|
"{comparable; error}": "{comparable; func (error).Error() string}",
|
||||||
|
|
||||||
"{m(); comparable; int|float32|string}": "{func (p.T).m(); int ∪ float32 ∪ string}",
|
"{m(); comparable; int|float32|string}": "{func (p.T).m(); int | float32 | string}",
|
||||||
"{m1(); int; m2(); comparable }": "{func (p.T).m1(); func (p.T).m2(); int}",
|
"{m1(); int; m2(); comparable }": "{func (p.T).m1(); func (p.T).m2(); int}",
|
||||||
|
|
||||||
"{E}; type E interface{}": "𝓤",
|
"{E}; type E interface{}": "𝓤",
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ func (xl termlist) String() string {
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
for i, x := range xl {
|
for i, x := range xl {
|
||||||
if i > 0 {
|
if i > 0 {
|
||||||
buf.WriteString(" ∪ ")
|
buf.WriteString(" | ")
|
||||||
}
|
}
|
||||||
buf.WriteString(x.String())
|
buf.WriteString(x.String())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ import (
|
||||||
// maketl makes a term list from a string of the term list.
|
// maketl makes a term list from a string of the term list.
|
||||||
func maketl(s string) termlist {
|
func maketl(s string) termlist {
|
||||||
s = strings.ReplaceAll(s, " ", "")
|
s = strings.ReplaceAll(s, " ", "")
|
||||||
names := strings.Split(s, "∪")
|
names := strings.Split(s, "|")
|
||||||
r := make(termlist, len(names))
|
r := make(termlist, len(names))
|
||||||
for i, n := range names {
|
for i, n := range names {
|
||||||
r[i] = testTerm(n)
|
r[i] = testTerm(n)
|
||||||
|
|
@ -33,10 +33,10 @@ func TestTermlistString(t *testing.T) {
|
||||||
"int",
|
"int",
|
||||||
"~int",
|
"~int",
|
||||||
"myInt",
|
"myInt",
|
||||||
"∅ ∪ ∅",
|
"∅ | ∅",
|
||||||
"𝓤 ∪ 𝓤",
|
"𝓤 | 𝓤",
|
||||||
"∅ ∪ 𝓤 ∪ int",
|
"∅ | 𝓤 | int",
|
||||||
"∅ ∪ 𝓤 ∪ int ∪ myInt",
|
"∅ | 𝓤 | int | myInt",
|
||||||
} {
|
} {
|
||||||
if got := maketl(want).String(); got != want {
|
if got := maketl(want).String(); got != want {
|
||||||
t.Errorf("(%v).String() == %v", want, got)
|
t.Errorf("(%v).String() == %v", want, got)
|
||||||
|
|
@ -47,12 +47,12 @@ func TestTermlistString(t *testing.T) {
|
||||||
func TestTermlistIsEmpty(t *testing.T) {
|
func TestTermlistIsEmpty(t *testing.T) {
|
||||||
for test, want := range map[string]bool{
|
for test, want := range map[string]bool{
|
||||||
"∅": true,
|
"∅": true,
|
||||||
"∅ ∪ ∅": true,
|
"∅ | ∅": true,
|
||||||
"∅ ∪ ∅ ∪ 𝓤": false,
|
"∅ | ∅ | 𝓤": false,
|
||||||
"∅ ∪ ∅ ∪ myInt": false,
|
"∅ | ∅ | myInt": false,
|
||||||
"𝓤": false,
|
"𝓤": false,
|
||||||
"𝓤 ∪ int": false,
|
"𝓤 | int": false,
|
||||||
"𝓤 ∪ myInt ∪ ∅": false,
|
"𝓤 | myInt | ∅": false,
|
||||||
} {
|
} {
|
||||||
xl := maketl(test)
|
xl := maketl(test)
|
||||||
got := xl.isEmpty()
|
got := xl.isEmpty()
|
||||||
|
|
@ -65,13 +65,13 @@ func TestTermlistIsEmpty(t *testing.T) {
|
||||||
func TestTermlistIsAll(t *testing.T) {
|
func TestTermlistIsAll(t *testing.T) {
|
||||||
for test, want := range map[string]bool{
|
for test, want := range map[string]bool{
|
||||||
"∅": false,
|
"∅": false,
|
||||||
"∅ ∪ ∅": false,
|
"∅ | ∅": false,
|
||||||
"int ∪ ~string": false,
|
"int | ~string": false,
|
||||||
"~int ∪ myInt": false,
|
"~int | myInt": false,
|
||||||
"∅ ∪ ∅ ∪ 𝓤": true,
|
"∅ | ∅ | 𝓤": true,
|
||||||
"𝓤": true,
|
"𝓤": true,
|
||||||
"𝓤 ∪ int": true,
|
"𝓤 | int": true,
|
||||||
"myInt ∪ 𝓤": true,
|
"myInt | 𝓤": true,
|
||||||
} {
|
} {
|
||||||
xl := maketl(test)
|
xl := maketl(test)
|
||||||
got := xl.isAll()
|
got := xl.isAll()
|
||||||
|
|
@ -86,17 +86,17 @@ func TestTermlistNorm(t *testing.T) {
|
||||||
xl, want string
|
xl, want string
|
||||||
}{
|
}{
|
||||||
{"∅", "∅"},
|
{"∅", "∅"},
|
||||||
{"∅ ∪ ∅", "∅"},
|
{"∅ | ∅", "∅"},
|
||||||
{"∅ ∪ int", "int"},
|
{"∅ | int", "int"},
|
||||||
{"∅ ∪ myInt", "myInt"},
|
{"∅ | myInt", "myInt"},
|
||||||
{"𝓤 ∪ int", "𝓤"},
|
{"𝓤 | int", "𝓤"},
|
||||||
{"𝓤 ∪ myInt", "𝓤"},
|
{"𝓤 | myInt", "𝓤"},
|
||||||
{"int ∪ myInt", "int ∪ myInt"},
|
{"int | myInt", "int | myInt"},
|
||||||
{"~int ∪ int", "~int"},
|
{"~int | int", "~int"},
|
||||||
{"~int ∪ myInt", "~int"},
|
{"~int | myInt", "~int"},
|
||||||
{"int ∪ ~string ∪ int", "int ∪ ~string"},
|
{"int | ~string | int", "int | ~string"},
|
||||||
{"~int ∪ string ∪ 𝓤 ∪ ~string ∪ int", "𝓤"},
|
{"~int | string | 𝓤 | ~string | int", "𝓤"},
|
||||||
{"~int ∪ string ∪ myInt ∪ ~string ∪ int", "~int ∪ ~string"},
|
{"~int | string | myInt | ~string | int", "~int | ~string"},
|
||||||
} {
|
} {
|
||||||
xl := maketl(test.xl)
|
xl := maketl(test.xl)
|
||||||
got := maketl(test.xl).norm()
|
got := maketl(test.xl).norm()
|
||||||
|
|
@ -116,15 +116,15 @@ func TestTermlistUnion(t *testing.T) {
|
||||||
{"∅", "int", "int"},
|
{"∅", "int", "int"},
|
||||||
{"𝓤", "~int", "𝓤"},
|
{"𝓤", "~int", "𝓤"},
|
||||||
{"int", "~int", "~int"},
|
{"int", "~int", "~int"},
|
||||||
{"int", "string", "int ∪ string"},
|
{"int", "string", "int | string"},
|
||||||
{"int", "myInt", "int ∪ myInt"},
|
{"int", "myInt", "int | myInt"},
|
||||||
{"~int", "myInt", "~int"},
|
{"~int", "myInt", "~int"},
|
||||||
{"int ∪ string", "~string", "int ∪ ~string"},
|
{"int | string", "~string", "int | ~string"},
|
||||||
{"~int ∪ string", "~string ∪ int", "~int ∪ ~string"},
|
{"~int | string", "~string | int", "~int | ~string"},
|
||||||
{"~int ∪ string ∪ ∅", "~string ∪ int", "~int ∪ ~string"},
|
{"~int | string | ∅", "~string | int", "~int | ~string"},
|
||||||
{"~int ∪ myInt ∪ ∅", "~string ∪ int", "~int ∪ ~string"},
|
{"~int | myInt | ∅", "~string | int", "~int | ~string"},
|
||||||
{"~int ∪ string ∪ 𝓤", "~string ∪ int", "𝓤"},
|
{"~int | string | 𝓤", "~string | int", "𝓤"},
|
||||||
{"~int ∪ string ∪ myInt", "~string ∪ int", "~int ∪ ~string"},
|
{"~int | string | myInt", "~string | int", "~int | ~string"},
|
||||||
} {
|
} {
|
||||||
xl := maketl(test.xl)
|
xl := maketl(test.xl)
|
||||||
yl := maketl(test.yl)
|
yl := maketl(test.yl)
|
||||||
|
|
@ -150,12 +150,12 @@ func TestTermlistIntersect(t *testing.T) {
|
||||||
{"int", "string", "∅"},
|
{"int", "string", "∅"},
|
||||||
{"int", "myInt", "∅"},
|
{"int", "myInt", "∅"},
|
||||||
{"~int", "myInt", "myInt"},
|
{"~int", "myInt", "myInt"},
|
||||||
{"int ∪ string", "~string", "string"},
|
{"int | string", "~string", "string"},
|
||||||
{"~int ∪ string", "~string ∪ int", "int ∪ string"},
|
{"~int | string", "~string | int", "int | string"},
|
||||||
{"~int ∪ string ∪ ∅", "~string ∪ int", "int ∪ string"},
|
{"~int | string | ∅", "~string | int", "int | string"},
|
||||||
{"~int ∪ myInt ∪ ∅", "~string ∪ int", "int"},
|
{"~int | myInt | ∅", "~string | int", "int"},
|
||||||
{"~int ∪ string ∪ 𝓤", "~string ∪ int", "int ∪ ~string"},
|
{"~int | string | 𝓤", "~string | int", "int | ~string"},
|
||||||
{"~int ∪ string ∪ myInt", "~string ∪ int", "int ∪ string"},
|
{"~int | string | myInt", "~string | int", "int | string"},
|
||||||
} {
|
} {
|
||||||
xl := maketl(test.xl)
|
xl := maketl(test.xl)
|
||||||
yl := maketl(test.yl)
|
yl := maketl(test.yl)
|
||||||
|
|
@ -174,12 +174,12 @@ func TestTermlistEqual(t *testing.T) {
|
||||||
{"∅", "∅", true},
|
{"∅", "∅", true},
|
||||||
{"∅", "𝓤", false},
|
{"∅", "𝓤", false},
|
||||||
{"𝓤", "𝓤", true},
|
{"𝓤", "𝓤", true},
|
||||||
{"𝓤 ∪ int", "𝓤", true},
|
{"𝓤 | int", "𝓤", true},
|
||||||
{"𝓤 ∪ int", "string ∪ 𝓤", true},
|
{"𝓤 | int", "string | 𝓤", true},
|
||||||
{"𝓤 ∪ myInt", "string ∪ 𝓤", true},
|
{"𝓤 | myInt", "string | 𝓤", true},
|
||||||
{"int ∪ ~string", "string ∪ int", false},
|
{"int | ~string", "string | int", false},
|
||||||
{"~int ∪ string", "string ∪ myInt", false},
|
{"~int | string", "string | myInt", false},
|
||||||
{"int ∪ ~string ∪ ∅", "string ∪ int ∪ ~string", true},
|
{"int | ~string | ∅", "string | int | ~string", true},
|
||||||
} {
|
} {
|
||||||
xl := maketl(test.xl)
|
xl := maketl(test.xl)
|
||||||
yl := maketl(test.yl)
|
yl := maketl(test.yl)
|
||||||
|
|
@ -201,11 +201,11 @@ func TestTermlistIncludes(t *testing.T) {
|
||||||
{"int", "string", false},
|
{"int", "string", false},
|
||||||
{"~int", "string", false},
|
{"~int", "string", false},
|
||||||
{"~int", "myInt", true},
|
{"~int", "myInt", true},
|
||||||
{"int ∪ string", "string", true},
|
{"int | string", "string", true},
|
||||||
{"~int ∪ string", "int", true},
|
{"~int | string", "int", true},
|
||||||
{"~int ∪ string", "myInt", true},
|
{"~int | string", "myInt", true},
|
||||||
{"~int ∪ myInt ∪ ∅", "myInt", true},
|
{"~int | myInt | ∅", "myInt", true},
|
||||||
{"myInt ∪ ∅ ∪ 𝓤", "int", true},
|
{"myInt | ∅ | 𝓤", "int", true},
|
||||||
} {
|
} {
|
||||||
xl := maketl(test.xl)
|
xl := maketl(test.xl)
|
||||||
yl := testTerm(test.typ).typ
|
yl := testTerm(test.typ).typ
|
||||||
|
|
@ -236,12 +236,12 @@ func TestTermlistSupersetOf(t *testing.T) {
|
||||||
{"myInt", "~int", false},
|
{"myInt", "~int", false},
|
||||||
{"int", "string", false},
|
{"int", "string", false},
|
||||||
{"~int", "string", false},
|
{"~int", "string", false},
|
||||||
{"int ∪ string", "string", true},
|
{"int | string", "string", true},
|
||||||
{"int ∪ string", "~string", false},
|
{"int | string", "~string", false},
|
||||||
{"~int ∪ string", "int", true},
|
{"~int | string", "int", true},
|
||||||
{"~int ∪ string", "myInt", true},
|
{"~int | string", "myInt", true},
|
||||||
{"~int ∪ string ∪ ∅", "string", true},
|
{"~int | string | ∅", "string", true},
|
||||||
{"~string ∪ ∅ ∪ 𝓤", "myInt", true},
|
{"~string | ∅ | 𝓤", "myInt", true},
|
||||||
} {
|
} {
|
||||||
xl := maketl(test.xl)
|
xl := maketl(test.xl)
|
||||||
y := testTerm(test.typ)
|
y := testTerm(test.typ)
|
||||||
|
|
@ -261,18 +261,18 @@ func TestTermlistSubsetOf(t *testing.T) {
|
||||||
{"∅", "𝓤", true},
|
{"∅", "𝓤", true},
|
||||||
{"𝓤", "∅", false},
|
{"𝓤", "∅", false},
|
||||||
{"𝓤", "𝓤", true},
|
{"𝓤", "𝓤", true},
|
||||||
{"int", "int ∪ string", true},
|
{"int", "int | string", true},
|
||||||
{"~int", "int ∪ string", false},
|
{"~int", "int | string", false},
|
||||||
{"~int", "myInt ∪ string", false},
|
{"~int", "myInt | string", false},
|
||||||
{"myInt", "~int ∪ string", true},
|
{"myInt", "~int | string", true},
|
||||||
{"~int", "string ∪ string ∪ int ∪ ~int", true},
|
{"~int", "string | string | int | ~int", true},
|
||||||
{"myInt", "string ∪ string ∪ ~int", true},
|
{"myInt", "string | string | ~int", true},
|
||||||
{"int ∪ string", "string", false},
|
{"int | string", "string", false},
|
||||||
{"int ∪ string", "string ∪ int", true},
|
{"int | string", "string | int", true},
|
||||||
{"int ∪ ~string", "string ∪ int", false},
|
{"int | ~string", "string | int", false},
|
||||||
{"myInt ∪ ~string", "string ∪ int ∪ 𝓤", true},
|
{"myInt | ~string", "string | int | 𝓤", true},
|
||||||
{"int ∪ ~string", "string ∪ int ∪ ∅ ∪ string", false},
|
{"int | ~string", "string | int | ∅ | string", false},
|
||||||
{"int ∪ myInt", "string ∪ ~int ∪ ∅ ∪ string", true},
|
{"int | myInt", "string | ~int | ∅ | string", true},
|
||||||
} {
|
} {
|
||||||
xl := maketl(test.xl)
|
xl := maketl(test.xl)
|
||||||
yl := maketl(test.yl)
|
yl := maketl(test.yl)
|
||||||
|
|
|
||||||
|
|
@ -22,13 +22,13 @@ func TestTypeSetString(t *testing.T) {
|
||||||
"{}": "𝓤",
|
"{}": "𝓤",
|
||||||
"{int}": "{int}",
|
"{int}": "{int}",
|
||||||
"{~int}": "{~int}",
|
"{~int}": "{~int}",
|
||||||
"{int|string}": "{int ∪ string}",
|
"{int|string}": "{int | string}",
|
||||||
"{int; string}": "∅",
|
"{int; string}": "∅",
|
||||||
|
|
||||||
"{comparable}": "{comparable}",
|
"{comparable}": "{comparable}",
|
||||||
"{comparable; int}": "{int}",
|
"{comparable; int}": "{int}",
|
||||||
"{~int; comparable}": "{~int}",
|
"{~int; comparable}": "{~int}",
|
||||||
"{int|string; comparable}": "{int ∪ string}",
|
"{int|string; comparable}": "{int | string}",
|
||||||
"{comparable; int; string}": "∅",
|
"{comparable; int; string}": "∅",
|
||||||
|
|
||||||
"{m()}": "{func (p.T).m()}",
|
"{m()}": "{func (p.T).m()}",
|
||||||
|
|
@ -38,7 +38,7 @@ func TestTypeSetString(t *testing.T) {
|
||||||
"{m1(); comparable; m2() int }": "{comparable; func (p.T).m1(); func (p.T).m2() int}",
|
"{m1(); comparable; m2() int }": "{comparable; func (p.T).m1(); func (p.T).m2() int}",
|
||||||
"{comparable; error}": "{comparable; func (error).Error() string}",
|
"{comparable; error}": "{comparable; func (error).Error() string}",
|
||||||
|
|
||||||
"{m(); comparable; int|float32|string}": "{func (p.T).m(); int ∪ float32 ∪ string}",
|
"{m(); comparable; int|float32|string}": "{func (p.T).m(); int | float32 | string}",
|
||||||
"{m1(); int; m2(); comparable }": "{func (p.T).m1(); func (p.T).m2(); int}",
|
"{m1(); int; m2(); comparable }": "{func (p.T).m1(); func (p.T).m2(); int}",
|
||||||
|
|
||||||
"{E}; type E interface{}": "𝓤",
|
"{E}; type E interface{}": "𝓤",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue