1package oraclematcher 2 3import "github.com/onsi/gomega/types" 4 5/* 6GomegaMatchers that also match the OracleMatcher interface can convey information about 7whether or not their result will change upon future attempts. 8 9This allows `Eventually` and `Consistently` to short circuit if success becomes impossible. 10 11For example, a process' exit code can never change. So, gexec's Exit matcher returns `true` 12for `MatchMayChangeInTheFuture` until the process exits, at which point it returns `false` forevermore. 13*/ 14type OracleMatcher interface { 15 MatchMayChangeInTheFuture(actual interface{}) bool 16} 17 18func 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} 26