(step PathStep)
| 236 | } |
| 237 | |
| 238 | func (s *state) compareAny(step PathStep) { |
| 239 | // Update the path stack. |
| 240 | s.curPath.push(step) |
| 241 | defer s.curPath.pop() |
| 242 | for _, r := range s.reporters { |
| 243 | r.PushStep(step) |
| 244 | defer r.PopStep() |
| 245 | } |
| 246 | s.recChecker.Check(s.curPath) |
| 247 | |
| 248 | // Cycle-detection for slice elements (see NOTE in compareSlice). |
| 249 | t := step.Type() |
| 250 | vx, vy := step.Values() |
| 251 | if si, ok := step.(SliceIndex); ok && si.isSlice && vx.IsValid() && vy.IsValid() { |
| 252 | px, py := vx.Addr(), vy.Addr() |
| 253 | if eq, visited := s.curPtrs.Push(px, py); visited { |
| 254 | s.report(eq, reportByCycle) |
| 255 | return |
| 256 | } |
| 257 | defer s.curPtrs.Pop(px, py) |
| 258 | } |
| 259 | |
| 260 | // Rule 1: Check whether an option applies on this node in the value tree. |
| 261 | if s.tryOptions(t, vx, vy) { |
| 262 | return |
| 263 | } |
| 264 | |
| 265 | // Rule 2: Check whether the type has a valid Equal method. |
| 266 | if s.tryMethod(t, vx, vy) { |
| 267 | return |
| 268 | } |
| 269 | |
| 270 | // Rule 3: Compare based on the underlying kind. |
| 271 | switch t.Kind() { |
| 272 | case reflect.Bool: |
| 273 | s.report(vx.Bool() == vy.Bool(), 0) |
| 274 | case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: |
| 275 | s.report(vx.Int() == vy.Int(), 0) |
| 276 | case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: |
| 277 | s.report(vx.Uint() == vy.Uint(), 0) |
| 278 | case reflect.Float32, reflect.Float64: |
| 279 | s.report(vx.Float() == vy.Float(), 0) |
| 280 | case reflect.Complex64, reflect.Complex128: |
| 281 | s.report(vx.Complex() == vy.Complex(), 0) |
| 282 | case reflect.String: |
| 283 | s.report(vx.String() == vy.String(), 0) |
| 284 | case reflect.Chan, reflect.UnsafePointer: |
| 285 | s.report(vx.Pointer() == vy.Pointer(), 0) |
| 286 | case reflect.Func: |
| 287 | s.report(vx.IsNil() && vy.IsNil(), 0) |
| 288 | case reflect.Struct: |
| 289 | s.compareStruct(t, vx, vy) |
| 290 | case reflect.Slice, reflect.Array: |
| 291 | s.compareSlice(t, vx, vy) |
| 292 | case reflect.Map: |
| 293 | s.compareMap(t, vx, vy) |
| 294 | case reflect.Ptr: |
| 295 | s.comparePtr(t, vx, vy) |
no test coverage detected