-
-
Notifications
You must be signed in to change notification settings - Fork 602
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prepare Matcher-to-Predicate migration-path features deprecation
- Tweak the Deprecation Roadmap in the README - Use Predicate in UserDescriptionTest - Separate Matcher usages in SynchronousTest into SynchronousDeprecatedTest and mark the entire class deprecated
- Loading branch information
Showing
5 changed files
with
122 additions
and
42 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
import Foundation | ||
import XCTest | ||
import Nimble | ||
|
||
@available(*, deprecated) | ||
final class SynchronousDeprecatedTest: XCTestCase { | ||
func testToMatchesIfMatcherReturnsTrue() { | ||
expect(1).to(MatcherFunc { _, _ in true }) | ||
expect {1}.to(MatcherFunc { _, _ in true }) | ||
|
||
expect(1).to(MatcherFunc { _, _ in true }.predicate) | ||
expect {1}.to(MatcherFunc { _, _ in true }.predicate) | ||
} | ||
|
||
func testToProvidesActualValueExpression() { | ||
var value: Int? | ||
expect(1).to(MatcherFunc { expr, _ in value = try expr.evaluate(); return true }) | ||
expect(value).to(equal(1)) | ||
} | ||
|
||
func testToProvidesAMemoizedActualValueExpression() { | ||
var callCount = 0 | ||
expect { callCount += 1 }.to(MatcherFunc { expr, _ in | ||
_ = try expr.evaluate() | ||
_ = try expr.evaluate() | ||
return true | ||
}) | ||
expect(callCount).to(equal(1)) | ||
} | ||
|
||
func testToProvidesAMemoizedActualValueExpressionIsEvaluatedAtMatcherControl() { | ||
var callCount = 0 | ||
expect { callCount += 1 }.to(MatcherFunc { expr, _ in | ||
expect(callCount).to(equal(0)) | ||
_ = try expr.evaluate() | ||
return true | ||
}) | ||
expect(callCount).to(equal(1)) | ||
} | ||
|
||
// repeated tests from to() for toNot() | ||
func testToNotMatchesIfMatcherReturnsTrue() { | ||
expect(1).toNot(MatcherFunc { _, _ in false }) | ||
expect {1}.toNot(MatcherFunc { _, _ in false }) | ||
|
||
expect(1).toNot(MatcherFunc { _, _ in false }.predicate) | ||
expect {1}.toNot(MatcherFunc { _, _ in false }.predicate) | ||
} | ||
|
||
func testToNotProvidesActualValueExpression() { | ||
var value: Int? | ||
expect(1).toNot(MatcherFunc { expr, _ in value = try expr.evaluate(); return false }) | ||
expect(value).to(equal(1)) | ||
} | ||
|
||
func testToNotProvidesAMemoizedActualValueExpression() { | ||
var callCount = 0 | ||
expect { callCount += 1 }.toNot(MatcherFunc { expr, _ in | ||
_ = try expr.evaluate() | ||
_ = try expr.evaluate() | ||
return false | ||
}) | ||
expect(callCount).to(equal(1)) | ||
} | ||
|
||
func testToNotProvidesAMemoizedActualValueExpressionIsEvaluatedAtMatcherControl() { | ||
var callCount = 0 | ||
expect { callCount += 1 }.toNot(MatcherFunc { expr, _ in | ||
expect(callCount).to(equal(0)) | ||
_ = try expr.evaluate() | ||
return false | ||
}) | ||
expect(callCount).to(equal(1)) | ||
} | ||
|
||
func testToNegativeMatches() { | ||
failsWithErrorMessage("expected to match, got <1>") { | ||
expect(1).to(MatcherFunc { _, _ in false }) | ||
} | ||
failsWithErrorMessage("expected to match, got <1>") { | ||
expect(1).to(MatcherFunc { _, _ in false }.predicate) | ||
} | ||
} | ||
|
||
func testToNotNegativeMatches() { | ||
failsWithErrorMessage("expected to not match, got <1>") { | ||
expect(1).toNot(MatcherFunc { _, _ in true }) | ||
} | ||
failsWithErrorMessage("expected to not match, got <1>") { | ||
expect(1).toNot(MatcherFunc { _, _ in true }.predicate) | ||
} | ||
} | ||
|
||
func testNotToMatchesLikeToNot() { | ||
expect(1).notTo(MatcherFunc { _, _ in false }) | ||
expect(1).notTo(MatcherFunc { _, _ in false }.predicate) | ||
} | ||
} |
This file contains 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
This file contains 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