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 characters
let localEmail = allowedLocalCharacters | |
.proliferateNonEmpty // Make a non-empty array of characters | |
.suchThat { $0[$0.index(before: $0.endIndex)] != "." } | |
.map { String($0) } // Then make a string. |
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 characters
let hostname = Gen<Character>.one(of: [ | |
lowerCaseLetters, | |
numeric, | |
Gen.pure("-"), // Only generate this character | |
]).proliferateNonEmpty.map { String($0) } |
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 characters
let tld : Gen<Character> = Gen<Character>.fromElements(of: ["com", "de", "net", "org", "io"]) |
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 characters
extension Email: Arbitray { | |
public static var arbitrary: Gen<Email> { | |
return Gen.compose { comp in | |
return Email(comp.generate(localEmail), comp.generate(hostname), comp.generate(tld)) | |
} | |
} | |
} |
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 characters
// our algorithm has this signature | |
func isCorrectEmail(email Email) -> Bool | |
property("emails should always be correct") <- forAll { (email: Email) in | |
return isCorrectEmail(email) | |
} |
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 characters
func getRandomCoordinate() -> XCUICoordinate { | |
let x = CGFloat(Float(arc4random()) / Float(UINT32_MAX)) | |
let y = CGFloat(Float(arc4random()) / Float(UINT32_MAX)) | |
let vector = CGVector(dx: x, dy: y) | |
let coordinate = getCoordinateForVector(vector: vector) | |
return coordinate | |
} |
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 characters
func testMonkey() { | |
let application = XCUIApplication(bundleIdentifier: "de.olbrich.jan.SnapshotTesting") | |
_ = application.descendants(matching: .any).element(boundBy: 0).frame | |
let monkey = Monkey(frame: application.frame) | |
monkey.addDefaultUIAutomationActions() | |
monkey.addXCTestTapAlertAction(interval: 100, application: application) | |
monkey.monkeyAround() | |
} |
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 characters
var paws: MonkeyPaws? | |
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { | |
if CommandLine.arguments.contains("--MonkeyPaws") { | |
paws = MonkeyPaws(view: window!) | |
} | |
return true | |
} |
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 characters
func method1() { | |
statement1() | |
statement2() | |
statement3() | |
statement4() | |
} |
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 characters
func method2() { | |
statement1 { | |
callback1() | |
} | |
statement2 | |
} |