Last active
September 4, 2022 14:40
Revisions
-
JARinteractive revised this gist
Mar 7, 2018 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ // https://gist.github.com/JARinteractive/7fb33b6b0043f365ddfd import Foundation import XCTest -
JARinteractive revised this gist
Mar 7, 2018 . 1 changed file with 15 additions and 10 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,14 +1,19 @@ import Foundation import XCTest @discardableResult public func AssertEventuallyTrue(file: StaticString = #file, line: UInt = #line, _ checkSuccess: @autoclosure () -> Bool) -> Bool { return AssertEventuallyTrue(10.0, file: file, line: line, checkSuccess) } @discardableResult public func AssertEventuallyTrue(_ timeout: Double, file: StaticString = #file, line: UInt = #line, _ checkSuccess: @autoclosure () -> Bool) -> Bool { let startDate = NSDate() var success = false while !success && abs(startDate.timeIntervalSinceNow) < timeout { RunLoop.current.run(until: Date(timeIntervalSinceNow: 0.01)) success = checkSuccess() } if !success { XCTFail("Timeout occurred while waiting for condition (waitUntil)", file: file, line: line) } return success } -
JARinteractive revised this gist
Jan 19, 2017 . 1 changed file with 10 additions and 11 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,15 +1,14 @@ import Foundation func waitUntil(_ checkSuccess: @autoclosure ()->Bool) { return waitUntil(1.0, checkSuccess) } func waitUntil(_ timeout: Double, _ checkSuccess: @autoclosure ()->Bool) { let startDate = NSDate() var success = false while !success && abs(startDate.timeIntervalSinceNow) < timeout { RunLoop.current.run(until: Date(timeIntervalSinceNow: 0.01)) success = checkSuccess() } } -
JARinteractive created this gist
Feb 17, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ import Foundation func waitUntil(@autoclosure checkSuccess: ()->Bool) -> Bool { return waitUntil(1.0, checkSuccess) } func waitUntil(timeout: Double, @autoclosure _ checkSuccess: ()->Bool) -> Bool { let startDate = NSDate() var success = false while !success && abs(startDate.timeIntervalSinceNow) < timeout { NSRunLoop.currentRunLoop().runUntilDate(NSDate(timeIntervalSinceNow: 0.01)) success = checkSuccess() } return success }