Skip to content

Commit

Permalink
adding deepequal interface test from tinygo-org#4360 (which passes, e…
Browse files Browse the repository at this point in the history
…xcellent)
  • Loading branch information
ldemailly committed Jul 31, 2024
1 parent 7024d11 commit 7104f88
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/reflect/all_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1102,6 +1102,20 @@ func init() {
cycleMap3["different"] = cycleMap3
}

type deepEqualInterface interface {
Foo()
}
type deepEqualConcrete struct {
int
}

func (deepEqualConcrete) Foo() {}

var (
deepEqualConcrete1 = deepEqualConcrete{1}
deepEqualConcrete2 = deepEqualConcrete{2}
)

var deepEqualTests = []DeepEqualTest{
// Equalities
{nil, nil, true},
Expand All @@ -1119,6 +1133,7 @@ var deepEqualTests = []DeepEqualTest{
{[]byte{1, 2, 3}, []byte{1, 2, 3}, true},
{[]MyByte{1, 2, 3}, []MyByte{1, 2, 3}, true},
{MyBytes{1, 2, 3}, MyBytes{1, 2, 3}, true},
{map[deepEqualInterface]string{deepEqualConcrete1: "a"}, map[deepEqualInterface]string{deepEqualConcrete1: "a"}, true},

// Inequalities
{1, 2, false},
Expand All @@ -1140,6 +1155,7 @@ var deepEqualTests = []DeepEqualTest{
{fn3, fn3, false},
{[][]int{{1}}, [][]int{{2}}, false},
{&structWithSelfPtr{p: &structWithSelfPtr{s: "a"}}, &structWithSelfPtr{p: &structWithSelfPtr{s: "b"}}, false},
{map[deepEqualInterface]string{deepEqualConcrete1: "a"}, map[deepEqualInterface]string{deepEqualConcrete2: "b"}, false},

// Fun with floating point.
{math.NaN(), math.NaN(), false},
Expand Down

0 comments on commit 7104f88

Please sign in to comment.