Skip to content

Commit 7a4614f

Browse files
committed
replace more cmp.Equal calls with cmp.Diff
1 parent 9612d6a commit 7a4614f

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

expr_lexer_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -576,11 +576,11 @@ func TestLexExpression(t *testing.T) {
576576
values = append(values, t.Value)
577577
}
578578

579-
if !cmp.Equal(kinds, tc.tokens) {
580-
t.Errorf("wanted token kinds %#v but got %#v", tc.tokens, kinds)
579+
if diff := cmp.Diff(kinds, tc.tokens); diff != "" {
580+
t.Error("unexpectedtoken kinds:", diff)
581581
}
582-
if !cmp.Equal(values, tc.values) {
583-
t.Errorf("wanted values %#v but got %#v", tc.values, values)
582+
if diff := cmp.Diff(values, tc.values); diff != "" {
583+
t.Error("unexpectedtoken values:", diff)
584584
}
585585

586586
if offset != len(tc.input)+len("}}") {

expr_sema_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -1664,8 +1664,8 @@ func TestExprSemanticsCheckerUpdateInputsMultipleTimes(t *testing.T) {
16641664
c.UpdateInputs(tc.first)
16651665
c.UpdateDispatchInputs(tc.second)
16661666
have := c.vars["inputs"]
1667-
if !cmp.Equal(have, tc.want) {
1668-
t.Fatal("Merged `inputs` type is unexpected", have, "v.s.", tc.want)
1667+
if diff := cmp.Diff(have, tc.want); diff != "" {
1668+
t.Fatal(diff)
16691669
}
16701670
})
16711671
}
@@ -1784,8 +1784,8 @@ func TestParseFormatSpecifiers(t *testing.T) {
17841784
}
17851785
have := parseFormatFuncSpecifiers(tc.in, len(tc.want))
17861786

1787-
if !cmp.Equal(want, have) {
1788-
t.Fatal(cmp.Diff(want, have))
1787+
if diff := cmp.Diff(want, have); diff != "" {
1788+
t.Fatal(diff)
17891789
}
17901790
})
17911791
}

expr_type_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1029,8 +1029,8 @@ func TestExprTypeTypeOfJSONValue(t *testing.T) {
10291029
for _, tc := range tests {
10301030
t.Run(tc.what, func(t *testing.T) {
10311031
have := typeOfJSONValue(tc.value)
1032-
if !cmp.Equal(tc.want, have) {
1033-
t.Fatal(cmp.Diff(tc.want, have))
1032+
if diff := cmp.Diff(tc.want, have); diff != "" {
1033+
t.Fatal(diff)
10341034
}
10351035
})
10361036
}

0 commit comments

Comments
 (0)