示例#1
0
文件: or.go 项目: 40a/bootkube
func (m *OrMatcher) MatchMayChangeInTheFuture(actual interface{}) bool {
	/*
		Example with 3 matchers: A, B, C

		Match evaluates them: F, T, <?>  => T
		So match is currently T, what should MatchMayChangeInTheFuture() return?
		Seems like it only depends on B, since currently B MUST change to allow the result to become F

		Match eval: F, F, F  => F
		So match is currently F, what should MatchMayChangeInTheFuture() return?
		Seems to depend on ANY of them being able to change to T.
	*/

	if m.firstSuccessfulMatcher != nil {
		// one of the matchers succeeded.. it must be able to change in order to affect the result
		return oraclematcher.MatchMayChangeInTheFuture(m.firstSuccessfulMatcher, actual)
	} else {
		// so all matchers failed.. Any one of them changing would change the result.
		for _, matcher := range m.Matchers {
			if oraclematcher.MatchMayChangeInTheFuture(matcher, actual) {
				return true
			}
		}
		return false // none of were going to change
	}
}
示例#2
0
func (assertion *AsyncAssertion) matcherMayChange(matcher types.GomegaMatcher, value interface{}) bool {
	if assertion.actualInputIsAFunction() {
		return true
	}

	return oraclematcher.MatchMayChangeInTheFuture(matcher, value)
}
示例#3
0
func (m *WithTransformMatcher) MatchMayChangeInTheFuture(_ interface{}) bool {
	// TODO: Maybe this should always just return true? (Only an issue for non-deterministic transformers.)
	//
	// Querying the next matcher is fine if the transformer always will return the same value.
	// But if the transformer is non-deterministic and returns a different value each time, then there
	// is no point in querying the next matcher, since it can only comment on the last transformed value.
	return oraclematcher.MatchMayChangeInTheFuture(m.Matcher, m.transformedValue)
}
示例#4
0
func (m *NotMatcher) MatchMayChangeInTheFuture(actual interface{}) bool {
	return oraclematcher.MatchMayChangeInTheFuture(m.Matcher, actual) // just return m.Matcher's value
}