コード例 #1
0
ファイル: and.go プロジェクト: jghiloni/hello-world-go
func (m *AndMatcher) MatchMayChangeInTheFuture(actual interface{}) bool {
	/*
		Example with 3 matchers: A, B, C

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

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

	if m.firstFailedMatcher == nil {
		// so all matchers succeeded.. 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
	} else {
		// one of the matchers failed.. it must be able to change in order to affect the result
		return oraclematcher.MatchMayChangeInTheFuture(m.firstFailedMatcher, actual)
	}
}
コード例 #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
ファイル: not.go プロジェクト: jghiloni/hello-world-go
func (m *NotMatcher) MatchMayChangeInTheFuture(actual interface{}) bool {
	return oraclematcher.MatchMayChangeInTheFuture(m.Matcher, actual) // just return m.Matcher's value
}