@@ -88,7 +88,7 @@ func (t Type) String() string {
8888 return "invalid type"
8989}
9090
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)
9292func IsExcess (d Differ ) bool {
9393 switch d .(type ) {
9494 default :
@@ -100,7 +100,7 @@ func IsExcess(d Differ) bool {
100100 }
101101}
102102
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)
104104func IsMissing (d Differ ) bool {
105105 switch d .(type ) {
106106 default :
@@ -112,23 +112,58 @@ func IsMissing(d Differ) bool {
112112 }
113113}
114114
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+
115150type visited struct {
116- LHS []uintptr
117- RHS []uintptr
151+ lhs []uintptr
152+ rhs []uintptr
118153}
119154
120155func (v * visited ) add (lhs , rhs reflect.Value ) error {
121156 if canAddr (lhs ) {
122- if inPointers (v .LHS , lhs ) {
157+ if inPointers (v .lhs , lhs ) {
123158 return ErrCyclic
124159 }
125- v .LHS = append (v .LHS , lhs .Pointer ())
160+ v .lhs = append (v .lhs , lhs .Pointer ())
126161 }
127162 if canAddr (rhs ) {
128- if inPointers (v .RHS , rhs ) {
163+ if inPointers (v .rhs , rhs ) {
129164 return ErrCyclic
130165 }
131- v .RHS = append (v .RHS , rhs .Pointer ())
166+ v .rhs = append (v .rhs , rhs .Pointer ())
132167 }
133168
134169 return nil
0 commit comments