initial commit
[govpp.git] / vendor / github.com / onsi / gomega / internal / oraclematcher / oracle_matcher.go
1 package oraclematcher
2
3 import "github.com/onsi/gomega/types"
4
5 /*
6 GomegaMatchers that also match the OracleMatcher interface can convey information about
7 whether or not their result will change upon future attempts.
8
9 This allows `Eventually` and `Consistently` to short circuit if success becomes impossible.
10
11 For example, a process' exit code can never change.  So, gexec's Exit matcher returns `true`
12 for `MatchMayChangeInTheFuture` until the process exits, at which point it returns `false` forevermore.
13 */
14 type OracleMatcher interface {
15         MatchMayChangeInTheFuture(actual interface{}) bool
16 }
17
18 func MatchMayChangeInTheFuture(matcher types.GomegaMatcher, value interface{}) bool {
19         oracleMatcher, ok := matcher.(OracleMatcher)
20         if !ok {
21                 return true
22         }
23
24         return oracleMatcher.MatchMayChangeInTheFuture(value)
25 }