Пример #1
0
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 asyncassertion.MatchMayChangeInTheFuture(m.firstSuccessfulMatcher, actual)
	} else {
		// so all matchers failed.. Any one of them changing would change the result.
		for _, matcher := range m.Matchers {
			if asyncassertion.MatchMayChangeInTheFuture(matcher, actual) {
				return true
			}
		}
		return false // none of were going to change
	}
}
Пример #2
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 asyncassertion.MatchMayChangeInTheFuture(m.Matcher, m.transformedValue)
}
Пример #3
0
func (m *NotMatcher) MatchMayChangeInTheFuture(actual interface{}) bool {
	return asyncassertion.MatchMayChangeInTheFuture(m.Matcher, actual) // just return m.Matcher's value
}