Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Non-custom-operator-based methods equivalents #261

Closed
alexhuang91 opened this issue Dec 27, 2017 · 3 comments
Closed

Feature Request: Non-custom-operator-based methods equivalents #261

alexhuang91 opened this issue Dec 27, 2017 · 3 comments

Comments

@alexhuang91
Copy link

It would be great to be able to call a method instead of using the custom '<-' operator. This would enable adoption in codebases that strongly discourages the use of custom operators.

/// Binds a Testable value to a property.
public func <- (checker : AssertiveQuickCheck, test : @autoclosure @escaping () -> Testable) {
	handleQuickCheckWithResult(checker: checker, test: test)
}

public func handleQuickCheckWithResult(checker : AssertiveQuickCheck, test : @autoclosure @escaping () -> Testable) {
	switch quickCheckWithResult(checker.args, test()) {
	case let .failure(_, _, seed, sz, reason, _, _):
		XCTFail(reason + "; Replay with \(seed) and size \(sz)", file: checker.file, line: checker.line)
	case let .noExpectedFailure(_, seed, sz, _, _):
		XCTFail("Expected property to fail but it didn't.  Replay with \(seed) and size \(sz)", file: checker.file, line: checker.line)
	case let .insufficientCoverage(_, seed, sz, _, _):
		XCTFail("Property coverage insufficient.  Replay with \(seed) and size \(sz)", file: checker.file, line: checker.line)
	default: ()
	}
}

Check.swift:162

Since the switch statement is on quickCheckWithResult(...), handleQuickCheckWithResult(...) seems like an appropriate name.

@CodaFi
Copy link
Member

CodaFi commented Dec 27, 2017

It's not publicized very well but if you just want to execute a test "quickly", we provide quickCheck(_:name:) here.

Did you have something else in mind?

@alexhuang91
Copy link
Author

alexhuang91 commented Dec 28, 2017

(Thank you for the swift reply!) If I understand correctly, that would drop the handling of the result. The code snippet above was what I had in mind.

@CodaFi
Copy link
Member

CodaFi commented Dec 28, 2017

Let me cook something up. I’m traveling today, but should be able to push things in between.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants