@@ -88,7 +88,7 @@ func (t Type) String() string {
88
88
return "invalid type"
89
89
}
90
90
91
- // IsExcess can be used in a WalkFn to find values missing from the LHS
91
+ // IsExcess returns true if d represent value missing from the LHS (in a map or an array)
92
92
func IsExcess (d Differ ) bool {
93
93
switch d .(type ) {
94
94
default :
@@ -100,7 +100,7 @@ func IsExcess(d Differ) bool {
100
100
}
101
101
}
102
102
103
- // IsMissing can be used in a WalkFn to find values missing from the RHS
103
+ // IsMissing returns true if d represent value missing from the RHS (in a map or an array)
104
104
func IsMissing (d Differ ) bool {
105
105
switch d .(type ) {
106
106
default :
@@ -112,23 +112,58 @@ func IsMissing(d Differ) bool {
112
112
}
113
113
}
114
114
115
+ // IsScalar returns true of d is a diff between two values that can be compared (int, float64, string, ...)
116
+ func IsScalar (d Differ ) bool {
117
+ _ , ok := d .(scalar )
118
+
119
+ return ok
120
+ }
121
+
122
+ // IsTypes returns true if d is a diff between two values of different types that cannot be compared
123
+ func IsTypes (d Differ ) bool {
124
+ _ , ok := d .(types )
125
+
126
+ return ok
127
+ }
128
+
129
+ // IsIgnore returns true if d is a diff created by NewIgnore
130
+ func IsIgnore (d Differ ) bool {
131
+ _ , ok := d .(ignore )
132
+
133
+ return ok
134
+ }
135
+
136
+ // IsMap returns true if d is a diff between towo maps
137
+ func IsMap (d Differ ) bool {
138
+ _ , ok := d .(mapDiff )
139
+
140
+ return ok
141
+ }
142
+
143
+ // IsSlice returns true if d is a diff between towo slices
144
+ func IsSlice (d Differ ) bool {
145
+ _ , ok := d .(slice )
146
+
147
+ return ok
148
+ }
149
+
115
150
type visited struct {
116
- LHS []uintptr
117
- RHS []uintptr
151
+ lhs []uintptr
152
+ rhs []uintptr
118
153
}
119
154
120
155
func (v * visited ) add (lhs , rhs reflect.Value ) error {
121
156
if canAddr (lhs ) {
122
- if inPointers (v .LHS , lhs ) {
157
+ if inPointers (v .lhs , lhs ) {
123
158
return ErrCyclic
124
159
}
125
- v .LHS = append (v .LHS , lhs .Pointer ())
160
+ v .lhs = append (v .lhs , lhs .Pointer ())
126
161
}
127
162
if canAddr (rhs ) {
128
- if inPointers (v .RHS , rhs ) {
163
+ if inPointers (v .rhs , rhs ) {
129
164
return ErrCyclic
130
165
}
131
- v .RHS = append (v .RHS , rhs .Pointer ())
166
+ v .rhs = append (v .rhs , rhs .Pointer ())
132
167
}
133
168
134
169
return nil
0 commit comments