Skip to content

Commit

Permalink
replace more cmp.Equal calls with cmp.Diff
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysd committed Nov 15, 2024
1 parent 9612d6a commit 7a4614f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions expr_lexer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -576,11 +576,11 @@ func TestLexExpression(t *testing.T) {
values = append(values, t.Value)
}

if !cmp.Equal(kinds, tc.tokens) {
t.Errorf("wanted token kinds %#v but got %#v", tc.tokens, kinds)
if diff := cmp.Diff(kinds, tc.tokens); diff != "" {
t.Error("unexpectedtoken kinds:", diff)
}
if !cmp.Equal(values, tc.values) {
t.Errorf("wanted values %#v but got %#v", tc.values, values)
if diff := cmp.Diff(values, tc.values); diff != "" {
t.Error("unexpectedtoken values:", diff)
}

if offset != len(tc.input)+len("}}") {
Expand Down
8 changes: 4 additions & 4 deletions expr_sema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1664,8 +1664,8 @@ func TestExprSemanticsCheckerUpdateInputsMultipleTimes(t *testing.T) {
c.UpdateInputs(tc.first)
c.UpdateDispatchInputs(tc.second)
have := c.vars["inputs"]
if !cmp.Equal(have, tc.want) {
t.Fatal("Merged `inputs` type is unexpected", have, "v.s.", tc.want)
if diff := cmp.Diff(have, tc.want); diff != "" {
t.Fatal(diff)
}
})
}
Expand Down Expand Up @@ -1784,8 +1784,8 @@ func TestParseFormatSpecifiers(t *testing.T) {
}
have := parseFormatFuncSpecifiers(tc.in, len(tc.want))

if !cmp.Equal(want, have) {
t.Fatal(cmp.Diff(want, have))
if diff := cmp.Diff(want, have); diff != "" {
t.Fatal(diff)
}
})
}
Expand Down
4 changes: 2 additions & 2 deletions expr_type_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1029,8 +1029,8 @@ func TestExprTypeTypeOfJSONValue(t *testing.T) {
for _, tc := range tests {
t.Run(tc.what, func(t *testing.T) {
have := typeOfJSONValue(tc.value)
if !cmp.Equal(tc.want, have) {
t.Fatal(cmp.Diff(tc.want, have))
if diff := cmp.Diff(tc.want, have); diff != "" {
t.Fatal(diff)
}
})
}
Expand Down

0 comments on commit 7a4614f

Please sign in to comment.