MCPcopy Create free account
hub / github.com/gavv/httpexpect / Iter

Method Iter

array.go:358–378  ·  view source on GitHub ↗

Iter returns a new slice of Values attached to array elements. Example: strings := []interface{}{"foo", "bar"} array := NewArray(t, strings) for index, value := range array.Iter() { value.String().IsEqual(strings[index]) }

()

Source from the content-addressed store, hash-verified

356// value.String().IsEqual(strings[index])
357// }
358func (a *Array) Iter() []Value {
359 opChain := a.chain.enter("Iter()")
360 defer opChain.leave()
361
362 if opChain.failed() {
363 return []Value{}
364 }
365
366 ret := []Value{}
367
368 for index, element := range a.value {
369 func() {
370 valueChain := opChain.replace("Iter[%d]", index)
371 defer valueChain.leave()
372
373 ret = append(ret, *newValue(valueChain, element))
374 }()
375 }
376
377 return ret
378}
379
380// Every runs the passed function on all the elements in the array.
381//

Callers 6

TestArray_IterFunction · 0.95
TestArray_FailedChainFunction · 0.45
TestValue_PathTypesFunction · 0.45
TestObject_FailedChainFunction · 0.45
TestIrisThingsFunction · 0.45
TestFruitsFunction · 0.45

Calls 5

newValueFunction · 0.85
enterMethod · 0.80
leaveMethod · 0.80
failedMethod · 0.80
replaceMethod · 0.80

Tested by 6

TestArray_IterFunction · 0.76
TestArray_FailedChainFunction · 0.36
TestValue_PathTypesFunction · 0.36
TestObject_FailedChainFunction · 0.36
TestIrisThingsFunction · 0.36
TestFruitsFunction · 0.36