MCPcopy
hub / github.com/google/go-cmp / PushStep

Method PushStep

cmp/report_value.go:53–81  ·  view source on GitHub ↗
(ps PathStep)

Source from the content-addressed store, hash-verified

51}
52
53func (parent *valueNode) PushStep(ps PathStep) (child *valueNode) {
54 vx, vy := ps.Values()
55 child = &valueNode{parent: parent, Type: ps.Type(), ValueX: vx, ValueY: vy}
56 switch s := ps.(type) {
57 case StructField:
58 assert(parent.Value == nil)
59 parent.Records = append(parent.Records, reportRecord{Key: reflect.ValueOf(s.Name()), Value: child})
60 case SliceIndex:
61 assert(parent.Value == nil)
62 parent.Records = append(parent.Records, reportRecord{Value: child})
63 case MapIndex:
64 assert(parent.Value == nil)
65 parent.Records = append(parent.Records, reportRecord{Key: s.Key(), Value: child})
66 case Indirect:
67 assert(parent.Value == nil && parent.Records == nil)
68 parent.Value = child
69 case TypeAssertion:
70 assert(parent.Value == nil && parent.Records == nil)
71 parent.Value = child
72 case Transform:
73 assert(parent.Value == nil && parent.Records == nil)
74 parent.Value = child
75 parent.TransformerName = s.Name()
76 parent.NumTransformed++
77 default:
78 assert(parent == nil) // Must be the root step
79 }
80 return child
81}
82
83func (r *valueNode) Report(rs Result) {
84 assert(r.MaxDepth == 0) // May only be called on leaf nodes

Callers

nothing calls this directly

Calls 5

assertFunction · 0.85
ValuesMethod · 0.65
TypeMethod · 0.65
NameMethod · 0.45
KeyMethod · 0.45

Tested by

no test coverage detected