From 32f48f6a0e92972b5c16ee5f9c5ce85a4b278e0f Mon Sep 17 00:00:00 2001 From: Giovanni Lodi Date: Mon, 30 Jan 2017 15:53:36 +1100 Subject: [PATCH 1/2] Update Quick dependency to version 1.0.0 And configure semver rule to get any version compatible with 1.0.0. --- Cartfile.private | 2 +- Cartfile.resolved | 2 +- Carthage/Checkouts/Quick/.Package.test.swift | 19 + .../Checkouts/Quick/.github/ISSUE_TEMPLATE | 36 ++ .../Quick/.github/PULL_REQUEST_TEMPLATE | 14 + Carthage/Checkouts/Quick/.hound.yml | 2 + Carthage/Checkouts/Quick/.swiftlint.yml | 12 + Carthage/Checkouts/Quick/.travis.yml | 6 +- .../Checkouts/Quick/Documentation/README.md | 1 + .../Documentation/en-us/InstallingQuick.md | 19 +- .../en-us/SettingUpYourXcodeProject.md | 9 +- .../Documentation/en-us/SharedExamples.md | 2 +- .../en-us/TestUsingTestDoubles.md | 68 +-- .../Documentation/pt-br/BehavioralTesting.md | 78 +++ .../Quick/Documentation/pt-br/README.md | 39 ++ .../Quick/Documentation/zh-cn/README.md | 1 + .../Documentation/zh-cn/SharedExamples.md | 113 ++++ .../Quick/Externals/Nimble/.gitignore | 4 +- .../Quick/Externals/Nimble/.travis.yml | 6 +- .../Quick/Externals/Nimble/CONTRIBUTING.md | 8 + .../Checkouts/Quick/Externals/Nimble/Gemfile | 2 +- .../Quick/Externals/Nimble/Gemfile.lock | 54 +- .../Quick/Externals/Nimble/Nimble.podspec | 33 +- .../Nimble/Nimble.xcodeproj/project.pbxproj | 138 ++++- .../xcschemes/Nimble-tvOS.xcscheme | 4 +- .../Quick/Externals/Nimble/Package.swift | 3 +- .../Quick/Externals/Nimble/README.md | 86 ++- .../CwlCatchException/.gitignore | 3 + .../CwlCatchException/CwlCatchException.h | 30 + .../CwlCatchException/CwlCatchException.m | 35 ++ .../CwlCatchException/CwlCatchException.swift | 32 ++ .../CwlCatchException/Info.plist | 28 + .../CwlBadInstructionException.swift | 76 +++ .../CwlCatchBadInstruction.h | 61 ++ .../CwlCatchBadInstruction.m | 50 ++ .../CwlCatchBadInstruction.swift | 194 +++++++ .../CwlCatchBadInstructionPOSIX.swift | 100 ++++ .../CwlDarwinDefinitions.swift | 63 ++ .../CwlPreconditionTesting/Info.plist | 28 + .../CwlPreconditionTesting/mach_excServer.c | 537 ++++++++++++++++++ .../CwlPreconditionTesting/mach_excServer.h | 298 ++++++++++ .../Lib/CwlPreconditionTesting/README.md | 80 +++ .../Nimble/Adapters/NimbleEnvironment.swift | 4 +- .../Nimble/Sources/Nimble/DSL+Wait.swift | 9 +- .../Nimble/Matchers/AsyncMatcherWrapper.swift | 6 +- .../Sources/Nimble/Matchers/BeLessThan.swift | 2 +- .../Sources/Nimble/Matchers/BeLogical.swift | 8 +- .../Sources/Nimble/Matchers/Match.swift | 4 +- .../Nimble/Matchers/ThrowAssertion.swift | 55 ++ .../Externals/Nimble/Sources/Nimble/Nimble.h | 7 + .../Nimble/Sources/Nimble/Utils/Async.swift | 29 +- .../Nimble/Sources/Nimble/Utils/Errors.swift | 17 +- .../Nimble/Sources/NimbleObjectiveC/DSL.h | 294 +++++++++- .../Nimble/Sources/NimbleObjectiveC/DSL.m | 22 +- .../Externals/Nimble/Tests/LinuxMain.swift | 4 +- .../Tests/NimbleTests/AsynchronousTest.swift | 10 +- .../Tests/NimbleTests/Helpers/utils.swift | 3 +- .../NimbleTests/Matchers/MatchErrorTest.swift | 5 + .../NimbleTests/Matchers/MatchTest.swift | 3 - .../Matchers/ThrowAssertionTest.swift | 62 ++ .../NimbleTests/Matchers/ThrowErrorTest.swift | 1 - .../Tests/NimbleTests/SynchronousTests.swift | 6 +- .../NimbleTests/UserDescriptionTest.swift | 6 - .../NimbleTests/objc/ObjCBeCloseToTest.m | 11 + .../Tests/NimbleTests/objc/ObjCBeFalseTest.m | 22 + .../Tests/NimbleTests/objc/ObjCBeFalsyTest.m | 34 +- .../objc/ObjCBeGreaterThanOrEqualToTest.m | 9 + .../NimbleTests/objc/ObjCBeGreaterThanTest.m | 8 + .../NimbleTests/objc/ObjCBeIdenticalToTest.m | 6 + .../objc/ObjCBeLessThanOrEqualToTest.m | 10 + .../NimbleTests/objc/ObjCBeLessThanTest.m | 9 + .../Tests/NimbleTests/objc/ObjCBeTrueTest.m | 22 + .../Tests/NimbleTests/objc/ObjCBeTruthyTest.m | 27 + .../Tests/NimbleTests/objc/ObjCEqualTest.m | 59 ++ .../Tests/NimbleTests/objc/ObjCHaveCount.m | 71 ++- Carthage/Checkouts/Quick/Package.swift | 7 +- Carthage/Checkouts/Quick/Quick.podspec | 2 +- .../Quick/Quick.xcodeproj/project.pbxproj | 444 ++++++++++++++- .../xcshareddata/xcschemes/Quick-iOS.xcscheme | 12 +- .../xcschemes/Quick-macOS.xcscheme | 12 +- .../xcschemes/Quick-tvOS.xcscheme | 12 +- Carthage/Checkouts/Quick/README.md | 16 + Carthage/Checkouts/Quick/Rakefile | 2 + .../Quick/Sources/Quick/Callsite.swift | 2 +- .../Quick/Configuration/Configuration.swift | 4 +- .../Quick/Sources/Quick/Example.swift | 4 +- .../Quick/Sources/Quick/ExampleGroup.swift | 2 +- .../Sources/Quick/Hooks/ExampleHooks.swift | 2 +- .../Quick/QuickSelectedTestSuiteBuilder.swift | 3 +- .../Quick/Sources/Quick/QuickSpec.swift | 2 +- .../Quick/Sources/Quick/URL+FileName.swift | 12 + .../Checkouts/Quick/Sources/Quick/World.swift | 8 +- .../Checkouts/Quick/Tests/LinuxMain.swift | 4 +- .../AfterSuiteTests+ObjC.m | 32 ++ .../AfterSuiteTests.swift | 26 + .../QuickAfterSuiteTests/Info.plist | 24 + .../QuickFocusedTests/FocusedTests.swift | 1 - .../QuickTests/QuickTestHelpers/TestRun.swift | 1 - .../QuickTestHelpers/XCTestCaseProvider.swift | 2 +- ...s_SharedExamplesTests_SharedExamples.swift | 2 +- .../FunctionalTests/AfterEachTests.swift | 10 +- .../FunctionalTests/BeforeEachTests.swift | 10 +- .../QuickTests/FunctionalTests/ItTests.swift | 20 +- .../Helpers/QuickTestsBridgingHeader.h | 2 +- 104 files changed, 3609 insertions(+), 292 deletions(-) create mode 100644 Carthage/Checkouts/Quick/.Package.test.swift create mode 100644 Carthage/Checkouts/Quick/.github/ISSUE_TEMPLATE create mode 100644 Carthage/Checkouts/Quick/.github/PULL_REQUEST_TEMPLATE create mode 100644 Carthage/Checkouts/Quick/.hound.yml create mode 100644 Carthage/Checkouts/Quick/.swiftlint.yml create mode 100644 Carthage/Checkouts/Quick/Documentation/pt-br/BehavioralTesting.md create mode 100644 Carthage/Checkouts/Quick/Documentation/pt-br/README.md create mode 100644 Carthage/Checkouts/Quick/Documentation/zh-cn/SharedExamples.md create mode 100644 Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/CwlCatchException/.gitignore create mode 100644 Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/CwlCatchException/CwlCatchException/CwlCatchException.h create mode 100644 Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/CwlCatchException/CwlCatchException/CwlCatchException.m create mode 100644 Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/CwlCatchException/CwlCatchException/CwlCatchException.swift create mode 100644 Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/CwlCatchException/CwlCatchException/Info.plist create mode 100644 Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlBadInstructionException.swift create mode 100644 Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlCatchBadInstruction.h create mode 100644 Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlCatchBadInstruction.m create mode 100644 Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlCatchBadInstruction.swift create mode 100644 Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlCatchBadInstructionPOSIX.swift create mode 100644 Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlDarwinDefinitions.swift create mode 100644 Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/Info.plist create mode 100644 Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/mach_excServer.c create mode 100644 Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/mach_excServer.h create mode 100644 Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/README.md create mode 100644 Carthage/Checkouts/Quick/Externals/Nimble/Sources/Nimble/Matchers/ThrowAssertion.swift create mode 100644 Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/Matchers/ThrowAssertionTest.swift create mode 100644 Carthage/Checkouts/Quick/Sources/Quick/URL+FileName.swift create mode 100644 Carthage/Checkouts/Quick/Tests/QuickTests/QuickAfterSuiteTests/AfterSuiteTests+ObjC.m create mode 100644 Carthage/Checkouts/Quick/Tests/QuickTests/QuickAfterSuiteTests/AfterSuiteTests.swift create mode 100644 Carthage/Checkouts/Quick/Tests/QuickTests/QuickAfterSuiteTests/Info.plist diff --git a/Cartfile.private b/Cartfile.private index c2786fb..6a8fd3c 100644 --- a/Cartfile.private +++ b/Cartfile.private @@ -1,2 +1,2 @@ -github "Quick/Quick" +github "Quick/Quick" ~> 1.0.0 github "Quick/Nimble" diff --git a/Cartfile.resolved b/Cartfile.resolved index 6291ac9..4bc14f7 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,3 +1,3 @@ github "Quick/Nimble" "v5.1.1" -github "Quick/Quick" "v0.10.0" +github "Quick/Quick" "v1.0.0" github "ReSwift/ReSwift" "3.0.0" diff --git a/Carthage/Checkouts/Quick/.Package.test.swift b/Carthage/Checkouts/Quick/.Package.test.swift new file mode 100644 index 0000000..34b9608 --- /dev/null +++ b/Carthage/Checkouts/Quick/.Package.test.swift @@ -0,0 +1,19 @@ +import PackageDescription + +let package = Package( + name: "Quick", + // TODO: Once the `test` command has been implemented in the Swift Package Manager, this should be changed to + // be `testDependencies:` instead. For now it has to be done like this for the library to get linked with the test targets. + // See: https://github.com/apple/swift-evolution/blob/master/proposals/0019-package-manager-testing.md + dependencies: [ + .Package(url: "https://github.com/Quick/Nimble", majorVersion: 5) + ], + exclude: [ + "Sources/QuickObjectiveC", + "Tests/QuickTests/QuickAfterSuiteTests/AfterSuiteTests+ObjC.m", + "Tests/QuickTests/QuickFocusedTests/FocusedTests+ObjC.m", + "Tests/QuickTests/QuickTests/FunctionalTests/ObjC", + "Tests/QuickTests/QuickTests/Helpers", + "Tests/QuickTests/QuickTests/QuickConfigurationTests.m", + ] +) diff --git a/Carthage/Checkouts/Quick/.github/ISSUE_TEMPLATE b/Carthage/Checkouts/Quick/.github/ISSUE_TEMPLATE new file mode 100644 index 0000000..ebe5a2b --- /dev/null +++ b/Carthage/Checkouts/Quick/.github/ISSUE_TEMPLATE @@ -0,0 +1,36 @@ +- [ ] I have read [CONTRIBUTING](https://github.com/Quick/Quick/blob/master/CONTRIBUTING.md) and have done my best to follow them. + +### What did you do? + +Please replace this with what you did. + +### What did you expect to happen? + +Please replace this with what you expected to happen. + +### What actually happened instead? + +Please replace this with what happened instead. + +### Environment + +List the software versions you're using: + + - Quick: *?.?.?* + - Nimble: *?.?.?* + - Xcode Version: *?.? (????)* (Open Xcode; In menubar: Xcode > About Xcode) + - Swift Version: *?.?* (Open Xcode Preferences; Components > Toolchains. If none, use `Xcode Default`.) + +Please also mention which package manager you used and its version. Delete the +other package managers in this list: + + - Cocoapods: *?.?.?* (Use `pod --version` in Terminal) + - Carthage: *?.?* (Use `carthage version` in Terminal) + - Swift Package Manager *?.?.? (swiftpm-???)* (Use `swift build --version` in Terminal) + +### Project that demonstrates the issue + +Please link to a project we can download that reproduces the issue. Feel free +to delete this section if it's not relevant to the issue (eg - feature request). + +The project should be [short, self-contained, and correct example](http://sscce.org/). diff --git a/Carthage/Checkouts/Quick/.github/PULL_REQUEST_TEMPLATE b/Carthage/Checkouts/Quick/.github/PULL_REQUEST_TEMPLATE new file mode 100644 index 0000000..20e40c8 --- /dev/null +++ b/Carthage/Checkouts/Quick/.github/PULL_REQUEST_TEMPLATE @@ -0,0 +1,14 @@ +The PR should summarize what was changed and why. Here are some questions to +help you if you're not sure: + + - What behavior was changed? + - What code was refactored / updated to support this change? + - What issues are related to this PR? Or why was this change introduced? + +Checklist - While not every PR needs it, new features should consider this list: + + - [ ] Does this have tests? + - [ ] Does this have documentation? + - [ ] Does this break the public API (Requires major version bump)? + - [ ] Is this a new feature (Requires minor version bump)? + diff --git a/Carthage/Checkouts/Quick/.hound.yml b/Carthage/Checkouts/Quick/.hound.yml new file mode 100644 index 0000000..b867fd9 --- /dev/null +++ b/Carthage/Checkouts/Quick/.hound.yml @@ -0,0 +1,2 @@ +swift: + config_file: .swiftlint.yml diff --git a/Carthage/Checkouts/Quick/.swiftlint.yml b/Carthage/Checkouts/Quick/.swiftlint.yml new file mode 100644 index 0000000..64760d5 --- /dev/null +++ b/Carthage/Checkouts/Quick/.swiftlint.yml @@ -0,0 +1,12 @@ + +disabled_rules: + - line_length + - type_name + - valid_docs + - empty_count + - force_unwrapping + - function_body_length + - variable_name +included: + - Sources + - Tests diff --git a/Carthage/Checkouts/Quick/.travis.yml b/Carthage/Checkouts/Quick/.travis.yml index fb9ecc5..4c57144 100644 --- a/Carthage/Checkouts/Quick/.travis.yml +++ b/Carthage/Checkouts/Quick/.travis.yml @@ -19,14 +19,12 @@ matrix: env: - PODSPEC=1 - os: linux - env: - - PLATFORM=linux sudo: required dist: trusty install: - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./script/travis-install-macos; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./script/travis-install-macos; fi - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./script/travis-install-linux; fi - if [[ "$PODSPEC" ]]; then rvm system; sudo gem install bundler; bundle install; fi script: - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./script/travis-script-macos; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./script/travis-script-macos; fi - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./script/travis-script-linux; fi diff --git a/Carthage/Checkouts/Quick/Documentation/README.md b/Carthage/Checkouts/Quick/Documentation/README.md index 457a0e3..08fb556 100644 --- a/Carthage/Checkouts/Quick/Documentation/README.md +++ b/Carthage/Checkouts/Quick/Documentation/README.md @@ -3,3 +3,4 @@ - [English](en-us/README.md) - [日本語](ja/README.md) - [中文](zh-cn/README.md) +- [pt-br](pt-br/README.md) diff --git a/Carthage/Checkouts/Quick/Documentation/en-us/InstallingQuick.md b/Carthage/Checkouts/Quick/Documentation/en-us/InstallingQuick.md index 6267c04..258956f 100644 --- a/Carthage/Checkouts/Quick/Documentation/en-us/InstallingQuick.md +++ b/Carthage/Checkouts/Quick/Documentation/en-us/InstallingQuick.md @@ -1,9 +1,6 @@ # Installing Quick -> **If you're using Xcode 7.1,** use the latest version of Quick--`v0.9.0` at the time of writing. -> New releases are developed on the `swift-2.0` branch. - - +>Before starting, check [here](../../README.md#swift-version) which versions of Quick and Nimble are compatible with your version of Swift. Quick provides the syntax to define examples and example groups. Nimble provides the `expect(...).to` assertion syntax. You may use either one, @@ -115,20 +112,6 @@ Finally, download and link Quick and Nimble to your tests: pod install ``` -### Using Swift 1.2? - -The latest release of Quick (0.4.0) is for Swift 2 (Xcode 7), but the latest Nimble (1.0.0) is for Swift 1.2 (Xcode 6). - -If you want Xcode 6 do: - -```sh -target 'MyTests' do - use_frameworks! - pod 'Quick', '~>0.3.0' - pod 'Nimble', '~>1.0.0' -end -``` - ## [Carthage](https://github.com/Carthage/Carthage) As test targets do not have the "Embedded Binaries" section, the frameworks must diff --git a/Carthage/Checkouts/Quick/Documentation/en-us/SettingUpYourXcodeProject.md b/Carthage/Checkouts/Quick/Documentation/en-us/SettingUpYourXcodeProject.md index b2ba8e1..dd49355 100644 --- a/Carthage/Checkouts/Quick/Documentation/en-us/SettingUpYourXcodeProject.md +++ b/Carthage/Checkouts/Quick/Documentation/en-us/SettingUpYourXcodeProject.md @@ -2,15 +2,18 @@ With the exception of the Command Line Tool project type, when you create a new project in Xcode 7, a unit test target is included by default. [See specific instructions for a Command Line Tool Project](#setting-up-a-test-target-for-a-command-line-tool-project). To write unit tests, you'll need to be able to use your main -target's code from within your test target. +target's code from within your test target. ## Testing Swift Code Using Swift In order to test code written in Swift, you'll need to do two things: -1. Set "defines module" in your `.xcodeproj` to `YES`. +1. Set "Defines Module" in your `.xcodeproj` to `YES`. - * To do this in Xcode: Choose your project, then "Build Settings" header, then "Defines Modules" line, then select "Yes". + * To do this in Xcode: Choose your project, then "Build Settings", then "Packaging" header, + then "Defines Module" line, then select "Yes". Note: you may have + to choose "All" (Build Settings) instead of "Basic" to see the + "Packaging" section. 2. `@testable import YourAppModuleName` in your unit tests. This will expose Any `public` and `internal` (the default) symbols to your tests. `private` symbols are still unavailable. diff --git a/Carthage/Checkouts/Quick/Documentation/en-us/SharedExamples.md b/Carthage/Checkouts/Quick/Documentation/en-us/SharedExamples.md index 1e3e7dd..3e67cb5 100644 --- a/Carthage/Checkouts/Quick/Documentation/en-us/SharedExamples.md +++ b/Carthage/Checkouts/Quick/Documentation/en-us/SharedExamples.md @@ -17,7 +17,7 @@ import Quick import Nimble class EdibleSharedExamplesConfiguration: QuickConfiguration { - override class func configure(configuration: Configuration) { + override class func configure(_ configuration: Configuration) { sharedExamples("something edible") { (sharedExampleContext: SharedExampleContext) in it("makes dolphins happy") { let dolphin = Dolphin(happy: false) diff --git a/Carthage/Checkouts/Quick/Documentation/en-us/TestUsingTestDoubles.md b/Carthage/Checkouts/Quick/Documentation/en-us/TestUsingTestDoubles.md index d69235e..fc4f3f9 100644 --- a/Carthage/Checkouts/Quick/Documentation/en-us/TestUsingTestDoubles.md +++ b/Carthage/Checkouts/Quick/Documentation/en-us/TestUsingTestDoubles.md @@ -1,39 +1,45 @@ -# Testing with Mock +# Testing with Mocks ## Test doubles -The following problem occurs frequently when writing tests. In example, `Car` depends on/uses `Tire`. +Dependencies between objects can cause problems when writing tests. For example, say you have a `Car` class that depends on/uses `Tire`. ![](https://github.com/Quick/Assets/blob/master/Screenshots/TestUsingMock_BusesA.png) -`CarTests` test `Car` which calls `Tire`. Now bugs in `Tire` could cause `CarTests` to fail (even though `Car` is okay). +`CarTests` tests `Car`, which calls `Tire`. Now bugs in `Tire` could cause `CarTests` to fail (even though `Car` is okay). It can be hard to answer the question: "What's broken?". -It can be hard to answer the question: "What's broken?". To avoid this problem, one can use a stand-in object for `Tire` in `CarTests`. In this case, we'll create a stand-in object for `Tire` called `PerfectTire`. +To avoid this problem, you can use a stand-in object for `Tire` in `CarTests`. In this case, we'll create a stand-in object for `Tire` called `PerfectTire`. ![](https://github.com/Quick/Assets/blob/master/Screenshots/TestUsingMock_BusesAmock.png) -`PerfectTire` would have all of the same functions and properties as `Tire`. However, the implementation of those functions and properties may differ. +`PerfectTire` will have all of the same public functions and properties as `Tire`. However, the implementation of some or all of those functions and properties will differ. -Objects like `PerfectTire` are called "test doubles". Test doubles are used as "stand-in objects" for testing functionality of related objects in isolation. There are several kinds of test doubles: +Objects like `PerfectTire` are called "test doubles". Test doubles are used as "stand-in objects" for testing the functionality of related objects in isolation. There are several kinds of test doubles: - Mock object: Used for receiving output from a test class. - Stub object: Used for providing input to a test class. -- Fake object: Behaves similar to the original class. +- Fake object: Behaves similarly to the original class, but in a simplified way. Let's start with how to use mock objects. ## Mock -A mock object focuses on fully specifying what the correct interaction is supposed to be with other objects and detecting when something goes awry. The mock object should know (in advance) what is supposed to happen during the test and how the mock object is supposed to react. +A mock object focuses on fully specifying the correct interaction with other objects and detecting when something goes awry. The mock object should know (in advance) the methods that should be called on it during the test and what values the mock object should return. -### Writing test with Mock in Swift +Mock objects are great because you can: + +- Run tests a lot quicker. +- Run tests even if you're not connected to the Internet. +- Focus on testing classes in isolation from their dependencies. + +### Writing Tests with Mock Objects in Swift #### Sample app -For example, we will provide an app which retrieves data from the internet. +For example, let's create an app which retrieves data from the Internet: -* Displays the data from the internet in `ViewController`. -* Custom class implements `DataProviderProtocol`, which is responsible for fetching data. +* Data from the Internet will be displayed in `ViewController`. +* A custom class will implement the `DataProviderProtocol`, which specifies methods for fetching data. `DataProviderProtocol` is defined as follows: @@ -43,26 +49,26 @@ protocol DataProviderProtocol: class { } ``` -`fetch()` gets data from the internet and returns it using a `callback` closure. +`fetch()` gets data from the Internet and returns it using a `callback` closure. -Here is `DataProvider` which implements the `DataProviderProtocol` protocol. +Here is the `DataProvider` class, which conforms to the `DataProviderProtocol` protocol. ```swift class DataProvider: NSObject, DataProviderProtocol { func fetch(callback: (data: String) -> Void) { - let url = NSURL(string: "http://example.com/")! - let session = NSURLSession(configuration: NSURLSessionConfiguration.defaultSessionConfiguration()) - let task = session.dataTaskWithURL(url, completionHandler: { + let url = URL(string: "http://example.com/")! + let session = URLSession(configuration: .default) + let task = session.dataTask(with: url) { (data, resp, err) in - let string = NSString(data:data!, encoding:NSUTF8StringEncoding) as! String + let string = String(data: data!, encoding: .utf8) callback(data: string) - }) + } task.resume() } } ``` -In our scenario, `fetch()` is called in `viewDidLoad()` of `ViewController`. +In our scenario, `fetch()` is called in the `viewDidLoad()` method of `ViewController`. ```swift class ViewController: UIViewController { @@ -86,13 +92,7 @@ class ViewController: UIViewController { #### Testing using a Mock of `DataProviderProtocol` -`ViewController` depends on `DataProviderProtocol`. Create a mock object which conforms to `DataProviderProtocol` in order to test the view controller. - -Mock objects are great because you can: - -- Run tests a lot quicker. -- Run tests even if you're not connected to the internet. -- Focus on testing `ViewController` in isolation. +`ViewController` depends on `DataProviderProtocol`. In order to test the view controller in isolation, you can create a mock object which conforms to `DataProviderProtocol`. ```swift class MockDataProvider: NSObject, DataProviderProtocol { @@ -104,26 +104,26 @@ class MockDataProvider: NSObject, DataProviderProtocol { } ``` -The `fetchCalled` property is set to `true` when `fetch()` is called. This helps the test determine if the object is ready to test. +The `fetchCalled` property is set to `true` when `fetch()` is called, so that the test can confirm that it was called. -The following test verifies that when `ViewController` is loaded, the view controller should call `dataProvider.fetch()`. +The following test verifies that when `ViewController` is loaded, the view controller calls `dataProvider.fetch()`. ```swift override func spec() { describe("view controller") { it("fetch data with data provider") { - let mockProvier = MockDataProvider() + let mockProvider = MockDataProvider() let viewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("ViewController") as! ViewController - viewController.dataProvier = mockProvier + viewController.dataProvider = mockProvider - expect(mockProvier.fetchCalled).to(equal(false)) + expect(mockProvider.fetchCalled).to(beFalse()) let _ = viewController.view - expect(mockProvier.fetchCalled).to(equal(true)) + expect(mockProvider.fetchCalled).to(beTrue()) } } } ``` -If you're interested in learning more about writing tests, continue on to https://realm.io/news/testing-in-swift/. +If you're interested in learning more about writing tests, continue on to . diff --git a/Carthage/Checkouts/Quick/Documentation/pt-br/BehavioralTesting.md b/Carthage/Checkouts/Quick/Documentation/pt-br/BehavioralTesting.md new file mode 100644 index 0000000..4e41676 --- /dev/null +++ b/Carthage/Checkouts/Quick/Documentation/pt-br/BehavioralTesting.md @@ -0,0 +1,78 @@ +# Não Teste o Código, Verifique Comportamento + +Testes devem falhar somente se a aplicação **se comportar diferente**. +Eles devem testar *o que* o código da aplicação faz, não *como* faz. + +- Testes que verificam *o que* a aplicação faz são **testes de comportamento**. +- Testes que quebram se o código da aplicação muda, mesmo que o comportamento seja mantido, são **teste frágeis**. + +Vamos supor que temos uma database de bananas, chamada `GorillaDB`. +`GorillaDB` é uma database baseada em chave-valor que guarda bananas. Nós podemos salvar bananas: + +```swift +let database = GorillaDB() +let banana = Banana() +database.save(banana: banana, key: "my-banana") +``` + +E podemos ler bananas: + +```swift +let banana = database.load(key: "my-banana") +``` + +## Testes Frágeis + +Como podemos testar esse comportamento? Um jeito seria checar o tamanho da database depois de salvar uma banana: + +```swift +// GorillaDBTests.swift + +func testSave_savesTheBananaToTheDatabase() { + // Arrange: Create a database and get its original size. + let database = GorillaDB() + let originalSize = database.size + + // Act: Save a banana to the database. + let banana = Banana() + database.save(banana: banana, key: "test-banana") + + // Assert: The size of the database should have increased by one. + XCTAssertEqual(database.size, originalSize + 1) +} +``` + + +Imagine, no entanto, que o código fonte da `GorillaDB` mude. Para que a operação de leitura de bananas da database seja mais rápida, é mantido um cache com as bananas lidas com maior frequência. `GorillaDB.size` aumenta conforme o tamanho do cache aumenta, e nosso teste falha: + +![](https://raw.githubusercontent.com/Quick/Assets/master/Screenshots/Screenshot_database_size_fail.png) + +## Testes de Comportamento + +O segredo para escrever testes de comportamento é determinar exatamente o que se espera que o código da aplicação faça. + +No contexto do teste `testSave_savesTheBananaToTheDatabase`: qual é o comportamento esperado quando uma banana é salva na database? "Salvar" implica que essa banana pode ser lida mais tarde. Então, ao invés de testar que o tamanho da database aumenta, nós devemos testar que é possível ler uma banana. + +```diff +// GorillaDBTests.swift + +func testSave_savesTheBananaToTheDatabase() { + // Arrange: Create a database and get its original size. + let database = GorillaDB() +- let originalSize = database.size + + // Act: Save a banana to the database. + let banana = Banana() + database.save(banana: banana, key: "test-banana") + +- // Assert: The size of the database should have increased by one. +- XCTAssertEqual(database.size, originalSize + 1) ++ // Assert: The bananas saved to and loaded from the database should be the same. ++ XCTAssertEqual(database.load(key: "test-banana"), banana) +} +``` + +O segredo para escrever testes de comportamento é perguntar: + +- O que exatamente o código dessa aplicação deve fazer? +- O meu teste está verificando *apenas* esse comportamento? Ou o teste pode falhar devido à forma como o código funciona? \ No newline at end of file diff --git a/Carthage/Checkouts/Quick/Documentation/pt-br/README.md b/Carthage/Checkouts/Quick/Documentation/pt-br/README.md new file mode 100644 index 0000000..c170942 --- /dev/null +++ b/Carthage/Checkouts/Quick/Documentation/pt-br/README.md @@ -0,0 +1,39 @@ +# Documentação + +Quick te ajuda a verificar como programas em Swift e Objective-C se comportam. + +Fazê-lo de forma eficaz não é apenas questão de saber como usar Quick. Os guias nesse diretório podem te ajudar a escrever testes eficazes --não apenas usando Quick, mas até mesmo XCTest ou outros framework de teste. + +Cada guia cobre um tópico em particular. Se você é completamente novo a teste unitário, considere lê-los na ordem que são introduzidos abaixo: + +- **[Configurar Testes no seu Xcode Project](SettingUpYourXcodeProject.md)**: + Leia isto se você esta com problemas para usar o código da sua aplicação de dentro dos seus arquivos de teste. +- **[Testes Eficazes Usando XCTest: Arrange, Act e Assert](ArrangeActAssert.md)**: + Leia isto para aprender como escrever `XCTestcase` testes que o ajudarão a escrever código mais rápido e mais eficaz. +- **[Não Teste o Código, Verifique Comportamento](BehavioralTesting.md)**: + Leia isto para aprender que tipos de testes te deixam mais rápido e quais os que só vão acabar te deixando mais devagar. +- **[Testes Limpos Usando Nimble Assertions](NimbleAssertions.md)**: + Leia isto para aprender a usar Nimble para gerar melhores mensagens de falha. + Melhores mensagens de falha ajudam a se mover mais rápido, gastando menos tempo tentando descobrir por que +    um teste falhou. +- **[Testes Organizados com Exemplos Quick e Grupos de Exemplo](QuickExamplesAndGroups.md)**: + Leia isto para aprender como Quick pode ajudar ainda mais a escrever testes eficazes, usando *exemplos* e *grupos de exemplos* +- **[Testando Aplicações OS X e iOS](TestingApps.md)**: + Leia isto para aprender mais sobre testar código que utiliza + AppKit e UIKit frameworks. +- **[Testando com testes dublês](TestUsingTestDoubles.md)**: + Leia isto para aprender o que são testes dublês e como usa-lôs. +- **[Reduzindo Teste Boilerplate com Assertions Compartilhados](SharedExamples.md)**: + Leia isto para aprender como compartilhar conjuntos de assertions entre seus testes. +- **[Configurando como Quick se Comporta](ConfiguringQuick.md)**: + Leia isto para aprender como você pode mudar como Quick se comporta quando roda os sua suite de testes. +- **[Usando Quick com Objective-C](QuickInObjectiveC.md)**: + Leia isto se você esta com problemas para usar Quick em Objective-C. +- **[Instalando Quick](InstallingQuick.md)**: + Leia isto para instruções de como adicionar Quick no seu projeto, usando Git submodules, CocoaPods, Carthage, ou Swift Package Manager. +- **[Instalando Arquivos Templates Quick](InstallingFileTemplates.md)**: +Leia isto para aprender como instalar arquivos templates que deixam escrever Quick specs mais rápidos. +- **[Mais Recursos](MoreResources.md)**: + Uma lista de recursos adicionais sobre testes OS X e iOS. +- **[Troubleshooting](Troubleshooting.md)**: + Leia isto quando você tiver outros problemas. diff --git a/Carthage/Checkouts/Quick/Documentation/zh-cn/README.md b/Carthage/Checkouts/Quick/Documentation/zh-cn/README.md index cf3051f..2c48f4c 100644 --- a/Carthage/Checkouts/Quick/Documentation/zh-cn/README.md +++ b/Carthage/Checkouts/Quick/Documentation/zh-cn/README.md @@ -9,6 +9,7 @@ Quick 能够帮助你验证你的 Swift 和 Objective-C 程序的行为。然而 - **[不要测试代码,而应该测试行为](BehavioralTesting.md)**:通过这份指南你能学习到哪些是好的测试,哪些是不好的测试。 - **[测试 OS X 和 iOS 应用](TestingApps.md)**:了解如何为使用 AppKit 和 UIKit 框架的代码编写测试。 - **[使用测试替身进行测试](TestUsingTestDoubles.md)**:阅读这份指南来了解什么是测试替身,以及如何使用它们。 +- **[使用 Shared Assertion 来复用测试模板代码](SharedExamples.md)**:学习如何在测试中共享测试代码。 - **[配置 Quick 的行为](ConfiguringQuick.md)**:阅读这份指南来了解如何在运行测试代码时改变 Quick 的行为。 - **[在 Objective-C 中使用 Quick](QuickInObjectiveC.md)**:如果你在 Objective-C 项目使用 Quick 的过程中遇到了困难,请阅读这份指南。 - **[安装 Quick](InstallingQuick.md)**:通过这份指南了解在项目中添加 Quick 的方法:Git submodules,CocoaPods,Carthage 和 Swift Package Manager 。 diff --git a/Carthage/Checkouts/Quick/Documentation/zh-cn/SharedExamples.md b/Carthage/Checkouts/Quick/Documentation/zh-cn/SharedExamples.md new file mode 100644 index 0000000..ec87138 --- /dev/null +++ b/Carthage/Checkouts/Quick/Documentation/zh-cn/SharedExamples.md @@ -0,0 +1,113 @@ +# 使用 Shared Assertion 来复用测试模板代码 + +在某种场合下,一些特定的测试代码可以应用在不同的对象上。 + +比如,假设有一个叫 `Edible` 的协议。当一只海豚吃了标识为 `Edible` 的食物时,它会变得高兴。`Mackerel` 和 `Cod` 都遵循 `Edible` 协议。这个时候,Quick 的 shared example(共享用例)能帮你更容易地测试 `Mackerel` 和 `Cod` 的行为。 + +下面的例子为一些 `Edible` 的食物定义了一组共享用例,以测试 mackerel 和 cod 的行为。 + +```swift +// Swift + +import Quick +import Nimble + +class EdibleSharedExamplesConfiguration: QuickConfiguration { + override class func configure(_ configuration: Configuration) { + sharedExamples("something edible") { (sharedExampleContext: SharedExampleContext) in + it("makes dolphins happy") { + let dolphin = Dolphin(happy: false) + let edible = sharedExampleContext()["edible"] + dolphin.eat(edible) + expect(dolphin.isHappy).to(beTruthy()) + } + } + } +} + +class MackerelSpec: QuickSpec { + override func spec() { + var mackerel: Mackerel! + beforeEach { + mackerel = Mackerel() + } + + itBehavesLike("something edible") { ["edible": mackerel] } + } +} + +class CodSpec: QuickSpec { + override func spec() { + var cod: Cod! + beforeEach { + cod = Cod() + } + + itBehavesLike("something edible") { ["edible": cod] } + } +} +``` + +```objc +// Objective-C + +@import Quick; +@import Nimble; + +QuickConfigurationBegin(EdibleSharedExamplesConfiguration) + ++ (void)configure:(Configuration *configuration) { + sharedExamples(@"something edible", ^(QCKDSLSharedExampleContext exampleContext) { + it(@"makes dolphins happy") { + Dolphin *dolphin = [[Dolphin alloc] init]; + dolphin.happy = NO; + id edible = exampleContext()[@"edible"]; + [dolphin eat:edible]; + expect(dolphin.isHappy).to(beTruthy()) + } + }); +} + +QuickConfigurationEnd + +QuickSpecBegin(MackerelSpec) + +__block Mackerel *mackerel = nil; +beforeEach(^{ + mackerel = [[Mackerel alloc] init]; +}); + +itBehavesLike(@"someting edible", ^{ return @{ @"edible": mackerel }; }); + +QuickSpecEnd + +QuickSpecBegin(CodSpec) + +__block Mackerel *cod = nil; +beforeEach(^{ + cod = [[Cod alloc] init]; +}); + +itBehavesLike(@"someting edible", ^{ return @{ @"edible": cod }; }); + +QuickSpecEnd +``` + +共享用例可以包括任意数量的 `it`, `context` 和 `describe` 代码块。当使用它们来测试不同对象的相同行为时,你可以少写*很多*不必要的重复代码。 + +一般来说,你使用共享用例进行测试时不需要依赖其他额外的对象。在 Swift 中,你可以简单地用一个不带参数的 `sharedExample` 闭包来使用共享用例。当你需要进行全局测试时,这很有用。 + +```swift +// Swift + +import Quick + +sharedExamples("everything under the sea") { + // ... +} + +itBehavesLike("everything under the sea") +``` +> 如果你使用 Objective-C 的话,你需要传入一个带 `QCKDSLSharedExampleContext` 参数的 block,即使你并不打算使用它。不好意思,你只能这样做,人生有时就是这么的无奈。:cookie: :bomb: + +你也可以使用 `fitBehavesLike` 函数来单独测试共享用例。 diff --git a/Carthage/Checkouts/Quick/Externals/Nimble/.gitignore b/Carthage/Checkouts/Quick/Externals/Nimble/.gitignore index b067294..e50906d 100644 --- a/Carthage/Checkouts/Quick/Externals/Nimble/.gitignore +++ b/Carthage/Checkouts/Quick/Externals/Nimble/.gitignore @@ -1,5 +1,7 @@ .DS_Store -xcuserdata/ +**/xcuserdata/* +**/*.xccheckout +**/*.xcscmblueprint build/ .idea DerivedData/ diff --git a/Carthage/Checkouts/Quick/Externals/Nimble/.travis.yml b/Carthage/Checkouts/Quick/Externals/Nimble/.travis.yml index 977a75b..3e2f896 100644 --- a/Carthage/Checkouts/Quick/Externals/Nimble/.travis.yml +++ b/Carthage/Checkouts/Quick/Externals/Nimble/.travis.yml @@ -2,9 +2,9 @@ osx_image: xcode8 language: generic matrix: include: - # - os: osx - # sudo: required - # env: TYPE=podspec + - os: osx + sudo: required + env: TYPE=podspec - os: osx env: TYPE=ios NIMBLE_RUNTIME_IOS_SDK_VERSION=10.0 - os: osx diff --git a/Carthage/Checkouts/Quick/Externals/Nimble/CONTRIBUTING.md b/Carthage/Checkouts/Quick/Externals/Nimble/CONTRIBUTING.md index a97114f..d9c4ba6 100644 --- a/Carthage/Checkouts/Quick/Externals/Nimble/CONTRIBUTING.md +++ b/Carthage/Checkouts/Quick/Externals/Nimble/CONTRIBUTING.md @@ -46,6 +46,14 @@ Be sure to include in your issue: - Use `Nimble.xcodeproj` to work on Nimble. +## Running the Swift Package Manager tests + +1. Install `swiftenv` by running a line from the build script (`.travis.yml`): + + eval "$(curl -sL https://gist.githubusercontent.com/kylef/5c0475ff02b7c7671d2a/raw/02090c7ede5a637b76e6df1710e83cd0bbe7dcdf/swiftenv-install.sh)" + +2. Run `./test swiftpm` + ## Pull Requests - Nothing is trivial. Submit pull requests for anything: typos, diff --git a/Carthage/Checkouts/Quick/Externals/Nimble/Gemfile b/Carthage/Checkouts/Quick/Externals/Nimble/Gemfile index 66d7eff..a6dc312 100644 --- a/Carthage/Checkouts/Quick/Externals/Nimble/Gemfile +++ b/Carthage/Checkouts/Quick/Externals/Nimble/Gemfile @@ -1,4 +1,4 @@ # A sample Gemfile source "https://rubygems.org" -gem 'cocoapods' +gem 'cocoapods', '1.1.0.rc.3' diff --git a/Carthage/Checkouts/Quick/Externals/Nimble/Gemfile.lock b/Carthage/Checkouts/Quick/Externals/Nimble/Gemfile.lock index 374561e..87dc02b 100644 --- a/Carthage/Checkouts/Quick/Externals/Nimble/Gemfile.lock +++ b/Carthage/Checkouts/Quick/Externals/Nimble/Gemfile.lock @@ -1,67 +1,69 @@ GEM remote: https://rubygems.org/ specs: - activesupport (4.2.6) + activesupport (4.2.7.1) i18n (~> 0.7) json (~> 1.7, >= 1.7.7) minitest (~> 5.1) thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) - claide (1.0.0) - cocoapods (1.0.1) - activesupport (>= 4.0.2) - claide (>= 1.0.0, < 2.0) - cocoapods-core (= 1.0.1) - cocoapods-deintegrate (>= 1.0.0, < 2.0) - cocoapods-downloader (>= 1.0.0, < 2.0) + claide (1.0.1) + cocoapods (1.1.0.rc.3) + activesupport (>= 4.0.2, < 5) + claide (>= 1.0.1, < 2.0) + cocoapods-core (= 1.1.0.rc.3) + cocoapods-deintegrate (>= 1.0.1, < 2.0) + cocoapods-downloader (>= 1.1.1, < 2.0) cocoapods-plugins (>= 1.0.0, < 2.0) cocoapods-search (>= 1.0.0, < 2.0) cocoapods-stats (>= 1.0.0, < 2.0) - cocoapods-trunk (>= 1.0.0, < 2.0) - cocoapods-try (>= 1.0.0, < 2.0) + cocoapods-trunk (= 1.1.0.beta.1) + cocoapods-try (>= 1.1.0, < 2.0) colored (~> 1.2) escape (~> 0.0.4) - fourflusher (~> 0.3.0) - molinillo (~> 0.4.5) + fourflusher (~> 2.0) + gh_inspector (~> 1.0) + molinillo (~> 0.5.1) nap (~> 1.0) - xcodeproj (>= 1.1.0, < 2.0) - cocoapods-core (1.0.1) - activesupport (>= 4.0.2) + xcodeproj (>= 1.3.2, < 2.0) + cocoapods-core (1.1.0.rc.3) + activesupport (>= 4.0.2, < 5) fuzzy_match (~> 2.0.4) nap (~> 1.0) - cocoapods-deintegrate (1.0.0) - cocoapods-downloader (1.0.1) + cocoapods-deintegrate (1.0.1) + cocoapods-downloader (1.1.1) cocoapods-plugins (1.0.0) nap cocoapods-search (1.0.0) cocoapods-stats (1.0.0) - cocoapods-trunk (1.0.0) + cocoapods-trunk (1.1.0.beta.1) nap (>= 0.8, < 2.0) netrc (= 0.7.8) - cocoapods-try (1.0.0) + cocoapods-try (1.1.0) colored (1.2) escape (0.0.4) - fourflusher (0.3.2) + fourflusher (2.0.1) fuzzy_match (2.0.4) + gh_inspector (1.0.2) i18n (0.7.0) json (1.8.3) - minitest (5.9.0) - molinillo (0.4.5) + minitest (5.9.1) + molinillo (0.5.1) nap (1.1.0) netrc (0.7.8) thread_safe (0.3.5) tzinfo (1.2.2) thread_safe (~> 0.1) - xcodeproj (1.1.0) + xcodeproj (1.3.2) activesupport (>= 3) - claide (>= 1.0.0, < 2.0) + claide (>= 1.0.1, < 2.0) colored (~> 1.2) PLATFORMS ruby DEPENDENCIES - cocoapods + cocoapods (= 1.1.0.rc.3) BUNDLED WITH - 1.12.3 + 1.13.1 diff --git a/Carthage/Checkouts/Quick/Externals/Nimble/Nimble.podspec b/Carthage/Checkouts/Quick/Externals/Nimble/Nimble.podspec index 5fa0974..8ca36a1 100644 --- a/Carthage/Checkouts/Quick/Externals/Nimble/Nimble.podspec +++ b/Carthage/Checkouts/Quick/Externals/Nimble/Nimble.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "Nimble" - s.version = "5.0.0" + s.version = "5.1.1" s.summary = "A Matcher Framework for Swift and Objective-C" s.description = <<-DESC Use Nimble to express the expected outcomes of Swift or Objective-C expressions. Inspired by Cedar. @@ -11,12 +11,37 @@ Pod::Spec.new do |s| s.ios.deployment_target = "8.0" s.osx.deployment_target = "10.10" s.tvos.deployment_target = "9.0" - s.source = { :git => "https://github.com/Quick/Nimble.git", :tag => "v#{s.version}" } + s.source = { :git => "https://github.com/Quick/Nimble.git", + :tag => "v#{s.version}" } + + s.source_files = "Sources/**/*.{swift,h,m,c}" + + s.osx.exclude_files = [ + "Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlCatchBadInstructionPOSIX.swift", + ] + s.ios.exclude_files = [ + "Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlCatchBadInstructionPOSIX.swift", + ] + s.tvos.exclude_files = [ + "Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlCatchBadInstruction.swift", + "Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlCatchBadInstruction.m", + "Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlBadInstructionException.swift", + "Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlDarwinDefinitions.swift", + "Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/mach_excServer.{h,c}", + "Sources/Lib/CwlPreconditionTesting/CwlCatchException/CwlCatchException.swift", + "Sources/Lib/CwlPreconditionTesting/CwlCatchException/CwlCatchException.m", + ] - s.source_files = "Sources/**/**/*.{swift,h,m}" s.private_header_files = "Sources/NimbleObjectiveC/CurrentTestCaseTracker.h" + s.tvos.private_header_files = "Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/mach_excServer.h" + s.exclude_files = "Sources/Nimble/Adapters/NonObjectiveC/*.swift" s.weak_framework = "XCTest" s.requires_arc = true - s.pod_target_xcconfig = { 'ENABLE_BITCODE' => 'NO', 'OTHER_LDFLAGS' => '-weak-lswiftXCTest', 'FRAMEWORK_SEARCH_PATHS' => '$(inherited) "$(PLATFORM_DIR)/Developer/Library/Frameworks"' } + s.compiler_flags = '-DPRODUCT_NAME=Nimble/Nimble' + s.pod_target_xcconfig = { + 'ENABLE_BITCODE' => 'NO', + 'OTHER_LDFLAGS' => '-weak-lswiftXCTest', + 'FRAMEWORK_SEARCH_PATHS' => '$(inherited) "$(PLATFORM_DIR)/Developer/Library/Frameworks"', + } end diff --git a/Carthage/Checkouts/Quick/Externals/Nimble/Nimble.xcodeproj/project.pbxproj b/Carthage/Checkouts/Quick/Externals/Nimble/Nimble.xcodeproj/project.pbxproj index c6fe033..7c2c084 100644 --- a/Carthage/Checkouts/Quick/Externals/Nimble/Nimble.xcodeproj/project.pbxproj +++ b/Carthage/Checkouts/Quick/Externals/Nimble/Nimble.xcodeproj/project.pbxproj @@ -48,12 +48,15 @@ 1F1B5AD51963E13900CA8BF9 /* BeAKindOfTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F1B5AD31963E13900CA8BF9 /* BeAKindOfTest.swift */; }; 1F299EAB19627B2D002641AF /* BeEmptyTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F299EAA19627B2D002641AF /* BeEmptyTest.swift */; }; 1F299EAC19627B2D002641AF /* BeEmptyTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F299EAA19627B2D002641AF /* BeEmptyTest.swift */; }; + 1F2D175B1DB618ED00EE9C7A /* mach_excServer.h in Headers */ = {isa = PBXBuildFile; fileRef = 9630C0261C6D0BB0000693EE /* mach_excServer.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 1F2D175C1DB618F000EE9C7A /* mach_excServer.c in Sources */ = {isa = PBXBuildFile; fileRef = 9630C0221C6D0B82000693EE /* mach_excServer.c */; }; 1F43728A1A1B343800EB80F8 /* Functional.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FD8CD251968AB07008ED995 /* Functional.swift */; }; 1F43728B1A1B343900EB80F8 /* Functional.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FD8CD251968AB07008ED995 /* Functional.swift */; }; 1F43728C1A1B343C00EB80F8 /* SourceLocation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FD8CD271968AB07008ED995 /* SourceLocation.swift */; }; 1F43728D1A1B343D00EB80F8 /* SourceLocation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FD8CD271968AB07008ED995 /* SourceLocation.swift */; }; 1F43728E1A1B343F00EB80F8 /* Stringers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FD8CD281968AB07008ED995 /* Stringers.swift */; }; 1F43728F1A1B344000EB80F8 /* Stringers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FD8CD281968AB07008ED995 /* Stringers.swift */; }; + 1F4999A61DBF2DD100BF8877 /* Nimble.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F1A742E1940169200FFFC47 /* Nimble.h */; settings = {ATTRIBUTES = (Public, ); }; }; 1F4A56661A3B305F009E1637 /* ObjCAsyncTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F4A56651A3B305F009E1637 /* ObjCAsyncTest.m */; }; 1F4A56671A3B305F009E1637 /* ObjCAsyncTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F4A56651A3B305F009E1637 /* ObjCAsyncTest.m */; }; 1F4A566A1A3B3108009E1637 /* ObjCBeAnInstanceOfTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F4A56691A3B3108009E1637 /* ObjCBeAnInstanceOfTest.m */; }; @@ -94,6 +97,14 @@ 1F4A569E1A3B3565009E1637 /* ObjCMatchTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F4A569C1A3B3565009E1637 /* ObjCMatchTest.m */; }; 1F4A56A01A3B359E009E1637 /* ObjCRaiseExceptionTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F4A569F1A3B359E009E1637 /* ObjCRaiseExceptionTest.m */; }; 1F4A56A11A3B359E009E1637 /* ObjCRaiseExceptionTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F4A569F1A3B359E009E1637 /* ObjCRaiseExceptionTest.m */; }; + 1F4BB8A41DAC9DC90048464B /* CwlCatchBadInstructionPOSIX.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F4BB89D1DAC9D930048464B /* CwlCatchBadInstructionPOSIX.swift */; }; + 1F4BB8AB1DAC9DE50048464B /* CwlCatchBadInstruction.h in Headers */ = {isa = PBXBuildFile; fileRef = 9630C00A1C6D0B18000693EE /* CwlCatchBadInstruction.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 1F4BB8AE1DAC9DED0048464B /* CwlCatchException.h in Headers */ = {isa = PBXBuildFile; fileRef = 9630C0161C6D0B2F000693EE /* CwlCatchException.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 1F4BB8B61DACA0E30048464B /* ThrowAssertionTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F4BB8B31DACA0D00048464B /* ThrowAssertionTest.swift */; }; + 1F4BB8B71DACA0E40048464B /* ThrowAssertionTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F4BB8B31DACA0D00048464B /* ThrowAssertionTest.swift */; }; + 1F4BB8B81DACAACF0048464B /* ThrowAssertionTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F4BB8B31DACA0D00048464B /* ThrowAssertionTest.swift */; }; + 1F4BB8BA1DACBFCF0048464B /* CwlCatchBadInstruction.m in Sources */ = {isa = PBXBuildFile; fileRef = 9630C00B1C6D0B18000693EE /* CwlCatchBadInstruction.m */; }; + 1F4BB8BB1DACBFD00048464B /* CwlCatchBadInstruction.m in Sources */ = {isa = PBXBuildFile; fileRef = 9630C00B1C6D0B18000693EE /* CwlCatchBadInstruction.m */; }; 1F5DF15F1BDCA0CE00C3A531 /* Nimble.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1F5DF1551BDCA0CE00C3A531 /* Nimble.framework */; }; 1F5DF16C1BDCA0F500C3A531 /* AssertionRecorder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FD8CD051968AB07008ED995 /* AssertionRecorder.swift */; }; 1F5DF16D1BDCA0F500C3A531 /* AdapterProtocols.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1FD8CD061968AB07008ED995 /* AdapterProtocols.swift */; }; @@ -155,7 +166,6 @@ 1F5DF1A91BDCA10200C3A531 /* MatchTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDB4D5EF19FE442800E9D9FE /* MatchTest.swift */; }; 1F5DF1AA1BDCA10200C3A531 /* RaisesExceptionTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F925EEB195C12C800ED456B /* RaisesExceptionTest.swift */; }; 1F5DF1AB1BDCA10200C3A531 /* ThrowErrorTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29EA59621B551ED2002D767E /* ThrowErrorTest.swift */; }; - 1F5DF1AE1BDCA17600C3A531 /* Nimble.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F1A742E1940169200FFFC47 /* Nimble.h */; settings = {ATTRIBUTES = (Public, ); }; }; 1F8A37B01B7C5042001C8357 /* ObjCSyncTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F8A37AF1B7C5042001C8357 /* ObjCSyncTest.m */; }; 1F8A37B11B7C5042001C8357 /* ObjCSyncTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F8A37AF1B7C5042001C8357 /* ObjCSyncTest.m */; }; 1F91DD2D1C74BF36002C309F /* BeVoidTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F91DD2C1C74BF36002C309F /* BeVoidTest.swift */; }; @@ -282,11 +292,25 @@ 7B5358BE1C38479700A23FAA /* SatisfyAnyOf.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B5358BD1C38479700A23FAA /* SatisfyAnyOf.swift */; }; 7B5358BF1C38479700A23FAA /* SatisfyAnyOf.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B5358BD1C38479700A23FAA /* SatisfyAnyOf.swift */; }; 7B5358C01C38479700A23FAA /* SatisfyAnyOf.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B5358BD1C38479700A23FAA /* SatisfyAnyOf.swift */; }; - 7B5358C51C39184200A23FAA /* ObjCSatisfyAnyOfTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B5358C11C39155600A23FAA /* ObjCSatisfyAnyOfTest.m */; }; - 7B5358C61C39184200A23FAA /* ObjCSatisfyAnyOfTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B5358C11C39155600A23FAA /* ObjCSatisfyAnyOfTest.m */; }; - 8DF1C3F71C94FC75004B2D36 /* ObjcStringersTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 8DF1C3F61C94FC75004B2D36 /* ObjcStringersTest.m */; }; - 8DF1C3F81C94FC75004B2D36 /* ObjcStringersTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 8DF1C3F61C94FC75004B2D36 /* ObjcStringersTest.m */; }; - 8DF1C3F91C94FD0C004B2D36 /* ObjcStringersTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 8DF1C3F61C94FC75004B2D36 /* ObjcStringersTest.m */; }; + 9630C00D1C6D0B18000693EE /* CwlCatchBadInstruction.h in Headers */ = {isa = PBXBuildFile; fileRef = 9630C00A1C6D0B18000693EE /* CwlCatchBadInstruction.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 9630C00E1C6D0B18000693EE /* CwlCatchBadInstruction.h in Headers */ = {isa = PBXBuildFile; fileRef = 9630C00A1C6D0B18000693EE /* CwlCatchBadInstruction.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 9630C0131C6D0B18000693EE /* CwlCatchBadInstruction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9630C00C1C6D0B18000693EE /* CwlCatchBadInstruction.swift */; }; + 9630C0141C6D0B18000693EE /* CwlCatchBadInstruction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9630C00C1C6D0B18000693EE /* CwlCatchBadInstruction.swift */; }; + 9630C0191C6D0B2F000693EE /* CwlCatchException.h in Headers */ = {isa = PBXBuildFile; fileRef = 9630C0161C6D0B2F000693EE /* CwlCatchException.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 9630C01A1C6D0B2F000693EE /* CwlCatchException.h in Headers */ = {isa = PBXBuildFile; fileRef = 9630C0161C6D0B2F000693EE /* CwlCatchException.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 9630C01C1C6D0B2F000693EE /* CwlCatchException.m in Sources */ = {isa = PBXBuildFile; fileRef = 9630C0171C6D0B2F000693EE /* CwlCatchException.m */; settings = {COMPILER_FLAGS = "-fobjc-arc"; }; }; + 9630C01D1C6D0B2F000693EE /* CwlCatchException.m in Sources */ = {isa = PBXBuildFile; fileRef = 9630C0171C6D0B2F000693EE /* CwlCatchException.m */; settings = {COMPILER_FLAGS = "-fobjc-arc"; }; }; + 9630C01F1C6D0B2F000693EE /* CwlCatchException.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9630C0181C6D0B2F000693EE /* CwlCatchException.swift */; }; + 9630C0201C6D0B2F000693EE /* CwlCatchException.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9630C0181C6D0B2F000693EE /* CwlCatchException.swift */; }; + 9630C0231C6D0B82000693EE /* mach_excServer.c in Sources */ = {isa = PBXBuildFile; fileRef = 9630C0221C6D0B82000693EE /* mach_excServer.c */; }; + 9630C0271C6D0BB0000693EE /* mach_excServer.h in Headers */ = {isa = PBXBuildFile; fileRef = 9630C0261C6D0BB0000693EE /* mach_excServer.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 9630C02C1C6D125F000693EE /* CwlBadInstructionException.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9630C02B1C6D125F000693EE /* CwlBadInstructionException.swift */; }; + 9630C02D1C6D125F000693EE /* CwlBadInstructionException.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9630C02B1C6D125F000693EE /* CwlBadInstructionException.swift */; }; + 9630C0301C6D139F000693EE /* CwlDarwinDefinitions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9630C02F1C6D139F000693EE /* CwlDarwinDefinitions.swift */; }; + 9630C0311C6D139F000693EE /* CwlDarwinDefinitions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9630C02F1C6D139F000693EE /* CwlDarwinDefinitions.swift */; }; + 964CFEFD1C4FF48900513336 /* ThrowAssertion.swift in Sources */ = {isa = PBXBuildFile; fileRef = 964CFEFC1C4FF48900513336 /* ThrowAssertion.swift */; }; + 964CFEFE1C4FF48900513336 /* ThrowAssertion.swift in Sources */ = {isa = PBXBuildFile; fileRef = 964CFEFC1C4FF48900513336 /* ThrowAssertion.swift */; }; + 964CFEFF1C4FF48900513336 /* ThrowAssertion.swift in Sources */ = {isa = PBXBuildFile; fileRef = 964CFEFC1C4FF48900513336 /* ThrowAssertion.swift */; }; 965B0D091B62B8ED0005AE66 /* ObjCUserDescriptionTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 965B0D081B62B8ED0005AE66 /* ObjCUserDescriptionTest.m */; }; 965B0D0A1B62B8ED0005AE66 /* ObjCUserDescriptionTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 965B0D081B62B8ED0005AE66 /* ObjCUserDescriptionTest.m */; }; 965B0D0C1B62C06D0005AE66 /* UserDescriptionTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 965B0D0B1B62C06D0005AE66 /* UserDescriptionTest.swift */; }; @@ -455,6 +479,8 @@ 1F4A56991A3B3539009E1637 /* ObjCEqualTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ObjCEqualTest.m; sourceTree = ""; }; 1F4A569C1A3B3565009E1637 /* ObjCMatchTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ObjCMatchTest.m; sourceTree = ""; }; 1F4A569F1A3B359E009E1637 /* ObjCRaiseExceptionTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ObjCRaiseExceptionTest.m; sourceTree = ""; }; + 1F4BB89D1DAC9D930048464B /* CwlCatchBadInstructionPOSIX.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = CwlCatchBadInstructionPOSIX.swift; path = CwlPreconditionTesting/CwlCatchBadInstructionPOSIX.swift; sourceTree = ""; }; + 1F4BB8B31DACA0D00048464B /* ThrowAssertionTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ThrowAssertionTest.swift; sourceTree = ""; }; 1F5DF1551BDCA0CE00C3A531 /* Nimble.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Nimble.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 1F5DF15E1BDCA0CE00C3A531 /* NimbleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = NimbleTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 1F8A37AF1B7C5042001C8357 /* ObjCSyncTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ObjCSyncTest.m; sourceTree = ""; }; @@ -521,6 +547,17 @@ 7B5358BD1C38479700A23FAA /* SatisfyAnyOf.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SatisfyAnyOf.swift; sourceTree = ""; }; 7B5358C11C39155600A23FAA /* ObjCSatisfyAnyOfTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ObjCSatisfyAnyOfTest.m; sourceTree = ""; }; 8DF1C3F61C94FC75004B2D36 /* ObjcStringersTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ObjcStringersTest.m; sourceTree = ""; }; + 9630C00A1C6D0B18000693EE /* CwlCatchBadInstruction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CwlCatchBadInstruction.h; path = CwlPreconditionTesting/CwlCatchBadInstruction.h; sourceTree = ""; }; + 9630C00B1C6D0B18000693EE /* CwlCatchBadInstruction.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CwlCatchBadInstruction.m; path = CwlPreconditionTesting/CwlCatchBadInstruction.m; sourceTree = ""; }; + 9630C00C1C6D0B18000693EE /* CwlCatchBadInstruction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = CwlCatchBadInstruction.swift; path = CwlPreconditionTesting/CwlCatchBadInstruction.swift; sourceTree = ""; }; + 9630C0161C6D0B2F000693EE /* CwlCatchException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CwlCatchException.h; path = CwlCatchException/CwlCatchException/CwlCatchException.h; sourceTree = ""; }; + 9630C0171C6D0B2F000693EE /* CwlCatchException.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CwlCatchException.m; path = CwlCatchException/CwlCatchException/CwlCatchException.m; sourceTree = ""; }; + 9630C0181C6D0B2F000693EE /* CwlCatchException.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = CwlCatchException.swift; path = CwlCatchException/CwlCatchException/CwlCatchException.swift; sourceTree = ""; }; + 9630C0221C6D0B82000693EE /* mach_excServer.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = mach_excServer.c; path = CwlPreconditionTesting/mach_excServer.c; sourceTree = ""; }; + 9630C0261C6D0BB0000693EE /* mach_excServer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = mach_excServer.h; path = CwlPreconditionTesting/mach_excServer.h; sourceTree = ""; }; + 9630C02B1C6D125F000693EE /* CwlBadInstructionException.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = CwlBadInstructionException.swift; path = CwlPreconditionTesting/CwlBadInstructionException.swift; sourceTree = ""; }; + 9630C02F1C6D139F000693EE /* CwlDarwinDefinitions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = CwlDarwinDefinitions.swift; path = CwlPreconditionTesting/CwlDarwinDefinitions.swift; sourceTree = ""; }; + 964CFEFC1C4FF48900513336 /* ThrowAssertion.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ThrowAssertion.swift; sourceTree = ""; }; 965B0D081B62B8ED0005AE66 /* ObjCUserDescriptionTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ObjCUserDescriptionTest.m; sourceTree = ""; }; 965B0D0B1B62C06D0005AE66 /* UserDescriptionTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserDescriptionTest.swift; sourceTree = ""; }; AE4BA9AC1C88DDB500B73906 /* Errors.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Errors.swift; sourceTree = ""; }; @@ -627,6 +664,7 @@ 1F1A742B1940169200FFFC47 /* Nimble */, 1F1871B91CA89E1B00A34BF2 /* NimbleObjectiveC */, 1F1A74381940169200FFFC47 /* NimbleTests */, + 9630C0081C6D0AB3000693EE /* Lib */, 1F1A742A1940169200FFFC47 /* Products */, ); indentWidth = 4; @@ -717,6 +755,7 @@ 7B5358B91C3846C900A23FAA /* SatisfyAnyOfTest.swift */, 1FCF914E1C61C85A00B15DCB /* PostNotificationTest.swift */, AE7ADE481C80C00D00B94CD3 /* MatchErrorTest.swift */, + 1F4BB8B31DACA0D00048464B /* ThrowAssertionTest.swift */, ); path = Matchers; sourceTree = ""; @@ -764,6 +803,7 @@ AE7ADE441C80BF8000B94CD3 /* MatchError.swift */, 1FCF91521C61C8A400B15DCB /* PostNotification.swift */, 1FD8CD1E1968AB07008ED995 /* RaisesException.swift */, + 964CFEFC1C4FF48900513336 /* ThrowAssertion.swift */, 7B5358BD1C38479700A23FAA /* SatisfyAnyOf.swift */, 29EA59651B551EE6002D767E /* ThrowError.swift */, ); @@ -817,6 +857,33 @@ path = objc; sourceTree = ""; }; + 9630C0081C6D0AB3000693EE /* Lib */ = { + isa = PBXGroup; + children = ( + 9630C0091C6D0ABA000693EE /* CwlPreconditionTesting */, + ); + name = Lib; + path = Sources/Lib; + sourceTree = ""; + }; + 9630C0091C6D0ABA000693EE /* CwlPreconditionTesting */ = { + isa = PBXGroup; + children = ( + 1F4BB89D1DAC9D930048464B /* CwlCatchBadInstructionPOSIX.swift */, + 9630C02B1C6D125F000693EE /* CwlBadInstructionException.swift */, + 9630C00C1C6D0B18000693EE /* CwlCatchBadInstruction.swift */, + 9630C00A1C6D0B18000693EE /* CwlCatchBadInstruction.h */, + 9630C00B1C6D0B18000693EE /* CwlCatchBadInstruction.m */, + 9630C0181C6D0B2F000693EE /* CwlCatchException.swift */, + 9630C0161C6D0B2F000693EE /* CwlCatchException.h */, + 9630C0171C6D0B2F000693EE /* CwlCatchException.m */, + 9630C02F1C6D139F000693EE /* CwlDarwinDefinitions.swift */, + 9630C0261C6D0BB0000693EE /* mach_excServer.h */, + 9630C0221C6D0B82000693EE /* mach_excServer.c */, + ); + path = CwlPreconditionTesting; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ @@ -824,10 +891,13 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + 9630C00D1C6D0B18000693EE /* CwlCatchBadInstruction.h in Headers */, + 9630C0191C6D0B2F000693EE /* CwlCatchException.h in Headers */, 1F1871C91CA89EDB00A34BF2 /* NMBStringify.h in Headers */, 1F1871C51CA89EDB00A34BF2 /* DSL.h in Headers */, 1F1871C71CA89EDB00A34BF2 /* NMBExceptionCapture.h in Headers */, 1F1A742F1940169200FFFC47 /* Nimble.h in Headers */, + 9630C0271C6D0BB0000693EE /* mach_excServer.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -835,10 +905,12 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + 1F4BB8AE1DAC9DED0048464B /* CwlCatchException.h in Headers */, 1F1871E21CA89EF600A34BF2 /* NMBStringify.h in Headers */, 1F1871E01CA89EF600A34BF2 /* DSL.h in Headers */, 1F1871E11CA89EF600A34BF2 /* NMBExceptionCapture.h in Headers */, - 1F5DF1AE1BDCA17600C3A531 /* Nimble.h in Headers */, + 1F4BB8AB1DAC9DE50048464B /* CwlCatchBadInstruction.h in Headers */, + 1F4999A61DBF2DD100BF8877 /* Nimble.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -846,6 +918,9 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + 9630C00E1C6D0B18000693EE /* CwlCatchBadInstruction.h in Headers */, + 9630C01A1C6D0B2F000693EE /* CwlCatchException.h in Headers */, + 1F2D175B1DB618ED00EE9C7A /* mach_excServer.h in Headers */, 1F1871DF1CA89EF500A34BF2 /* NMBStringify.h in Headers */, 1F1871DD1CA89EF500A34BF2 /* DSL.h in Headers */, 1F1871DE1CA89EF500A34BF2 /* NMBExceptionCapture.h in Headers */, @@ -1109,6 +1184,7 @@ 1F1871C61CA89EDB00A34BF2 /* DSL.m in Sources */, 1FD8CD301968AB07008ED995 /* AdapterProtocols.swift in Sources */, AE7ADE451C80BF8000B94CD3 /* MatchError.swift in Sources */, + 1F4BB8BA1DACBFCF0048464B /* CwlCatchBadInstruction.m in Sources */, 1FC494AA1C29CBA40010975C /* NimbleEnvironment.swift in Sources */, 1FD8CD5E1968AB07008ED995 /* RaisesException.swift in Sources */, 1FD8CD561968AB07008ED995 /* Contain.swift in Sources */, @@ -1128,6 +1204,13 @@ 1FD8CD381968AB07008ED995 /* Expression.swift in Sources */, 1FD8CD3A1968AB07008ED995 /* FailureMessage.swift in Sources */, 472FD1351B9E085700C7B8DA /* HaveCount.swift in Sources */, + 9630C0301C6D139F000693EE /* CwlDarwinDefinitions.swift in Sources */, + 9630C0231C6D0B82000693EE /* mach_excServer.c in Sources */, + 9630C01F1C6D0B2F000693EE /* CwlCatchException.swift in Sources */, + 9630C0131C6D0B18000693EE /* CwlCatchBadInstruction.swift in Sources */, + 9630C01C1C6D0B2F000693EE /* CwlCatchException.m in Sources */, + 9630C02C1C6D125F000693EE /* CwlBadInstructionException.swift in Sources */, + 964CFEFD1C4FF48900513336 /* ThrowAssertion.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1146,7 +1229,6 @@ DDB4D5F019FE442800E9D9FE /* MatchTest.swift in Sources */, 1F4A56731A3B3210009E1637 /* ObjCBeginWithTest.m in Sources */, 1F4A56821A3B336F009E1637 /* ObjCBeLessThanOrEqualToTest.m in Sources */, - 8DF1C3F71C94FC75004B2D36 /* ObjcStringersTest.m in Sources */, 1F925F02195C189500ED456B /* ContainTest.swift in Sources */, 1F4A56881A3B33CB009E1637 /* ObjCBeFalsyTest.m in Sources */, 1F4A568E1A3B342B009E1637 /* ObjCBeFalseTest.m in Sources */, @@ -1179,6 +1261,7 @@ 1F0648CC19639F5A001F9C46 /* ObjectWithLazyProperty.swift in Sources */, 1F4A56851A3B33A0009E1637 /* ObjCBeTruthyTest.m in Sources */, DD9A9A8F19CF439B00706F49 /* BeIdenticalToObjectTest.swift in Sources */, + 1F4BB8B71DACA0E40048464B /* ThrowAssertionTest.swift in Sources */, 1F0648D41963AAB2001F9C46 /* SynchronousTests.swift in Sources */, 347155CA1C337C8900549F03 /* XCTestCaseProvider.swift in Sources */, 4793854D1BA0BB2500296F85 /* ObjCHaveCount.m in Sources */, @@ -1187,7 +1270,6 @@ 1F925F05195C18B700ED456B /* EqualTest.swift in Sources */, 1F4A566D1A3B3159009E1637 /* ObjCBeKindOfTest.m in Sources */, DD72EC641A93874A002F7651 /* AllPassTest.swift in Sources */, - 7B5358C51C39184200A23FAA /* ObjCSatisfyAnyOfTest.m in Sources */, 1F4A569D1A3B3565009E1637 /* ObjCMatchTest.m in Sources */, 1F925EE9195C124400ED456B /* BeAnInstanceOfTest.swift in Sources */, 29EA59631B551ED2002D767E /* ThrowErrorTest.swift in Sources */, @@ -1220,6 +1302,7 @@ 1F5DF1781BDCA0F500C3A531 /* BeAnInstanceOf.swift in Sources */, 1F5DF1771BDCA0F500C3A531 /* BeAKindOf.swift in Sources */, 1F5DF17F1BDCA0F500C3A531 /* BeLessThan.swift in Sources */, + 1F4BB8A41DAC9DC90048464B /* CwlCatchBadInstructionPOSIX.swift in Sources */, 1F5DF17C1BDCA0F500C3A531 /* BeGreaterThan.swift in Sources */, 1F91DD331C74BF61002C309F /* BeVoid.swift in Sources */, 1FCF91551C61C8A400B15DCB /* PostNotification.swift in Sources */, @@ -1242,6 +1325,7 @@ 1F1871D81CA89EEF00A34BF2 /* NMBStringify.m in Sources */, 1F5DF1821BDCA0F500C3A531 /* BeNil.swift in Sources */, 1F5DF16F1BDCA0F500C3A531 /* AssertionDispatcher.swift in Sources */, + 964CFEFF1C4FF48900513336 /* ThrowAssertion.swift in Sources */, 1F5DF1841BDCA0F500C3A531 /* EndWith.swift in Sources */, 1F5DF18D1BDCA0F500C3A531 /* SourceLocation.swift in Sources */, 1F5DF1701BDCA0F500C3A531 /* DSL.swift in Sources */, @@ -1301,13 +1385,13 @@ CD79C9A51D2CC848004B6F9A /* ObjCBeginWithTest.m in Sources */, 347155CC1C337C8900549F03 /* XCTestCaseProvider.swift in Sources */, 1F5DF1AA1BDCA10200C3A531 /* RaisesExceptionTest.swift in Sources */, - 8DF1C3F91C94FD0C004B2D36 /* ObjcStringersTest.m in Sources */, 1F5DF1941BDCA10200C3A531 /* UserDescriptionTest.swift in Sources */, CD79C9AF1D2CC848004B6F9A /* ObjCContainTest.m in Sources */, 1F5DF19F1BDCA10200C3A531 /* BeIdenticalToObjectTest.swift in Sources */, CD79C99E1D2CC832004B6F9A /* ObjCAsyncTest.m in Sources */, 1F91DD2F1C74BF36002C309F /* BeVoidTest.swift in Sources */, 6CAEDD0C1CAEA86F003F1584 /* LinuxSupport.swift in Sources */, + 1F4BB8B81DACAACF0048464B /* ThrowAssertionTest.swift in Sources */, CD79C9B71D2CC848004B6F9A /* ObjCSatisfyAnyOfTest.m in Sources */, 1F5DF1991BDCA10200C3A531 /* BeAnInstanceOfTest.swift in Sources */, CD79C9B11D2CC848004B6F9A /* ObjCEqualTest.m in Sources */, @@ -1350,7 +1434,9 @@ F8A1BE301CB3710900031679 /* XCTestObservationCenter+Register.m in Sources */, 1F1871DA1CA89EF100A34BF2 /* NMBObjCMatcher.swift in Sources */, 1FD8CD311968AB07008ED995 /* AdapterProtocols.swift in Sources */, + 1F2D175C1DB618F000EE9C7A /* mach_excServer.c in Sources */, 1F1871D21CA89EEE00A34BF2 /* DSL.m in Sources */, + 1F4BB8BB1DACBFD00048464B /* CwlCatchBadInstruction.m in Sources */, AE7ADE461C80BF8000B94CD3 /* MatchError.swift in Sources */, 1FC494AB1C29CBA40010975C /* NimbleEnvironment.swift in Sources */, 1FD8CD5F1968AB07008ED995 /* RaisesException.swift in Sources */, @@ -1363,6 +1449,7 @@ 1F1871D41CA89EEE00A34BF2 /* NMBStringify.m in Sources */, 1FD8CD531968AB07008ED995 /* BeNil.swift in Sources */, 1FD8CD6B1968AB07008ED995 /* Async.swift in Sources */, + 964CFEFE1C4FF48900513336 /* ThrowAssertion.swift in Sources */, 1FD8CD591968AB07008ED995 /* EndWith.swift in Sources */, 1FD8CD5D1968AB07008ED995 /* MatcherProtocols.swift in Sources */, 1FD8CD351968AB07008ED995 /* DSL.swift in Sources */, @@ -1370,6 +1457,11 @@ 1FD8CD391968AB07008ED995 /* Expression.swift in Sources */, 1FD8CD3B1968AB07008ED995 /* FailureMessage.swift in Sources */, 472FD1391B9E0A9700C7B8DA /* HaveCount.swift in Sources */, + 9630C0311C6D139F000693EE /* CwlDarwinDefinitions.swift in Sources */, + 9630C0201C6D0B2F000693EE /* CwlCatchException.swift in Sources */, + 9630C0141C6D0B18000693EE /* CwlCatchBadInstruction.swift in Sources */, + 9630C01D1C6D0B2F000693EE /* CwlCatchException.m in Sources */, + 9630C02D1C6D125F000693EE /* CwlBadInstructionException.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1388,7 +1480,6 @@ DDB4D5F119FE442800E9D9FE /* MatchTest.swift in Sources */, 1F4A56741A3B3210009E1637 /* ObjCBeginWithTest.m in Sources */, 1F4A56831A3B336F009E1637 /* ObjCBeLessThanOrEqualToTest.m in Sources */, - 8DF1C3F81C94FC75004B2D36 /* ObjcStringersTest.m in Sources */, 1F925F03195C189500ED456B /* ContainTest.swift in Sources */, 1F4A56891A3B33CB009E1637 /* ObjCBeFalsyTest.m in Sources */, 1F4A568F1A3B342B009E1637 /* ObjCBeFalseTest.m in Sources */, @@ -1421,6 +1512,7 @@ 1F0648CD19639F5A001F9C46 /* ObjectWithLazyProperty.swift in Sources */, 1F4A56861A3B33A0009E1637 /* ObjCBeTruthyTest.m in Sources */, DD9A9A9019CF43AD00706F49 /* BeIdenticalToObjectTest.swift in Sources */, + 1F4BB8B61DACA0E30048464B /* ThrowAssertionTest.swift in Sources */, 1F0648D51963AAB2001F9C46 /* SynchronousTests.swift in Sources */, 347155CB1C337C8900549F03 /* XCTestCaseProvider.swift in Sources */, 4793854E1BA0BB2500296F85 /* ObjCHaveCount.m in Sources */, @@ -1429,7 +1521,6 @@ 1F925F06195C18B700ED456B /* EqualTest.swift in Sources */, 1F4A566E1A3B3159009E1637 /* ObjCBeKindOfTest.m in Sources */, DD72EC651A93874A002F7651 /* AllPassTest.swift in Sources */, - 7B5358C61C39184200A23FAA /* ObjCSatisfyAnyOfTest.m in Sources */, 1F4A569E1A3B3565009E1637 /* ObjCMatchTest.m in Sources */, 1F925EEA195C124400ED456B /* BeAnInstanceOfTest.swift in Sources */, 29EA59641B551ED2002D767E /* ThrowErrorTest.swift in Sources */, @@ -1607,6 +1698,11 @@ "$(PLATFORM_DIR)/Developer/Library/Frameworks", "$(DEVELOPER_FRAMEWORKS_DIR)", ); + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "PRODUCT_NAME=$(PRODUCT_NAME)/$(PRODUCT_NAME)", + "$(inherited)", + ); GCC_TREAT_WARNINGS_AS_ERRORS = YES; INFOPLIST_FILE = Sources/Nimble/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; @@ -1638,6 +1734,10 @@ "$(PLATFORM_DIR)/Developer/Library/Frameworks", "$(DEVELOPER_FRAMEWORKS_DIR)", ); + GCC_PREPROCESSOR_DEFINITIONS = ( + "PRODUCT_NAME=$(PRODUCT_NAME)/$(PRODUCT_NAME)", + "$(inherited)", + ); GCC_TREAT_WARNINGS_AS_ERRORS = YES; INFOPLIST_FILE = Sources/Nimble/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; @@ -1709,6 +1809,11 @@ "$(DEVELOPER_FRAMEWORKS_DIR)", ); GCC_NO_COMMON_BLOCKS = YES; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "PRODUCT_NAME=$(PRODUCT_NAME)/$(PRODUCT_NAME)", + "$(inherited)", + ); INFOPLIST_FILE = Sources/Nimble/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; @@ -1742,6 +1847,10 @@ "$(DEVELOPER_FRAMEWORKS_DIR)", ); GCC_NO_COMMON_BLOCKS = YES; + GCC_PREPROCESSOR_DEFINITIONS = ( + "PRODUCT_NAME=$(PRODUCT_NAME)/$(PRODUCT_NAME)", + "$(inherited)", + ); INFOPLIST_FILE = Sources/Nimble/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; @@ -1818,6 +1927,7 @@ FRAMEWORK_VERSION = A; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", + "PRODUCT_NAME=$(PRODUCT_NAME)/$(PRODUCT_NAME)", "$(inherited)", ); GCC_TREAT_WARNINGS_AS_ERRORS = YES; @@ -1853,6 +1963,10 @@ "$(DEVELOPER_FRAMEWORKS_DIR)", ); FRAMEWORK_VERSION = A; + GCC_PREPROCESSOR_DEFINITIONS = ( + "PRODUCT_NAME=$(PRODUCT_NAME)/$(PRODUCT_NAME)", + "$(inherited)", + ); GCC_TREAT_WARNINGS_AS_ERRORS = YES; INFOPLIST_FILE = Sources/Nimble/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; diff --git a/Carthage/Checkouts/Quick/Externals/Nimble/Nimble.xcodeproj/xcshareddata/xcschemes/Nimble-tvOS.xcscheme b/Carthage/Checkouts/Quick/Externals/Nimble/Nimble.xcodeproj/xcshareddata/xcschemes/Nimble-tvOS.xcscheme index c1c4ade..2309132 100644 --- a/Carthage/Checkouts/Quick/Externals/Nimble/Nimble.xcodeproj/xcshareddata/xcschemes/Nimble-tvOS.xcscheme +++ b/Carthage/Checkouts/Quick/Externals/Nimble/Nimble.xcodeproj/xcshareddata/xcschemes/Nimble-tvOS.xcscheme @@ -24,8 +24,8 @@ Void in fatalError() }.to(throwAssertion()) +expect { precondition(false) }.to(throwAssertion()) + +// Passes if throwing a NSError is not equal to throwing an assertion: +expect { throw NSError(domain: "test", code: 0, userInfo: nil) }.toNot(throwAssertion()) + +// Passes if the post assertion code is not run: +var reachedPoint1 = false +var reachedPoint2 = false +expect { + reachedPoint1 = true + precondition(false, "condition message") + reachedPoint2 = true +}.to(throwAssertion()) + +expect(reachedPoint1) == true +expect(reachedPoint2) == false +``` + +Notes: + +* This feature is only available in Swift. +* It is only supported for `x86_64` binaries, meaning _you cannot run this matcher on iOS devices, only simulators_. +* The tvOS simulator is supported, but using a different mechanism, requiring you to turn off the `Debug executable` scheme setting for your tvOS scheme's Test configuration. + ## Swift Error Handling If you're using Swift 2.0+, you can use the `throwError` matcher to check if an error is thrown. @@ -975,10 +1047,10 @@ expect(actual).to(satisfyAnyOf(beLessThan(@10), beGreaterThan(@20))) expect(@6).to(satisfyAnyOf(equal(@2), equal(@3), equal(@4), equal(@5), equal(@6), equal(@7))) ``` -Note: This matcher allows you to chain any number of matchers together. This provides flexibility, - but if you find yourself chaining many matchers together in one test, consider whether you - could instead refactor that single test into multiple, more precisely focused tests for - better coverage. +Note: This matcher allows you to chain any number of matchers together. This provides flexibility, + but if you find yourself chaining many matchers together in one test, consider whether you + could instead refactor that single test into multiple, more precisely focused tests for + better coverage. # Writing Your Own Matchers @@ -1189,7 +1261,7 @@ extension NMBObjCMatcher { > Nimble can be used on its own, or in conjunction with its sister project, [Quick](https://github.com/Quick/Quick). To install both Quick and Nimble, follow [the installation instructions in the Quick - README](https://github.com/Quick/Quick#how-to-install-quick). + Documentation](https://github.com/Quick/Quick/blob/master/Documentation/en-us/InstallingQuick.md). Nimble can currently be installed in one of two ways: using CocoaPods, or with git submodules. @@ -1224,7 +1296,7 @@ source 'https://github.com/CocoaPods/Specs.git' target 'YOUR_APP_NAME_HERE_Tests', :exclusive => true do use_frameworks! - pod 'Nimble', '~> 4.0.0' + pod 'Nimble', '~> 5.0.0' end ``` diff --git a/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/CwlCatchException/.gitignore b/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/CwlCatchException/.gitignore new file mode 100644 index 0000000..5b05d7e --- /dev/null +++ b/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/CwlCatchException/.gitignore @@ -0,0 +1,3 @@ +.DS_Store +project.xcworkspace/ +xcuserdata/ diff --git a/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/CwlCatchException/CwlCatchException/CwlCatchException.h b/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/CwlCatchException/CwlCatchException/CwlCatchException.h new file mode 100644 index 0000000..6ec6a29 --- /dev/null +++ b/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/CwlCatchException/CwlCatchException/CwlCatchException.h @@ -0,0 +1,30 @@ +// +// CwlCatchException.h +// CwlCatchException +// +// Created by Matt Gallagher on 2016/01/10. +// Copyright © 2016 Matt Gallagher ( http://cocoawithlove.com ). All rights reserved. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR +// IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +// + +#import + +//! Project version number for CwlCatchException. +FOUNDATION_EXPORT double CwlCatchExceptionVersionNumber; + +//! Project version string for CwlCatchException. +FOUNDATION_EXPORT const unsigned char CwlCatchExceptionVersionString[]; + +__attribute__((visibility("hidden"))) +NSException* __nullable catchExceptionOfKind(Class __nonnull type, __attribute__((noescape)) void (^ __nonnull inBlock)()); diff --git a/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/CwlCatchException/CwlCatchException/CwlCatchException.m b/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/CwlCatchException/CwlCatchException/CwlCatchException.m new file mode 100644 index 0000000..4f9772c --- /dev/null +++ b/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/CwlCatchException/CwlCatchException/CwlCatchException.m @@ -0,0 +1,35 @@ +// +// CwlCatchException.m +// CwlAssertionTesting +// +// Created by Matt Gallagher on 2016/01/10. +// Copyright © 2016 Matt Gallagher ( http://cocoawithlove.com ). All rights reserved. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR +// IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +// + +#import "CwlCatchException.h" + +__attribute__((visibility("hidden"))) +NSException* catchExceptionOfKind(Class __nonnull type, __attribute__((noescape)) void (^ __nonnull inBlock)()) { + @try { + inBlock(); + } @catch (NSException *exception) { + if ([exception isKindOfClass:type]) { + return exception; + } else { + @throw; + } + } + return nil; +} diff --git a/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/CwlCatchException/CwlCatchException/CwlCatchException.swift b/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/CwlCatchException/CwlCatchException/CwlCatchException.swift new file mode 100644 index 0000000..b44a232 --- /dev/null +++ b/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/CwlCatchException/CwlCatchException/CwlCatchException.swift @@ -0,0 +1,32 @@ +// +// CwlCatchException.swift +// CwlAssertionTesting +// +// Created by Matt Gallagher on 2016/01/10. +// Copyright © 2016 Matt Gallagher ( http://cocoawithlove.com ). All rights reserved. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR +// IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +// + +import Foundation + +// We can't simply cast to Self? in the catchInBlock method so we need this generic function wrapper to do the conversion for us. Mildly annoying. +private func catchReturnTypeConverter(_ type: T.Type, block: () -> Void) -> T? { + return catchExceptionOfKind(type, block) as? T +} + +extension NSException { + public static func catchException(in block: () -> Void) -> Self? { + return catchReturnTypeConverter(self, block: block) + } +} diff --git a/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/CwlCatchException/CwlCatchException/Info.plist b/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/CwlCatchException/CwlCatchException/Info.plist new file mode 100644 index 0000000..f14cf1e --- /dev/null +++ b/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/CwlCatchException/CwlCatchException/Info.plist @@ -0,0 +1,28 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + $(CURRENT_PROJECT_VERSION) + NSHumanReadableCopyright + Copyright © 2016 Matt Gallagher. All rights reserved. + NSPrincipalClass + + + diff --git a/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlBadInstructionException.swift b/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlBadInstructionException.swift new file mode 100644 index 0000000..2fa67c9 --- /dev/null +++ b/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlBadInstructionException.swift @@ -0,0 +1,76 @@ +// +// CwlBadInstructionException.swift +// CwlPreconditionTesting +// +// Created by Matt Gallagher on 2016/01/10. +// Copyright © 2016 Matt Gallagher ( http://cocoawithlove.com ). All rights reserved. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR +// IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +// + +import Foundation + +private func raiseBadInstructionException() { + BadInstructionException().raise() +} + +/// A simple NSException subclass. It's not required to subclass NSException (since the exception type is represented in the name) but this helps for identifying the exception through runtime type. +@objc public class BadInstructionException: NSException { + static var name: String = "com.cocoawithlove.BadInstruction" + + init() { + super.init(name: NSExceptionName(rawValue: BadInstructionException.name), reason: nil, userInfo: nil) + } + + required public init?(coder aDecoder: NSCoder) { + super.init(coder: aDecoder) + } + + /// An Objective-C callable function, invoked from the `mach_exc_server` callback function `catch_mach_exception_raise_state` to push the `raiseBadInstructionException` function onto the stack. + public class func catch_mach_exception_raise_state(_ exception_port: mach_port_t, exception: exception_type_t, code: UnsafePointer, codeCnt: mach_msg_type_number_t, flavor: UnsafeMutablePointer, old_state: UnsafePointer, old_stateCnt: mach_msg_type_number_t, new_state: thread_state_t, new_stateCnt: UnsafeMutablePointer) -> kern_return_t { + + #if arch(x86_64) + // Make sure we've been given enough memory + if old_stateCnt != x86_THREAD_STATE64_COUNT || new_stateCnt.pointee < x86_THREAD_STATE64_COUNT { + return KERN_INVALID_ARGUMENT + } + + // Read the old thread state + var state = old_state.withMemoryRebound(to: x86_thread_state64_t.self, capacity: 1) { return $0.pointee } + + // 1. Decrement the stack pointer + state.__rsp -= __uint64_t(MemoryLayout.size) + + // 2. Save the old Instruction Pointer to the stack. + if let pointer = UnsafeMutablePointer<__uint64_t>(bitPattern: UInt(state.__rsp)) { + pointer.pointee = state.__rip + } else { + return KERN_INVALID_ARGUMENT + } + + // 3. Set the Instruction Pointer to the new function's address + var f: @convention(c) () -> Void = raiseBadInstructionException + withUnsafePointer(to: &f) { + state.__rip = $0.withMemoryRebound(to: __uint64_t.self, capacity: 1) { return $0.pointee } + } + + // Write the new thread state + new_state.withMemoryRebound(to: x86_thread_state64_t.self, capacity: 1) { $0.pointee = state } + new_stateCnt.pointee = x86_THREAD_STATE64_COUNT + + return KERN_SUCCESS + #else + fatalError("Unavailable for this CPU architecture") + #endif + } +} diff --git a/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlCatchBadInstruction.h b/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlCatchBadInstruction.h new file mode 100644 index 0000000..0333ed2 --- /dev/null +++ b/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlCatchBadInstruction.h @@ -0,0 +1,61 @@ +// +// CwlCatchBadInstruction.h +// CwlPreconditionTesting +// +// Created by Matt Gallagher on 2016/01/10. +// Copyright © 2016 Matt Gallagher ( http://cocoawithlove.com ). All rights reserved. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR +// IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +// + +#if defined(__x86_64__) + +#import +#import + +NS_ASSUME_NONNULL_BEGIN + +// The request_mach_exception_raise_t struct is passed to mach_msg which assumes its exact layout. To avoid problems with different layouts, we keep the definition in C rather than Swift. +typedef struct +{ + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t thread; + mach_msg_port_descriptor_t task; + /* end of the kernel processed data */ + NDR_record_t NDR; + exception_type_t exception; + mach_msg_type_number_t codeCnt; + int64_t code[2]; + int flavor; + mach_msg_type_number_t old_stateCnt; + natural_t old_state[224]; +} request_mach_exception_raise_t; + +// The reply_mach_exception_raise_state_t struct is passed to mach_msg which assumes its exact layout. To avoid problems with different layouts, we keep the definition in C rather than Swift. +typedef struct +{ + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + int flavor; + mach_msg_type_number_t new_stateCnt; + natural_t new_state[224]; +} reply_mach_exception_raise_state_t; + +extern boolean_t mach_exc_server(mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP); + +NS_ASSUME_NONNULL_END + +#endif diff --git a/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlCatchBadInstruction.m b/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlCatchBadInstruction.m new file mode 100644 index 0000000..22c1377 --- /dev/null +++ b/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlCatchBadInstruction.m @@ -0,0 +1,50 @@ +// +// CwlCatchBadInstruction.m +// CwlPreconditionTesting +// +// Created by Matt Gallagher on 2016/01/10. +// Copyright © 2016 Matt Gallagher ( http://cocoawithlove.com ). All rights reserved. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR +// IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +// + +#if defined(__x86_64__) + +#import "CwlCatchBadInstruction.h" + +// Assuming the "PRODUCT_NAME" macro is defined, this will create the name of the Swift generated header file +#define STRINGIZE_NO_EXPANSION(A) #A +#define STRINGIZE_WITH_EXPANSION(A) STRINGIZE_NO_EXPANSION(A) +#define SWIFT_INCLUDE STRINGIZE_WITH_EXPANSION(PRODUCT_NAME-Swift.h) + +// Include the Swift generated header file +#import SWIFT_INCLUDE + +/// A basic function that receives callbacks from mach_exc_server and relays them to the Swift implemented BadInstructionException.catch_mach_exception_raise_state. +kern_return_t catch_mach_exception_raise_state(mach_port_t exception_port, exception_type_t exception, const mach_exception_data_t code, mach_msg_type_number_t codeCnt, int *flavor, const thread_state_t old_state, mach_msg_type_number_t old_stateCnt, thread_state_t new_state, mach_msg_type_number_t *new_stateCnt) { + return [BadInstructionException catch_mach_exception_raise_state:exception_port exception:exception code:code codeCnt:codeCnt flavor:flavor old_state:old_state old_stateCnt:old_stateCnt new_state:new_state new_stateCnt:new_stateCnt]; +} + +// The mach port should be configured so that this function is never used. +kern_return_t catch_mach_exception_raise(mach_port_t exception_port, mach_port_t thread, mach_port_t task, exception_type_t exception, mach_exception_data_t code, mach_msg_type_number_t codeCnt) { + assert(false); + return KERN_FAILURE; +} + +// The mach port should be configured so that this function is never used. +kern_return_t catch_mach_exception_raise_state_identity(mach_port_t exception_port, mach_port_t thread, mach_port_t task, exception_type_t exception, mach_exception_data_t code, mach_msg_type_number_t codeCnt, int *flavor, thread_state_t old_state, mach_msg_type_number_t old_stateCnt, thread_state_t new_state, mach_msg_type_number_t *new_stateCnt) { + assert(false); + return KERN_FAILURE; +} + +#endif diff --git a/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlCatchBadInstruction.swift b/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlCatchBadInstruction.swift new file mode 100644 index 0000000..ab460b3 --- /dev/null +++ b/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlCatchBadInstruction.swift @@ -0,0 +1,194 @@ +// +// CwlCatchBadInstruction.swift +// CwlPreconditionTesting +// +// Created by Matt Gallagher on 2016/01/10. +// Copyright © 2016 Matt Gallagher ( http://cocoawithlove.com ). All rights reserved. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR +// IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +// + +import Foundation + +#if arch(x86_64) + + private enum PthreadError: Error { case code(Int32) } + private enum MachExcServer: Error { case code(kern_return_t) } + + /// A quick function for converting Mach error results into Swift errors + private func kernCheck(_ f: () -> Int32) throws { + let r = f() + guard r == KERN_SUCCESS else { + throw NSError(domain: NSMachErrorDomain, code: Int(r), userInfo: nil) + } + } + + extension execTypesCountTuple { + mutating func pointer(in block: (UnsafeMutablePointer) -> R) -> R { + return withUnsafeMutablePointer(to: &self) { p -> R in + return p.withMemoryRebound(to: T.self, capacity: EXC_TYPES_COUNT) { ptr -> R in + return block(ptr) + } + } + } + } + + extension request_mach_exception_raise_t { + mutating func withMsgHeaderPointer(in block: (UnsafeMutablePointer) -> R) -> R { + return withUnsafeMutablePointer(to: &self) { p -> R in + return p.withMemoryRebound(to: mach_msg_header_t.self, capacity: 1) { ptr -> R in + return block(ptr) + } + } + } + } + + extension reply_mach_exception_raise_state_t { + mutating func withMsgHeaderPointer(in block: (UnsafeMutablePointer) -> R) -> R { + return withUnsafeMutablePointer(to: &self) { p -> R in + return p.withMemoryRebound(to: mach_msg_header_t.self, capacity: 1) { ptr -> R in + return block(ptr) + } + } + } + } + + /// A structure used to store context associated with the Mach message port + private struct MachContext { + var masks = execTypesCountTuple() + var count: mach_msg_type_number_t = 0 + var ports = execTypesCountTuple() + var behaviors = execTypesCountTuple() + var flavors = execTypesCountTuple() + var currentExceptionPort: mach_port_t = 0 + var handlerThread: pthread_t? = nil + + mutating func withUnsafeMutablePointers(in block: (UnsafeMutablePointer, UnsafeMutablePointer, UnsafeMutablePointer, UnsafeMutablePointer) -> R) -> R { + return masks.pointer { masksPtr in + return ports.pointer { portsPtr in + return behaviors.pointer { behaviorsPtr in + return flavors.pointer { flavorsPtr in + return block(masksPtr, portsPtr, behaviorsPtr, flavorsPtr) + } + } + } + } + } + } + + /// A function for receiving mach messages and parsing the first with mach_exc_server (and if any others are received, throwing them away). + private func machMessageHandler(_ arg: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer? { + let context = arg.assumingMemoryBound(to: MachContext.self).pointee + var request = request_mach_exception_raise_t() + var reply = reply_mach_exception_raise_state_t() + + var handledfirstException = false + repeat { do { + // Request the next mach message from the port + request.Head.msgh_local_port = context.currentExceptionPort + request.Head.msgh_size = UInt32(MemoryLayout.size) + try kernCheck { request.withMsgHeaderPointer { requestPtr in + mach_msg(requestPtr, MACH_RCV_MSG | MACH_RCV_INTERRUPT, 0, request.Head.msgh_size, context.currentExceptionPort, 0, UInt32(MACH_PORT_NULL)) + } } + + // Prepare the reply structure + reply.Head.msgh_bits = MACH_MSGH_BITS(MACH_MSGH_BITS_REMOTE(request.Head.msgh_bits), 0) + reply.Head.msgh_local_port = UInt32(MACH_PORT_NULL) + reply.Head.msgh_remote_port = request.Head.msgh_remote_port + reply.Head.msgh_size = UInt32(MemoryLayout.size) + reply.NDR = NDR_record + + if !handledfirstException { + // Use the MiG generated server to invoke our handler for the request and fill in the rest of the reply structure + guard request.withMsgHeaderPointer(in: { requestPtr in reply.withMsgHeaderPointer { replyPtr in + mach_exc_server(requestPtr, replyPtr) + } }) != 0 else { throw MachExcServer.code(reply.RetCode) } + + handledfirstException = true + } else { + // If multiple fatal errors occur, don't handle subsquent errors (let the program crash) + reply.RetCode = KERN_FAILURE + } + + // Send the reply + try kernCheck { reply.withMsgHeaderPointer { replyPtr in + mach_msg(replyPtr, MACH_SEND_MSG, reply.Head.msgh_size, 0, UInt32(MACH_PORT_NULL), 0, UInt32(MACH_PORT_NULL)) + } } + } catch let error as NSError where (error.domain == NSMachErrorDomain && (error.code == Int(MACH_RCV_PORT_CHANGED) || error.code == Int(MACH_RCV_INVALID_NAME))) { + // Port was already closed before we started or closed while we were listening. + // This means the controlling thread shut down. + return nil + } catch { + // Should never be reached but this is testing code, don't try to recover, just abort + fatalError("Mach message error: \(error)") + } } while true + } + + /// Run the provided block. If a mach "BAD_INSTRUCTION" exception is raised, catch it and return a BadInstructionException (which captures stack information about the throw site, if desired). Otherwise return nil. + /// NOTE: This function is only intended for use in test harnesses – use in a distributed build is almost certainly a bad choice. If a "BAD_INSTRUCTION" exception is raised, the block will be exited before completion via Objective-C exception. The risks associated with an Objective-C exception apply here: most Swift/Objective-C functions are *not* exception-safe. Memory may be leaked and the program will not necessarily be left in a safe state. + /// - parameter block: a function without parameters that will be run + /// - returns: if an EXC_BAD_INSTRUCTION is raised during the execution of `block` then a BadInstructionException will be returned, otherwise `nil`. + public func catchBadInstruction(in block: () -> Void) -> BadInstructionException? { + var context = MachContext() + var result: BadInstructionException? = nil + do { + var handlerThread: pthread_t? = nil + defer { + // 8. Wait for the thread to terminate *if* we actually made it to the creation point + // The mach port should be destroyed *before* calling pthread_join to avoid a deadlock. + if handlerThread != nil { + pthread_join(handlerThread!, nil) + } + } + + try kernCheck { + // 1. Create the mach port + mach_port_allocate(mach_task_self_, MACH_PORT_RIGHT_RECEIVE, &context.currentExceptionPort) + } + defer { + // 7. Cleanup the mach port + mach_port_destroy(mach_task_self_, context.currentExceptionPort) + } + + try kernCheck { + // 2. Configure the mach port + mach_port_insert_right(mach_task_self_, context.currentExceptionPort, context.currentExceptionPort, MACH_MSG_TYPE_MAKE_SEND) + } + + try kernCheck { context.withUnsafeMutablePointers { masksPtr, portsPtr, behaviorsPtr, flavorsPtr in + // 3. Apply the mach port as the handler for this thread + thread_swap_exception_ports(mach_thread_self(), EXC_MASK_BAD_INSTRUCTION, context.currentExceptionPort, Int32(bitPattern: UInt32(EXCEPTION_STATE) | MACH_EXCEPTION_CODES), x86_THREAD_STATE64, masksPtr, &context.count, portsPtr, behaviorsPtr, flavorsPtr) + } } + + defer { context.withUnsafeMutablePointers { masksPtr, portsPtr, behaviorsPtr, flavorsPtr in + // 6. Unapply the mach port + _ = thread_swap_exception_ports(mach_thread_self(), EXC_MASK_BAD_INSTRUCTION, 0, EXCEPTION_DEFAULT, THREAD_STATE_NONE, masksPtr, &context.count, portsPtr, behaviorsPtr, flavorsPtr) + } } + + try withUnsafeMutablePointer(to: &context) { c throws in + // 4. Create the thread + let e = pthread_create(&handlerThread, nil, machMessageHandler, c) + guard e == 0 else { throw PthreadError.code(e) } + + // 5. Run the block + result = BadInstructionException.catchException(in: block) + } + } catch { + // Should never be reached but this is testing code, don't try to recover, just abort + fatalError("Mach port error: \(error)") + } + return result + } + +#endif + diff --git a/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlCatchBadInstructionPOSIX.swift b/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlCatchBadInstructionPOSIX.swift new file mode 100644 index 0000000..b3afb12 --- /dev/null +++ b/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlCatchBadInstructionPOSIX.swift @@ -0,0 +1,100 @@ +// +// CwlCatchBadInstructionPOSIX.swift +// CwlPreconditionTesting +// +// Created by Matt Gallagher on 8/02/2016. +// Copyright © 2016 Matt Gallagher ( http://cocoawithlove.com ). All rights reserved. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR +// IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +// + +import Foundation + +#if arch(x86_64) + +// This file is an alternative implementation to CwlCatchBadInstruction.swift that uses a SIGILL signal action and setenv/longjmp instead of a Mach exception handler and Objective-C exception raising. +// +// WARNING: +// This code is quick and dirty. It's a proof of concept for using a SIGILL handler and setjmp/longjmp where Mach exceptions and the Obj-C runtime aren't available. I ran the automated tests when I first wrote this code but I don't personally use it at all so by the time you're reading this comment, it probably broke and I didn't notice. +// Obvious limitations: +// * It doesn't work when debugging with lldb. +// * It doesn't scope correctly to the thread (it's global) +// * In violation of rules for signal handlers, it writes to the "red zone" on the stack +// * It isn't re-entrant +// * Plus all of the same caveats as the Mach exceptions version (doesn't play well with other handlers, probably leaks ARC memory, etc) +// Treat it like a loaded shotgun. Don't point it at your face. + +private var env = jmp_buf(0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0) + +private func triggerLongJmp() { + longjmp(&env.0, 1) +} + +private func sigIllHandler(code: Int32, info: UnsafeMutablePointer<__siginfo>?, uap: UnsafeMutableRawPointer?) -> Void { + guard let context = uap?.assumingMemoryBound(to: ucontext64_t.self) else { return } + + // 1. Decrement the stack pointer + context.pointee.uc_mcontext64.pointee.__ss.__rsp -= __uint64_t(MemoryLayout.size) + + // 2. Save the old Instruction Pointer to the stack. + let rsp = context.pointee.uc_mcontext64.pointee.__ss.__rsp + if let ump = UnsafeMutablePointer<__uint64_t>(bitPattern: UInt(rsp)) { + ump.pointee = rsp + } + + // 3. Set the Instruction Pointer to the new function's address + var f: @convention(c) () -> Void = triggerLongJmp + withUnsafePointer(to: &f) { $0.withMemoryRebound(to: __uint64_t.self, capacity: 1) { ptr in + context.pointee.uc_mcontext64.pointee.__ss.__rip = ptr.pointee + } } +} + +/// Without Mach exceptions or the Objective-C runtime, there's nothing to put in the exception object. It's really just a boolean – either a SIGILL was caught or not. +public class BadInstructionException { +} + +/// Run the provided block. If a POSIX SIGILL is received, handle it and return a BadInstructionException (which is just an empty object in this POSIX signal version). Otherwise return nil. +/// NOTE: This function is only intended for use in test harnesses – use in a distributed build is almost certainly a bad choice. If a SIGILL is received, the block will be interrupted using a C `longjmp`. The risks associated with abrupt jumps apply here: most Swift functions are *not* interrupt-safe. Memory may be leaked and the program will not necessarily be left in a safe state. +/// - parameter block: a function without parameters that will be run +/// - returns: if an SIGILL is raised during the execution of `block` then a BadInstructionException will be returned, otherwise `nil`. +public func catchBadInstruction( block: () -> Void) -> BadInstructionException? { + // Construct the signal action + var sigActionPrev = sigaction() + let action = __sigaction_u(__sa_sigaction: sigIllHandler) + var sigActionNew = sigaction(__sigaction_u: action, sa_mask: sigset_t(), sa_flags: SA_SIGINFO) + + // Install the signal action + if sigaction(SIGILL, &sigActionNew, &sigActionPrev) != 0 { + fatalError("Sigaction error: \(errno)") + } + + defer { + // Restore the previous signal action + if sigaction(SIGILL, &sigActionPrev, nil) != 0 { + fatalError("Sigaction error: \(errno)") + } + } + + // Prepare the jump point + if setjmp(&env.0) != 0 { + // Handle jump received + return BadInstructionException() + } + + // Run the block + block() + + return nil +} + +#endif diff --git a/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlDarwinDefinitions.swift b/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlDarwinDefinitions.swift new file mode 100644 index 0000000..12a6b9f --- /dev/null +++ b/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlDarwinDefinitions.swift @@ -0,0 +1,63 @@ +// +// CwlDarwinDefinitions.swift +// CwlPreconditionTesting +// +// Created by Matt Gallagher on 2016/01/10. +// Copyright © 2016 Matt Gallagher ( http://cocoawithlove.com ). All rights reserved. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR +// IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +// + +import Darwin + +#if arch(x86_64) + +// From /usr/include/mach/port.h +// #define MACH_PORT_RIGHT_RECEIVE ((mach_port_right_t) 1) +let MACH_PORT_RIGHT_RECEIVE: mach_port_right_t = 1 + +// From /usr/include/mach/message.h +// #define MACH_MSG_TYPE_MAKE_SEND 20 /* Must hold receive right */ +// #define MACH_MSGH_BITS_REMOTE(bits) \ +// ((bits) & MACH_MSGH_BITS_REMOTE_MASK) +// #define MACH_MSGH_BITS(remote, local) /* legacy */ \ +// ((remote) | ((local) << 8)) +let MACH_MSG_TYPE_MAKE_SEND: UInt32 = 20 +func MACH_MSGH_BITS_REMOTE(_ bits: UInt32) -> UInt32 { return bits & UInt32(MACH_MSGH_BITS_REMOTE_MASK) } +func MACH_MSGH_BITS(_ remote: UInt32, _ local: UInt32) -> UInt32 { return ((remote) | ((local) << 8)) } + +// From /usr/include/mach/exception_types.h +// #define EXC_BAD_INSTRUCTION 2 /* Instruction failed */ +// #define EXC_MASK_BAD_INSTRUCTION (1 << EXC_BAD_INSTRUCTION) +// #define EXCEPTION_DEFAULT 1 +let EXC_BAD_INSTRUCTION: UInt32 = 2 +let EXC_MASK_BAD_INSTRUCTION: UInt32 = 1 << EXC_BAD_INSTRUCTION +let EXCEPTION_DEFAULT: Int32 = 1 + +// From /usr/include/mach/i386/thread_status.h +// #define THREAD_STATE_NONE 13 +// #define x86_THREAD_STATE64_COUNT ((mach_msg_type_number_t) \ +// ( sizeof (x86_thread_state64_t) / sizeof (int) )) +let THREAD_STATE_NONE: Int32 = 13 +let x86_THREAD_STATE64_COUNT = UInt32(MemoryLayout.size / MemoryLayout.size) + +let EXC_TYPES_COUNT = 14 +struct execTypesCountTuple { + // From /usr/include/mach/i386/exception.h + // #define EXC_TYPES_COUNT 14 /* incl. illegal exception 0 */ + var value: (T,T,T,T,T,T,T,T,T,T,T,T,T,T) = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) + init() { + } +} + +#endif diff --git a/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/Info.plist b/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/Info.plist new file mode 100644 index 0000000..f14cf1e --- /dev/null +++ b/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/Info.plist @@ -0,0 +1,28 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + $(CURRENT_PROJECT_VERSION) + NSHumanReadableCopyright + Copyright © 2016 Matt Gallagher. All rights reserved. + NSPrincipalClass + + + diff --git a/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/mach_excServer.c b/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/mach_excServer.c new file mode 100644 index 0000000..2334538 --- /dev/null +++ b/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/mach_excServer.c @@ -0,0 +1,537 @@ +/* + * IDENTIFICATION: + * stub generated Mon Jan 11 00:24:26 2016 + * with a MiG generated by bootstrap_cmds-93 + * OPTIONS: + */ + +/* Module mach_exc */ + +#if defined(__x86_64__) + +#define __MIG_check__Request__mach_exc_subsystem__ 1 + +#include "mach_excServer.h" + +#ifndef mig_internal +#define mig_internal static __inline__ +#endif /* mig_internal */ + +#ifndef mig_external +#define mig_external +#endif /* mig_external */ + +#if !defined(__MigTypeCheck) && defined(TypeCheck) +#define __MigTypeCheck TypeCheck /* Legacy setting */ +#endif /* !defined(__MigTypeCheck) */ + +#if !defined(__MigKernelSpecificCode) && defined(_MIG_KERNEL_SPECIFIC_CODE_) +#define __MigKernelSpecificCode _MIG_KERNEL_SPECIFIC_CODE_ /* Legacy setting */ +#endif /* !defined(__MigKernelSpecificCode) */ + +#ifndef LimitCheck +#define LimitCheck 0 +#endif /* LimitCheck */ + +#ifndef min +#define min(a,b) ( ((a) < (b))? (a): (b) ) +#endif /* min */ + +#if !defined(_WALIGN_) +#define _WALIGN_(x) (((x) + 3) & ~3) +#endif /* !defined(_WALIGN_) */ + +#if !defined(_WALIGNSZ_) +#define _WALIGNSZ_(x) _WALIGN_(sizeof(x)) +#endif /* !defined(_WALIGNSZ_) */ + +#ifndef UseStaticTemplates +#define UseStaticTemplates 0 +#endif /* UseStaticTemplates */ + +#ifndef __DeclareRcvRpc +#define __DeclareRcvRpc(_NUM_, _NAME_) +#endif /* __DeclareRcvRpc */ + +#ifndef __BeforeRcvRpc +#define __BeforeRcvRpc(_NUM_, _NAME_) +#endif /* __BeforeRcvRpc */ + +#ifndef __AfterRcvRpc +#define __AfterRcvRpc(_NUM_, _NAME_) +#endif /* __AfterRcvRpc */ + +#ifndef __DeclareRcvSimple +#define __DeclareRcvSimple(_NUM_, _NAME_) +#endif /* __DeclareRcvSimple */ + +#ifndef __BeforeRcvSimple +#define __BeforeRcvSimple(_NUM_, _NAME_) +#endif /* __BeforeRcvSimple */ + +#ifndef __AfterRcvSimple +#define __AfterRcvSimple(_NUM_, _NAME_) +#endif /* __AfterRcvSimple */ + +#define novalue void + +#define msgh_request_port msgh_local_port +#define MACH_MSGH_BITS_REQUEST(bits) MACH_MSGH_BITS_LOCAL(bits) +#define msgh_reply_port msgh_remote_port +#define MACH_MSGH_BITS_REPLY(bits) MACH_MSGH_BITS_REMOTE(bits) + +#define MIG_RETURN_ERROR(X, code) {\ + ((mig_reply_error_t *)X)->RetCode = code;\ + ((mig_reply_error_t *)X)->NDR = NDR_record;\ + return;\ + } + +/* Forward Declarations */ + + +mig_internal novalue _Xmach_exception_raise + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP); + +mig_internal novalue _Xmach_exception_raise_state + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP); + +mig_internal novalue _Xmach_exception_raise_state_identity + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP); + + +#if ( __MigTypeCheck ) +#if __MIG_check__Request__mach_exc_subsystem__ +#if !defined(__MIG_check__Request__mach_exception_raise_t__defined) +#define __MIG_check__Request__mach_exception_raise_t__defined + +mig_internal kern_return_t __MIG_check__Request__mach_exception_raise_t(__attribute__((__unused__)) __Request__mach_exception_raise_t *In0P) +{ + + typedef __Request__mach_exception_raise_t __Request; +#if __MigTypeCheck + unsigned int msgh_size; +#endif /* __MigTypeCheck */ + +#if __MigTypeCheck + msgh_size = In0P->Head.msgh_size; + if (!(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + (In0P->msgh_body.msgh_descriptor_count != 2) || + (msgh_size < (mach_msg_size_t)(sizeof(__Request) - 16)) || (msgh_size > (mach_msg_size_t)sizeof(__Request))) + return MIG_BAD_ARGUMENTS; +#endif /* __MigTypeCheck */ + +#if __MigTypeCheck + if (In0P->thread.type != MACH_MSG_PORT_DESCRIPTOR || + In0P->thread.disposition != 17) + return MIG_TYPE_ERROR; +#endif /* __MigTypeCheck */ + +#if __MigTypeCheck + if (In0P->task.type != MACH_MSG_PORT_DESCRIPTOR || + In0P->task.disposition != 17) + return MIG_TYPE_ERROR; +#endif /* __MigTypeCheck */ + +#if defined(__NDR_convert__int_rep__Request__mach_exception_raise_t__codeCnt__defined) + if (In0P->NDR.int_rep != NDR_record.int_rep) + __NDR_convert__int_rep__Request__mach_exception_raise_t__codeCnt(&In0P->codeCnt, In0P->NDR.int_rep); +#endif /* __NDR_convert__int_rep__Request__mach_exception_raise_t__codeCnt__defined */ +#if __MigTypeCheck + if ( In0P->codeCnt > 2 ) + return MIG_BAD_ARGUMENTS; + if (((msgh_size - (mach_msg_size_t)(sizeof(__Request) - 16)) / 8 < In0P->codeCnt) || + (msgh_size != (mach_msg_size_t)(sizeof(__Request) - 16) + (8 * In0P->codeCnt))) + return MIG_BAD_ARGUMENTS; +#endif /* __MigTypeCheck */ + + return MACH_MSG_SUCCESS; +} +#endif /* !defined(__MIG_check__Request__mach_exception_raise_t__defined) */ +#endif /* __MIG_check__Request__mach_exc_subsystem__ */ +#endif /* ( __MigTypeCheck ) */ + + +/* Routine mach_exception_raise */ +mig_internal novalue _Xmach_exception_raise + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t thread; + mach_msg_port_descriptor_t task; + /* end of the kernel processed data */ + NDR_record_t NDR; + exception_type_t exception; + mach_msg_type_number_t codeCnt; + int64_t code[2]; + mach_msg_trailer_t trailer; + } Request __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack() +#endif + typedef __Request__mach_exception_raise_t __Request; + typedef __Reply__mach_exception_raise_t Reply __attribute__((unused)); + + /* + * typedef struct { + * mach_msg_header_t Head; + * NDR_record_t NDR; + * kern_return_t RetCode; + * } mig_reply_error_t; + */ + + Request *In0P = (Request *) InHeadP; + Reply *OutP = (Reply *) OutHeadP; +#ifdef __MIG_check__Request__mach_exception_raise_t__defined + kern_return_t check_result; +#endif /* __MIG_check__Request__mach_exception_raise_t__defined */ + + __DeclareRcvRpc(2405, "mach_exception_raise") + __BeforeRcvRpc(2405, "mach_exception_raise") + +#if defined(__MIG_check__Request__mach_exception_raise_t__defined) + check_result = __MIG_check__Request__mach_exception_raise_t((__Request *)In0P); + if (check_result != MACH_MSG_SUCCESS) + { MIG_RETURN_ERROR(OutP, check_result); } +#endif /* defined(__MIG_check__Request__mach_exception_raise_t__defined) */ + + OutP->RetCode = catch_mach_exception_raise(In0P->Head.msgh_request_port, In0P->thread.name, In0P->task.name, In0P->exception, In0P->code, In0P->codeCnt); + + OutP->NDR = NDR_record; + + + __AfterRcvRpc(2405, "mach_exception_raise") +} + +#if ( __MigTypeCheck ) +#if __MIG_check__Request__mach_exc_subsystem__ +#if !defined(__MIG_check__Request__mach_exception_raise_state_t__defined) +#define __MIG_check__Request__mach_exception_raise_state_t__defined + +mig_internal kern_return_t __MIG_check__Request__mach_exception_raise_state_t(__attribute__((__unused__)) __Request__mach_exception_raise_state_t *In0P, __attribute__((__unused__)) __Request__mach_exception_raise_state_t **In1PP) +{ + + typedef __Request__mach_exception_raise_state_t __Request; + __Request *In1P; +#if __MigTypeCheck + unsigned int msgh_size; +#endif /* __MigTypeCheck */ + unsigned int msgh_size_delta; + +#if __MigTypeCheck + msgh_size = In0P->Head.msgh_size; + if ((In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + (msgh_size < (mach_msg_size_t)(sizeof(__Request) - 912)) || (msgh_size > (mach_msg_size_t)sizeof(__Request))) + return MIG_BAD_ARGUMENTS; +#endif /* __MigTypeCheck */ + +#if defined(__NDR_convert__int_rep__Request__mach_exception_raise_state_t__codeCnt__defined) + if (In0P->NDR.int_rep != NDR_record.int_rep) + __NDR_convert__int_rep__Request__mach_exception_raise_state_t__codeCnt(&In0P->codeCnt, In0P->NDR.int_rep); +#endif /* __NDR_convert__int_rep__Request__mach_exception_raise_state_t__codeCnt__defined */ + msgh_size_delta = (8 * In0P->codeCnt); +#if __MigTypeCheck + if ( In0P->codeCnt > 2 ) + return MIG_BAD_ARGUMENTS; + if (((msgh_size - (mach_msg_size_t)(sizeof(__Request) - 912)) / 8 < In0P->codeCnt) || + (msgh_size < (mach_msg_size_t)(sizeof(__Request) - 912) + (8 * In0P->codeCnt))) + return MIG_BAD_ARGUMENTS; + msgh_size -= msgh_size_delta; +#endif /* __MigTypeCheck */ + + *In1PP = In1P = (__Request *) ((pointer_t) In0P + msgh_size_delta - 16); + +#if defined(__NDR_convert__int_rep__Request__mach_exception_raise_state_t__old_stateCnt__defined) + if (In0P->NDR.int_rep != NDR_record.int_rep) + __NDR_convert__int_rep__Request__mach_exception_raise_state_t__old_stateCnt(&In1P->old_stateCnt, In1P->NDR.int_rep); +#endif /* __NDR_convert__int_rep__Request__mach_exception_raise_state_t__old_stateCnt__defined */ +#if __MigTypeCheck + if ( In1P->old_stateCnt > 224 ) + return MIG_BAD_ARGUMENTS; + if (((msgh_size - (mach_msg_size_t)(sizeof(__Request) - 912)) / 4 < In1P->old_stateCnt) || + (msgh_size != (mach_msg_size_t)(sizeof(__Request) - 912) + (4 * In1P->old_stateCnt))) + return MIG_BAD_ARGUMENTS; +#endif /* __MigTypeCheck */ + + return MACH_MSG_SUCCESS; +} +#endif /* !defined(__MIG_check__Request__mach_exception_raise_state_t__defined) */ +#endif /* __MIG_check__Request__mach_exc_subsystem__ */ +#endif /* ( __MigTypeCheck ) */ + + +/* Routine mach_exception_raise_state */ +mig_internal novalue _Xmach_exception_raise_state + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + exception_type_t exception; + mach_msg_type_number_t codeCnt; + int64_t code[2]; + int flavor; + mach_msg_type_number_t old_stateCnt; + natural_t old_state[224]; + mach_msg_trailer_t trailer; + } Request __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack() +#endif + typedef __Request__mach_exception_raise_state_t __Request; + typedef __Reply__mach_exception_raise_state_t Reply __attribute__((unused)); + + /* + * typedef struct { + * mach_msg_header_t Head; + * NDR_record_t NDR; + * kern_return_t RetCode; + * } mig_reply_error_t; + */ + + Request *In0P = (Request *) InHeadP; + Request *In1P; + Reply *OutP = (Reply *) OutHeadP; +#ifdef __MIG_check__Request__mach_exception_raise_state_t__defined + kern_return_t check_result; +#endif /* __MIG_check__Request__mach_exception_raise_state_t__defined */ + + __DeclareRcvRpc(2406, "mach_exception_raise_state") + __BeforeRcvRpc(2406, "mach_exception_raise_state") + +#if defined(__MIG_check__Request__mach_exception_raise_state_t__defined) + check_result = __MIG_check__Request__mach_exception_raise_state_t((__Request *)In0P, (__Request **)&In1P); + if (check_result != MACH_MSG_SUCCESS) + { MIG_RETURN_ERROR(OutP, check_result); } +#endif /* defined(__MIG_check__Request__mach_exception_raise_state_t__defined) */ + + OutP->new_stateCnt = 224; + + OutP->RetCode = catch_mach_exception_raise_state(In0P->Head.msgh_request_port, In0P->exception, In0P->code, In0P->codeCnt, &In1P->flavor, In1P->old_state, In1P->old_stateCnt, OutP->new_state, &OutP->new_stateCnt); + if (OutP->RetCode != KERN_SUCCESS) { + MIG_RETURN_ERROR(OutP, OutP->RetCode); + } + + OutP->NDR = NDR_record; + + + OutP->flavor = In1P->flavor; + OutP->Head.msgh_size = (mach_msg_size_t)(sizeof(Reply) - 896) + (((4 * OutP->new_stateCnt))); + + __AfterRcvRpc(2406, "mach_exception_raise_state") +} + +#if ( __MigTypeCheck ) +#if __MIG_check__Request__mach_exc_subsystem__ +#if !defined(__MIG_check__Request__mach_exception_raise_state_identity_t__defined) +#define __MIG_check__Request__mach_exception_raise_state_identity_t__defined + +mig_internal kern_return_t __MIG_check__Request__mach_exception_raise_state_identity_t(__attribute__((__unused__)) __Request__mach_exception_raise_state_identity_t *In0P, __attribute__((__unused__)) __Request__mach_exception_raise_state_identity_t **In1PP) +{ + + typedef __Request__mach_exception_raise_state_identity_t __Request; + __Request *In1P; +#if __MigTypeCheck + unsigned int msgh_size; +#endif /* __MigTypeCheck */ + unsigned int msgh_size_delta; + +#if __MigTypeCheck + msgh_size = In0P->Head.msgh_size; + if (!(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || + (In0P->msgh_body.msgh_descriptor_count != 2) || + (msgh_size < (mach_msg_size_t)(sizeof(__Request) - 912)) || (msgh_size > (mach_msg_size_t)sizeof(__Request))) + return MIG_BAD_ARGUMENTS; +#endif /* __MigTypeCheck */ + +#if __MigTypeCheck + if (In0P->thread.type != MACH_MSG_PORT_DESCRIPTOR || + In0P->thread.disposition != 17) + return MIG_TYPE_ERROR; +#endif /* __MigTypeCheck */ + +#if __MigTypeCheck + if (In0P->task.type != MACH_MSG_PORT_DESCRIPTOR || + In0P->task.disposition != 17) + return MIG_TYPE_ERROR; +#endif /* __MigTypeCheck */ + +#if defined(__NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__codeCnt__defined) + if (In0P->NDR.int_rep != NDR_record.int_rep) + __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__codeCnt(&In0P->codeCnt, In0P->NDR.int_rep); +#endif /* __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__codeCnt__defined */ + msgh_size_delta = (8 * In0P->codeCnt); +#if __MigTypeCheck + if ( In0P->codeCnt > 2 ) + return MIG_BAD_ARGUMENTS; + if (((msgh_size - (mach_msg_size_t)(sizeof(__Request) - 912)) / 8 < In0P->codeCnt) || + (msgh_size < (mach_msg_size_t)(sizeof(__Request) - 912) + (8 * In0P->codeCnt))) + return MIG_BAD_ARGUMENTS; + msgh_size -= msgh_size_delta; +#endif /* __MigTypeCheck */ + + *In1PP = In1P = (__Request *) ((pointer_t) In0P + msgh_size_delta - 16); + +#if defined(__NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__old_stateCnt__defined) + if (In0P->NDR.int_rep != NDR_record.int_rep) + __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__old_stateCnt(&In1P->old_stateCnt, In1P->NDR.int_rep); +#endif /* __NDR_convert__int_rep__Request__mach_exception_raise_state_identity_t__old_stateCnt__defined */ +#if __MigTypeCheck + if ( In1P->old_stateCnt > 224 ) + return MIG_BAD_ARGUMENTS; + if (((msgh_size - (mach_msg_size_t)(sizeof(__Request) - 912)) / 4 < In1P->old_stateCnt) || + (msgh_size != (mach_msg_size_t)(sizeof(__Request) - 912) + (4 * In1P->old_stateCnt))) + return MIG_BAD_ARGUMENTS; +#endif /* __MigTypeCheck */ + + return MACH_MSG_SUCCESS; +} +#endif /* !defined(__MIG_check__Request__mach_exception_raise_state_identity_t__defined) */ +#endif /* __MIG_check__Request__mach_exc_subsystem__ */ +#endif /* ( __MigTypeCheck ) */ + + +/* Routine mach_exception_raise_state_identity */ +mig_internal novalue _Xmach_exception_raise_state_identity + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t thread; + mach_msg_port_descriptor_t task; + /* end of the kernel processed data */ + NDR_record_t NDR; + exception_type_t exception; + mach_msg_type_number_t codeCnt; + int64_t code[2]; + int flavor; + mach_msg_type_number_t old_stateCnt; + natural_t old_state[224]; + mach_msg_trailer_t trailer; + } Request __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack() +#endif + typedef __Request__mach_exception_raise_state_identity_t __Request; + typedef __Reply__mach_exception_raise_state_identity_t Reply __attribute__((unused)); + + /* + * typedef struct { + * mach_msg_header_t Head; + * NDR_record_t NDR; + * kern_return_t RetCode; + * } mig_reply_error_t; + */ + + Request *In0P = (Request *) InHeadP; + Request *In1P; + Reply *OutP = (Reply *) OutHeadP; +#ifdef __MIG_check__Request__mach_exception_raise_state_identity_t__defined + kern_return_t check_result; +#endif /* __MIG_check__Request__mach_exception_raise_state_identity_t__defined */ + + __DeclareRcvRpc(2407, "mach_exception_raise_state_identity") + __BeforeRcvRpc(2407, "mach_exception_raise_state_identity") + +#if defined(__MIG_check__Request__mach_exception_raise_state_identity_t__defined) + check_result = __MIG_check__Request__mach_exception_raise_state_identity_t((__Request *)In0P, (__Request **)&In1P); + if (check_result != MACH_MSG_SUCCESS) + { MIG_RETURN_ERROR(OutP, check_result); } +#endif /* defined(__MIG_check__Request__mach_exception_raise_state_identity_t__defined) */ + + OutP->new_stateCnt = 224; + + OutP->RetCode = catch_mach_exception_raise_state_identity(In0P->Head.msgh_request_port, In0P->thread.name, In0P->task.name, In0P->exception, In0P->code, In0P->codeCnt, &In1P->flavor, In1P->old_state, In1P->old_stateCnt, OutP->new_state, &OutP->new_stateCnt); + if (OutP->RetCode != KERN_SUCCESS) { + MIG_RETURN_ERROR(OutP, OutP->RetCode); + } + + OutP->NDR = NDR_record; + + + OutP->flavor = In1P->flavor; + OutP->Head.msgh_size = (mach_msg_size_t)(sizeof(Reply) - 896) + (((4 * OutP->new_stateCnt))); + + __AfterRcvRpc(2407, "mach_exception_raise_state_identity") +} + + + +/* Description of this subsystem, for use in direct RPC */ +const struct catch_mach_exc_subsystem catch_mach_exc_subsystem = { + mach_exc_server_routine, + 2405, + 2408, + (mach_msg_size_t)sizeof(union __ReplyUnion__catch_mach_exc_subsystem), + (vm_address_t)0, + { + { (mig_impl_routine_t) 0, + (mig_stub_routine_t) _Xmach_exception_raise, 6, 0, (routine_arg_descriptor_t)0, (mach_msg_size_t)sizeof(__Reply__mach_exception_raise_t)}, + { (mig_impl_routine_t) 0, + (mig_stub_routine_t) _Xmach_exception_raise_state, 9, 0, (routine_arg_descriptor_t)0, (mach_msg_size_t)sizeof(__Reply__mach_exception_raise_state_t)}, + { (mig_impl_routine_t) 0, + (mig_stub_routine_t) _Xmach_exception_raise_state_identity, 11, 0, (routine_arg_descriptor_t)0, (mach_msg_size_t)sizeof(__Reply__mach_exception_raise_state_identity_t)}, + } +}; + +mig_external boolean_t mach_exc_server + (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) +{ + /* + * typedef struct { + * mach_msg_header_t Head; + * NDR_record_t NDR; + * kern_return_t RetCode; + * } mig_reply_error_t; + */ + + register mig_routine_t routine; + + OutHeadP->msgh_bits = MACH_MSGH_BITS(MACH_MSGH_BITS_REPLY(InHeadP->msgh_bits), 0); + OutHeadP->msgh_remote_port = InHeadP->msgh_reply_port; + /* Minimal size: routine() will update it if different */ + OutHeadP->msgh_size = (mach_msg_size_t)sizeof(mig_reply_error_t); + OutHeadP->msgh_local_port = MACH_PORT_NULL; + OutHeadP->msgh_id = InHeadP->msgh_id + 100; + + if ((InHeadP->msgh_id > 2407) || (InHeadP->msgh_id < 2405) || + ((routine = catch_mach_exc_subsystem.routine[InHeadP->msgh_id - 2405].stub_routine) == 0)) { + ((mig_reply_error_t *)OutHeadP)->NDR = NDR_record; + ((mig_reply_error_t *)OutHeadP)->RetCode = MIG_BAD_ID; + return FALSE; + } + (*routine) (InHeadP, OutHeadP); + return TRUE; +} + +mig_external mig_routine_t mach_exc_server_routine + (mach_msg_header_t *InHeadP) +{ + register int msgh_id; + + msgh_id = InHeadP->msgh_id - 2405; + + if ((msgh_id > 2) || (msgh_id < 0)) + return 0; + + return catch_mach_exc_subsystem.routine[msgh_id].stub_routine; +} + +#endif + diff --git a/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/mach_excServer.h b/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/mach_excServer.h new file mode 100644 index 0000000..766ba11 --- /dev/null +++ b/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/mach_excServer.h @@ -0,0 +1,298 @@ +#ifndef _mach_exc_server_ +#define _mach_exc_server_ + +/* Module mach_exc */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* BEGIN VOUCHER CODE */ + +#ifndef KERNEL +#if defined(__has_include) +#if __has_include() +#ifndef USING_VOUCHERS +#define USING_VOUCHERS +#endif +#ifndef __VOUCHER_FORWARD_TYPE_DECLS__ +#define __VOUCHER_FORWARD_TYPE_DECLS__ +#ifdef __cplusplus +extern "C" { +#endif + extern boolean_t voucher_mach_msg_set(mach_msg_header_t *msg) __attribute__((weak_import)); +#ifdef __cplusplus +} +#endif +#endif // __VOUCHER_FORWARD_TYPE_DECLS__ +#endif // __has_include() +#endif // __has_include +#endif // !KERNEL + +/* END VOUCHER CODE */ + + +#ifdef AUTOTEST +#ifndef FUNCTION_PTR_T +#define FUNCTION_PTR_T +typedef void (*function_ptr_t)(mach_port_t, char *, mach_msg_type_number_t); +typedef struct { + char *name; + function_ptr_t function; +} function_table_entry; +typedef function_table_entry *function_table_t; +#endif /* FUNCTION_PTR_T */ +#endif /* AUTOTEST */ + +#ifndef mach_exc_MSG_COUNT +#define mach_exc_MSG_COUNT 3 +#endif /* mach_exc_MSG_COUNT */ + +#include +#include +#include +#include + +#ifdef __BeforeMigServerHeader +__BeforeMigServerHeader +#endif /* __BeforeMigServerHeader */ + + +/* Routine mach_exception_raise */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t catch_mach_exception_raise +( + mach_port_t exception_port, + mach_port_t thread, + mach_port_t task, + exception_type_t exception, + mach_exception_data_t code, + mach_msg_type_number_t codeCnt +); + +/* Routine mach_exception_raise_state */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t catch_mach_exception_raise_state +( + mach_port_t exception_port, + exception_type_t exception, + const mach_exception_data_t code, + mach_msg_type_number_t codeCnt, + int *flavor, + const thread_state_t old_state, + mach_msg_type_number_t old_stateCnt, + thread_state_t new_state, + mach_msg_type_number_t *new_stateCnt +); + +/* Routine mach_exception_raise_state_identity */ +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +kern_return_t catch_mach_exception_raise_state_identity +( + mach_port_t exception_port, + mach_port_t thread, + mach_port_t task, + exception_type_t exception, + mach_exception_data_t code, + mach_msg_type_number_t codeCnt, + int *flavor, + thread_state_t old_state, + mach_msg_type_number_t old_stateCnt, + thread_state_t new_state, + mach_msg_type_number_t *new_stateCnt +); + +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +boolean_t mach_exc_server( + mach_msg_header_t *InHeadP, + mach_msg_header_t *OutHeadP); + +#ifdef mig_external +mig_external +#else +extern +#endif /* mig_external */ +mig_routine_t mach_exc_server_routine( + mach_msg_header_t *InHeadP); + + +/* Description of this subsystem, for use in direct RPC */ +extern const struct catch_mach_exc_subsystem { + mig_server_routine_t server; /* Server routine */ + mach_msg_id_t start; /* Min routine number */ + mach_msg_id_t end; /* Max routine number + 1 */ + unsigned int maxsize; /* Max msg size */ + vm_address_t reserved; /* Reserved */ + struct routine_descriptor /*Array of routine descriptors */ + routine[3]; +} catch_mach_exc_subsystem; + +/* typedefs for all requests */ + +#ifndef __Request__mach_exc_subsystem__defined +#define __Request__mach_exc_subsystem__defined + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t thread; + mach_msg_port_descriptor_t task; + /* end of the kernel processed data */ + NDR_record_t NDR; + exception_type_t exception; + mach_msg_type_number_t codeCnt; + int64_t code[2]; + } __Request__mach_exception_raise_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + exception_type_t exception; + mach_msg_type_number_t codeCnt; + int64_t code[2]; + int flavor; + mach_msg_type_number_t old_stateCnt; + natural_t old_state[224]; + } __Request__mach_exception_raise_state_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + /* start of the kernel processed data */ + mach_msg_body_t msgh_body; + mach_msg_port_descriptor_t thread; + mach_msg_port_descriptor_t task; + /* end of the kernel processed data */ + NDR_record_t NDR; + exception_type_t exception; + mach_msg_type_number_t codeCnt; + int64_t code[2]; + int flavor; + mach_msg_type_number_t old_stateCnt; + natural_t old_state[224]; + } __Request__mach_exception_raise_state_identity_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack() +#endif +#endif /* !__Request__mach_exc_subsystem__defined */ + + +/* union of all requests */ + +#ifndef __RequestUnion__catch_mach_exc_subsystem__defined +#define __RequestUnion__catch_mach_exc_subsystem__defined +union __RequestUnion__catch_mach_exc_subsystem { + __Request__mach_exception_raise_t Request_mach_exception_raise; + __Request__mach_exception_raise_state_t Request_mach_exception_raise_state; + __Request__mach_exception_raise_state_identity_t Request_mach_exception_raise_state_identity; +}; +#endif /* __RequestUnion__catch_mach_exc_subsystem__defined */ +/* typedefs for all replies */ + +#ifndef __Reply__mach_exc_subsystem__defined +#define __Reply__mach_exc_subsystem__defined + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + } __Reply__mach_exception_raise_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + int flavor; + mach_msg_type_number_t new_stateCnt; + natural_t new_state[224]; + } __Reply__mach_exception_raise_state_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack() +#endif + +#ifdef __MigPackStructs +#pragma pack(4) +#endif + typedef struct { + mach_msg_header_t Head; + NDR_record_t NDR; + kern_return_t RetCode; + int flavor; + mach_msg_type_number_t new_stateCnt; + natural_t new_state[224]; + } __Reply__mach_exception_raise_state_identity_t __attribute__((unused)); +#ifdef __MigPackStructs +#pragma pack() +#endif +#endif /* !__Reply__mach_exc_subsystem__defined */ + + +/* union of all replies */ + +#ifndef __ReplyUnion__catch_mach_exc_subsystem__defined +#define __ReplyUnion__catch_mach_exc_subsystem__defined +union __ReplyUnion__catch_mach_exc_subsystem { + __Reply__mach_exception_raise_t Reply_mach_exception_raise; + __Reply__mach_exception_raise_state_t Reply_mach_exception_raise_state; + __Reply__mach_exception_raise_state_identity_t Reply_mach_exception_raise_state_identity; +}; +#endif /* __RequestUnion__catch_mach_exc_subsystem__defined */ + +#ifndef subsystem_to_name_map_mach_exc +#define subsystem_to_name_map_mach_exc \ + { "mach_exception_raise", 2405 },\ + { "mach_exception_raise_state", 2406 },\ + { "mach_exception_raise_state_identity", 2407 } +#endif + +#ifdef __AfterMigServerHeader +__AfterMigServerHeader +#endif /* __AfterMigServerHeader */ + +#endif /* _mach_exc_server_ */ diff --git a/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/README.md b/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/README.md new file mode 100644 index 0000000..a1a9a70 --- /dev/null +++ b/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Lib/CwlPreconditionTesting/README.md @@ -0,0 +1,80 @@ +# CwlPreconditionTesting + +A Mach exception handler, written in Swift and Objective-C, that allows `EXC_BAD_INSTRUCTION` (as raised by Swift's `assertionFailure`/`preconditionFailure`/`fatalError`) to be caught and tested. + +For an extended discussion of this code, please see the Cocoa with Love article: + +[Partial functions in Swift, Part 2: Catching precondition failures](http://cocoawithlove.com/blog/2016/02/02/partial-functions-part-two-catching-precondition-failures.html) + +## Usage + +The short version is: + +1. `git clone https://github.com/mattgallagher/CwlPreconditionTesting.git` +2. drag the "CwlPreconditionTesting.xcodeproj" file into your project's file tree in Xcode +3. go to your testing target's Build Phase settings and under "Target Dependencies" press the "+" button and select the relevant "CwlPreconditionTesting" target ("_iOS" or "_OSX", depending on your testing target's SDK) +4. write `import CwlPreconditionTesting` at the top of any test file where you want to use `catchBadInstruction` (Swift should handle the linkage automatically when you do this) +5. use the `catchBadInstruction` function as shown in the [CwlCatchBadInstructionTests.swift tests file](https://github.com/mattgallagher/CwlPreconditionTesting/blob/master/CwlPreconditionTestingTests/CwlCatchBadInstructionTests.swift?ts=4) + +### Project details + +The "CwlPreconditionTesting.xcodeproj" contains two targets: + +* CwlPreconditionTesting_OSX +* CwlPreconditionTesting_iOS + +both build a framework named "CwlPreconditionTesting.framework". If you're linking manually, be certain to select the "CwlPreconditionTesting.framework" from the appropriate target. + +Remember: the iOS build is useful only in the simulator. All Mach exception handling code will be conditionally excluded in any device build. + +### Static inclusion + +Due to the complications associated with needing to call into and out of Objective-C, static inclusion in other projects is not a single file nor a quick drag and drop. There's at least 7 files and you'll need to add some project settings. + +All of the following files: + +* CwlCatchBadInstruction.swift +* CwlCatchBadInstruction.h +* CwlCatchBadInstruction.m +* CwlCatchException.swift +* CwlCatchException.h +* CwlCatchException.m + +and either: + +* $(SDKROOT)/usr/include/mach/mach_exc.defs +* mach_excServer.c + +need to be added to the testing target for OS X projects or iOS projects, respectively. + +Your target will also need to have the following macros defined in the "Apple LLVM - Preprocessing" → "Preprocessor Macros" build setting: + + PRODUCT_NAME=$(PRODUCT_NAME) + +This lets the Objective-C file generate the include directive for the autogenerated Swift header so it can call back into Swift during the Mach exception handler callbacks. This macro should stay in sync if you change the target name but if you do anything else in your project that changes the name of the autogenerated Swift header independent of the target name (or you want to add spaces or other command-line complications to the target name), you'll want to update "CwlCatchBadInstruction.m" directly with the correct include directive. + +Additionally, you'll need a standard Objective-C "Bridging header" for your testing target and it will need to include the following import statements: + +``` +#if defined(__x86_64__) +#import +#endif + +#import +``` + +### Using POSIX signals and setjmp/longjmp + +For comparison or for anyone running this code on a platform without Mach exceptions or the Objective-C runtime, I've added a proof-of-concept implementation of `catchBadInstruction` that uses a POSIX SIGILL `sigaction` and `setjmp`/`longjmp` to perform the throw. + +In Xcode, you can simply select the CwlPreconditionTesting_POSIX target (instead of the OSX or iOS targets). If you're building without Xcode: all you need is the CwlCatchBadInstructionPOSIX.swift file (compared to the Mach exception handler, the code is tiny doesn't have any weird Objective-C/MiG file dependencies). + +**Warning No. 1**: on OS X, this approach can't be used when lldb is attached since lldb's Mach exception handler blocks the SIGILL from ever occurring (I've disabled the "Debug Executable" setting for the tests in Xcode - re-enable it to witness the problem). + +**Warning No. 2**: if you're switching between the CwlPreconditionTesting_OSX and CwlPreconditionTesting_POSIX targets, Xcode (as of Xcode 7.2.1) will not detect the change and will not remove the old framework correctly so you'll need to *clean your project* otherwise the old framework will hang around. + +Additional problems in decreasing severity include: + +* the signal handler is whole process (rather than correctly scoped to the thread where the "catch" occurs) +* the signal handler doesn't deal with re-entrancy whereas the mach exception handler remains deterministic in the face of multiple fatal errors +* the signal handler overwrites the "[red zone](https://en.wikipedia.org/wiki/Red_zone_(computing))" which is technically frowned upon in signal handlers (although unlikely to cause problems here) diff --git a/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Nimble/Adapters/NimbleEnvironment.swift b/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Nimble/Adapters/NimbleEnvironment.swift index 5434aaf..a55cb27 100644 --- a/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Nimble/Adapters/NimbleEnvironment.swift +++ b/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Nimble/Adapters/NimbleEnvironment.swift @@ -1,3 +1,4 @@ +import Dispatch import Foundation /// "Global" state of Nimble is stored here. Only DSL functions should access / be aware of this @@ -25,7 +26,7 @@ internal class NimbleEnvironment { set { NimbleAssertionHandler = newValue } } -#if _runtime(_ObjC) + var suppressTVOSAssertionWarning: Bool = false var awaiter: Awaiter init() { @@ -41,5 +42,4 @@ internal class NimbleEnvironment { asyncQueue: .main, timeoutQueue: timeoutQueue) } -#endif } diff --git a/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Nimble/DSL+Wait.swift b/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Nimble/DSL+Wait.swift index fa5a10f..619b6dc 100644 --- a/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Nimble/DSL+Wait.swift +++ b/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Nimble/DSL+Wait.swift @@ -1,6 +1,6 @@ +import Dispatch import Foundation -#if _runtime(_ObjC) private enum ErrorResult { case exception(NSException) case error(Error) @@ -70,10 +70,16 @@ internal class NMBWait: NSObject { } } + #if _runtime(_ObjC) @objc(untilFile:line:action:) internal class func until(_ file: FileString = #file, line: UInt = #line, action: @escaping (() -> Void) -> Void) -> Void { until(timeout: 1, file: file, line: line, action: action) } + #else + internal class func until(_ file: FileString = #file, line: UInt = #line, action: @escaping (() -> Void) -> Void) -> Void { + until(timeout: 1, file: file, line: line, action: action) + } + #endif } internal func blockedRunLoopErrorMessageFor(_ fnName: String, leeway: TimeInterval) -> String { @@ -90,4 +96,3 @@ internal func blockedRunLoopErrorMessageFor(_ fnName: String, leeway: TimeInterv public func waitUntil(timeout: TimeInterval = 1, file: FileString = #file, line: UInt = #line, action: @escaping (@escaping () -> Void) -> Void) -> Void { NMBWait.until(timeout: timeout, file: file, line: line, action: action) } -#endif diff --git a/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Nimble/Matchers/AsyncMatcherWrapper.swift b/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Nimble/Matchers/AsyncMatcherWrapper.swift index c028f5a..6b89c76 100644 --- a/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Nimble/Matchers/AsyncMatcherWrapper.swift +++ b/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Nimble/Matchers/AsyncMatcherWrapper.swift @@ -1,7 +1,7 @@ import Foundation -#if _runtime(_ObjC) - +/// If you are running on a slower machine, it could be useful to increase the default timeout value +/// or slow down poll interval. Default timeout interval is 1, and poll interval is 0.01. public struct AsyncDefaults { public static var Timeout: TimeInterval = 1 public static var PollInterval: TimeInterval = 0.01 @@ -144,5 +144,3 @@ extension Expectation { return toEventuallyNot(matcher, timeout: timeout, pollInterval: pollInterval, description: description) } } - -#endif diff --git a/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Nimble/Matchers/BeLessThan.swift b/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Nimble/Matchers/BeLessThan.swift index 4cd1a05..fbcd7c7 100644 --- a/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Nimble/Matchers/BeLessThan.swift +++ b/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Nimble/Matchers/BeLessThan.swift @@ -33,7 +33,7 @@ public func <(lhs: Expectation, rhs: NMBComparable?) { extension NMBObjCMatcher { public class func beLessThanMatcher(_ expected: NMBComparable?) -> NMBObjCMatcher { return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in - let expr = actualExpression.cast { $0 as! NMBComparable? } + let expr = actualExpression.cast { $0 as? NMBComparable } return try! beLessThan(expected).matches(expr, failureMessage: failureMessage) } } diff --git a/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Nimble/Matchers/BeLogical.swift b/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Nimble/Matchers/BeLogical.swift index ee62928..49272a3 100644 --- a/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Nimble/Matchers/BeLogical.swift +++ b/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Nimble/Matchers/BeLogical.swift @@ -144,28 +144,28 @@ public func beFalsy() -> MatcherFunc extension NMBObjCMatcher { public class func beTruthyMatcher() -> NMBObjCMatcher { return NMBObjCMatcher { actualExpression, failureMessage in - let expr = actualExpression.cast { ($0 as? NSNumber)?.boolValue ?? false as Bool? } + let expr = actualExpression.cast { ($0 as? NSNumber)?.boolValue ?? false } return try! beTruthy().matches(expr, failureMessage: failureMessage) } } public class func beFalsyMatcher() -> NMBObjCMatcher { return NMBObjCMatcher { actualExpression, failureMessage in - let expr = actualExpression.cast { ($0 as? NSNumber)?.boolValue ?? false as Bool? } + let expr = actualExpression.cast { ($0 as? NSNumber)?.boolValue ?? false } return try! beFalsy().matches(expr, failureMessage: failureMessage) } } public class func beTrueMatcher() -> NMBObjCMatcher { return NMBObjCMatcher { actualExpression, failureMessage in - let expr = actualExpression.cast { ($0 as? NSNumber)?.boolValue ?? false as Bool? } + let expr = actualExpression.cast { ($0 as? NSNumber)?.boolValue ?? false } return try! beTrue().matches(expr, failureMessage: failureMessage) } } public class func beFalseMatcher() -> NMBObjCMatcher { return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in - let expr = actualExpression.cast { ($0 as? NSNumber)?.boolValue ?? false as Bool? } + let expr = actualExpression.cast { ($0 as? NSNumber)?.boolValue ?? false } return try! beFalse().matches(expr, failureMessage: failureMessage) } } diff --git a/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Nimble/Matchers/Match.swift b/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Nimble/Matchers/Match.swift index c225f88..3ad5fb5 100644 --- a/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Nimble/Matchers/Match.swift +++ b/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Nimble/Matchers/Match.swift @@ -1,7 +1,5 @@ import Foundation -#if _runtime(_ObjC) - /// A Nimble matcher that succeeds when the actual string satisfies the regular expression /// described by the expected string. public func match(_ expectedValue: String?) -> NonNilMatcherFunc { @@ -18,6 +16,8 @@ public func match(_ expectedValue: String?) -> NonNilMatcherFunc { } } +#if _runtime(_ObjC) + extension NMBObjCMatcher { public class func matchMatcher(_ expected: NSString) -> NMBMatcher { return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in diff --git a/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Nimble/Matchers/ThrowAssertion.swift b/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Nimble/Matchers/ThrowAssertion.swift new file mode 100644 index 0000000..67f9cf6 --- /dev/null +++ b/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Nimble/Matchers/ThrowAssertion.swift @@ -0,0 +1,55 @@ +import Foundation + +public func throwAssertion() -> MatcherFunc { + return MatcherFunc { actualExpression, failureMessage in + #if arch(x86_64) && _runtime(_ObjC) && !SWIFT_PACKAGE + failureMessage.postfixMessage = "throw an assertion" + failureMessage.actualValue = nil + + var succeeded = true + + let caughtException: BadInstructionException? = catchBadInstruction { + #if os(tvOS) + if (!NimbleEnvironment.activeInstance.suppressTVOSAssertionWarning) { + print() + print("[Nimble Warning]: If you're getting stuck on a debugger breakpoint for a " + + "fatal error while using throwAssertion(), please disable 'Debug Executable' " + + "in your scheme. Go to 'Edit Scheme > Test > Info' and uncheck " + + "'Debug Executable'. If you've already done that, suppress this warning " + + "by setting `NimbleEnvironment.activeInstance.suppressTVOSAssertionWarning = true`. " + + "This is required because the standard methods of catching assertions " + + "(mach APIs) are unavailable for tvOS. Instead, the same mechanism the " + + "debugger uses is the fallback method for tvOS." + ) + print() + NimbleEnvironment.activeInstance.suppressTVOSAssertionWarning = true + } + #endif + do { + try actualExpression.evaluate() + } catch let error { + succeeded = false + failureMessage.postfixMessage += "; threw error instead <\(error)>" + } + } + + if !succeeded { + return false + } + + if caughtException == nil { + return false + } + + return true + #elseif SWIFT_PACKAGE + fatalError("The throwAssertion Nimble matcher does not currently support Swift CLI." + + " You can silence this error by placing the test case inside an #if !SWIFT_PACKAGE" + + " conditional statement") + #else + fatalError("The throwAssertion Nimble matcher can only run on x86_64 platforms with " + + "Objective-C (e.g. Mac, iPhone 5s or later simulators). You can silence this error " + + "by placing the test case inside an #if arch(x86_64) or _runtime(_ObjC) conditional statement") + #endif + } +} diff --git a/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Nimble/Nimble.h b/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Nimble/Nimble.h index 1eab61a..790d16d 100644 --- a/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Nimble/Nimble.h +++ b/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Nimble/Nimble.h @@ -3,5 +3,12 @@ #import "NMBStringify.h" #import "DSL.h" +#import "CwlCatchException.h" +#import "CwlCatchBadInstruction.h" + +#if !TARGET_OS_TV + #import "mach_excServer.h" +#endif + FOUNDATION_EXPORT double NimbleVersionNumber; FOUNDATION_EXPORT const unsigned char NimbleVersionString[]; diff --git a/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Nimble/Utils/Async.swift b/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Nimble/Utils/Async.swift index a78a147..c902692 100644 --- a/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Nimble/Utils/Async.swift +++ b/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Nimble/Utils/Async.swift @@ -1,10 +1,13 @@ +import CoreFoundation +import Dispatch import Foundation -#if _runtime(_ObjC) -import Dispatch +#if !_runtime(_ObjC) + import CDispatch +#endif -private let timeoutLeeway = DispatchTimeInterval.nanoseconds(Int(NSEC_PER_MSEC)) -private let pollLeeway = DispatchTimeInterval.nanoseconds(Int(NSEC_PER_MSEC)) +private let timeoutLeeway = DispatchTimeInterval.milliseconds(1) +private let pollLeeway = DispatchTimeInterval.milliseconds(1) /// Stores debugging information about callers internal struct WaitingInfo: CustomStringConvertible { @@ -29,8 +32,13 @@ internal class AssertionWaitLock: WaitLock { func acquireWaitingLock(_ fnName: String, file: FileString, line: UInt) { let info = WaitingInfo(name: fnName, file: file, lineNumber: line) + #if _runtime(_ObjC) + let isMainThread = Thread.isMainThread + #else + let isMainThread = _CFIsMainThread() + #endif nimblePrecondition( - Thread.isMainThread, + isMainThread, "InvalidNimbleAPIUsage", "\(fnName) can only run on the main thread." ) @@ -177,7 +185,12 @@ internal class AwaitPromiseBuilder { let semTimedOutOrBlocked = DispatchSemaphore(value: 0) semTimedOutOrBlocked.signal() let runLoop = CFRunLoopGetMain() - CFRunLoopPerformBlock(runLoop, CFRunLoopMode.defaultMode.rawValue) { + #if _runtime(_ObjC) + let runLoopMode = CFRunLoopMode.defaultMode.rawValue + #else + let runLoopMode = kCFRunLoopDefaultMode + #endif + CFRunLoopPerformBlock(runLoop, runLoopMode) { if semTimedOutOrBlocked.wait(timeout: .now()) == .success { timedOutSem.signal() semTimedOutOrBlocked.signal() @@ -237,7 +250,7 @@ internal class AwaitPromiseBuilder { self.trigger.timeoutSource.resume() while self.promise.asyncResult.isIncomplete() { // Stopping the run loop does not work unless we run only 1 mode - RunLoop.current.run(mode: .defaultRunLoopMode, before: .distantFuture) + _ = RunLoop.current.run(mode: .defaultRunLoopMode, before: .distantFuture) } self.trigger.timeoutSource.suspend() self.trigger.timeoutSource.cancel() @@ -346,5 +359,3 @@ internal func pollBlock( return result } - -#endif diff --git a/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Nimble/Utils/Errors.swift b/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Nimble/Utils/Errors.swift index 54bed92..d424c98 100644 --- a/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Nimble/Utils/Errors.swift +++ b/Carthage/Checkouts/Quick/Externals/Nimble/Sources/Nimble/Utils/Errors.swift @@ -77,14 +77,21 @@ internal func errorMatchesNonNilFieldsOrClosure( matches = false } } - } else if errorType != nil && closure != nil { + } else if errorType != nil { + matches = (actualError is T) // The closure expects another ErrorProtocol as argument, so this // is _supposed_ to fail, so that it becomes more obvious. - let assertions = gatherExpectations { - expect(actualError is T).to(equal(true)) + if let closure = closure { + let assertions = gatherExpectations { + if let actual = actualError as? T { + closure(actual) + } + } + let messages = assertions.map { $0.message } + if messages.count > 0 { + matches = false + } } - precondition(assertions.map { $0.message }.count > 0) - matches = false } } diff --git a/Carthage/Checkouts/Quick/Externals/Nimble/Sources/NimbleObjectiveC/DSL.h b/Carthage/Checkouts/Quick/Externals/Nimble/Sources/NimbleObjectiveC/DSL.h index a499059..54677ee 100644 --- a/Carthage/Checkouts/Quick/Externals/Nimble/Sources/NimbleObjectiveC/DSL.h +++ b/Carthage/Checkouts/Quick/Externals/Nimble/Sources/NimbleObjectiveC/DSL.h @@ -6,48 +6,222 @@ @protocol NMBMatcher; +NS_ASSUME_NONNULL_BEGIN + + +#define NIMBLE_OVERLOADABLE __attribute__((overloadable)) #define NIMBLE_EXPORT FOUNDATION_EXPORT +#define NIMBLE_EXPORT_INLINE FOUNDATION_STATIC_INLINE + +#define NIMBLE_VALUE_OF(VAL) ({ \ + __typeof__((VAL)) val = (VAL); \ + [NSValue valueWithBytes:&val objCType:@encode(__typeof__((VAL)))]; \ +}) #ifdef NIMBLE_DISABLE_SHORT_SYNTAX #define NIMBLE_SHORT(PROTO, ORIGINAL) +#define NIMBLE_SHORT_OVERLOADED(PROTO, ORIGINAL) #else #define NIMBLE_SHORT(PROTO, ORIGINAL) FOUNDATION_STATIC_INLINE PROTO { return (ORIGINAL); } +#define NIMBLE_SHORT_OVERLOADED(PROTO, ORIGINAL) FOUNDATION_STATIC_INLINE NIMBLE_OVERLOADABLE PROTO { return (ORIGINAL); } #endif -NIMBLE_EXPORT NMBExpectation *NMB_expect(id(^actualBlock)(), NSString *file, NSUInteger line); + + +#define DEFINE_NMB_EXPECT_OVERLOAD(TYPE, EXPR) \ + NIMBLE_EXPORT_INLINE NIMBLE_OVERLOADABLE \ + NMBExpectation *NMB_expect(TYPE(^actualBlock)(), NSString *file, NSUInteger line) { \ + return NMB_expect(^id { return EXPR; }, file, line); \ + } + + NIMBLE_EXPORT NIMBLE_OVERLOADABLE + NMBExpectation *NMB_expect(id(^actualBlock)(), NSString *file, NSUInteger line); + + // overloaded dispatch for nils - expect(nil) + DEFINE_NMB_EXPECT_OVERLOAD(void*, nil) + DEFINE_NMB_EXPECT_OVERLOAD(NSRange, NIMBLE_VALUE_OF(actualBlock())) + DEFINE_NMB_EXPECT_OVERLOAD(long, @(actualBlock())) + DEFINE_NMB_EXPECT_OVERLOAD(unsigned long, @(actualBlock())) + DEFINE_NMB_EXPECT_OVERLOAD(int, @(actualBlock())) + DEFINE_NMB_EXPECT_OVERLOAD(unsigned int, @(actualBlock())) + DEFINE_NMB_EXPECT_OVERLOAD(float, @(actualBlock())) + DEFINE_NMB_EXPECT_OVERLOAD(double, @(actualBlock())) + DEFINE_NMB_EXPECT_OVERLOAD(long long, @(actualBlock())) + DEFINE_NMB_EXPECT_OVERLOAD(unsigned long long, @(actualBlock())) + DEFINE_NMB_EXPECT_OVERLOAD(char, @(actualBlock())) + DEFINE_NMB_EXPECT_OVERLOAD(unsigned char, @(actualBlock())) + // bool doesn't get the compiler to dispatch to BOOL types, but using BOOL here seems to allow + // the compiler to dispatch to bool. + DEFINE_NMB_EXPECT_OVERLOAD(BOOL, @(actualBlock())) + DEFINE_NMB_EXPECT_OVERLOAD(char *, @(actualBlock())) + + +#undef DEFINE_NMB_EXPECT_OVERLOAD + + + NIMBLE_EXPORT NMBExpectation *NMB_expectAction(void(^actualBlock)(), NSString *file, NSUInteger line); -NIMBLE_EXPORT id NMB_equal(id expectedValue); -NIMBLE_SHORT(id equal(id expectedValue), - NMB_equal(expectedValue)); -NIMBLE_EXPORT id NMB_haveCount(id expectedValue); -NIMBLE_SHORT(id haveCount(id expectedValue), - NMB_haveCount(expectedValue)); -NIMBLE_EXPORT NMBObjCBeCloseToMatcher *NMB_beCloseTo(NSNumber *expectedValue); -NIMBLE_SHORT(NMBObjCBeCloseToMatcher *beCloseTo(id expectedValue), - NMB_beCloseTo(expectedValue)); +#define DEFINE_OVERLOAD(TYPE, EXPR) \ + NIMBLE_EXPORT_INLINE NIMBLE_OVERLOADABLE \ + id NMB_equal(TYPE expectedValue) { \ + return NMB_equal((EXPR)); \ + } \ + NIMBLE_SHORT_OVERLOADED(id equal(TYPE expectedValue), NMB_equal(expectedValue)); + + + NIMBLE_EXPORT NIMBLE_OVERLOADABLE + id NMB_equal(__nullable id expectedValue); + + NIMBLE_SHORT_OVERLOADED(id equal(__nullable id expectedValue), + NMB_equal(expectedValue)); + + // overloaded dispatch for nils - expect(nil) + DEFINE_OVERLOAD(void*__nullable, (id)nil) + DEFINE_OVERLOAD(NSRange, NIMBLE_VALUE_OF(expectedValue)) + DEFINE_OVERLOAD(long, @(expectedValue)) + DEFINE_OVERLOAD(unsigned long, @(expectedValue)) + DEFINE_OVERLOAD(int, @(expectedValue)) + DEFINE_OVERLOAD(unsigned int, @(expectedValue)) + DEFINE_OVERLOAD(float, @(expectedValue)) + DEFINE_OVERLOAD(double, @(expectedValue)) + DEFINE_OVERLOAD(long long, @(expectedValue)) + DEFINE_OVERLOAD(unsigned long long, @(expectedValue)) + DEFINE_OVERLOAD(char, @(expectedValue)) + DEFINE_OVERLOAD(unsigned char, @(expectedValue)) + // bool doesn't get the compiler to dispatch to BOOL types, but using BOOL here seems to allow + // the compiler to dispatch to bool. + DEFINE_OVERLOAD(BOOL, @(expectedValue)) + DEFINE_OVERLOAD(char *, @(expectedValue)) + +#undef DEFINE_OVERLOAD + + +#define DEFINE_OVERLOAD(TYPE, EXPR) \ + NIMBLE_EXPORT_INLINE NIMBLE_OVERLOADABLE \ + id NMB_haveCount(TYPE expectedValue) { \ + return NMB_haveCount((EXPR)); \ + } \ + NIMBLE_SHORT_OVERLOADED(id haveCount(TYPE expectedValue), \ + NMB_haveCount(expectedValue)); + + + NIMBLE_EXPORT NIMBLE_OVERLOADABLE + id NMB_haveCount(id expectedValue); + + NIMBLE_SHORT_OVERLOADED(id haveCount(id expectedValue), + NMB_haveCount(expectedValue)); + + DEFINE_OVERLOAD(long, @(expectedValue)) + DEFINE_OVERLOAD(unsigned long, @(expectedValue)) + DEFINE_OVERLOAD(int, @(expectedValue)) + DEFINE_OVERLOAD(unsigned int, @(expectedValue)) + DEFINE_OVERLOAD(long long, @(expectedValue)) + DEFINE_OVERLOAD(unsigned long long, @(expectedValue)) + DEFINE_OVERLOAD(char, @(expectedValue)) + DEFINE_OVERLOAD(unsigned char, @(expectedValue)) + +#undef DEFINE_OVERLOAD + +#define DEFINE_OVERLOAD(TYPE, EXPR) \ + NIMBLE_EXPORT_INLINE NIMBLE_OVERLOADABLE \ + NMBObjCBeCloseToMatcher *NMB_beCloseTo(TYPE expectedValue) { \ + return NMB_beCloseTo((NSNumber *)(EXPR)); \ + } \ + NIMBLE_SHORT_OVERLOADED(NMBObjCBeCloseToMatcher *beCloseTo(TYPE expectedValue), \ + NMB_beCloseTo(expectedValue)); + + NIMBLE_EXPORT NIMBLE_OVERLOADABLE NMBObjCBeCloseToMatcher *NMB_beCloseTo(NSNumber *expectedValue); + NIMBLE_SHORT_OVERLOADED(NMBObjCBeCloseToMatcher *beCloseTo(NSNumber *expectedValue), + NMB_beCloseTo(expectedValue)); + + // it would be better to only overload float & double, but zero becomes ambigious + + DEFINE_OVERLOAD(long, @(expectedValue)) + DEFINE_OVERLOAD(unsigned long, @(expectedValue)) + DEFINE_OVERLOAD(int, @(expectedValue)) + DEFINE_OVERLOAD(unsigned int, @(expectedValue)) + DEFINE_OVERLOAD(float, @(expectedValue)) + DEFINE_OVERLOAD(double, @(expectedValue)) + DEFINE_OVERLOAD(long long, @(expectedValue)) + DEFINE_OVERLOAD(unsigned long long, @(expectedValue)) + DEFINE_OVERLOAD(char, @(expectedValue)) + DEFINE_OVERLOAD(unsigned char, @(expectedValue)) + +#undef DEFINE_OVERLOAD NIMBLE_EXPORT id NMB_beAnInstanceOf(Class expectedClass); -NIMBLE_SHORT(id beAnInstanceOf(Class expectedClass), - NMB_beAnInstanceOf(expectedClass)); +NIMBLE_EXPORT_INLINE id beAnInstanceOf(Class expectedClass) { + return NMB_beAnInstanceOf(expectedClass); +} NIMBLE_EXPORT id NMB_beAKindOf(Class expectedClass); -NIMBLE_SHORT(id beAKindOf(Class expectedClass), - NMB_beAKindOf(expectedClass)); +NIMBLE_EXPORT_INLINE id beAKindOf(Class expectedClass) { + return NMB_beAKindOf(expectedClass); +} NIMBLE_EXPORT id NMB_beginWith(id itemElementOrSubstring); -NIMBLE_SHORT(id beginWith(id itemElementOrSubstring), - NMB_beginWith(itemElementOrSubstring)); - -NIMBLE_EXPORT id NMB_beGreaterThan(NSNumber *expectedValue); -NIMBLE_SHORT(id beGreaterThan(NSNumber *expectedValue), - NMB_beGreaterThan(expectedValue)); - -NIMBLE_EXPORT id NMB_beGreaterThanOrEqualTo(NSNumber *expectedValue); -NIMBLE_SHORT(id beGreaterThanOrEqualTo(NSNumber *expectedValue), - NMB_beGreaterThanOrEqualTo(expectedValue)); +NIMBLE_EXPORT_INLINE id beginWith(id itemElementOrSubstring) { + return NMB_beginWith(itemElementOrSubstring); +} + +#define DEFINE_OVERLOAD(TYPE, EXPR) \ + NIMBLE_EXPORT_INLINE NIMBLE_OVERLOADABLE \ + id NMB_beGreaterThan(TYPE expectedValue) { \ + return NMB_beGreaterThan((EXPR)); \ + } \ + NIMBLE_SHORT_OVERLOADED(id beGreaterThan(TYPE expectedValue), NMB_beGreaterThan(expectedValue)); + + NIMBLE_EXPORT NIMBLE_OVERLOADABLE + id NMB_beGreaterThan(NSNumber *expectedValue); + + NIMBLE_EXPORT_INLINE NIMBLE_OVERLOADABLE + id beGreaterThan(NSNumber *expectedValue) { + return NMB_beGreaterThan(expectedValue); + } + + DEFINE_OVERLOAD(long, @(expectedValue)) + DEFINE_OVERLOAD(unsigned long, @(expectedValue)) + DEFINE_OVERLOAD(int, @(expectedValue)) + DEFINE_OVERLOAD(unsigned int, @(expectedValue)) + DEFINE_OVERLOAD(long long, @(expectedValue)) + DEFINE_OVERLOAD(unsigned long long, @(expectedValue)) + DEFINE_OVERLOAD(char, @(expectedValue)) + DEFINE_OVERLOAD(unsigned char, @(expectedValue)) + +#undef DEFINE_OVERLOAD + +#define DEFINE_OVERLOAD(TYPE, EXPR) \ + NIMBLE_EXPORT_INLINE NIMBLE_OVERLOADABLE \ + id NMB_beGreaterThanOrEqualTo(TYPE expectedValue) { \ + return NMB_beGreaterThanOrEqualTo((EXPR)); \ + } \ + NIMBLE_SHORT_OVERLOADED(id beGreaterThanOrEqualTo(TYPE expectedValue), \ + NMB_beGreaterThanOrEqualTo(expectedValue)); + + NIMBLE_EXPORT NIMBLE_OVERLOADABLE + id NMB_beGreaterThanOrEqualTo(NSNumber *expectedValue); + + NIMBLE_EXPORT_INLINE NIMBLE_OVERLOADABLE + id beGreaterThanOrEqualTo(NSNumber *expectedValue) { + return NMB_beGreaterThanOrEqualTo(expectedValue); + } + + DEFINE_OVERLOAD(long, @(expectedValue)) + DEFINE_OVERLOAD(unsigned long, @(expectedValue)) + DEFINE_OVERLOAD(int, @(expectedValue)) + DEFINE_OVERLOAD(unsigned int, @(expectedValue)) + DEFINE_OVERLOAD(float, @(expectedValue)) + DEFINE_OVERLOAD(double, @(expectedValue)) + DEFINE_OVERLOAD(long long, @(expectedValue)) + DEFINE_OVERLOAD(unsigned long long, @(expectedValue)) + DEFINE_OVERLOAD(char, @(expectedValue)) + DEFINE_OVERLOAD(unsigned char, @(expectedValue)) + + +#undef DEFINE_OVERLOAD NIMBLE_EXPORT id NMB_beIdenticalTo(id expectedInstance); NIMBLE_SHORT(id beIdenticalTo(id expectedInstance), @@ -57,13 +231,66 @@ NIMBLE_EXPORT id NMB_be(id expectedInstance); NIMBLE_SHORT(id be(id expectedInstance), NMB_be(expectedInstance)); -NIMBLE_EXPORT id NMB_beLessThan(NSNumber *expectedValue); -NIMBLE_SHORT(id beLessThan(NSNumber *expectedValue), - NMB_beLessThan(expectedValue)); -NIMBLE_EXPORT id NMB_beLessThanOrEqualTo(NSNumber *expectedValue); -NIMBLE_SHORT(id beLessThanOrEqualTo(NSNumber *expectedValue), - NMB_beLessThanOrEqualTo(expectedValue)); +#define DEFINE_OVERLOAD(TYPE, EXPR) \ + NIMBLE_EXPORT_INLINE NIMBLE_OVERLOADABLE \ + id NMB_beLessThan(TYPE expectedValue) { \ + return NMB_beLessThan((EXPR)); \ + } \ + NIMBLE_SHORT_OVERLOADED(id beLessThan(TYPE expectedValue), \ + NMB_beLessThan(expectedValue)); + + NIMBLE_EXPORT NIMBLE_OVERLOADABLE + id NMB_beLessThan(NSNumber *expectedValue); + + NIMBLE_EXPORT_INLINE NIMBLE_OVERLOADABLE + id beLessThan(NSNumber *expectedValue) { + return NMB_beLessThan(expectedValue); + } + + DEFINE_OVERLOAD(long, @(expectedValue)) + DEFINE_OVERLOAD(unsigned long, @(expectedValue)) + DEFINE_OVERLOAD(int, @(expectedValue)) + DEFINE_OVERLOAD(unsigned int, @(expectedValue)) + DEFINE_OVERLOAD(float, @(expectedValue)) + DEFINE_OVERLOAD(double, @(expectedValue)) + DEFINE_OVERLOAD(long long, @(expectedValue)) + DEFINE_OVERLOAD(unsigned long long, @(expectedValue)) + DEFINE_OVERLOAD(char, @(expectedValue)) + DEFINE_OVERLOAD(unsigned char, @(expectedValue)) + +#undef DEFINE_OVERLOAD + + +#define DEFINE_OVERLOAD(TYPE, EXPR) \ + NIMBLE_EXPORT_INLINE NIMBLE_OVERLOADABLE \ + id NMB_beLessThanOrEqualTo(TYPE expectedValue) { \ + return NMB_beLessThanOrEqualTo((EXPR)); \ + } \ + NIMBLE_SHORT_OVERLOADED(id beLessThanOrEqualTo(TYPE expectedValue), \ + NMB_beLessThanOrEqualTo(expectedValue)); + + + NIMBLE_EXPORT NIMBLE_OVERLOADABLE + id NMB_beLessThanOrEqualTo(NSNumber *expectedValue); + + NIMBLE_EXPORT_INLINE NIMBLE_OVERLOADABLE + id beLessThanOrEqualTo(NSNumber *expectedValue) { + return NMB_beLessThanOrEqualTo(expectedValue); + } + + DEFINE_OVERLOAD(long, @(expectedValue)) + DEFINE_OVERLOAD(unsigned long, @(expectedValue)) + DEFINE_OVERLOAD(int, @(expectedValue)) + DEFINE_OVERLOAD(unsigned int, @(expectedValue)) + DEFINE_OVERLOAD(float, @(expectedValue)) + DEFINE_OVERLOAD(double, @(expectedValue)) + DEFINE_OVERLOAD(long long, @(expectedValue)) + DEFINE_OVERLOAD(unsigned long long, @(expectedValue)) + DEFINE_OVERLOAD(char, @(expectedValue)) + DEFINE_OVERLOAD(unsigned char, @(expectedValue)) + +#undef DEFINE_OVERLOAD NIMBLE_EXPORT id NMB_beTruthy(void); NIMBLE_SHORT(id beTruthy(void), @@ -134,7 +361,7 @@ NIMBLE_EXPORT void NMB_failWithMessage(NSString *msg, NSString *file, NSUInteger #define NMB_waitUntil NMB_waitUntilBuilder(@(__FILE__), __LINE__) #ifndef NIMBLE_DISABLE_SHORT_SYNTAX -#define expect(...) NMB_expect(^id{ return (__VA_ARGS__); }, @(__FILE__), __LINE__) +#define expect(...) NMB_expect(^{ return (__VA_ARGS__); }, @(__FILE__), __LINE__) #define expectAction(BLOCK) NMB_expectAction((BLOCK), @(__FILE__), __LINE__) #define failWithMessage(msg) NMB_failWithMessage(msg, @(__FILE__), __LINE__) #define fail() failWithMessage(@"fail() always fails") @@ -142,4 +369,9 @@ NIMBLE_EXPORT void NMB_failWithMessage(NSString *msg, NSString *file, NSUInteger #define waitUntilTimeout NMB_waitUntilTimeout #define waitUntil NMB_waitUntil + +#undef NIMBLE_VALUE_OF + #endif + +NS_ASSUME_NONNULL_END diff --git a/Carthage/Checkouts/Quick/Externals/Nimble/Sources/NimbleObjectiveC/DSL.m b/Carthage/Checkouts/Quick/Externals/Nimble/Sources/NimbleObjectiveC/DSL.m index 2170238..cd93ddd 100644 --- a/Carthage/Checkouts/Quick/Externals/Nimble/Sources/NimbleObjectiveC/DSL.m +++ b/Carthage/Checkouts/Quick/Externals/Nimble/Sources/NimbleObjectiveC/DSL.m @@ -9,7 +9,11 @@ + (void)untilFile:(NSString *)file line:(NSUInteger)line action:(void(^)())actio @end -NIMBLE_EXPORT NMBExpectation *NMB_expect(id(^actualBlock)(), NSString *file, NSUInteger line) { + +NS_ASSUME_NONNULL_BEGIN + + +NIMBLE_EXPORT NIMBLE_OVERLOADABLE NMBExpectation *__nonnull NMB_expect(id __nullable(^actualBlock)(), NSString *__nonnull file, NSUInteger line) { return [[NMBExpectation alloc] initWithActualBlock:actualBlock negative:NO file:file @@ -35,7 +39,7 @@ NIMBLE_EXPORT void NMB_failWithMessage(NSString *msg, NSString *file, NSUInteger return [NMBObjCMatcher beAKindOfMatcher:expectedClass]; } -NIMBLE_EXPORT NMBObjCBeCloseToMatcher *NMB_beCloseTo(NSNumber *expectedValue) { +NIMBLE_EXPORT NIMBLE_OVERLOADABLE NMBObjCBeCloseToMatcher *NMB_beCloseTo(NSNumber *expectedValue) { return [NMBObjCMatcher beCloseToMatcher:expectedValue within:0.001]; } @@ -43,11 +47,11 @@ NIMBLE_EXPORT void NMB_failWithMessage(NSString *msg, NSString *file, NSUInteger return [NMBObjCMatcher beginWithMatcher:itemElementOrSubstring]; } -NIMBLE_EXPORT id NMB_beGreaterThan(NSNumber *expectedValue) { +NIMBLE_EXPORT NIMBLE_OVERLOADABLE id NMB_beGreaterThan(NSNumber *expectedValue) { return [NMBObjCMatcher beGreaterThanMatcher:expectedValue]; } -NIMBLE_EXPORT id NMB_beGreaterThanOrEqualTo(NSNumber *expectedValue) { +NIMBLE_EXPORT NIMBLE_OVERLOADABLE id NMB_beGreaterThanOrEqualTo(NSNumber *expectedValue) { return [NMBObjCMatcher beGreaterThanOrEqualToMatcher:expectedValue]; } @@ -59,11 +63,11 @@ NIMBLE_EXPORT void NMB_failWithMessage(NSString *msg, NSString *file, NSUInteger return [NMBObjCMatcher beIdenticalToMatcher:expectedInstance]; } -NIMBLE_EXPORT id NMB_beLessThan(NSNumber *expectedValue) { +NIMBLE_EXPORT NIMBLE_OVERLOADABLE id NMB_beLessThan(NSNumber *expectedValue) { return [NMBObjCMatcher beLessThanMatcher:expectedValue]; } -NIMBLE_EXPORT id NMB_beLessThanOrEqualTo(NSNumber *expectedValue) { +NIMBLE_EXPORT NIMBLE_OVERLOADABLE id NMB_beLessThanOrEqualTo(NSNumber *expectedValue) { return [NMBObjCMatcher beLessThanOrEqualToMatcher:expectedValue]; } @@ -113,11 +117,11 @@ NIMBLE_EXPORT void NMB_failWithMessage(NSString *msg, NSString *file, NSUInteger return [NMBObjCMatcher endWithMatcher:itemElementOrSubstring]; } -NIMBLE_EXPORT id NMB_equal(id expectedValue) { +NIMBLE_EXPORT NIMBLE_OVERLOADABLE id NMB_equal(__nullable id expectedValue) { return [NMBObjCMatcher equalMatcher:expectedValue]; } -NIMBLE_EXPORT id NMB_haveCount(id expectedValue) { +NIMBLE_EXPORT NIMBLE_OVERLOADABLE id NMB_haveCount(id expectedValue) { return [NMBObjCMatcher haveCountMatcher:expectedValue]; } @@ -148,3 +152,5 @@ NIMBLE_EXPORT NMBWaitUntilBlock NMB_waitUntilBuilder(NSString *file, NSUInteger [NMBWait untilFile:file line:line action:action]; }; } + +NS_ASSUME_NONNULL_END diff --git a/Carthage/Checkouts/Quick/Externals/Nimble/Tests/LinuxMain.swift b/Carthage/Checkouts/Quick/Externals/Nimble/Tests/LinuxMain.swift index 6cae8ca..4210ef0 100644 --- a/Carthage/Checkouts/Quick/Externals/Nimble/Tests/LinuxMain.swift +++ b/Carthage/Checkouts/Quick/Externals/Nimble/Tests/LinuxMain.swift @@ -4,7 +4,7 @@ import XCTest // This is the entry point for NimbleTests on Linux XCTMain([ - // testCase(AsynchronousTests.allTests), + testCase(AsyncTest.allTests), testCase(SynchronousTest.allTests), testCase(UserDescriptionTest.allTests), @@ -29,7 +29,7 @@ XCTMain([ testCase(EndWithTest.allTests), testCase(EqualTest.allTests), testCase(HaveCountTest.allTests), - // testCase(MatchTest.allTests), + testCase(MatchTest.allTests), // testCase(RaisesExceptionTest.allTests), testCase(ThrowErrorTest.allTests), testCase(SatisfyAnyOfTest.allTests), diff --git a/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/AsynchronousTest.swift b/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/AsynchronousTest.swift index 0ccd220..ff78d47 100644 --- a/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/AsynchronousTest.swift +++ b/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/AsynchronousTest.swift @@ -1,11 +1,8 @@ +import Dispatch import Foundation import XCTest import Nimble -// These tests require the ObjC runtimes do not currently have the GCD and run loop facilities -// required for working with Nimble's async matchers -#if _runtime(_ObjC) - final class AsyncTest: XCTestCase, XCTestCaseProvider { static var allTests: [(String, (AsyncTest) -> () throws -> Void)] { return [ @@ -24,7 +21,8 @@ final class AsyncTest: XCTestCase, XCTestCaseProvider { ] } - let errorToThrow = NSError(domain: NSExceptionName.internalInconsistencyException.rawValue, code: 42, userInfo: nil) + class Error: Swift.Error {} + let errorToThrow = Error() private func doThrowError() throws -> Int { throw errorToThrow @@ -222,5 +220,3 @@ final class AsyncTest: XCTestCase, XCTestCaseProvider { #endif } } -#endif - diff --git a/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/Helpers/utils.swift b/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/Helpers/utils.swift index 7962ae4..0b33ea6 100644 --- a/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/Helpers/utils.swift +++ b/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/Helpers/utils.swift @@ -1,3 +1,4 @@ +import Dispatch import Foundation @testable import Nimble import XCTest @@ -58,14 +59,12 @@ func failsWithErrorMessageForNil(_ message: String, file: FileString = #file, li failsWithErrorMessage("\(message) (use beNil() to match nils)", file: file, line: line, preferOriginalSourceLocation: preferOriginalSourceLocation, closure: closure) } -#if _runtime(_ObjC) func deferToMainQueue(action: @escaping () -> Void) { DispatchQueue.main.async { Thread.sleep(forTimeInterval: 0.01) action() } } -#endif public class NimbleHelper : NSObject { public class func expectFailureMessage(_ message: NSString, block: @escaping () -> Void, file: FileString, line: UInt) { diff --git a/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/Matchers/MatchErrorTest.swift b/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/Matchers/MatchErrorTest.swift index 7bd3e4c..940a214 100644 --- a/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/Matchers/MatchErrorTest.swift +++ b/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/Matchers/MatchErrorTest.swift @@ -26,6 +26,7 @@ final class MatchErrorTest: XCTestCase, XCTestCaseProvider { func testMatchErrorNegative() { expect(NimbleError.laugh).toNot(matchError(NimbleError.cry)) expect(NimbleError.laugh as Error).toNot(matchError(NimbleError.cry)) + expect(NimbleError.laugh).toNot(matchError(EquatableError.self)) } func testMatchNSErrorPositive() { @@ -64,6 +65,10 @@ final class MatchErrorTest: XCTestCase, XCTestCaseProvider { failsWithErrorMessage("expected to not match error , got ") { expect(NimbleError.laugh).toNot(matchError(NimbleError.laugh)) } + + failsWithErrorMessage("expected to match error from type , got ") { + expect(NimbleError.laugh).to(matchError(EquatableError.self)) + } } func testDoesNotMatchNils() { diff --git a/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/Matchers/MatchTest.swift b/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/Matchers/MatchTest.swift index 24257ba..5b6d77f 100644 --- a/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/Matchers/MatchTest.swift +++ b/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/Matchers/MatchTest.swift @@ -1,8 +1,6 @@ import XCTest import Nimble -#if _runtime(_ObjC) - final class MatchTest:XCTestCase, XCTestCaseProvider { static var allTests: [(String, (MatchTest) -> () throws -> Void)] { return [ @@ -46,4 +44,3 @@ final class MatchTest:XCTestCase, XCTestCaseProvider { } } } -#endif diff --git a/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/Matchers/ThrowAssertionTest.swift b/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/Matchers/ThrowAssertionTest.swift new file mode 100644 index 0000000..c227b1b --- /dev/null +++ b/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/Matchers/ThrowAssertionTest.swift @@ -0,0 +1,62 @@ +import Foundation +import XCTest +import Nimble + +#if _runtime(_ObjC) && !SWIFT_PACKAGE + +final class ThrowAssertionTest: XCTestCase, XCTestCaseProvider { + static var allTests: [(String, (ThrowAssertionTest) -> () throws -> Void)] { + return [ + ("testPositiveMatch", testPositiveMatch), + ("testErrorThrown", testErrorThrown), + ("testPostAssertionCodeNotRun", testPostAssertionCodeNotRun), + ("testNegativeMatch", testNegativeMatch), + ("testPositiveMessage", testPositiveMessage), + ("testNegativeMessage", testNegativeMessage), + ] + } + + func testPositiveMatch() { + expect { () -> Void in fatalError() }.to(throwAssertion()) + } + + func testErrorThrown() { + expect { throw NSError(domain: "test", code: 0, userInfo: nil) }.toNot(throwAssertion()) + } + + func testPostAssertionCodeNotRun() { + var reachedPoint1 = false + var reachedPoint2 = false + + expect { + reachedPoint1 = true + precondition(false, "condition message") + reachedPoint2 = true + }.to(throwAssertion()) + + expect(reachedPoint1) == true + expect(reachedPoint2) == false + } + + func testNegativeMatch() { + var reachedPoint1 = false + + expect { reachedPoint1 = true }.toNot(throwAssertion()) + + expect(reachedPoint1) == true + } + + func testPositiveMessage() { + failsWithErrorMessage("expected to throw an assertion") { + expect { () -> Void? in return }.to(throwAssertion()) + } + } + + func testNegativeMessage() { + failsWithErrorMessage("expected to not throw an assertion") { + expect { () -> Void in fatalError() }.toNot(throwAssertion()) + } + } +} + +#endif diff --git a/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/Matchers/ThrowErrorTest.swift b/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/Matchers/ThrowErrorTest.swift index 8fd5baf..d7cd312 100644 --- a/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/Matchers/ThrowErrorTest.swift +++ b/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/Matchers/ThrowErrorTest.swift @@ -136,7 +136,6 @@ final class ThrowErrorTest: XCTestCase, XCTestCaseProvider { let moduleName = "NimbleTests" let innerFailureMessage = "expected to equal , got <\(moduleName).NimbleError>" let closure = { (error: Error) in - print("** In closure! With domain \(error._domain)") expect(error._domain).to(equal("foo")) } diff --git a/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/SynchronousTests.swift b/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/SynchronousTests.swift index b50e19b..6234932 100644 --- a/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/SynchronousTests.swift +++ b/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/SynchronousTests.swift @@ -21,7 +21,9 @@ final class SynchronousTest: XCTestCase, XCTestCaseProvider { ] } - let errorToThrow = NSError(domain: NSCocoaErrorDomain, code: 42, userInfo: nil) + class Error: Swift.Error {} + let errorToThrow = Error() + private func doThrowError() throws -> Int { throw errorToThrow } @@ -36,14 +38,12 @@ final class SynchronousTest: XCTestCase, XCTestCaseProvider { } func testUnexpectedErrorsThrownFails() { -#if _runtime(_ObjC) // This test triggers a weird segfault on Linux currently failsWithErrorMessage("expected to equal <1>, got an unexpected error thrown: <\(errorToThrow)>") { expect { try self.doThrowError() }.to(equal(1)) } failsWithErrorMessage("expected to not equal <1>, got an unexpected error thrown: <\(errorToThrow)>") { expect { try self.doThrowError() }.toNot(equal(1)) } -#endif } func testToMatchesIfMatcherReturnsTrue() { diff --git a/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/UserDescriptionTest.swift b/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/UserDescriptionTest.swift index ef754ec..e22d64e 100644 --- a/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/UserDescriptionTest.swift +++ b/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/UserDescriptionTest.swift @@ -38,33 +38,27 @@ final class UserDescriptionTest: XCTestCase, XCTestCaseProvider { } func testToEventuallyMatch_CustomFailureMessage() { -#if _runtime(_ObjC) failsWithErrorMessage( "These aren't eventually equal!\n" + "expected to eventually equal <1>, got <0>") { expect { 0 }.toEventually(equal(1), description: "These aren't eventually equal!") } -#endif } func testToEventuallyNotMatch_CustomFailureMessage() { -#if _runtime(_ObjC) failsWithErrorMessage( "These are eventually equal!\n" + "expected to eventually not equal <1>, got <1>") { expect { 1 }.toEventuallyNot(equal(1), description: "These are eventually equal!") } -#endif } func testToNotEventuallyMatch_CustomFailureMessage() { -#if _runtime(_ObjC) failsWithErrorMessage( "These are eventually equal!\n" + "expected to eventually not equal <1>, got <1>") { expect { 1 }.toEventuallyNot(equal(1), description: "These are eventually equal!") } -#endif } } diff --git a/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/objc/ObjCBeCloseToTest.m b/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/objc/ObjCBeCloseToTest.m index c3f5639..c33d643 100644 --- a/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/objc/ObjCBeCloseToTest.m +++ b/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/objc/ObjCBeCloseToTest.m @@ -12,6 +12,11 @@ - (void)testPositiveMatches { expect(@1.2).to(beCloseTo(@2).within(10)); expect(@2).toNot(beCloseTo(@1)); expect(@1.00001).toNot(beCloseTo(@1).within(0.00000001)); + + expect(1.2).to(beCloseTo(1.2001)); + expect(1.2).to(beCloseTo(2).within(10)); + expect(2).toNot(beCloseTo(1)); + expect(1.00001).toNot(beCloseTo(1).within(0.00000001)); } - (void)testNegativeMatches { @@ -21,6 +26,12 @@ - (void)testNegativeMatches { expectFailureMessage(@"expected to not be close to <0> (within 0.001), got <0.0001>", ^{ expect(@(0.0001)).toNot(beCloseTo(@0)); }); + expectFailureMessage(@"expected to be close to <0> (within 0.001), got <1>", ^{ + expect(1).to(beCloseTo(0)); + }); + expectFailureMessage(@"expected to not be close to <0> (within 0.001), got <0.0001>", ^{ + expect(0.0001).toNot(beCloseTo(0)); + }); } - (void)testNilMatches { diff --git a/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/objc/ObjCBeFalseTest.m b/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/objc/ObjCBeFalseTest.m index 5b99842..5a5bce8 100644 --- a/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/objc/ObjCBeFalseTest.m +++ b/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/objc/ObjCBeFalseTest.m @@ -10,6 +10,14 @@ @implementation ObjCBeFalseTest - (void)testPositiveMatches { expect(@NO).to(beFalse()); expect(@YES).toNot(beFalse()); + + expect(false).to(beFalse()); + expect(true).toNot(beFalse()); + + expect(NO).to(beFalse()); + expect(YES).toNot(beFalse()); + + expect(10).toNot(beFalse()); } - (void)testNegativeMatches { @@ -19,6 +27,20 @@ - (void)testNegativeMatches { expectNilFailureMessage(@"expected to not be false, got ", ^{ expect(nil).toNot(beFalse()); }); + + expectFailureMessage(@"expected to be false, got <1>", ^{ + expect(true).to(beFalse()); + }); + expectFailureMessage(@"expected to not be false, got <0>", ^{ + expect(false).toNot(beFalse()); + }); + + expectFailureMessage(@"expected to be false, got <1>", ^{ + expect(YES).to(beFalse()); + }); + expectFailureMessage(@"expected to not be false, got <0>", ^{ + expect(NO).toNot(beFalse()); + }); } @end diff --git a/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/objc/ObjCBeFalsyTest.m b/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/objc/ObjCBeFalsyTest.m index 4b6281e..f3f5c98 100644 --- a/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/objc/ObjCBeFalsyTest.m +++ b/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/objc/ObjCBeFalsyTest.m @@ -11,6 +11,15 @@ - (void)testPositiveMatches { expect(@NO).to(beFalsy()); expect(@YES).toNot(beFalsy()); expect(nil).to(beFalsy()); + + expect(true).toNot(beFalsy()); + expect(false).to(beFalsy()); + + expect(YES).toNot(beFalsy()); + expect(NO).to(beFalsy()); + + expect(10).toNot(beFalsy()); + expect(0).to(beFalsy()); } - (void)testNegativeMatches { @@ -20,8 +29,29 @@ - (void)testNegativeMatches { expectFailureMessage(@"expected to be falsy, got <1>", ^{ expect(@1).to(beFalsy()); }); - expectFailureMessage(@"expected to be truthy, got <0>", ^{ - expect(@NO).to(beTruthy()); + expectFailureMessage(@"expected to not be falsy, got <0>", ^{ + expect(@NO).toNot(beFalsy()); + }); + + expectFailureMessage(@"expected to be falsy, got <1>", ^{ + expect(true).to(beFalsy()); + }); + expectFailureMessage(@"expected to not be falsy, got <0>", ^{ + expect(false).toNot(beFalsy()); + }); + + expectFailureMessage(@"expected to be falsy, got <1>", ^{ + expect(YES).to(beFalsy()); + }); + expectFailureMessage(@"expected to not be falsy, got <0>", ^{ + expect(NO).toNot(beFalsy()); + }); + + expectFailureMessage(@"expected to be falsy, got <10>", ^{ + expect(10).to(beFalsy()); + }); + expectFailureMessage(@"expected to not be falsy, got <0>", ^{ + expect(0).toNot(beFalsy()); }); } diff --git a/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/objc/ObjCBeGreaterThanOrEqualToTest.m b/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/objc/ObjCBeGreaterThanOrEqualToTest.m index cec26c7..22cab3a 100644 --- a/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/objc/ObjCBeGreaterThanOrEqualToTest.m +++ b/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/objc/ObjCBeGreaterThanOrEqualToTest.m @@ -10,6 +10,9 @@ @implementation ObjCBeGreaterThanOrEqualToTest - (void)testPositiveMatches { expect(@2).to(beGreaterThanOrEqualTo(@2)); expect(@2).toNot(beGreaterThanOrEqualTo(@3)); + expect(2).to(beGreaterThanOrEqualTo(0)); + expect(2).to(beGreaterThanOrEqualTo(2)); + expect(2).toNot(beGreaterThanOrEqualTo(3)); } - (void)testNegativeMatches { @@ -19,6 +22,12 @@ - (void)testNegativeMatches { expectFailureMessage(@"expected to not be greater than or equal to <1>, got <2>", ^{ expect(@2).toNot(beGreaterThanOrEqualTo(@(1))); }); + expectFailureMessage(@"expected to be greater than or equal to <0>, got <-1>", ^{ + expect(-1).to(beGreaterThanOrEqualTo(0)); + }); + expectFailureMessage(@"expected to not be greater than or equal to <1>, got <2>", ^{ + expect(2).toNot(beGreaterThanOrEqualTo(1)); + }); } - (void)testNilMatches { diff --git a/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/objc/ObjCBeGreaterThanTest.m b/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/objc/ObjCBeGreaterThanTest.m index 5ad3087..13336d5 100644 --- a/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/objc/ObjCBeGreaterThanTest.m +++ b/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/objc/ObjCBeGreaterThanTest.m @@ -10,6 +10,8 @@ @implementation ObjCBeGreaterThanTest - (void)testPositiveMatches { expect(@2).to(beGreaterThan(@1)); expect(@2).toNot(beGreaterThan(@2)); + expect(@2).to(beGreaterThan(0)); + expect(@2).toNot(beGreaterThan(2)); } - (void)testNegativeMatches { @@ -19,6 +21,12 @@ - (void)testNegativeMatches { expectFailureMessage(@"expected to not be greater than <1>, got <0>", ^{ expect(@0).toNot(beGreaterThan(@(1))); }); + expectFailureMessage(@"expected to be greater than <0>, got <-1>", ^{ + expect(-1).to(beGreaterThan(0)); + }); + expectFailureMessage(@"expected to not be greater than <1>, got <0>", ^{ + expect(0).toNot(beGreaterThan(1)); + }); } - (void)testNilMatches { diff --git a/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/objc/ObjCBeIdenticalToTest.m b/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/objc/ObjCBeIdenticalToTest.m index ab60a81..a9d9d51 100644 --- a/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/objc/ObjCBeIdenticalToTest.m +++ b/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/objc/ObjCBeIdenticalToTest.m @@ -25,9 +25,12 @@ - (void)testNegativeMatches { - (void)testNilMatches { NSNull *obj = [NSNull null]; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wnonnull" expectNilFailureMessage(@"expected to be identical to nil, got nil", ^{ expect(nil).to(beIdenticalTo(nil)); }); +#pragma clang diagnostic pop expectNilFailureMessage(([NSString stringWithFormat:@"expected to not be identical to <%p>, got nil", obj]), ^{ expect(nil).toNot(beIdenticalTo(obj)); }); @@ -51,9 +54,12 @@ - (void)testAliasNegativeMatches { - (void)testAliasNilMatches { NSNull *obj = [NSNull null]; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wnonnull" expectNilFailureMessage(@"expected to be identical to nil, got nil", ^{ expect(nil).to(be(nil)); }); +#pragma clang diagnostic pop expectNilFailureMessage(([NSString stringWithFormat:@"expected to not be identical to <%p>, got nil", obj]), ^{ expect(nil).toNot(be(obj)); }); diff --git a/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/objc/ObjCBeLessThanOrEqualToTest.m b/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/objc/ObjCBeLessThanOrEqualToTest.m index dbd2062..4a738ec 100644 --- a/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/objc/ObjCBeLessThanOrEqualToTest.m +++ b/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/objc/ObjCBeLessThanOrEqualToTest.m @@ -10,6 +10,9 @@ @implementation ObjCBeLessThanOrEqualToTest - (void)testPositiveMatches { expect(@2).to(beLessThanOrEqualTo(@2)); expect(@2).toNot(beLessThanOrEqualTo(@1)); + expect(2).to(beLessThanOrEqualTo(2)); + expect(2).toNot(beLessThanOrEqualTo(1)); + expect(2).toNot(beLessThanOrEqualTo(0)); } - (void)testNegativeMatches { @@ -19,6 +22,13 @@ - (void)testNegativeMatches { expectFailureMessage(@"expected to not be less than or equal to <1>, got <1>", ^{ expect(@1).toNot(beLessThanOrEqualTo(@1)); }); + + expectFailureMessage(@"expected to be less than or equal to <1>, got <2>", ^{ + expect(2).to(beLessThanOrEqualTo(1)); + }); + expectFailureMessage(@"expected to not be less than or equal to <1>, got <1>", ^{ + expect(1).toNot(beLessThanOrEqualTo(1)); + }); } - (void)testNilMatches { diff --git a/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/objc/ObjCBeLessThanTest.m b/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/objc/ObjCBeLessThanTest.m index 4d9da72..7ba38b2 100644 --- a/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/objc/ObjCBeLessThanTest.m +++ b/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/objc/ObjCBeLessThanTest.m @@ -10,6 +10,9 @@ @implementation ObjCBeLessThanTest - (void)testPositiveMatches { expect(@2).to(beLessThan(@3)); expect(@2).toNot(beLessThan(@2)); + expect(2).to(beLessThan(3)); + expect(2).toNot(beLessThan(2)); + expect(2).toNot(beLessThan(0)); } - (void)testNegativeMatches { @@ -19,6 +22,12 @@ - (void)testNegativeMatches { expectFailureMessage(@"expected to not be less than <1>, got <0>", ^{ expect(@0).toNot(beLessThan(@1)); }); + expectFailureMessage(@"expected to be less than <0>, got <-1>", ^{ + expect(-1).to(beLessThan(0)); + }); + expectFailureMessage(@"expected to not be less than <1>, got <0>", ^{ + expect(0).toNot(beLessThan(1)); + }); } - (void)testNilMatches { diff --git a/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/objc/ObjCBeTrueTest.m b/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/objc/ObjCBeTrueTest.m index 3f10ce3..c669475 100644 --- a/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/objc/ObjCBeTrueTest.m +++ b/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/objc/ObjCBeTrueTest.m @@ -11,6 +11,12 @@ - (void)testPositiveMatches { expect(@YES).to(beTrue()); expect(@NO).toNot(beTrue()); expect(nil).toNot(beTrue()); + + expect(true).to(beTrue()); + expect(false).toNot(beTrue()); + + expect(YES).to(beTrue()); + expect(NO).toNot(beTrue()); } - (void)testNegativeMatches { @@ -20,6 +26,22 @@ - (void)testNegativeMatches { expectFailureMessage(@"expected to be true, got ", ^{ expect(nil).to(beTrue()); }); + + expectFailureMessage(@"expected to be true, got <0>", ^{ + expect(false).to(beTrue()); + }); + + expectFailureMessage(@"expected to not be true, got <1>", ^{ + expect(true).toNot(beTrue()); + }); + + expectFailureMessage(@"expected to be true, got <0>", ^{ + expect(NO).to(beTrue()); + }); + + expectFailureMessage(@"expected to not be true, got <1>", ^{ + expect(YES).toNot(beTrue()); + }); } @end diff --git a/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/objc/ObjCBeTruthyTest.m b/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/objc/ObjCBeTruthyTest.m index 93180a2..1ad7913 100644 --- a/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/objc/ObjCBeTruthyTest.m +++ b/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/objc/ObjCBeTruthyTest.m @@ -11,6 +11,15 @@ - (void)testPositiveMatches { expect(@YES).to(beTruthy()); expect(@NO).toNot(beTruthy()); expect(nil).toNot(beTruthy()); + + expect(true).to(beTruthy()); + expect(false).toNot(beTruthy()); + + expect(YES).to(beTruthy()); + expect(NO).toNot(beTruthy()); + + expect(10).to(beTruthy()); + expect(0).toNot(beTruthy()); } - (void)testNegativeMatches { @@ -23,6 +32,24 @@ - (void)testNegativeMatches { expectFailureMessage(@"expected to be truthy, got <0>", ^{ expect(@NO).to(beTruthy()); }); + expectFailureMessage(@"expected to be truthy, got <0>", ^{ + expect(false).to(beTruthy()); + }); + expectFailureMessage(@"expected to not be truthy, got <1>", ^{ + expect(true).toNot(beTruthy()); + }); + expectFailureMessage(@"expected to be truthy, got <0>", ^{ + expect(NO).to(beTruthy()); + }); + expectFailureMessage(@"expected to not be truthy, got <1>", ^{ + expect(YES).toNot(beTruthy()); + }); + expectFailureMessage(@"expected to not be truthy, got <10>", ^{ + expect(10).toNot(beTruthy()); + }); + expectFailureMessage(@"expected to be truthy, got <0>", ^{ + expect(0).to(beTruthy()); + }); } @end diff --git a/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/objc/ObjCEqualTest.m b/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/objc/ObjCEqualTest.m index e5a2be0..6c20809 100644 --- a/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/objc/ObjCEqualTest.m +++ b/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/objc/ObjCEqualTest.m @@ -12,6 +12,31 @@ - (void)testPositiveMatches { expect(@1).toNot(equal(@2)); expect(@1).notTo(equal(@2)); expect(@"hello").to(equal(@"hello")); + expect("hello").to(equal("hello")); + expect(NSMakeRange(0, 10)).to(equal(NSMakeRange(0, 10))); + expect(NSMakeRange(0, 10)).toNot(equal(NSMakeRange(0, 5))); + expect((NSInteger)1).to(equal((NSInteger)1)); + expect((NSInteger)1).toNot(equal((NSInteger)2)); + expect((NSUInteger)1).to(equal((NSUInteger)1)); + expect((NSUInteger)1).toNot(equal((NSUInteger)2)); + expect(0).to(equal(0)); + expect(1).to(equal(1)); + expect(1).toNot(equal(2)); + expect(1.0).to(equal(1.0)); // Note: not recommended, use beCloseTo() instead + expect(1.0).toNot(equal(2.0)); // Note: not recommended, use beCloseTo() instead + expect((float)1.0).to(equal((float)1.0)); // Note: not recommended, use beCloseTo() instead + expect((float)1.0).toNot(equal((float)2.0)); // Note: not recommended, use beCloseTo() instead + expect((double)1.0).to(equal((double)1.0)); // Note: not recommended, use beCloseTo() instead + expect((double)1.0).toNot(equal((double)2.0)); // Note: not recommended, use beCloseTo() instead + expect((long long)1).to(equal((long long)1)); + expect((long long)1).toNot(equal((long long)2)); + expect((unsigned long long)1).to(equal((unsigned long long)1)); + expect((unsigned long long)1).toNot(equal((unsigned long long)2)); +} + +- (void)testNimbleCurrentlyBoxesNumbersWhichAllowsImplicitTypeConversions { + expect(1).to(equal(1.0)); + expect((long long)1).to(equal((unsigned long long)1)); } - (void)testNegativeMatches { @@ -21,9 +46,43 @@ - (void)testNegativeMatches { expectFailureMessage(@"expected to not equal <1>, got <1>", ^{ expect(@1).toNot(equal(@1)); }); + expectFailureMessage(@"expected to not equal , got ", ^{ + expect("bar").toNot(equal("foo")); + }); + expectFailureMessage(@"expected to equal , got ", ^{ + expect(NSMakeRange(0, 10)).to(equal(NSMakeRange(0, 5))); + }); + + expectFailureMessage(@"expected to equal <2>, got <1>", ^{ + expect((NSInteger)1).to(equal((NSInteger)2)); + }); + expectFailureMessage(@"expected to equal <2>, got <1>", ^{ + expect((NSUInteger)1).to(equal((NSUInteger)2)); + }); + expectFailureMessage(@"expected to equal <2>, got <1>", ^{ + expect(1).to(equal(2)); + }); + expectFailureMessage(@"expected to equal <2>, got <1>", ^{ + expect(1.0).to(equal(2.0)); + }); + expectFailureMessage(@"expected to equal <2>, got <1>", ^{ + expect((float)1.0).to(equal((float)2.0)); + }); + expectFailureMessage(@"expected to equal <2>, got <1>", ^{ + expect((double)1.0).to(equal((double)2.0)); + }); + expectFailureMessage(@"expected to equal <2>, got <1>", ^{ + expect((long long)1.0).to(equal((long long)2.0)); + }); + expectFailureMessage(@"expected to equal <2>, got <1>", ^{ + expect((unsigned long long)1.0).to(equal((unsigned long long)2.0)); + }); } - (void)testNilMatches { + expectNilFailureMessage(@"expected to equal , got ", ^{ + expect(NULL).to(equal(NULL)); + }); expectNilFailureMessage(@"expected to equal , got ", ^{ expect(nil).to(equal(nil)); }); diff --git a/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/objc/ObjCHaveCount.m b/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/objc/ObjCHaveCount.m index d5fdf4f..31053c8 100644 --- a/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/objc/ObjCHaveCount.m +++ b/Carthage/Checkouts/Quick/Externals/Nimble/Tests/NimbleTests/objc/ObjCHaveCount.m @@ -14,6 +14,12 @@ - (void)testHaveCountForNSArray { expect(@[]).to(haveCount(@0)); expect(@[@1]).notTo(haveCount(@0)); + expect(@[@1, @2, @3]).to(haveCount(3)); + expect(@[@1, @2, @3]).notTo(haveCount(1)); + + expect(@[]).to(haveCount(0)); + expect(@[@1]).notTo(haveCount(0)); + expectFailureMessage(@"expected to have NSArray with count 1, got 3\nActual Value: (1, 2, 3)", ^{ expect(@[@1, @2, @3]).to(haveCount(@1)); }); @@ -22,12 +28,22 @@ - (void)testHaveCountForNSArray { expect(@[@1, @2, @3]).notTo(haveCount(@3)); }); + expectFailureMessage(@"expected to have NSArray with count 1, got 3\nActual Value: (1, 2, 3)", ^{ + expect(@[@1, @2, @3]).to(haveCount(1)); + }); + + expectFailureMessage(@"expected to not have NSArray with count 3, got 3\nActual Value: (1, 2, 3)", ^{ + expect(@[@1, @2, @3]).notTo(haveCount(3)); + }); } - (void)testHaveCountForNSDictionary { expect(@{@"1":@1, @"2":@2, @"3":@3}).to(haveCount(@3)); expect(@{@"1":@1, @"2":@2, @"3":@3}).notTo(haveCount(@1)); + expect(@{@"1":@1, @"2":@2, @"3":@3}).to(haveCount(3)); + expect(@{@"1":@1, @"2":@2, @"3":@3}).notTo(haveCount(1)); + expectFailureMessage(@"expected to have NSDictionary with count 1, got 3\nActual Value: {1 = 1;2 = 2;3 = 3;}", ^{ expect(@{@"1":@1, @"2":@2, @"3":@3}).to(haveCount(@1)); }); @@ -35,6 +51,14 @@ - (void)testHaveCountForNSDictionary { expectFailureMessage(@"expected to not have NSDictionary with count 3, got 3\nActual Value: {1 = 1;2 = 2;3 = 3;}", ^{ expect(@{@"1":@1, @"2":@2, @"3":@3}).notTo(haveCount(@3)); }); + + expectFailureMessage(@"expected to have NSDictionary with count 1, got 3\nActual Value: {1 = 1;2 = 2;3 = 3;}", ^{ + expect(@{@"1":@1, @"2":@2, @"3":@3}).to(haveCount(1)); + }); + + expectFailureMessage(@"expected to not have NSDictionary with count 3, got 3\nActual Value: {1 = 1;2 = 2;3 = 3;}", ^{ + expect(@{@"1":@1, @"2":@2, @"3":@3}).notTo(haveCount(3)); + }); } - (void)testHaveCountForNSHashtable { @@ -46,6 +70,9 @@ - (void)testHaveCountForNSHashtable { expect(table).to(haveCount(@3)); expect(table).notTo(haveCount(@1)); + expect(table).to(haveCount(3)); + expect(table).notTo(haveCount(1)); + NSString *msg = [NSString stringWithFormat: @"expected to have NSHashTable {[2] 2[12] 1[13] 3}with count 1, got 3\nActual Value: %@", [table.description stringByReplacingOccurrencesOfString:@"\n" withString:@""]]; @@ -53,13 +80,27 @@ - (void)testHaveCountForNSHashtable { expect(table).to(haveCount(@1)); }); - msg = [NSString stringWithFormat: @"expected to not have NSHashTable {[2] 2[12] 1[13] 3}with count 3, got 3\nActual Value: %@", [table.description stringByReplacingOccurrencesOfString:@"\n" withString:@""]]; expectFailureMessage(msg, ^{ expect(table).notTo(haveCount(@3)); }); + + + msg = [NSString stringWithFormat: + @"expected to have NSHashTable {[2] 2[12] 1[13] 3}with count 1, got 3\nActual Value: %@", + [table.description stringByReplacingOccurrencesOfString:@"\n" withString:@""]]; + expectFailureMessage(msg, ^{ + expect(table).to(haveCount(1)); + }); + + msg = [NSString stringWithFormat: + @"expected to not have NSHashTable {[2] 2[12] 1[13] 3}with count 3, got 3\nActual Value: %@", + [table.description stringByReplacingOccurrencesOfString:@"\n" withString:@""]]; + expectFailureMessage(msg, ^{ + expect(table).notTo(haveCount(3)); + }); } - (void)testHaveCountForNSSet { @@ -67,6 +108,8 @@ - (void)testHaveCountForNSSet { expect(set).to(haveCount(@3)); expect(set).notTo(haveCount(@1)); + expect(set).to(haveCount(3)); + expect(set).notTo(haveCount(1)); expectFailureMessage(@"expected to have NSSet with count 1, got 3\nActual Value: {(3,1,2)}", ^{ expect(set).to(haveCount(@1)); @@ -75,6 +118,14 @@ - (void)testHaveCountForNSSet { expectFailureMessage(@"expected to not have NSSet with count 3, got 3\nActual Value: {(3,1,2)}", ^{ expect(set).notTo(haveCount(@3)); }); + + expectFailureMessage(@"expected to have NSSet with count 1, got 3\nActual Value: {(3,1,2)}", ^{ + expect(set).to(haveCount(1)); + }); + + expectFailureMessage(@"expected to not have NSSet with count 3, got 3\nActual Value: {(3,1,2)}", ^{ + expect(set).notTo(haveCount(3)); + }); } - (void)testHaveCountForNSIndexSet { @@ -82,6 +133,8 @@ - (void)testHaveCountForNSIndexSet { expect(set).to(haveCount(@3)); expect(set).notTo(haveCount(@1)); + expect(set).to(haveCount(3)); + expect(set).notTo(haveCount(1)); expectFailureMessage(@"expected to have NSIndexSet with count 1, got 3\nActual Value: (1, 2, 3)", ^{ expect(set).to(haveCount(@1)); @@ -90,6 +143,14 @@ - (void)testHaveCountForNSIndexSet { expectFailureMessage(@"expected to not have NSIndexSet with count 3, got 3\nActual Value: (1, 2, 3)", ^{ expect(set).notTo(haveCount(@3)); }); + + expectFailureMessage(@"expected to have NSIndexSet with count 1, got 3\nActual Value: (1, 2, 3)", ^{ + expect(set).to(haveCount(1)); + }); + + expectFailureMessage(@"expected to not have NSIndexSet with count 3, got 3\nActual Value: (1, 2, 3)", ^{ + expect(set).notTo(haveCount(3)); + }); } - (void)testHaveCountForUnsupportedTypes { @@ -100,6 +161,14 @@ - (void)testHaveCountForUnsupportedTypes { expectFailureMessage(@"expected to get type of NSArray, NSSet, NSDictionary, or NSHashTable, got __NSCFNumber", ^{ expect(@1).to(haveCount(@6)); }); + + expectFailureMessage(@"expected to get type of NSArray, NSSet, NSDictionary, or NSHashTable, got __NSCFConstantString", ^{ + expect(@"string").to(haveCount(6)); + }); + + expectFailureMessage(@"expected to get type of NSArray, NSSet, NSDictionary, or NSHashTable, got __NSCFNumber", ^{ + expect(@1).to(haveCount(6)); + }); } @end diff --git a/Carthage/Checkouts/Quick/Package.swift b/Carthage/Checkouts/Quick/Package.swift index 6b97ba5..6d2fac9 100644 --- a/Carthage/Checkouts/Quick/Package.swift +++ b/Carthage/Checkouts/Quick/Package.swift @@ -2,14 +2,9 @@ import PackageDescription let package = Package( name: "Quick", - // TODO: Once the `test` command has been implemented in the Swift Package Manager, this should be changed to - // be `testDependencies:` instead. For now it has to be done like this for the library to get linked with the test targets. - // See: https://github.com/apple/swift-evolution/blob/master/proposals/0019-package-manager-testing.md - dependencies: [ - .Package(url: "https://github.com/Quick/Nimble", "5.0.0") - ], exclude: [ "Sources/QuickObjectiveC", + "Tests/QuickTests/QuickAfterSuiteTests/AfterSuiteTests+ObjC.m", "Tests/QuickTests/QuickFocusedTests/FocusedTests+ObjC.m", "Tests/QuickTests/QuickTests/FunctionalTests/ObjC", "Tests/QuickTests/QuickTests/Helpers", diff --git a/Carthage/Checkouts/Quick/Quick.podspec b/Carthage/Checkouts/Quick/Quick.podspec index f5253d5..1cdc852 100644 --- a/Carthage/Checkouts/Quick/Quick.podspec +++ b/Carthage/Checkouts/Quick/Quick.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "Quick" - s.version = "0.10.0" + s.version = "1.0.0" s.summary = "The Swift (and Objective-C) testing framework." s.description = <<-DESC diff --git a/Carthage/Checkouts/Quick/Quick.xcodeproj/project.pbxproj b/Carthage/Checkouts/Quick/Quick.xcodeproj/project.pbxproj index d93c36c..613590c 100644 --- a/Carthage/Checkouts/Quick/Quick.xcodeproj/project.pbxproj +++ b/Carthage/Checkouts/Quick/Quick.xcodeproj/project.pbxproj @@ -43,8 +43,6 @@ 1F118D1B1BDCA556005013A2 /* PendingTests+ObjC.m in Sources */ = {isa = PBXBuildFile; fileRef = 4715903F1A488F3F00FBA644 /* PendingTests+ObjC.m */; }; 1F118D1C1BDCA556005013A2 /* BeforeSuiteTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA8F91A419F3208B006F6675 /* BeforeSuiteTests.swift */; }; 1F118D1D1BDCA556005013A2 /* BeforeSuiteTests+ObjC.m in Sources */ = {isa = PBXBuildFile; fileRef = 47876F7B1A4999B0002575C7 /* BeforeSuiteTests+ObjC.m */; }; - 1F118D1E1BDCA556005013A2 /* AfterSuiteTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA8F91A719F32556006F6675 /* AfterSuiteTests.swift */; }; - 1F118D1F1BDCA556005013A2 /* AfterSuiteTests+ObjC.m in Sources */ = {isa = PBXBuildFile; fileRef = 477217391A59C1B00022013E /* AfterSuiteTests+ObjC.m */; }; 1F118D201BDCA556005013A2 /* SharedExamplesTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA8F91AA19F3299E006F6675 /* SharedExamplesTests.swift */; }; 1F118D211BDCA556005013A2 /* SharedExamplesTests+ObjC.m in Sources */ = {isa = PBXBuildFile; fileRef = 4728253A1A5EECCE008DC74F /* SharedExamplesTests+ObjC.m */; }; 1F118D221BDCA556005013A2 /* SharedExamples+BeforeEachTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAB0136E19FC4315006AFBEE /* SharedExamples+BeforeEachTests.swift */; }; @@ -96,8 +94,6 @@ 4728253C1A5EECCE008DC74F /* SharedExamplesTests+ObjC.m in Sources */ = {isa = PBXBuildFile; fileRef = 4728253A1A5EECCE008DC74F /* SharedExamplesTests+ObjC.m */; }; 4748E8941A6AEBB3009EC992 /* SharedExamples+BeforeEachTests+ObjC.m in Sources */ = {isa = PBXBuildFile; fileRef = 4748E8931A6AEBB3009EC992 /* SharedExamples+BeforeEachTests+ObjC.m */; }; 4748E8951A6AEBB3009EC992 /* SharedExamples+BeforeEachTests+ObjC.m in Sources */ = {isa = PBXBuildFile; fileRef = 4748E8931A6AEBB3009EC992 /* SharedExamples+BeforeEachTests+ObjC.m */; }; - 4772173A1A59C1B00022013E /* AfterSuiteTests+ObjC.m in Sources */ = {isa = PBXBuildFile; fileRef = 477217391A59C1B00022013E /* AfterSuiteTests+ObjC.m */; }; - 4772173B1A59C1B00022013E /* AfterSuiteTests+ObjC.m in Sources */ = {isa = PBXBuildFile; fileRef = 477217391A59C1B00022013E /* AfterSuiteTests+ObjC.m */; }; 47876F7D1A49AD63002575C7 /* BeforeSuiteTests+ObjC.m in Sources */ = {isa = PBXBuildFile; fileRef = 47876F7B1A4999B0002575C7 /* BeforeSuiteTests+ObjC.m */; }; 47876F7E1A49AD71002575C7 /* BeforeSuiteTests+ObjC.m in Sources */ = {isa = PBXBuildFile; fileRef = 47876F7B1A4999B0002575C7 /* BeforeSuiteTests+ObjC.m */; }; 479C31E31A36171B00DA8718 /* ItTests+ObjC.m in Sources */ = {isa = PBXBuildFile; fileRef = 479C31E11A36156E00DA8718 /* ItTests+ObjC.m */; }; @@ -106,6 +102,17 @@ 47FAEA371A3F49EB005A1D2F /* BeforeEachTests+ObjC.m in Sources */ = {isa = PBXBuildFile; fileRef = 47FAEA341A3F45ED005A1D2F /* BeforeEachTests+ObjC.m */; }; 5A5D118719473F2100F6D13D /* Quick.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5A5D117C19473F2100F6D13D /* Quick.framework */; }; 5A5D11A7194740E000F6D13D /* Quick.h in Headers */ = {isa = PBXBuildFile; fileRef = DAEB6B931943873100289F44 /* Quick.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 64076CEF1D6D7C2000E2B499 /* Quick.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DAEB6B8E1943873100289F44 /* Quick.framework */; }; + 64076CF01D6D7C2000E2B499 /* Nimble.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8100E901A1E4447007595ED /* Nimble.framework */; }; + 64076D021D6D7CD600E2B499 /* Quick.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5A5D117C19473F2100F6D13D /* Quick.framework */; }; + 64076D031D6D7CD600E2B499 /* Nimble.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F8100E901A1E4447007595ED /* Nimble.framework */; }; + 64076D141D6D7CEA00E2B499 /* Quick.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1F118CD51BDCA4AB005013A2 /* Quick.framework */; }; + 64076D151D6D7CEA00E2B499 /* Nimble.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1F118D361BDCA65C005013A2 /* Nimble.framework */; }; + 64076D211D6D7E4D00E2B499 /* AfterSuiteTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64076D1D1D6D7D0B00E2B499 /* AfterSuiteTests.swift */; }; + 64076D221D6D7E5B00E2B499 /* AfterSuiteTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64076D1D1D6D7D0B00E2B499 /* AfterSuiteTests.swift */; }; + 64076D231D6D7E6B00E2B499 /* AfterSuiteTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 64076D1D1D6D7D0B00E2B499 /* AfterSuiteTests.swift */; }; + 64076D261D6D80B500E2B499 /* AfterSuiteTests+ObjC.m in Sources */ = {isa = PBXBuildFile; fileRef = 64076D241D6D80B500E2B499 /* AfterSuiteTests+ObjC.m */; }; + 64076D271D6D80B500E2B499 /* AfterSuiteTests+ObjC.m in Sources */ = {isa = PBXBuildFile; fileRef = 64076D241D6D80B500E2B499 /* AfterSuiteTests+ObjC.m */; }; 7B44ADBE1C5444940007AF2E /* HooksPhase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B44ADBD1C5444940007AF2E /* HooksPhase.swift */; }; 7B44ADBF1C5444940007AF2E /* HooksPhase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B44ADBD1C5444940007AF2E /* HooksPhase.swift */; }; 7B44ADC01C5444940007AF2E /* HooksPhase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B44ADBD1C5444940007AF2E /* HooksPhase.swift */; }; @@ -130,20 +137,21 @@ AED9C8631CC8A7BD00432F62 /* CrossReferencingSpecs.swift in Sources */ = {isa = PBXBuildFile; fileRef = AED9C8621CC8A7BD00432F62 /* CrossReferencingSpecs.swift */; }; AED9C8641CC8A7BD00432F62 /* CrossReferencingSpecs.swift in Sources */ = {isa = PBXBuildFile; fileRef = AED9C8621CC8A7BD00432F62 /* CrossReferencingSpecs.swift */; }; AED9C8651CC8A7BD00432F62 /* CrossReferencingSpecs.swift in Sources */ = {isa = PBXBuildFile; fileRef = AED9C8621CC8A7BD00432F62 /* CrossReferencingSpecs.swift */; }; + CD264DBD1DDA147A0038B0EB /* AfterSuiteTests+ObjC.m in Sources */ = {isa = PBXBuildFile; fileRef = 64076D241D6D80B500E2B499 /* AfterSuiteTests+ObjC.m */; }; CE57CEDD1C430BD200D63004 /* NSBundle+CurrentTestBundle.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE57CED81C430BD200D63004 /* NSBundle+CurrentTestBundle.swift */; }; CE57CEDE1C430BD200D63004 /* QuickSelectedTestSuiteBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE57CED91C430BD200D63004 /* QuickSelectedTestSuiteBuilder.swift */; }; CE57CEDF1C430BD200D63004 /* QuickTestSuite.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE57CEDA1C430BD200D63004 /* QuickTestSuite.swift */; }; - CE57CEE01C430BD200D63004 /* String+FileName.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE57CEDB1C430BD200D63004 /* String+FileName.swift */; }; + CE57CEE01C430BD200D63004 /* URL+FileName.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE57CEDB1C430BD200D63004 /* URL+FileName.swift */; }; CE57CEE11C430BD200D63004 /* XCTestSuite+QuickTestSuiteBuilder.m in Sources */ = {isa = PBXBuildFile; fileRef = CE57CEDC1C430BD200D63004 /* XCTestSuite+QuickTestSuiteBuilder.m */; }; CE590E1A1C431FE300253D19 /* QuickTestSuite.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE57CEDA1C430BD200D63004 /* QuickTestSuite.swift */; }; CE590E1B1C431FE300253D19 /* QuickSelectedTestSuiteBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE57CED91C430BD200D63004 /* QuickSelectedTestSuiteBuilder.swift */; }; CE590E1C1C431FE300253D19 /* NSBundle+CurrentTestBundle.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE57CED81C430BD200D63004 /* NSBundle+CurrentTestBundle.swift */; }; - CE590E1D1C431FE300253D19 /* String+FileName.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE57CEDB1C430BD200D63004 /* String+FileName.swift */; }; + CE590E1D1C431FE300253D19 /* URL+FileName.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE57CEDB1C430BD200D63004 /* URL+FileName.swift */; }; CE590E1E1C431FE300253D19 /* XCTestSuite+QuickTestSuiteBuilder.m in Sources */ = {isa = PBXBuildFile; fileRef = CE57CEDC1C430BD200D63004 /* XCTestSuite+QuickTestSuiteBuilder.m */; }; CE590E1F1C431FE400253D19 /* QuickTestSuite.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE57CEDA1C430BD200D63004 /* QuickTestSuite.swift */; }; CE590E201C431FE400253D19 /* QuickSelectedTestSuiteBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE57CED91C430BD200D63004 /* QuickSelectedTestSuiteBuilder.swift */; }; CE590E211C431FE400253D19 /* NSBundle+CurrentTestBundle.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE57CED81C430BD200D63004 /* NSBundle+CurrentTestBundle.swift */; }; - CE590E221C431FE400253D19 /* String+FileName.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE57CEDB1C430BD200D63004 /* String+FileName.swift */; }; + CE590E221C431FE400253D19 /* URL+FileName.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE57CEDB1C430BD200D63004 /* URL+FileName.swift */; }; CE590E231C431FE400253D19 /* XCTestSuite+QuickTestSuiteBuilder.m in Sources */ = {isa = PBXBuildFile; fileRef = CE57CEDC1C430BD200D63004 /* XCTestSuite+QuickTestSuiteBuilder.m */; }; DA02C91919A8073100093156 /* ExampleMetadata.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA02C91819A8073100093156 /* ExampleMetadata.swift */; }; DA02C91A19A8073100093156 /* ExampleMetadata.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA02C91819A8073100093156 /* ExampleMetadata.swift */; }; @@ -185,8 +193,6 @@ DA8F919E19F31921006F6675 /* FailureTests+ObjC.m in Sources */ = {isa = PBXBuildFile; fileRef = DA8F919C19F31921006F6675 /* FailureTests+ObjC.m */; }; DA8F91A519F3208B006F6675 /* BeforeSuiteTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA8F91A419F3208B006F6675 /* BeforeSuiteTests.swift */; }; DA8F91A619F3208B006F6675 /* BeforeSuiteTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA8F91A419F3208B006F6675 /* BeforeSuiteTests.swift */; }; - DA8F91A819F32556006F6675 /* AfterSuiteTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA8F91A719F32556006F6675 /* AfterSuiteTests.swift */; }; - DA8F91A919F32556006F6675 /* AfterSuiteTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA8F91A719F32556006F6675 /* AfterSuiteTests.swift */; }; DA8F91AB19F3299E006F6675 /* SharedExamplesTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA8F91AA19F3299E006F6675 /* SharedExamplesTests.swift */; }; DA8F91AC19F3299E006F6675 /* SharedExamplesTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA8F91AA19F3299E006F6675 /* SharedExamplesTests.swift */; }; DA8F91AE19F32CE2006F6675 /* FunctionalTests_SharedExamplesTests_SharedExamples.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA8F91AD19F32CE2006F6675 /* FunctionalTests_SharedExamplesTests_SharedExamples.swift */; }; @@ -391,6 +397,27 @@ remoteGlobalIDString = 5A5D117B19473F2100F6D13D; remoteInfo = "Quick-iOS"; }; + 64076CE71D6D7C2000E2B499 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = DAEB6B851943873100289F44 /* Project object */; + proxyType = 1; + remoteGlobalIDString = DAEB6B8D1943873100289F44; + remoteInfo = "Quick-OSX"; + }; + 64076CFA1D6D7CD600E2B499 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = DAEB6B851943873100289F44 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 5A5D117B19473F2100F6D13D; + remoteInfo = "Quick-iOS"; + }; + 64076D0C1D6D7CEA00E2B499 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = DAEB6B851943873100289F44 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 1F118CD41BDCA4AB005013A2; + remoteInfo = "Quick-tvOS"; + }; 93625F381951DDC8006B1FE1 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = DAEB6B851943873100289F44 /* Project object */; @@ -441,12 +468,16 @@ 4715903F1A488F3F00FBA644 /* PendingTests+ObjC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "PendingTests+ObjC.m"; sourceTree = ""; }; 4728253A1A5EECCE008DC74F /* SharedExamplesTests+ObjC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "SharedExamplesTests+ObjC.m"; sourceTree = ""; }; 4748E8931A6AEBB3009EC992 /* SharedExamples+BeforeEachTests+ObjC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "SharedExamples+BeforeEachTests+ObjC.m"; sourceTree = ""; }; - 477217391A59C1B00022013E /* AfterSuiteTests+ObjC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "AfterSuiteTests+ObjC.m"; sourceTree = ""; }; 47876F7B1A4999B0002575C7 /* BeforeSuiteTests+ObjC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "BeforeSuiteTests+ObjC.m"; sourceTree = ""; }; 479C31E11A36156E00DA8718 /* ItTests+ObjC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "ItTests+ObjC.m"; sourceTree = ""; }; 47FAEA341A3F45ED005A1D2F /* BeforeEachTests+ObjC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "BeforeEachTests+ObjC.m"; sourceTree = ""; }; 5A5D117C19473F2100F6D13D /* Quick.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Quick.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 5A5D118619473F2100F6D13D /* Quick-iOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Quick-iOSTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; + 64076CF51D6D7C2000E2B499 /* QuickAfterSuite-macOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "QuickAfterSuite-macOSTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; + 64076D081D6D7CD600E2B499 /* QuickAfterSuite-iOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "QuickAfterSuite-iOSTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; + 64076D1A1D6D7CEA00E2B499 /* QuickAfterSuite-tvOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "QuickAfterSuite-tvOSTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; + 64076D1D1D6D7D0B00E2B499 /* AfterSuiteTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AfterSuiteTests.swift; sourceTree = ""; }; + 64076D241D6D80B500E2B499 /* AfterSuiteTests+ObjC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "AfterSuiteTests+ObjC.m"; sourceTree = ""; }; 7B44ADBD1C5444940007AF2E /* HooksPhase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HooksPhase.swift; sourceTree = ""; }; 7B5358CA1C3D4E2A00A23FAA /* ContextTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ContextTests.swift; sourceTree = ""; }; 8D010A561C11726F00633E2B /* DescribeTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DescribeTests.swift; sourceTree = ""; }; @@ -457,7 +488,7 @@ CE57CED81C430BD200D63004 /* NSBundle+CurrentTestBundle.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSBundle+CurrentTestBundle.swift"; sourceTree = ""; }; CE57CED91C430BD200D63004 /* QuickSelectedTestSuiteBuilder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = QuickSelectedTestSuiteBuilder.swift; sourceTree = ""; }; CE57CEDA1C430BD200D63004 /* QuickTestSuite.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = QuickTestSuite.swift; sourceTree = ""; }; - CE57CEDB1C430BD200D63004 /* String+FileName.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "String+FileName.swift"; sourceTree = ""; }; + CE57CEDB1C430BD200D63004 /* URL+FileName.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "URL+FileName.swift"; sourceTree = ""; }; CE57CEDC1C430BD200D63004 /* XCTestSuite+QuickTestSuiteBuilder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "XCTestSuite+QuickTestSuiteBuilder.m"; sourceTree = ""; }; DA02C91819A8073100093156 /* ExampleMetadata.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExampleMetadata.swift; sourceTree = ""; }; DA05D60F19F73A3800771050 /* AfterEachTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AfterEachTests.swift; sourceTree = ""; }; @@ -481,7 +512,6 @@ DA8F919819F31680006F6675 /* XCTestObservationCenter+QCKSuspendObservation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "XCTestObservationCenter+QCKSuspendObservation.h"; sourceTree = ""; }; DA8F919C19F31921006F6675 /* FailureTests+ObjC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "FailureTests+ObjC.m"; sourceTree = ""; }; DA8F91A419F3208B006F6675 /* BeforeSuiteTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BeforeSuiteTests.swift; sourceTree = ""; }; - DA8F91A719F32556006F6675 /* AfterSuiteTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AfterSuiteTests.swift; sourceTree = ""; }; DA8F91AA19F3299E006F6675 /* SharedExamplesTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SharedExamplesTests.swift; sourceTree = ""; }; DA8F91AD19F32CE2006F6675 /* FunctionalTests_SharedExamplesTests_SharedExamples.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FunctionalTests_SharedExamplesTests_SharedExamples.swift; sourceTree = ""; }; DA9876B21A4C70EB0004AA17 /* QuickFocused-iOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "QuickFocused-iOSTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -548,6 +578,33 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 64076CEE1D6D7C2000E2B499 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 64076CEF1D6D7C2000E2B499 /* Quick.framework in Frameworks */, + 64076CF01D6D7C2000E2B499 /* Nimble.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 64076D011D6D7CD600E2B499 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 64076D021D6D7CD600E2B499 /* Quick.framework in Frameworks */, + 64076D031D6D7CD600E2B499 /* Nimble.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 64076D131D6D7CEA00E2B499 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 64076D141D6D7CEA00E2B499 /* Quick.framework in Frameworks */, + 64076D151D6D7CEA00E2B499 /* Nimble.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; DA5663E51A4C8D8500193C88 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -594,6 +651,16 @@ name = Frameworks; sourceTree = ""; }; + 64076D1C1D6D7D0B00E2B499 /* QuickAfterSuiteTests */ = { + isa = PBXGroup; + children = ( + 64076D1D1D6D7D0B00E2B499 /* AfterSuiteTests.swift */, + 64076D241D6D80B500E2B499 /* AfterSuiteTests+ObjC.m */, + ); + name = QuickAfterSuiteTests; + path = Tests/QuickTests/QuickAfterSuiteTests; + sourceTree = ""; + }; 6C3983EE1D1E930D00637469 /* QuickObjectiveC */ = { isa = PBXGroup; children = ( @@ -634,7 +701,6 @@ isa = PBXGroup; children = ( 470D6EC91A43409600043E50 /* AfterEachTests+ObjC.m */, - 477217391A59C1B00022013E /* AfterSuiteTests+ObjC.m */, 47FAEA341A3F45ED005A1D2F /* BeforeEachTests+ObjC.m */, 47876F7B1A4999B0002575C7 /* BeforeSuiteTests+ObjC.m */, DA8F919C19F31921006F6675 /* FailureTests+ObjC.m */, @@ -701,7 +767,6 @@ DA05D60F19F73A3800771050 /* AfterEachTests.swift */, DAA63EA219F7637300CD0A3B /* PendingTests.swift */, DA8F91A419F3208B006F6675 /* BeforeSuiteTests.swift */, - DA8F91A719F32556006F6675 /* AfterSuiteTests.swift */, DA8F91AA19F3299E006F6675 /* SharedExamplesTests.swift */, DAB0136E19FC4315006AFBEE /* SharedExamples+BeforeEachTests.swift */, 7B5358CA1C3D4E2A00A23FAA /* ContextTests.swift */, @@ -763,6 +828,7 @@ 6C3983EE1D1E930D00637469 /* QuickObjectiveC */, DAEB6B9D1943873100289F44 /* QuickTests */, DA9876BE1A4C87200004AA17 /* QuickFocusedTests */, + 64076D1C1D6D7D0B00E2B499 /* QuickAfterSuiteTests */, DAEB6B8F1943873100289F44 /* Products */, 1F118D331BDCA645005013A2 /* Frameworks */, ); @@ -782,6 +848,9 @@ 1F118CD51BDCA4AB005013A2 /* Quick.framework */, 1F118CDE1BDCA4AB005013A2 /* Quick-tvOSTests.xctest */, 1F118CF01BDCA4BB005013A2 /* QuickFocused-tvOSTests.xctest */, + 64076CF51D6D7C2000E2B499 /* QuickAfterSuite-macOSTests.xctest */, + 64076D081D6D7CD600E2B499 /* QuickAfterSuite-iOSTests.xctest */, + 64076D1A1D6D7CEA00E2B499 /* QuickAfterSuite-tvOSTests.xctest */, ); name = Products; sourceTree = ""; @@ -801,7 +870,7 @@ CE57CEDA1C430BD200D63004 /* QuickTestSuite.swift */, CE57CED91C430BD200D63004 /* QuickSelectedTestSuiteBuilder.swift */, CE57CED81C430BD200D63004 /* NSBundle+CurrentTestBundle.swift */, - CE57CEDB1C430BD200D63004 /* String+FileName.swift */, + CE57CEDB1C430BD200D63004 /* URL+FileName.swift */, 34C586071C4AC5E500D4F057 /* ErrorUtility.swift */, DAEB6B911943873100289F44 /* Supporting Files */, ); @@ -914,6 +983,7 @@ 1F118CD11BDCA4AB005013A2 /* Frameworks */, 1F118CD21BDCA4AB005013A2 /* Headers */, 1F118CD31BDCA4AB005013A2 /* Resources */, + A870E6171DE00FC7006891AD /* ShellScript */, ); buildRules = ( ); @@ -968,6 +1038,7 @@ 5A5D117819473F2100F6D13D /* Frameworks */, 5A5D117919473F2100F6D13D /* Headers */, 5A5D117A19473F2100F6D13D /* Resources */, + A870E6161DE00E50006891AD /* ShellScript */, ); buildRules = ( ); @@ -1006,6 +1077,60 @@ productReference = 5A5D118619473F2100F6D13D /* Quick-iOSTests.xctest */; productType = "com.apple.product-type.bundle.unit-test"; }; + 64076CE51D6D7C2000E2B499 /* QuickAfterSuite-macOSTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 64076CF21D6D7C2000E2B499 /* Build configuration list for PBXNativeTarget "QuickAfterSuite-macOSTests" */; + buildPhases = ( + 64076CE81D6D7C2000E2B499 /* Sources */, + 64076CEE1D6D7C2000E2B499 /* Frameworks */, + 64076CF11D6D7C2000E2B499 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 64076CE61D6D7C2000E2B499 /* PBXTargetDependency */, + ); + name = "QuickAfterSuite-macOSTests"; + productName = "QuickFocused-macOSTests"; + productReference = 64076CF51D6D7C2000E2B499 /* QuickAfterSuite-macOSTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; + 64076CF81D6D7CD600E2B499 /* QuickAfterSuite-iOSTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 64076D051D6D7CD600E2B499 /* Build configuration list for PBXNativeTarget "QuickAfterSuite-iOSTests" */; + buildPhases = ( + 64076CFB1D6D7CD600E2B499 /* Sources */, + 64076D011D6D7CD600E2B499 /* Frameworks */, + 64076D041D6D7CD600E2B499 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 64076CF91D6D7CD600E2B499 /* PBXTargetDependency */, + ); + name = "QuickAfterSuite-iOSTests"; + productName = "QuickFocused-iOSTests"; + productReference = 64076D081D6D7CD600E2B499 /* QuickAfterSuite-iOSTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; + 64076D0A1D6D7CEA00E2B499 /* QuickAfterSuite-tvOSTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 64076D171D6D7CEA00E2B499 /* Build configuration list for PBXNativeTarget "QuickAfterSuite-tvOSTests" */; + buildPhases = ( + 64076D0D1D6D7CEA00E2B499 /* Sources */, + 64076D131D6D7CEA00E2B499 /* Frameworks */, + 64076D161D6D7CEA00E2B499 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 64076D0B1D6D7CEA00E2B499 /* PBXTargetDependency */, + ); + name = "QuickAfterSuite-tvOSTests"; + productName = "QuickFocused-tvOSTests"; + productReference = 64076D1A1D6D7CEA00E2B499 /* QuickAfterSuite-tvOSTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; DA5663E71A4C8D8500193C88 /* QuickFocused-macOSTests */ = { isa = PBXNativeTarget; buildConfigurationList = DA5663F31A4C8D8500193C88 /* Build configuration list for PBXNativeTarget "QuickFocused-macOSTests" */; @@ -1020,7 +1145,7 @@ DA5663F01A4C8D8500193C88 /* PBXTargetDependency */, ); name = "QuickFocused-macOSTests"; - productName = "QuickFocused-OSXTests"; + productName = "QuickFocused-macOSTests"; productReference = DA5663E81A4C8D8500193C88 /* QuickFocused-macOSTests.xctest */; productType = "com.apple.product-type.bundle.unit-test"; }; @@ -1050,6 +1175,7 @@ DAEB6B8A1943873100289F44 /* Frameworks */, DAEB6B8B1943873100289F44 /* Headers */, DAEB6B8C1943873100289F44 /* Resources */, + A870E6151DE00E37006891AD /* ShellScript */, ); buildRules = ( ); @@ -1097,7 +1223,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0710; - LastUpgradeCheck = 0800; + LastUpgradeCheck = 0810; ORGANIZATIONNAME = "Brian Ivan Gesiak"; TargetAttributes = { 1F118CD41BDCA4AB005013A2 = { @@ -1155,12 +1281,15 @@ DAEB6B8D1943873100289F44 /* Quick-macOS */, DAEB6B981943873100289F44 /* Quick-macOSTests */, DA5663E71A4C8D8500193C88 /* QuickFocused-macOSTests */, + 64076CE51D6D7C2000E2B499 /* QuickAfterSuite-macOSTests */, 5A5D117B19473F2100F6D13D /* Quick-iOS */, 5A5D118519473F2100F6D13D /* Quick-iOSTests */, DA9876B11A4C70EB0004AA17 /* QuickFocused-iOSTests */, + 64076CF81D6D7CD600E2B499 /* QuickAfterSuite-iOSTests */, 1F118CD41BDCA4AB005013A2 /* Quick-tvOS */, 1F118CDD1BDCA4AB005013A2 /* Quick-tvOSTests */, 1F118CEF1BDCA4BB005013A2 /* QuickFocused-tvOSTests */, + 64076D0A1D6D7CEA00E2B499 /* QuickAfterSuite-tvOSTests */, ); }; /* End PBXProject section */ @@ -1201,6 +1330,27 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 64076CF11D6D7C2000E2B499 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 64076D041D6D7CD600E2B499 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 64076D161D6D7CEA00E2B499 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; DA5663E61A4C8D8500193C88 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -1231,6 +1381,48 @@ }; /* End PBXResourcesBuildPhase section */ +/* Begin PBXShellScriptBuildPhase section */ + A870E6151DE00E37006891AD /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "if which swiftlint >/dev/null; then\nswiftlint\nelse\necho \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi"; + }; + A870E6161DE00E50006891AD /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "if which swiftlint >/dev/null; then\nswiftlint\nelse\necho \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi"; + }; + A870E6171DE00FC7006891AD /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "if which swiftlint >/dev/null; then\nswiftlint\nelse\necho \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi"; + }; +/* End PBXShellScriptBuildPhase section */ + /* Begin PBXSourcesBuildPhase section */ 1F118CD01BDCA4AB005013A2 /* Sources */ = { isa = PBXSourcesBuildPhase; @@ -1250,7 +1442,7 @@ CE590E231C431FE400253D19 /* XCTestSuite+QuickTestSuiteBuilder.m in Sources */, 1F118D081BDCA536005013A2 /* Filter.swift in Sources */, 1F118CFD1BDCA536005013A2 /* World+DSL.swift in Sources */, - CE590E221C431FE400253D19 /* String+FileName.swift in Sources */, + CE590E221C431FE400253D19 /* URL+FileName.swift in Sources */, 1F118D0A1BDCA536005013A2 /* NSString+QCKSelectorName.m in Sources */, 1F118CFE1BDCA536005013A2 /* DSL.swift in Sources */, 7B44ADC01C5444940007AF2E /* HooksPhase.swift in Sources */, @@ -1275,7 +1467,6 @@ 1F118D141BDCA556005013A2 /* FailureTests+ObjC.m in Sources */, 1F118D0F1BDCA54B005013A2 /* FunctionalTests_SharedExamplesTests_SharedExamples.swift in Sources */, 1F118D101BDCA556005013A2 /* Configuration+AfterEach.swift in Sources */, - 1F118D1F1BDCA556005013A2 /* AfterSuiteTests+ObjC.m in Sources */, 1F118D1A1BDCA556005013A2 /* PendingTests.swift in Sources */, 1F118D171BDCA556005013A2 /* BeforeEachTests+ObjC.m in Sources */, 1F118D231BDCA556005013A2 /* SharedExamples+BeforeEachTests+ObjC.m in Sources */, @@ -1293,7 +1484,6 @@ 1F118D1B1BDCA556005013A2 /* PendingTests+ObjC.m in Sources */, 34C586051C4ABD4100D4F057 /* XCTestCaseProvider.swift in Sources */, 8D010A591C11726F00633E2B /* DescribeTests.swift in Sources */, - 1F118D1E1BDCA556005013A2 /* AfterSuiteTests.swift in Sources */, 1F118D111BDCA556005013A2 /* Configuration+AfterEachTests.swift in Sources */, 1F118D161BDCA556005013A2 /* BeforeEachTests.swift in Sources */, 7B5358D01C3D4FC000A23FAA /* ContextTests.swift in Sources */, @@ -1330,7 +1520,7 @@ CE590E1E1C431FE300253D19 /* XCTestSuite+QuickTestSuiteBuilder.m in Sources */, 34F375A819515CA700CE1B99 /* Callsite.swift in Sources */, 34F375AE19515CA700CE1B99 /* ExampleGroup.swift in Sources */, - CE590E1D1C431FE300253D19 /* String+FileName.swift in Sources */, + CE590E1D1C431FE300253D19 /* URL+FileName.swift in Sources */, 34F375BC19515CA700CE1B99 /* World.swift in Sources */, DA169E4919FF5DF100619816 /* Configuration.swift in Sources */, 7B44ADBF1C5444940007AF2E /* HooksPhase.swift in Sources */, @@ -1368,8 +1558,6 @@ 471590411A488F3F00FBA644 /* PendingTests+ObjC.m in Sources */, DA8F919E19F31921006F6675 /* FailureTests+ObjC.m in Sources */, DAE714F419FF65E7005905B8 /* Configuration+BeforeEach.swift in Sources */, - DA8F91A919F32556006F6675 /* AfterSuiteTests.swift in Sources */, - 4772173B1A59C1B00022013E /* AfterSuiteTests+ObjC.m in Sources */, 479C31E41A36172700DA8718 /* ItTests+ObjC.m in Sources */, 34C586031C4ABD4000D4F057 /* XCTestCaseProvider.swift in Sources */, 8D010A581C11726F00633E2B /* DescribeTests.swift in Sources */, @@ -1380,6 +1568,33 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 64076CE81D6D7C2000E2B499 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 64076D211D6D7E4D00E2B499 /* AfterSuiteTests.swift in Sources */, + CD264DBD1DDA147A0038B0EB /* AfterSuiteTests+ObjC.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 64076CFB1D6D7CD600E2B499 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 64076D221D6D7E5B00E2B499 /* AfterSuiteTests.swift in Sources */, + 64076D261D6D80B500E2B499 /* AfterSuiteTests+ObjC.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 64076D0D1D6D7CEA00E2B499 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 64076D231D6D7E6B00E2B499 /* AfterSuiteTests.swift in Sources */, + 64076D271D6D80B500E2B499 /* AfterSuiteTests+ObjC.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; DA5663E41A4C8D8500193C88 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -1422,7 +1637,7 @@ CE57CEE11C430BD200D63004 /* XCTestSuite+QuickTestSuiteBuilder.m in Sources */, DAE7150019FF6A62005905B8 /* QuickConfiguration.m in Sources */, 34F375A719515CA700CE1B99 /* Callsite.swift in Sources */, - CE57CEE01C430BD200D63004 /* String+FileName.swift in Sources */, + CE57CEE01C430BD200D63004 /* URL+FileName.swift in Sources */, 34F375AD19515CA700CE1B99 /* ExampleGroup.swift in Sources */, 34F375BB19515CA700CE1B99 /* World.swift in Sources */, DA169E4819FF5DF100619816 /* Configuration.swift in Sources */, @@ -1460,8 +1675,6 @@ 471590401A488F3F00FBA644 /* PendingTests+ObjC.m in Sources */, DA8F919D19F31921006F6675 /* FailureTests+ObjC.m in Sources */, DAE714F319FF65E7005905B8 /* Configuration+BeforeEach.swift in Sources */, - DA8F91A819F32556006F6675 /* AfterSuiteTests.swift in Sources */, - 4772173A1A59C1B00022013E /* AfterSuiteTests+ObjC.m in Sources */, 479C31E31A36171B00DA8718 /* ItTests+ObjC.m in Sources */, 34C586011C4ABD3F00D4F057 /* XCTestCaseProvider.swift in Sources */, 8D010A571C11726F00633E2B /* DescribeTests.swift in Sources */, @@ -1595,6 +1808,21 @@ target = 5A5D117B19473F2100F6D13D /* Quick-iOS */; targetProxy = 5A5D11F1194741B500F6D13D /* PBXContainerItemProxy */; }; + 64076CE61D6D7C2000E2B499 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = DAEB6B8D1943873100289F44 /* Quick-macOS */; + targetProxy = 64076CE71D6D7C2000E2B499 /* PBXContainerItemProxy */; + }; + 64076CF91D6D7CD600E2B499 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 5A5D117B19473F2100F6D13D /* Quick-iOS */; + targetProxy = 64076CFA1D6D7CD600E2B499 /* PBXContainerItemProxy */; + }; + 64076D0B1D6D7CEA00E2B499 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 1F118CD41BDCA4AB005013A2 /* Quick-tvOS */; + targetProxy = 64076D0C1D6D7CEA00E2B499 /* PBXContainerItemProxy */; + }; 93625F391951DDC8006B1FE1 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = DAEB6B8D1943873100289F44 /* Quick-macOS */; @@ -1870,6 +2098,139 @@ }; name = Release; }; + 64076CF31D6D7C2000E2B499 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ENABLE_MODULES = YES; + COMBINE_HIDPI_IMAGES = YES; + FRAMEWORK_SEARCH_PATHS = ( + "$(DEVELOPER_FRAMEWORKS_DIR)", + "$(inherited)", + ); + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + INFOPLIST_FILE = Tests/QuickTests/QuickAfterSuiteTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; + MACOSX_DEPLOYMENT_TARGET = 10.10; + MTL_ENABLE_DEBUG_INFO = YES; + PRODUCT_BUNDLE_IDENTIFIER = "io.quick.$(PRODUCT_NAME:rfc1034identifier)"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = Tests/QuickTests/QuickTests/Helpers/QuickTestsBridgingHeader.h; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 64076CF41D6D7C2000E2B499 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ENABLE_MODULES = YES; + COMBINE_HIDPI_IMAGES = YES; + FRAMEWORK_SEARCH_PATHS = ( + "$(DEVELOPER_FRAMEWORKS_DIR)", + "$(inherited)", + ); + INFOPLIST_FILE = Tests/QuickTests/QuickAfterSuiteTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; + MACOSX_DEPLOYMENT_TARGET = 10.10; + MTL_ENABLE_DEBUG_INFO = NO; + PRODUCT_BUNDLE_IDENTIFIER = "io.quick.$(PRODUCT_NAME:rfc1034identifier)"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = Tests/QuickTests/QuickTests/Helpers/QuickTestsBridgingHeader.h; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + }; + name = Release; + }; + 64076D061D6D7CD600E2B499 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ENABLE_MODULES = YES; + FRAMEWORK_SEARCH_PATHS = ( + "$(SDKROOT)/Developer/Library/Frameworks", + "$(inherited)", + ); + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + INFOPLIST_FILE = Tests/QuickTests/QuickAfterSuiteTests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = NO; + PRODUCT_BUNDLE_IDENTIFIER = "io.quick.$(PRODUCT_NAME:rfc1034identifier)"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = iphoneos; + SWIFT_OBJC_BRIDGING_HEADER = Tests/QuickTests/QuickTests/Helpers/QuickTestsBridgingHeader.h; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 64076D071D6D7CD600E2B499 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ENABLE_MODULES = YES; + FRAMEWORK_SEARCH_PATHS = ( + "$(SDKROOT)/Developer/Library/Frameworks", + "$(inherited)", + ); + INFOPLIST_FILE = Tests/QuickTests/QuickAfterSuiteTests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MTL_ENABLE_DEBUG_INFO = NO; + ONLY_ACTIVE_ARCH = NO; + PRODUCT_BUNDLE_IDENTIFIER = "io.quick.$(PRODUCT_NAME:rfc1034identifier)"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = iphoneos; + SWIFT_OBJC_BRIDGING_HEADER = Tests/QuickTests/QuickTests/Helpers/QuickTestsBridgingHeader.h; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 64076D181D6D7CEA00E2B499 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + DEBUG_INFORMATION_FORMAT = dwarf; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Externals/Nimble/build/Debug-appletvos", + ); + GCC_NO_COMMON_BLOCKS = YES; + INFOPLIST_FILE = Tests/QuickTests/QuickAfterSuiteTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MTL_ENABLE_DEBUG_INFO = YES; + PRODUCT_BUNDLE_IDENTIFIER = "io.quick.${PRODUCT_NAME:rfc1034identifier}"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = appletvos; + SWIFT_OBJC_BRIDGING_HEADER = Tests/QuickTests/QuickTests/Helpers/QuickTestsBridgingHeader.h; + TVOS_DEPLOYMENT_TARGET = 9.0; + }; + name = Debug; + }; + 64076D191D6D7CEA00E2B499 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + COPY_PHASE_STRIP = NO; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Externals/Nimble/build/Debug-appletvos", + ); + GCC_NO_COMMON_BLOCKS = YES; + INFOPLIST_FILE = Tests/QuickTests/QuickAfterSuiteTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MTL_ENABLE_DEBUG_INFO = NO; + PRODUCT_BUNDLE_IDENTIFIER = "io.quick.${PRODUCT_NAME:rfc1034identifier}"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = appletvos; + SWIFT_OBJC_BRIDGING_HEADER = Tests/QuickTests/QuickTests/Helpers/QuickTestsBridgingHeader.h; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + TVOS_DEPLOYMENT_TARGET = 9.0; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; DA5663F11A4C8D8500193C88 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -1974,8 +2335,10 @@ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGNING_REQUIRED = NO; @@ -2024,8 +2387,10 @@ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGNING_REQUIRED = NO; @@ -2198,6 +2563,33 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + 64076CF21D6D7C2000E2B499 /* Build configuration list for PBXNativeTarget "QuickAfterSuite-macOSTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 64076CF31D6D7C2000E2B499 /* Debug */, + 64076CF41D6D7C2000E2B499 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 64076D051D6D7CD600E2B499 /* Build configuration list for PBXNativeTarget "QuickAfterSuite-iOSTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 64076D061D6D7CD600E2B499 /* Debug */, + 64076D071D6D7CD600E2B499 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 64076D171D6D7CEA00E2B499 /* Build configuration list for PBXNativeTarget "QuickAfterSuite-tvOSTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 64076D181D6D7CEA00E2B499 /* Debug */, + 64076D191D6D7CEA00E2B499 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; DA5663F31A4C8D8500193C88 /* Build configuration list for PBXNativeTarget "QuickFocused-macOSTests" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/Carthage/Checkouts/Quick/Quick.xcodeproj/xcshareddata/xcschemes/Quick-iOS.xcscheme b/Carthage/Checkouts/Quick/Quick.xcodeproj/xcshareddata/xcschemes/Quick-iOS.xcscheme index e2eb4c7..988da03 100644 --- a/Carthage/Checkouts/Quick/Quick.xcodeproj/xcshareddata/xcschemes/Quick-iOS.xcscheme +++ b/Carthage/Checkouts/Quick/Quick.xcodeproj/xcshareddata/xcschemes/Quick-iOS.xcscheme @@ -1,6 +1,6 @@ + + + + + + + + + + + + Bool { +public func == (lhs: Callsite, rhs: Callsite) -> Bool { return lhs.file == rhs.file && lhs.line == rhs.line } diff --git a/Carthage/Checkouts/Quick/Sources/Quick/Configuration/Configuration.swift b/Carthage/Checkouts/Quick/Sources/Quick/Configuration/Configuration.swift index 9836fef..99c1c93 100644 --- a/Carthage/Checkouts/Quick/Sources/Quick/Configuration/Configuration.swift +++ b/Carthage/Checkouts/Quick/Sources/Quick/Configuration/Configuration.swift @@ -19,14 +19,14 @@ public typealias ExampleFilter = (_ example: Example) -> Bool final public class Configuration: NSObject { internal let exampleHooks = ExampleHooks() internal let suiteHooks = SuiteHooks() - internal var exclusionFilters: [ExampleFilter] = [{ example in + internal var exclusionFilters: [ExampleFilter] = [ { example in if let pending = example.filterFlags[Filter.pending] { return pending } else { return false } }] - internal var inclusionFilters: [ExampleFilter] = [{ example in + internal var inclusionFilters: [ExampleFilter] = [ { example in if let focused = example.filterFlags[Filter.focused] { return focused } else { diff --git a/Carthage/Checkouts/Quick/Sources/Quick/Example.swift b/Carthage/Checkouts/Quick/Sources/Quick/Example.swift index 844bf3f..07bc529 100644 --- a/Carthage/Checkouts/Quick/Sources/Quick/Example.swift +++ b/Carthage/Checkouts/Quick/Sources/Quick/Example.swift @@ -32,7 +32,7 @@ final public class Example: NSObject { self.callsite = callsite self.flags = flags } - + public override var description: String { return internalDescription } @@ -106,6 +106,6 @@ final public class Example: NSObject { Returns a boolean indicating whether two Example objects are equal. If two examples are defined at the exact same callsite, they must be equal. */ -public func ==(lhs: Example, rhs: Example) -> Bool { +public func == (lhs: Example, rhs: Example) -> Bool { return lhs.callsite == rhs.callsite } diff --git a/Carthage/Checkouts/Quick/Sources/Quick/ExampleGroup.swift b/Carthage/Checkouts/Quick/Sources/Quick/ExampleGroup.swift index b0b8be4..79f24ca 100644 --- a/Carthage/Checkouts/Quick/Sources/Quick/ExampleGroup.swift +++ b/Carthage/Checkouts/Quick/Sources/Quick/ExampleGroup.swift @@ -8,7 +8,7 @@ import Foundation final public class ExampleGroup: NSObject { weak internal var parent: ExampleGroup? internal let hooks = ExampleHooks() - + internal var phase: HooksPhase = .nothingExecuted private let internalDescription: String diff --git a/Carthage/Checkouts/Quick/Sources/Quick/Hooks/ExampleHooks.swift b/Carthage/Checkouts/Quick/Sources/Quick/Hooks/ExampleHooks.swift index ef6d53e..565287b 100644 --- a/Carthage/Checkouts/Quick/Sources/Quick/Hooks/ExampleHooks.swift +++ b/Carthage/Checkouts/Quick/Sources/Quick/Hooks/ExampleHooks.swift @@ -27,7 +27,7 @@ final internal class ExampleHooks { for before in befores { before(exampleMetadata) } - + phase = .beforesFinished } diff --git a/Carthage/Checkouts/Quick/Sources/Quick/QuickSelectedTestSuiteBuilder.swift b/Carthage/Checkouts/Quick/Sources/Quick/QuickSelectedTestSuiteBuilder.swift index 63b55e1..ec2e308 100644 --- a/Carthage/Checkouts/Quick/Sources/Quick/QuickSelectedTestSuiteBuilder.swift +++ b/Carthage/Checkouts/Quick/Sources/Quick/QuickSelectedTestSuiteBuilder.swift @@ -66,7 +66,8 @@ private func testCaseClassForTestCaseWithName(_ name: String) -> AnyClass? { if let testCaseClass = bundle.classNamed(className) { return testCaseClass } - guard let moduleName = bundle.bundlePath.fileName else { return nil } + let bundleFileName = bundle.bundleURL.fileName + let moduleName = bundleFileName.replacingOccurrences(of: " ", with: "_") return NSClassFromString("\(moduleName).\(className)") } diff --git a/Carthage/Checkouts/Quick/Sources/Quick/QuickSpec.swift b/Carthage/Checkouts/Quick/Sources/Quick/QuickSpec.swift index b70e32f..e4dd728 100644 --- a/Carthage/Checkouts/Quick/Sources/Quick/QuickSpec.swift +++ b/Carthage/Checkouts/Quick/Sources/Quick/QuickSpec.swift @@ -21,7 +21,7 @@ open class QuickSpec: XCTestCase { static var allTestsCache = [String : [(String, (XCTestCase) -> () throws -> Void)]]() - public class var allTests : [(String, (XCTestCase) -> () throws -> Void)] { + public class var allTests: [(String, (XCTestCase) -> () throws -> Void)] { if let cached = allTestsCache[String(describing: self)] { return cached } diff --git a/Carthage/Checkouts/Quick/Sources/Quick/URL+FileName.swift b/Carthage/Checkouts/Quick/Sources/Quick/URL+FileName.swift new file mode 100644 index 0000000..23c4781 --- /dev/null +++ b/Carthage/Checkouts/Quick/Sources/Quick/URL+FileName.swift @@ -0,0 +1,12 @@ +import Foundation + +extension URL { + + /** + Returns the path file name without file extension. + */ + var fileName: String { + return self.deletingPathExtension().lastPathComponent + } + +} diff --git a/Carthage/Checkouts/Quick/Sources/Quick/World.swift b/Carthage/Checkouts/Quick/Sources/Quick/World.swift index 56dae51..487902e 100644 --- a/Carthage/Checkouts/Quick/Sources/Quick/World.swift +++ b/Carthage/Checkouts/Quick/Sources/Quick/World.swift @@ -165,7 +165,7 @@ final internal class World: NSObject { internal var includedExampleCount: Int { return includedExamples.count } - + internal var beforesCurrentlyExecuting: Bool { let suiteBeforesExecuting = suiteHooks.phase == .beforesExecuting let exampleBeforesExecuting = exampleHooks.phase == .beforesExecuting @@ -173,10 +173,10 @@ final internal class World: NSObject { if let runningExampleGroup = currentExampleMetadata?.example.group { groupBeforesExecuting = runningExampleGroup.phase == .beforesExecuting } - + return suiteBeforesExecuting || exampleBeforesExecuting || groupBeforesExecuting } - + internal var aftersCurrentlyExecuting: Bool { let suiteAftersExecuting = suiteHooks.phase == .aftersExecuting let exampleAftersExecuting = exampleHooks.phase == .aftersExecuting @@ -184,7 +184,7 @@ final internal class World: NSObject { if let runningExampleGroup = currentExampleMetadata?.example.group { groupAftersExecuting = runningExampleGroup.phase == .aftersExecuting } - + return suiteAftersExecuting || exampleAftersExecuting || groupAftersExecuting } diff --git a/Carthage/Checkouts/Quick/Tests/LinuxMain.swift b/Carthage/Checkouts/Quick/Tests/LinuxMain.swift index c7c3a28..938f54f 100644 --- a/Carthage/Checkouts/Quick/Tests/LinuxMain.swift +++ b/Carthage/Checkouts/Quick/Tests/LinuxMain.swift @@ -5,8 +5,7 @@ import Quick Quick.QCKMain([ FunctionalTests_AfterEachSpec.self, - FunctionalTests_AfterSuite_AfterSuiteSpec.self, - FunctionalTests_AfterSuite_Spec.self, + AfterSuiteTests.self, FunctionalTests_BeforeEachSpec.self, FunctionalTests_BeforeSuite_BeforeSuiteSpec.self, FunctionalTests_BeforeSuite_Spec.self, @@ -31,7 +30,6 @@ configurations: [ ], testCases: [ testCase(AfterEachTests.allTests), - testCase(AfterSuiteTests.allTests), testCase(BeforeEachTests.allTests), testCase(BeforeSuiteTests.allTests), // testCase(DescribeTests.allTests), diff --git a/Carthage/Checkouts/Quick/Tests/QuickTests/QuickAfterSuiteTests/AfterSuiteTests+ObjC.m b/Carthage/Checkouts/Quick/Tests/QuickTests/QuickAfterSuiteTests/AfterSuiteTests+ObjC.m new file mode 100644 index 0000000..cd3522d --- /dev/null +++ b/Carthage/Checkouts/Quick/Tests/QuickTests/QuickAfterSuiteTests/AfterSuiteTests+ObjC.m @@ -0,0 +1,32 @@ +@import XCTest; +@import Quick; +@import Nimble; + +static BOOL afterSuiteFirstTestExecuted = NO; +static BOOL afterSuiteTestsWasExecuted = NO; + +@interface AfterSuiteTests_ObjC : QuickSpec + +@end + +@implementation AfterSuiteTests_ObjC + +- (void)spec { + it(@"is executed before afterSuite", ^{ + expect(@(afterSuiteTestsWasExecuted)).to(beFalsy()); + }); + + afterSuite(^{ + afterSuiteTestsWasExecuted = YES; + }); +} + ++ (void)tearDown { + if (afterSuiteFirstTestExecuted) { + assert(afterSuiteTestsWasExecuted); + } else { + afterSuiteFirstTestExecuted = true; + } +} + +@end diff --git a/Carthage/Checkouts/Quick/Tests/QuickTests/QuickAfterSuiteTests/AfterSuiteTests.swift b/Carthage/Checkouts/Quick/Tests/QuickTests/QuickAfterSuiteTests/AfterSuiteTests.swift new file mode 100644 index 0000000..ea4fc3e --- /dev/null +++ b/Carthage/Checkouts/Quick/Tests/QuickTests/QuickAfterSuiteTests/AfterSuiteTests.swift @@ -0,0 +1,26 @@ +import XCTest +import Quick +import Nimble + +var afterSuiteFirstTestExecuted = false +var afterSuiteTestsWasExecuted = false + +class AfterSuiteTests: QuickSpec { + override func spec() { + afterSuite { + afterSuiteTestsWasExecuted = true + } + + it("is executed before afterSuite") { + expect(afterSuiteTestsWasExecuted).to(beFalsy()) + } + } + + override class func tearDown() { + if afterSuiteFirstTestExecuted { + assert(afterSuiteTestsWasExecuted, "afterSuiteTestsWasExecuted needs to be true") + } else { + afterSuiteFirstTestExecuted = true + } + } +} diff --git a/Carthage/Checkouts/Quick/Tests/QuickTests/QuickAfterSuiteTests/Info.plist b/Carthage/Checkouts/Quick/Tests/QuickTests/QuickAfterSuiteTests/Info.plist new file mode 100644 index 0000000..ba72822 --- /dev/null +++ b/Carthage/Checkouts/Quick/Tests/QuickTests/QuickAfterSuiteTests/Info.plist @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + + diff --git a/Carthage/Checkouts/Quick/Tests/QuickTests/QuickFocusedTests/FocusedTests.swift b/Carthage/Checkouts/Quick/Tests/QuickTests/QuickFocusedTests/FocusedTests.swift index 28b74f2..0569a7b 100644 --- a/Carthage/Checkouts/Quick/Tests/QuickTests/QuickFocusedTests/FocusedTests.swift +++ b/Carthage/Checkouts/Quick/Tests/QuickTests/QuickFocusedTests/FocusedTests.swift @@ -21,7 +21,6 @@ class FunctionalTests_FocusedSpec_Focused: QuickSpec { fit("has a focused example that passes (3)") {} } - // TODO: Port fitBehavesLike to Swift. itBehavesLike("two passing shared examples", flags: [Filter.focused: true]) } } diff --git a/Carthage/Checkouts/Quick/Tests/QuickTests/QuickTestHelpers/TestRun.swift b/Carthage/Checkouts/Quick/Tests/QuickTests/QuickTestHelpers/TestRun.swift index cfa160e..3ef0d6c 100644 --- a/Carthage/Checkouts/Quick/Tests/QuickTests/QuickTestHelpers/TestRun.swift +++ b/Carthage/Checkouts/Quick/Tests/QuickTests/QuickTestHelpers/TestRun.swift @@ -1,4 +1,3 @@ - public struct TestRun { public var executionCount: UInt public var hasSucceeded: Bool diff --git a/Carthage/Checkouts/Quick/Tests/QuickTests/QuickTestHelpers/XCTestCaseProvider.swift b/Carthage/Checkouts/Quick/Tests/QuickTests/QuickTestHelpers/XCTestCaseProvider.swift index 78729d4..0b02978 100644 --- a/Carthage/Checkouts/Quick/Tests/QuickTests/QuickTestHelpers/XCTestCaseProvider.swift +++ b/Carthage/Checkouts/Quick/Tests/QuickTests/QuickTestHelpers/XCTestCaseProvider.swift @@ -48,5 +48,5 @@ public extension XCTestCaseProvider where Self: XCTestCaseProviderStatic { XCTAssert(contains, "Test '\(name)' is missing from the allTests array") } } - + #endif diff --git a/Carthage/Checkouts/Quick/Tests/QuickTests/QuickTests/Fixtures/FunctionalTests_SharedExamplesTests_SharedExamples.swift b/Carthage/Checkouts/Quick/Tests/QuickTests/QuickTests/Fixtures/FunctionalTests_SharedExamplesTests_SharedExamples.swift index 5056a58..e5eed68 100644 --- a/Carthage/Checkouts/Quick/Tests/QuickTests/QuickTests/Fixtures/FunctionalTests_SharedExamplesTests_SharedExamples.swift +++ b/Carthage/Checkouts/Quick/Tests/QuickTests/QuickTests/Fixtures/FunctionalTests_SharedExamplesTests_SharedExamples.swift @@ -12,7 +12,7 @@ class FunctionalTests_SharedExamplesTests_SharedExamples: QuickConfiguration { sharedExamples("shared examples that take a context") { (sharedExampleContext: @escaping SharedExampleContext) in it("is passed the correct parameters via the context") { - let callsite = sharedExampleContext()["callsite"] as! String + let callsite = sharedExampleContext()["callsite"] as? String expect(callsite).to(equal("SharedExamplesSpec")) } } diff --git a/Carthage/Checkouts/Quick/Tests/QuickTests/QuickTests/FunctionalTests/AfterEachTests.swift b/Carthage/Checkouts/Quick/Tests/QuickTests/QuickTests/FunctionalTests/AfterEachTests.swift index f69818c..713e8ae 100644 --- a/Carthage/Checkouts/Quick/Tests/QuickTests/QuickTests/FunctionalTests/AfterEachTests.swift +++ b/Carthage/Checkouts/Quick/Tests/QuickTests/QuickTests/FunctionalTests/AfterEachTests.swift @@ -19,23 +19,23 @@ class FunctionalTests_AfterEachSpec: QuickSpec { afterEach { afterEachOrder.append(AfterEachType.OuterOne) } afterEach { afterEachOrder.append(AfterEachType.OuterTwo) } afterEach { afterEachOrder.append(AfterEachType.OuterThree) } - + it("executes the outer afterEach closures once, but not before this closure [1]") { // No examples have been run, so no afterEach will have been run either. // The list should be empty. expect(afterEachOrder).to(beEmpty()) } - + it("executes the outer afterEach closures a second time, but not before this closure [2]") { // The afterEach for the previous example should have been run. // The list should contain the afterEach for that example, executed from top to bottom. expect(afterEachOrder).to(equal([AfterEachType.OuterOne, AfterEachType.OuterTwo, AfterEachType.OuterThree])) } - + context("when there are nested afterEach") { afterEach { afterEachOrder.append(AfterEachType.InnerOne) } afterEach { afterEachOrder.append(AfterEachType.InnerTwo) } - + it("executes the outer and inner afterEach closures, but not before this closure [3]") { // The afterEach for the previous two examples should have been run. // The list should contain the afterEach for those example, executed from top to bottom. @@ -45,7 +45,7 @@ class FunctionalTests_AfterEachSpec: QuickSpec { ])) } } - + context("when there are nested afterEach without examples") { afterEach { afterEachOrder.append(AfterEachType.NoExamples) } } diff --git a/Carthage/Checkouts/Quick/Tests/QuickTests/QuickTests/FunctionalTests/BeforeEachTests.swift b/Carthage/Checkouts/Quick/Tests/QuickTests/QuickTests/FunctionalTests/BeforeEachTests.swift index 27a8d64..d46ae68 100644 --- a/Carthage/Checkouts/Quick/Tests/QuickTests/QuickTests/FunctionalTests/BeforeEachTests.swift +++ b/Carthage/Checkouts/Quick/Tests/QuickTests/QuickTests/FunctionalTests/BeforeEachTests.swift @@ -15,22 +15,22 @@ private var beforeEachOrder = [BeforeEachType]() class FunctionalTests_BeforeEachSpec: QuickSpec { override func spec() { - + describe("beforeEach ordering") { beforeEach { beforeEachOrder.append(BeforeEachType.OuterOne) } beforeEach { beforeEachOrder.append(BeforeEachType.OuterTwo) } - + it("executes the outer beforeEach closures once [1]") {} it("executes the outer beforeEach closures a second time [2]") {} - + context("when there are nested beforeEach") { beforeEach { beforeEachOrder.append(BeforeEachType.InnerOne) } beforeEach { beforeEachOrder.append(BeforeEachType.InnerTwo) } beforeEach { beforeEachOrder.append(BeforeEachType.InnerThree) } - + it("executes the outer and inner beforeEach closures [3]") {} } - + context("when there are nested beforeEach without examples") { beforeEach { beforeEachOrder.append(BeforeEachType.NoExamples) } } diff --git a/Carthage/Checkouts/Quick/Tests/QuickTests/QuickTests/FunctionalTests/ItTests.swift b/Carthage/Checkouts/Quick/Tests/QuickTests/QuickTests/FunctionalTests/ItTests.swift index 320995d..61e4504 100644 --- a/Carthage/Checkouts/Quick/Tests/QuickTests/QuickTests/FunctionalTests/ItTests.swift +++ b/Carthage/Checkouts/Quick/Tests/QuickTests/QuickTests/FunctionalTests/ItTests.swift @@ -18,41 +18,39 @@ class FunctionalTests_ItSpec: QuickSpec { #if _runtime(_ObjC) && !SWIFT_PACKAGE - describe("when an example has a unique name"){ + describe("when an example has a unique name") { it("has a unique name") {} - + it("doesn't add multiple selectors for it") { let allSelectors = [String]( FunctionalTests_ItSpec.allSelectors() - .filter { $0.hasPrefix("when_an_example_has_a_unique_name__") } - ) + .filter { $0.hasPrefix("when_an_example_has_a_unique_name__") }) .sorted(by: <) - + expect(allSelectors) == [ "when_an_example_has_a_unique_name__doesn_t_add_multiple_selectors_for_it", "when_an_example_has_a_unique_name__has_a_unique_name" ] } } - + describe("when two examples have the exact name") { it("has exactly the same name") {} it("has exactly the same name") {} - + it("makes a unique name for each of the above") { let allSelectors = [String]( FunctionalTests_ItSpec.allSelectors() - .filter { $0.hasPrefix("when_two_examples_have_the_exact_name__") } - ) + .filter { $0.hasPrefix("when_two_examples_have_the_exact_name__") }) .sorted(by: <) - + expect(allSelectors) == [ "when_two_examples_have_the_exact_name__has_exactly_the_same_name", "when_two_examples_have_the_exact_name__has_exactly_the_same_name_2", "when_two_examples_have_the_exact_name__makes_a_unique_name_for_each_of_the_above" ] } - + } describe("error handling when misusing ordering") { diff --git a/Carthage/Checkouts/Quick/Tests/QuickTests/QuickTests/Helpers/QuickTestsBridgingHeader.h b/Carthage/Checkouts/Quick/Tests/QuickTests/QuickTests/Helpers/QuickTestsBridgingHeader.h index f93b1cb..301c5d5 100644 --- a/Carthage/Checkouts/Quick/Tests/QuickTests/QuickTests/Helpers/QuickTestsBridgingHeader.h +++ b/Carthage/Checkouts/Quick/Tests/QuickTests/QuickTests/Helpers/QuickTestsBridgingHeader.h @@ -1,2 +1,2 @@ #import "QCKSpecRunner.h" -#import "QuickSpec+QuickSpec_MethodList.h" \ No newline at end of file +#import "QuickSpec+QuickSpec_MethodList.h" From 8490d62a499c904f4557de19ef97dc5314fdd11c Mon Sep 17 00:00:00 2001 From: Giovanni Lodi Date: Mon, 30 Jan 2017 15:54:25 +1100 Subject: [PATCH 2/2] Update Nimble dependency to 6.0.1 And configure semver rule to get any version compatible with 6.0.0. This results in version 6.0.1 being fetched ;) --- Cartfile.private | 2 +- Cartfile.resolved | 2 +- .../Checkouts/Nimble/.github/ISSUE_TEMPLATE | 36 ++++ .../Nimble/.github/PULL_REQUEST_TEMPLATE | 14 ++ Carthage/Checkouts/Nimble/.hound.yml | 2 + Carthage/Checkouts/Nimble/.swiftlint.yml | 16 ++ Carthage/Checkouts/Nimble/LICENSE | 201 ++++++++++++++++++ Carthage/Checkouts/Nimble/Nimble.podspec | 4 +- .../Nimble/Nimble.xcodeproj/project.pbxproj | 79 ++++++- Carthage/Checkouts/Nimble/README.md | 107 +++++++++- .../CwlBadInstructionException.swift | 18 +- .../CwlCatchBadInstruction.swift | 41 ++-- .../CwlCatchBadInstructionPOSIX.swift | 6 +- .../CwlDarwinDefinitions.swift | 2 +- .../Nimble/Adapters/AssertionDispatcher.swift | 1 - .../Nimble/Adapters/AssertionRecorder.swift | 4 +- .../Nimble/Adapters/NMBExpectation.swift | 6 +- .../Nimble/Adapters/NMBObjCMatcher.swift | 2 +- .../Nimble/Adapters/NimbleXCTestHandler.swift | 15 +- .../Nimble/Sources/Nimble/DSL+Wait.swift | 6 +- .../Nimble/Sources/Nimble/Expectation.swift | 15 +- .../Nimble/Sources/Nimble/Expression.swift | 2 +- .../Sources/Nimble/FailureMessage.swift | 2 +- .../Sources/Nimble/Matchers/AllPass.swift | 34 ++- .../Nimble/Matchers/AsyncMatcherWrapper.swift | 19 +- .../Sources/Nimble/Matchers/BeAKindOf.swift | 26 ++- .../Nimble/Matchers/BeAnInstanceOf.swift | 20 +- .../Sources/Nimble/Matchers/BeCloseTo.swift | 4 +- .../Sources/Nimble/Matchers/BeEmpty.swift | 1 - .../Nimble/Matchers/BeGreaterThan.swift | 3 +- .../Nimble/Matchers/BeIdenticalTo.swift | 5 +- .../Sources/Nimble/Matchers/BeLessThan.swift | 2 +- .../Sources/Nimble/Matchers/BeVoid.swift | 6 +- .../Sources/Nimble/Matchers/BeginWith.swift | 4 +- .../Sources/Nimble/Matchers/Contain.swift | 6 +- .../Matchers/ContainElementSatisfying.swift | 59 +++++ .../Sources/Nimble/Matchers/EndWith.swift | 7 +- .../Sources/Nimble/Matchers/Equal.swift | 10 +- .../Sources/Nimble/Matchers/Match.swift | 2 +- .../Nimble/Matchers/MatcherProtocols.swift | 4 +- .../Nimble/Matchers/PostNotification.swift | 4 +- .../Nimble/Matchers/RaisesException.swift | 4 +- .../Nimble/Matchers/SatisfyAnyOf.swift | 23 +- .../Nimble/Matchers/ThrowAssertion.swift | 10 +- .../Sources/Nimble/Matchers/ThrowError.swift | 4 +- .../Nimble/Sources/Nimble/Utils/Async.swift | 6 +- .../Nimble/Sources/Nimble/Utils/Errors.swift | 3 +- .../Sources/Nimble/Utils/SourceLocation.swift | 8 +- .../Sources/Nimble/Utils/Stringers.swift | 11 +- .../Nimble/Sources/NimbleObjectiveC/DSL.h | 4 + .../Nimble/Sources/NimbleObjectiveC/DSL.m | 4 + .../NimbleObjectiveC/NMBExceptionCapture.h | 2 +- .../Checkouts/Nimble/Tests/LinuxMain.swift | 2 +- .../Tests/NimbleTests/AsynchronousTest.swift | 12 +- .../Helpers/XCTestCaseProvider.swift | 2 +- .../Tests/NimbleTests/Helpers/utils.swift | 2 +- .../NimbleTests/Matchers/AllPassTest.swift | 30 +-- .../NimbleTests/Matchers/BeAKindOfTest.swift | 79 +++++-- .../Matchers/BeAnInstanceOfTest.swift | 53 +++-- .../NimbleTests/Matchers/BeCloseToTest.swift | 16 +- .../NimbleTests/Matchers/BeEmptyTest.swift | 10 +- .../Matchers/BeGreaterThanTest.swift | 2 +- .../Matchers/BeIdenticalToObjectTest.swift | 8 +- .../Matchers/BeIdenticalToTest.swift | 2 +- .../NimbleTests/Matchers/BeLogicalTest.swift | 14 +- .../NimbleTests/Matchers/BeNilTest.swift | 2 +- .../ContainElementSatisfyingTest.swift | 86 ++++++++ .../NimbleTests/Matchers/ContainTest.swift | 2 +- .../NimbleTests/Matchers/EqualTest.swift | 110 +++++----- .../NimbleTests/Matchers/HaveCountTest.swift | 2 +- .../NimbleTests/Matchers/MatchTest.swift | 8 +- .../Matchers/RaisesExceptionTest.swift | 2 +- .../Matchers/SatisfyAnyOfTest.swift | 8 +- .../Matchers/ThrowAssertionTest.swift | 2 +- .../NimbleTests/Matchers/ThrowErrorTest.swift | 16 +- .../Tests/NimbleTests/SynchronousTests.swift | 25 ++- .../NimbleTests/UserDescriptionTest.swift | 18 +- .../objc/ObjCContainElementSatisfying.m | 64 ++++++ .../NimbleTests/objc/ObjCRaiseExceptionTest.m | 2 +- 79 files changed, 1077 insertions(+), 380 deletions(-) create mode 100644 Carthage/Checkouts/Nimble/.github/ISSUE_TEMPLATE create mode 100644 Carthage/Checkouts/Nimble/.github/PULL_REQUEST_TEMPLATE create mode 100644 Carthage/Checkouts/Nimble/.hound.yml create mode 100644 Carthage/Checkouts/Nimble/.swiftlint.yml create mode 100644 Carthage/Checkouts/Nimble/LICENSE create mode 100644 Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/ContainElementSatisfying.swift create mode 100644 Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/ContainElementSatisfyingTest.swift create mode 100644 Carthage/Checkouts/Nimble/Tests/NimbleTests/objc/ObjCContainElementSatisfying.m diff --git a/Cartfile.private b/Cartfile.private index 6a8fd3c..d951429 100644 --- a/Cartfile.private +++ b/Cartfile.private @@ -1,2 +1,2 @@ github "Quick/Quick" ~> 1.0.0 -github "Quick/Nimble" +github "Quick/Nimble" ~> 6.0.0 diff --git a/Cartfile.resolved b/Cartfile.resolved index 4bc14f7..19d7771 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,3 +1,3 @@ -github "Quick/Nimble" "v5.1.1" +github "Quick/Nimble" "v6.0.1" github "Quick/Quick" "v1.0.0" github "ReSwift/ReSwift" "3.0.0" diff --git a/Carthage/Checkouts/Nimble/.github/ISSUE_TEMPLATE b/Carthage/Checkouts/Nimble/.github/ISSUE_TEMPLATE new file mode 100644 index 0000000..85e591e --- /dev/null +++ b/Carthage/Checkouts/Nimble/.github/ISSUE_TEMPLATE @@ -0,0 +1,36 @@ +- [ ] I have read [CONTRIBUTING](https://github.com/Quick/Nimble/blob/master/CONTRIBUTING.md) and have done my best to follow them. + +### What did you do? + +Please replace this with what you did. + +### What did you expect to happen? + +Please replace this with what you expected to happen. + +### What actually happened instead? + +Please replace this with what happened instead. + +### Environment + +List the software versions you're using: + + - Quick: *?.?.?* + - Nimble: *?.?.?* + - Xcode Version: *?.? (????)* (Open Xcode; In menubar: Xcode > About Xcode) + - Swift Version: *?.?* (Open Xcode Preferences; Components > Toolchains. If none, use `Xcode Default`.) + +Please also mention which package manager you used and its version. Delete the +other package managers in this list: + + - Cocoapods: *?.?.?* (Use `pod --version` in Terminal) + - Carthage: *?.?* (Use `carthage version` in Terminal) + - Swift Package Manager *?.?.? (swiftpm-???)* (Use `swift build --version` in Terminal) + +### Project that demonstrates the issue + +Please link to a project we can download that reproduces the issue. Feel free +to delete this section if it's not relevant to the issue (eg - feature request). + +The project should be [short, self-contained, and correct example](http://sscce.org/). diff --git a/Carthage/Checkouts/Nimble/.github/PULL_REQUEST_TEMPLATE b/Carthage/Checkouts/Nimble/.github/PULL_REQUEST_TEMPLATE new file mode 100644 index 0000000..20e40c8 --- /dev/null +++ b/Carthage/Checkouts/Nimble/.github/PULL_REQUEST_TEMPLATE @@ -0,0 +1,14 @@ +The PR should summarize what was changed and why. Here are some questions to +help you if you're not sure: + + - What behavior was changed? + - What code was refactored / updated to support this change? + - What issues are related to this PR? Or why was this change introduced? + +Checklist - While not every PR needs it, new features should consider this list: + + - [ ] Does this have tests? + - [ ] Does this have documentation? + - [ ] Does this break the public API (Requires major version bump)? + - [ ] Is this a new feature (Requires minor version bump)? + diff --git a/Carthage/Checkouts/Nimble/.hound.yml b/Carthage/Checkouts/Nimble/.hound.yml new file mode 100644 index 0000000..b867fd9 --- /dev/null +++ b/Carthage/Checkouts/Nimble/.hound.yml @@ -0,0 +1,2 @@ +swift: + config_file: .swiftlint.yml diff --git a/Carthage/Checkouts/Nimble/.swiftlint.yml b/Carthage/Checkouts/Nimble/.swiftlint.yml new file mode 100644 index 0000000..d412589 --- /dev/null +++ b/Carthage/Checkouts/Nimble/.swiftlint.yml @@ -0,0 +1,16 @@ +disabled_rules: + - line_length + - todo + - variable_name + - force_try + - function_parameter_count + - force_cast + - type_name + - large_tuple + +included: + - Sources + - Tests + +trailing_comma: + mandatory_comma: true diff --git a/Carthage/Checkouts/Nimble/LICENSE b/Carthage/Checkouts/Nimble/LICENSE new file mode 100644 index 0000000..82b84bf --- /dev/null +++ b/Carthage/Checkouts/Nimble/LICENSE @@ -0,0 +1,201 @@ +Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2016 Quick Team + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/Carthage/Checkouts/Nimble/Nimble.podspec b/Carthage/Checkouts/Nimble/Nimble.podspec index 8ca36a1..d9ad8a0 100644 --- a/Carthage/Checkouts/Nimble/Nimble.podspec +++ b/Carthage/Checkouts/Nimble/Nimble.podspec @@ -1,12 +1,12 @@ Pod::Spec.new do |s| s.name = "Nimble" - s.version = "5.1.1" + s.version = "6.0.1" s.summary = "A Matcher Framework for Swift and Objective-C" s.description = <<-DESC Use Nimble to express the expected outcomes of Swift or Objective-C expressions. Inspired by Cedar. DESC s.homepage = "https://github.com/Quick/Nimble" - s.license = { :type => "Apache 2.0", :file => "LICENSE.md" } + s.license = { :type => "Apache 2.0", :file => "LICENSE" } s.author = "Quick Contributors" s.ios.deployment_target = "8.0" s.osx.deployment_target = "10.10" diff --git a/Carthage/Checkouts/Nimble/Nimble.xcodeproj/project.pbxproj b/Carthage/Checkouts/Nimble/Nimble.xcodeproj/project.pbxproj index 7c2c084..54f1cce 100644 --- a/Carthage/Checkouts/Nimble/Nimble.xcodeproj/project.pbxproj +++ b/Carthage/Checkouts/Nimble/Nimble.xcodeproj/project.pbxproj @@ -286,6 +286,15 @@ 6CAEDD0A1CAEA86F003F1584 /* LinuxSupport.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CAEDD091CAEA86F003F1584 /* LinuxSupport.swift */; }; 6CAEDD0B1CAEA86F003F1584 /* LinuxSupport.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CAEDD091CAEA86F003F1584 /* LinuxSupport.swift */; }; 6CAEDD0C1CAEA86F003F1584 /* LinuxSupport.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6CAEDD091CAEA86F003F1584 /* LinuxSupport.swift */; }; + 7B13BA061DD360AA00C9098C /* ContainElementSatisfying.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B13BA051DD360AA00C9098C /* ContainElementSatisfying.swift */; }; + 7B13BA0B1DD361D200C9098C /* ContainElementSatisfying.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B13BA051DD360AA00C9098C /* ContainElementSatisfying.swift */; }; + 7B13BA0C1DD361D300C9098C /* ContainElementSatisfying.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B13BA051DD360AA00C9098C /* ContainElementSatisfying.swift */; }; + 7B13BA0D1DD361DE00C9098C /* ContainElementSatisfyingTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B13BA091DD360DE00C9098C /* ContainElementSatisfyingTest.swift */; }; + 7B13BA0E1DD361DF00C9098C /* ContainElementSatisfyingTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B13BA091DD360DE00C9098C /* ContainElementSatisfyingTest.swift */; }; + 7B13BA0F1DD361DF00C9098C /* ContainElementSatisfyingTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B13BA091DD360DE00C9098C /* ContainElementSatisfyingTest.swift */; }; + 7B13BA101DD361EA00C9098C /* ObjCContainElementSatisfying.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B13BA071DD360C300C9098C /* ObjCContainElementSatisfying.m */; }; + 7B13BA111DD361EB00C9098C /* ObjCContainElementSatisfying.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B13BA071DD360C300C9098C /* ObjCContainElementSatisfying.m */; }; + 7B13BA121DD361EB00C9098C /* ObjCContainElementSatisfying.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B13BA071DD360C300C9098C /* ObjCContainElementSatisfying.m */; }; 7B5358BA1C3846C900A23FAA /* SatisfyAnyOfTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B5358B91C3846C900A23FAA /* SatisfyAnyOfTest.swift */; }; 7B5358BB1C3846C900A23FAA /* SatisfyAnyOfTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B5358B91C3846C900A23FAA /* SatisfyAnyOfTest.swift */; }; 7B5358BC1C3846C900A23FAA /* SatisfyAnyOfTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B5358B91C3846C900A23FAA /* SatisfyAnyOfTest.swift */; }; @@ -410,28 +419,28 @@ containerPortal = 1F1A74201940169200FFFC47 /* Project object */; proxyType = 1; remoteGlobalIDString = 1F925EAC195C0D6300ED456B; - remoteInfo = "Nimble-OSX"; + remoteInfo = "Nimble-macOS"; }; 1F9B7BFD1968AD760094EB8F /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 1F1A74201940169200FFFC47 /* Project object */; proxyType = 1; remoteGlobalIDString = 1F925EAC195C0D6300ED456B; - remoteInfo = "Nimble-OSX"; + remoteInfo = "Nimble-macOS"; }; 1F9B7BFF1968AD760094EB8F /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 1F1A74201940169200FFFC47 /* Project object */; proxyType = 1; remoteGlobalIDString = 1F925EAC195C0D6300ED456B; - remoteInfo = "Nimble-OSX"; + remoteInfo = "Nimble-macOS"; }; 1F9B7C011968AD820094EB8F /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 1F1A74201940169200FFFC47 /* Project object */; proxyType = 1; remoteGlobalIDString = 1F925EAC195C0D6300ED456B; - remoteInfo = "Nimble-OSX"; + remoteInfo = "Nimble-macOS"; }; /* End PBXContainerItemProxy section */ @@ -543,6 +552,9 @@ 472FD1361B9E094B00C7B8DA /* HaveCountTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HaveCountTest.swift; sourceTree = ""; }; 4793854C1BA0BB2500296F85 /* ObjCHaveCount.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ObjCHaveCount.m; sourceTree = ""; }; 6CAEDD091CAEA86F003F1584 /* LinuxSupport.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LinuxSupport.swift; sourceTree = ""; }; + 7B13BA051DD360AA00C9098C /* ContainElementSatisfying.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ContainElementSatisfying.swift; sourceTree = ""; }; + 7B13BA071DD360C300C9098C /* ObjCContainElementSatisfying.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ObjCContainElementSatisfying.m; sourceTree = ""; }; + 7B13BA091DD360DE00C9098C /* ContainElementSatisfyingTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ContainElementSatisfyingTest.swift; sourceTree = ""; }; 7B5358B91C3846C900A23FAA /* SatisfyAnyOfTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SatisfyAnyOfTest.swift; sourceTree = ""; }; 7B5358BD1C38479700A23FAA /* SatisfyAnyOf.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SatisfyAnyOf.swift; sourceTree = ""; }; 7B5358C11C39155600A23FAA /* ObjCSatisfyAnyOfTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ObjCSatisfyAnyOfTest.m; sourceTree = ""; }; @@ -745,6 +757,7 @@ 1F925EEE195C136500ED456B /* BeLogicalTest.swift */, 1F925EF8195C175000ED456B /* BeNilTest.swift */, 1F91DD2C1C74BF36002C309F /* BeVoidTest.swift */, + 7B13BA091DD360DE00C9098C /* ContainElementSatisfyingTest.swift */, 1F925F01195C189500ED456B /* ContainTest.swift */, 1F925EFE195C187600ED456B /* EndWithTest.swift */, 1F925F04195C18B700ED456B /* EqualTest.swift */, @@ -793,6 +806,7 @@ 1FD8CD171968AB07008ED995 /* BeLogical.swift */, 1FD8CD181968AB07008ED995 /* BeNil.swift */, 1F91DD301C74BF61002C309F /* BeVoid.swift */, + 7B13BA051DD360AA00C9098C /* ContainElementSatisfying.swift */, 1FD8CD1A1968AB07008ED995 /* Contain.swift */, 1FD8CD1B1968AB07008ED995 /* EndWith.swift */, 1FD8CD1C1968AB07008ED995 /* Equal.swift */, @@ -843,6 +857,7 @@ 1F4A56901A3B344A009E1637 /* ObjCBeNilTest.m */, 1F4A568A1A3B3407009E1637 /* ObjCBeTrueTest.m */, 1F4A56841A3B33A0009E1637 /* ObjCBeTruthyTest.m */, + 7B13BA071DD360C300C9098C /* ObjCContainElementSatisfying.m */, 1F4A56931A3B346F009E1637 /* ObjCContainTest.m */, 1F4A56961A3B34AA009E1637 /* ObjCEndWithTest.m */, 1F4A56991A3B3539009E1637 /* ObjCEqualTest.m */, @@ -939,6 +954,7 @@ 1F1A74251940169200FFFC47 /* Frameworks */, 1F1A74261940169200FFFC47 /* Headers */, 1F1A74271940169200FFFC47 /* Resources */, + 36D948361E0C6F4E0088F9E9 /* ShellScript */, ); buildRules = ( ); @@ -978,6 +994,7 @@ 1F5DF1511BDCA0CE00C3A531 /* Frameworks */, 1F5DF1521BDCA0CE00C3A531 /* Headers */, 1F5DF1531BDCA0CE00C3A531 /* Resources */, + 36D948371E0C6F590088F9E9 /* ShellScript */, ); buildRules = ( ); @@ -1014,13 +1031,14 @@ 1F925EA9195C0D6300ED456B /* Frameworks */, 1F925EAA195C0D6300ED456B /* Headers */, 1F925EAB195C0D6300ED456B /* Resources */, + 36D948351E0C6F420088F9E9 /* ShellScript */, ); buildRules = ( ); dependencies = ( ); name = "Nimble-macOS"; - productName = "Nimble-OSX"; + productName = "Nimble-macOS"; productReference = 1F925EAD195C0D6300ED456B /* Nimble.framework */; productType = "com.apple.product-type.framework"; }; @@ -1150,6 +1168,48 @@ }; /* End PBXResourcesBuildPhase section */ +/* Begin PBXShellScriptBuildPhase section */ + 36D948351E0C6F420088F9E9 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "if which swiftlint >/dev/null; then\n swiftlint\nfi"; + }; + 36D948361E0C6F4E0088F9E9 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "if which swiftlint >/dev/null; then\n swiftlint\nfi"; + }; + 36D948371E0C6F590088F9E9 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "if which swiftlint >/dev/null; then\n swiftlint\nfi"; + }; +/* End PBXShellScriptBuildPhase section */ + /* Begin PBXSourcesBuildPhase section */ 1F1A74241940169200FFFC47 /* Sources */ = { isa = PBXSourcesBuildPhase; @@ -1173,6 +1233,7 @@ 1FD8CD3E1968AB07008ED995 /* BeAKindOf.swift in Sources */, DDB4D5ED19FE43C200E9D9FE /* Match.swift in Sources */, 1F91DD311C74BF61002C309F /* BeVoid.swift in Sources */, + 7B13BA0B1DD361D200C9098C /* ContainElementSatisfying.swift in Sources */, 1FCF91531C61C8A400B15DCB /* PostNotification.swift in Sources */, 1FD8CD2E1968AB07008ED995 /* AssertionRecorder.swift in Sources */, 29EA59661B551EE6002D767E /* ThrowError.swift in Sources */, @@ -1229,6 +1290,7 @@ DDB4D5F019FE442800E9D9FE /* MatchTest.swift in Sources */, 1F4A56731A3B3210009E1637 /* ObjCBeginWithTest.m in Sources */, 1F4A56821A3B336F009E1637 /* ObjCBeLessThanOrEqualToTest.m in Sources */, + 7B13BA0E1DD361DF00C9098C /* ContainElementSatisfyingTest.swift in Sources */, 1F925F02195C189500ED456B /* ContainTest.swift in Sources */, 1F4A56881A3B33CB009E1637 /* ObjCBeFalsyTest.m in Sources */, 1F4A568E1A3B342B009E1637 /* ObjCBeFalseTest.m in Sources */, @@ -1251,6 +1313,7 @@ 1F8A37B01B7C5042001C8357 /* ObjCSyncTest.m in Sources */, 1F4A56941A3B346F009E1637 /* ObjCContainTest.m in Sources */, 1F299EAB19627B2D002641AF /* BeEmptyTest.swift in Sources */, + 7B13BA111DD361EB00C9098C /* ObjCContainElementSatisfying.m in Sources */, 1F925EF6195C147800ED456B /* BeCloseToTest.swift in Sources */, 1F4A56791A3B32E3009E1637 /* ObjCBeGreaterThanOrEqualToTest.m in Sources */, AE7ADE491C80C00D00B94CD3 /* MatchErrorTest.swift in Sources */, @@ -1331,6 +1394,7 @@ 1F5DF1701BDCA0F500C3A531 /* DSL.swift in Sources */, 1F5DF1721BDCA0F500C3A531 /* Expectation.swift in Sources */, 7B5358C01C38479700A23FAA /* SatisfyAnyOf.swift in Sources */, + 7B13BA0C1DD361D300C9098C /* ContainElementSatisfying.swift in Sources */, 1F5DF18B1BDCA0F500C3A531 /* Functional.swift in Sources */, 1F5DF1871BDCA0F500C3A531 /* Match.swift in Sources */, ); @@ -1355,7 +1419,9 @@ 1F5DF1AB1BDCA10200C3A531 /* ThrowErrorTest.swift in Sources */, CD79C9A91D2CC848004B6F9A /* ObjCBeKindOfTest.m in Sources */, 1F5DF1A51BDCA10200C3A531 /* ContainTest.swift in Sources */, + 7B13BA121DD361EB00C9098C /* ObjCContainElementSatisfying.m in Sources */, AE7ADE4B1C80C00D00B94CD3 /* MatchErrorTest.swift in Sources */, + 7B13BA0F1DD361DF00C9098C /* ContainElementSatisfyingTest.swift in Sources */, CD79C9B31D2CC848004B6F9A /* ObjCMatchTest.m in Sources */, 1F5DF19E1BDCA10200C3A531 /* BeGreaterThanTest.swift in Sources */, 1F5DF1A21BDCA10200C3A531 /* BeLessThanTest.swift in Sources */, @@ -1424,6 +1490,7 @@ DDB1BC7A1A92235600F743C3 /* AllPass.swift in Sources */, 1FD8CD3F1968AB07008ED995 /* BeAKindOf.swift in Sources */, 1FD8CD2F1968AB07008ED995 /* AssertionRecorder.swift in Sources */, + 7B13BA061DD360AA00C9098C /* ContainElementSatisfying.swift in Sources */, 1F91DD321C74BF61002C309F /* BeVoid.swift in Sources */, 1FCF91541C61C8A400B15DCB /* PostNotification.swift in Sources */, DDB4D5EE19FE43C200E9D9FE /* Match.swift in Sources */, @@ -1480,6 +1547,7 @@ DDB4D5F119FE442800E9D9FE /* MatchTest.swift in Sources */, 1F4A56741A3B3210009E1637 /* ObjCBeginWithTest.m in Sources */, 1F4A56831A3B336F009E1637 /* ObjCBeLessThanOrEqualToTest.m in Sources */, + 7B13BA0D1DD361DE00C9098C /* ContainElementSatisfyingTest.swift in Sources */, 1F925F03195C189500ED456B /* ContainTest.swift in Sources */, 1F4A56891A3B33CB009E1637 /* ObjCBeFalsyTest.m in Sources */, 1F4A568F1A3B342B009E1637 /* ObjCBeFalseTest.m in Sources */, @@ -1502,6 +1570,7 @@ 1F8A37B11B7C5042001C8357 /* ObjCSyncTest.m in Sources */, 1F4A56951A3B346F009E1637 /* ObjCContainTest.m in Sources */, 1F299EAC19627B2D002641AF /* BeEmptyTest.swift in Sources */, + 7B13BA101DD361EA00C9098C /* ObjCContainElementSatisfying.m in Sources */, 1F925EF7195C147800ED456B /* BeCloseToTest.swift in Sources */, 1F4A567A1A3B32E3009E1637 /* ObjCBeGreaterThanOrEqualToTest.m in Sources */, AE7ADE4A1C80C00D00B94CD3 /* MatchErrorTest.swift in Sources */, diff --git a/Carthage/Checkouts/Nimble/README.md b/Carthage/Checkouts/Nimble/README.md index 684255e..ecf9501 100644 --- a/Carthage/Checkouts/Nimble/README.md +++ b/Carthage/Checkouts/Nimble/README.md @@ -23,7 +23,7 @@ expect(ocean.isClean).toEventually(beTruthy()) - [Some Background: Expressing Outcomes Using Assertions in XCTest](#some-background-expressing-outcomes-using-assertions-in-xctest) - [Nimble: Expectations Using `expect(...).to`](#nimble-expectations-using-expectto) - [Custom Failure Messages](#custom-failure-messages) - - [Type Checking](#type-checking) + - [Type Safety](#type-safety) - [Operator Overloads](#operator-overloads) - [Lazily Computed Values](#lazily-computed-values) - [C Primitives](#c-primitives) @@ -31,6 +31,7 @@ expect(ocean.isClean).toEventually(beTruthy()) - [Objective-C Support](#objective-c-support) - [Disabling Objective-C Shorthand](#disabling-objective-c-shorthand) - [Built-in Matcher Functions](#built-in-matcher-functions) + - [Type Checking](#type-checking) - [Equivalence](#equivalence) - [Identity](#identity) - [Comparisons](#comparisons) @@ -164,7 +165,7 @@ expect(@(1+1)).toWithDescription(equal(@3), @"Make sure libKindergartenMath is l // expected to equal <3.0000>, got <2.0000> ``` -## Type Checking +## Type Safety Nimble makes sure you don't compare two types that don't match: @@ -489,6 +490,67 @@ NMB_expect(^{ return seagull.squawk; }, __FILE__, __LINE__).to(NMB_equal(@"Squee Nimble includes a wide variety of matcher functions. +## Type Checking + +Nimble supports checking the type membership of any kind of object, whether +Objective-C conformant or not: + +```swift +// Swift + +protocol SomeProtocol{} +class SomeClassConformingToProtocol: SomeProtocol{} +struct SomeStructConformingToProtocol: SomeProtocol{} + +// The following tests pass +expect(1).to(beKindOf(Int.self)) +expect("turtle").to(beKindOf(String.self)) + +let classObject = SomeClassConformingToProtocol() +expect(classObject).to(beKindOf(SomeProtocol.self)) +expect(classObject).to(beKindOf(SomeClassConformingToProtocol.self)) +expect(classObject).toNot(beKindOf(SomeStructConformingToProtocol.self)) + +let structObject = SomeStructConformingToProtocol() +expect(structObject).to(beKindOf(SomeProtocol.self)) +expect(structObject).to(beKindOf(SomeStructConformingToProtocol.self)) +expect(structObject).toNot(beKindOf(SomeClassConformingToProtocol.self)) +``` + +```objc +// Objective-C + +// The following tests pass +NSMutableArray *array = [NSMutableArray array]; +expect(array).to(beAKindOf([NSArray class])); +expect(@1).toNot(beAKindOf([NSNull class])); +``` + +Objects can be tested for their exact types using the `beAnInstanceOf` matcher: +```swift +// Swift + +protocol SomeProtocol{} +class SomeClassConformingToProtocol: SomeProtocol{} +struct SomeStructConformingToProtocol: SomeProtocol{} + +// Unlike the 'beKindOf' matcher, the 'beAnInstanceOf' matcher only +// passes if the object is the EXACT type requested. The following +// tests pass -- note its behavior when working in an inheritance hierarchy. +expect(1).to(beAnInstanceOf(Int.self)) +expect("turtle").to(beAnInstanceOf(String.self)) + +let classObject = SomeClassConformingToProtocol() +expect(classObject).toNot(beAnInstanceOf(SomeProtocol.self)) +expect(classObject).to(beAnInstanceOf(SomeClassConformingToProtocol.self)) +expect(classObject).toNot(beAnInstanceOf(SomeStructConformingToProtocol.self)) + +let structObject = SomeStructConformingToProtocol() +expect(structObject).toNot(beAnInstanceOf(SomeProtocol.self)) +expect(structObject).to(beAnInstanceOf(SomeStructConformingToProtocol.self)) +expect(structObject).toNot(beAnInstanceOf(SomeClassConformingToProtocol.self)) +```` + ## Equivalence ```swift @@ -911,6 +973,47 @@ expect(actual).to(endWith(expected)); Like `contain`, in Objective-C `beginWith` and `endWith` only support a single argument [for now](https://github.com/Quick/Nimble/issues/27). +For code that returns collections of complex objects without a strict +ordering, there is the `containElementSatisfying` matcher: + +```swift +struct Turtle { + var color: String! +} + +var turtles = functionThatReturnsSomeTurtlesInAnyOrder() + +// This set of matchers passes whether the array is [{color: "blue"}, {color: "green"}] +// or [{color: "green"}, {color: "blue"}] +expect(turtles).to(containElementSatisfying({ turtle in + return turtle.color == "green" +})) +expect(turtles).to(containElementSatisfying({ turtle in + return turtle.color == "blue" +}, "that is a turtle with color 'blue'")) + +// The second matcher will incorporate the provided string in the error message +// should it fail +``` + +```objc +@interface Turtle: NSObject +@property(nonatomic) NSString *color; +@end +@implementation Turtle @end + +NSArray *turtles = functionThatReturnsSomeTurtlesInAnyOrder(); + +// This set of matchers passes whether the array is [{color: "blue"}, {color: "green"}] +// or [{color: "green"}, {color: "blue"}] +expect(turtles).to(containElementSatisfying(^BOOL(id object) { + return [turtle.color isEqualToString:@"green"]; +})); +expect(turtles).to(containElementSatisfying(^BOOL(id object) { + return [turtle.color isEqualToString:@"blue"]; +})); +``` + ## Strings ```swift diff --git a/Carthage/Checkouts/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlBadInstructionException.swift b/Carthage/Checkouts/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlBadInstructionException.swift index 2fa67c9..5bf2794 100644 --- a/Carthage/Checkouts/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlBadInstructionException.swift +++ b/Carthage/Checkouts/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlBadInstructionException.swift @@ -27,43 +27,43 @@ private func raiseBadInstructionException() { /// A simple NSException subclass. It's not required to subclass NSException (since the exception type is represented in the name) but this helps for identifying the exception through runtime type. @objc public class BadInstructionException: NSException { static var name: String = "com.cocoawithlove.BadInstruction" - + init() { super.init(name: NSExceptionName(rawValue: BadInstructionException.name), reason: nil, userInfo: nil) } - + required public init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) } - + /// An Objective-C callable function, invoked from the `mach_exc_server` callback function `catch_mach_exception_raise_state` to push the `raiseBadInstructionException` function onto the stack. public class func catch_mach_exception_raise_state(_ exception_port: mach_port_t, exception: exception_type_t, code: UnsafePointer, codeCnt: mach_msg_type_number_t, flavor: UnsafeMutablePointer, old_state: UnsafePointer, old_stateCnt: mach_msg_type_number_t, new_state: thread_state_t, new_stateCnt: UnsafeMutablePointer) -> kern_return_t { - + #if arch(x86_64) // Make sure we've been given enough memory if old_stateCnt != x86_THREAD_STATE64_COUNT || new_stateCnt.pointee < x86_THREAD_STATE64_COUNT { return KERN_INVALID_ARGUMENT } - + // Read the old thread state var state = old_state.withMemoryRebound(to: x86_thread_state64_t.self, capacity: 1) { return $0.pointee } - + // 1. Decrement the stack pointer state.__rsp -= __uint64_t(MemoryLayout.size) - + // 2. Save the old Instruction Pointer to the stack. if let pointer = UnsafeMutablePointer<__uint64_t>(bitPattern: UInt(state.__rsp)) { pointer.pointee = state.__rip } else { return KERN_INVALID_ARGUMENT } - + // 3. Set the Instruction Pointer to the new function's address var f: @convention(c) () -> Void = raiseBadInstructionException withUnsafePointer(to: &f) { state.__rip = $0.withMemoryRebound(to: __uint64_t.self, capacity: 1) { return $0.pointee } } - + // Write the new thread state new_state.withMemoryRebound(to: x86_thread_state64_t.self, capacity: 1) { $0.pointee = state } new_stateCnt.pointee = x86_THREAD_STATE64_COUNT diff --git a/Carthage/Checkouts/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlCatchBadInstruction.swift b/Carthage/Checkouts/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlCatchBadInstruction.swift index ab460b3..4d82f7a 100644 --- a/Carthage/Checkouts/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlCatchBadInstruction.swift +++ b/Carthage/Checkouts/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlCatchBadInstruction.swift @@ -21,10 +21,10 @@ import Foundation #if arch(x86_64) - + private enum PthreadError: Error { case code(Int32) } private enum MachExcServer: Error { case code(kern_return_t) } - + /// A quick function for converting Mach error results into Swift errors private func kernCheck(_ f: () -> Int32) throws { let r = f() @@ -32,7 +32,7 @@ import Foundation throw NSError(domain: NSMachErrorDomain, code: Int(r), userInfo: nil) } } - + extension execTypesCountTuple { mutating func pointer(in block: (UnsafeMutablePointer) -> R) -> R { return withUnsafeMutablePointer(to: &self) { p -> R in @@ -42,7 +42,7 @@ import Foundation } } } - + extension request_mach_exception_raise_t { mutating func withMsgHeaderPointer(in block: (UnsafeMutablePointer) -> R) -> R { return withUnsafeMutablePointer(to: &self) { p -> R in @@ -52,7 +52,7 @@ import Foundation } } } - + extension reply_mach_exception_raise_state_t { mutating func withMsgHeaderPointer(in block: (UnsafeMutablePointer) -> R) -> R { return withUnsafeMutablePointer(to: &self) { p -> R in @@ -62,7 +62,7 @@ import Foundation } } } - + /// A structure used to store context associated with the Mach message port private struct MachContext { var masks = execTypesCountTuple() @@ -72,7 +72,7 @@ import Foundation var flavors = execTypesCountTuple() var currentExceptionPort: mach_port_t = 0 var handlerThread: pthread_t? = nil - + mutating func withUnsafeMutablePointers(in block: (UnsafeMutablePointer, UnsafeMutablePointer, UnsafeMutablePointer, UnsafeMutablePointer) -> R) -> R { return masks.pointer { masksPtr in return ports.pointer { portsPtr in @@ -85,13 +85,13 @@ import Foundation } } } - + /// A function for receiving mach messages and parsing the first with mach_exc_server (and if any others are received, throwing them away). private func machMessageHandler(_ arg: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer? { let context = arg.assumingMemoryBound(to: MachContext.self).pointee var request = request_mach_exception_raise_t() var reply = reply_mach_exception_raise_state_t() - + var handledfirstException = false repeat { do { // Request the next mach message from the port @@ -100,26 +100,26 @@ import Foundation try kernCheck { request.withMsgHeaderPointer { requestPtr in mach_msg(requestPtr, MACH_RCV_MSG | MACH_RCV_INTERRUPT, 0, request.Head.msgh_size, context.currentExceptionPort, 0, UInt32(MACH_PORT_NULL)) } } - + // Prepare the reply structure reply.Head.msgh_bits = MACH_MSGH_BITS(MACH_MSGH_BITS_REMOTE(request.Head.msgh_bits), 0) reply.Head.msgh_local_port = UInt32(MACH_PORT_NULL) reply.Head.msgh_remote_port = request.Head.msgh_remote_port reply.Head.msgh_size = UInt32(MemoryLayout.size) reply.NDR = NDR_record - + if !handledfirstException { // Use the MiG generated server to invoke our handler for the request and fill in the rest of the reply structure guard request.withMsgHeaderPointer(in: { requestPtr in reply.withMsgHeaderPointer { replyPtr in mach_exc_server(requestPtr, replyPtr) } }) != 0 else { throw MachExcServer.code(reply.RetCode) } - + handledfirstException = true } else { // If multiple fatal errors occur, don't handle subsquent errors (let the program crash) reply.RetCode = KERN_FAILURE } - + // Send the reply try kernCheck { reply.withMsgHeaderPointer { replyPtr in mach_msg(replyPtr, MACH_SEND_MSG, reply.Head.msgh_size, 0, UInt32(MACH_PORT_NULL), 0, UInt32(MACH_PORT_NULL)) @@ -133,7 +133,7 @@ import Foundation fatalError("Mach message error: \(error)") } } while true } - + /// Run the provided block. If a mach "BAD_INSTRUCTION" exception is raised, catch it and return a BadInstructionException (which captures stack information about the throw site, if desired). Otherwise return nil. /// NOTE: This function is only intended for use in test harnesses – use in a distributed build is almost certainly a bad choice. If a "BAD_INSTRUCTION" exception is raised, the block will be exited before completion via Objective-C exception. The risks associated with an Objective-C exception apply here: most Swift/Objective-C functions are *not* exception-safe. Memory may be leaked and the program will not necessarily be left in a safe state. /// - parameter block: a function without parameters that will be run @@ -150,7 +150,7 @@ import Foundation pthread_join(handlerThread!, nil) } } - + try kernCheck { // 1. Create the mach port mach_port_allocate(mach_task_self_, MACH_PORT_RIGHT_RECEIVE, &context.currentExceptionPort) @@ -159,27 +159,27 @@ import Foundation // 7. Cleanup the mach port mach_port_destroy(mach_task_self_, context.currentExceptionPort) } - + try kernCheck { // 2. Configure the mach port mach_port_insert_right(mach_task_self_, context.currentExceptionPort, context.currentExceptionPort, MACH_MSG_TYPE_MAKE_SEND) } - + try kernCheck { context.withUnsafeMutablePointers { masksPtr, portsPtr, behaviorsPtr, flavorsPtr in // 3. Apply the mach port as the handler for this thread thread_swap_exception_ports(mach_thread_self(), EXC_MASK_BAD_INSTRUCTION, context.currentExceptionPort, Int32(bitPattern: UInt32(EXCEPTION_STATE) | MACH_EXCEPTION_CODES), x86_THREAD_STATE64, masksPtr, &context.count, portsPtr, behaviorsPtr, flavorsPtr) } } - + defer { context.withUnsafeMutablePointers { masksPtr, portsPtr, behaviorsPtr, flavorsPtr in // 6. Unapply the mach port _ = thread_swap_exception_ports(mach_thread_self(), EXC_MASK_BAD_INSTRUCTION, 0, EXCEPTION_DEFAULT, THREAD_STATE_NONE, masksPtr, &context.count, portsPtr, behaviorsPtr, flavorsPtr) } } - + try withUnsafeMutablePointer(to: &context) { c throws in // 4. Create the thread let e = pthread_create(&handlerThread, nil, machMessageHandler, c) guard e == 0 else { throw PthreadError.code(e) } - + // 5. Run the block result = BadInstructionException.catchException(in: block) } @@ -191,4 +191,3 @@ import Foundation } #endif - diff --git a/Carthage/Checkouts/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlCatchBadInstructionPOSIX.swift b/Carthage/Checkouts/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlCatchBadInstructionPOSIX.swift index b3afb12..bf30908 100644 --- a/Carthage/Checkouts/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlCatchBadInstructionPOSIX.swift +++ b/Carthage/Checkouts/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlCatchBadInstructionPOSIX.swift @@ -34,7 +34,7 @@ import Foundation // * Plus all of the same caveats as the Mach exceptions version (doesn't play well with other handlers, probably leaks ARC memory, etc) // Treat it like a loaded shotgun. Don't point it at your face. -private var env = jmp_buf(0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0) +private var env = jmp_buf(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) private func triggerLongJmp() { longjmp(&env.0, 1) @@ -72,7 +72,7 @@ public func catchBadInstruction( block: () -> Void) -> BadInstructionException? var sigActionPrev = sigaction() let action = __sigaction_u(__sa_sigaction: sigIllHandler) var sigActionNew = sigaction(__sigaction_u: action, sa_mask: sigset_t(), sa_flags: SA_SIGINFO) - + // Install the signal action if sigaction(SIGILL, &sigActionNew, &sigActionPrev) != 0 { fatalError("Sigaction error: \(errno)") @@ -93,7 +93,7 @@ public func catchBadInstruction( block: () -> Void) -> BadInstructionException? // Run the block block() - + return nil } diff --git a/Carthage/Checkouts/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlDarwinDefinitions.swift b/Carthage/Checkouts/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlDarwinDefinitions.swift index 12a6b9f..35e1ad5 100644 --- a/Carthage/Checkouts/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlDarwinDefinitions.swift +++ b/Carthage/Checkouts/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlDarwinDefinitions.swift @@ -55,7 +55,7 @@ let EXC_TYPES_COUNT = 14 struct execTypesCountTuple { // From /usr/include/mach/i386/exception.h // #define EXC_TYPES_COUNT 14 /* incl. illegal exception 0 */ - var value: (T,T,T,T,T,T,T,T,T,T,T,T,T,T) = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) + var value: (T, T, T, T, T, T, T, T, T, T, T, T, T, T) = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) init() { } } diff --git a/Carthage/Checkouts/Nimble/Sources/Nimble/Adapters/AssertionDispatcher.swift b/Carthage/Checkouts/Nimble/Sources/Nimble/Adapters/AssertionDispatcher.swift index 2e30f61..94a9030 100644 --- a/Carthage/Checkouts/Nimble/Sources/Nimble/Adapters/AssertionDispatcher.swift +++ b/Carthage/Checkouts/Nimble/Sources/Nimble/Adapters/AssertionDispatcher.swift @@ -1,4 +1,3 @@ - /// AssertionDispatcher allows multiple AssertionHandlers to receive /// assertion messages. /// diff --git a/Carthage/Checkouts/Nimble/Sources/Nimble/Adapters/AssertionRecorder.swift b/Carthage/Checkouts/Nimble/Sources/Nimble/Adapters/AssertionRecorder.swift index 7d0bab2..740c392 100644 --- a/Carthage/Checkouts/Nimble/Sources/Nimble/Adapters/AssertionRecorder.swift +++ b/Carthage/Checkouts/Nimble/Sources/Nimble/Adapters/AssertionRecorder.swift @@ -22,7 +22,7 @@ public struct AssertionRecord: CustomStringConvertible { /// This is useful for testing failure messages for matchers. /// /// @see AssertionHandler -public class AssertionRecorder : AssertionHandler { +public class AssertionRecorder: AssertionHandler { /// All the assertions that were captured by this recorder public var assertions = [AssertionRecord]() @@ -43,7 +43,7 @@ public class AssertionRecorder : AssertionHandler { /// Once the closure finishes, then the original Nimble assertion handler is restored. /// /// @see AssertionHandler -public func withAssertionHandler(_ tempAssertionHandler: AssertionHandler, closure: @escaping () throws -> Void) { +public func withAssertionHandler(_ tempAssertionHandler: AssertionHandler, closure: () throws -> Void) { let environment = NimbleEnvironment.activeInstance let oldRecorder = environment.assertionHandler let capturer = NMBExceptionCapture(handler: nil, finally: ({ diff --git a/Carthage/Checkouts/Nimble/Sources/Nimble/Adapters/NMBExpectation.swift b/Carthage/Checkouts/Nimble/Sources/Nimble/Adapters/NMBExpectation.swift index 47d4eed..1c51cd7 100644 --- a/Carthage/Checkouts/Nimble/Sources/Nimble/Adapters/NMBExpectation.swift +++ b/Carthage/Checkouts/Nimble/Sources/Nimble/Adapters/NMBExpectation.swift @@ -2,7 +2,7 @@ import Foundation #if _runtime(_ObjC) -internal struct ObjCMatcherWrapper : Matcher { +internal struct ObjCMatcherWrapper: Matcher { let matcher: NMBMatcher func matches(_ actualExpression: Expression, failureMessage: FailureMessage) -> Bool { @@ -21,7 +21,7 @@ internal struct ObjCMatcherWrapper : Matcher { } // Equivalent to Expectation, but for Nimble's Objective-C interface -public class NMBExpectation : NSObject { +public class NMBExpectation: NSObject { internal let _actualBlock: () -> NSObject! internal var _negative: Bool internal let _file: FileString @@ -36,7 +36,7 @@ public class NMBExpectation : NSObject { } private var expectValue: Expectation { - return expect(_file, line: _line){ + return expect(_file, line: _line) { self._actualBlock() as NSObject? } } diff --git a/Carthage/Checkouts/Nimble/Sources/Nimble/Adapters/NMBObjCMatcher.swift b/Carthage/Checkouts/Nimble/Sources/Nimble/Adapters/NMBObjCMatcher.swift index c609f69..19a4567 100644 --- a/Carthage/Checkouts/Nimble/Sources/Nimble/Adapters/NMBObjCMatcher.swift +++ b/Carthage/Checkouts/Nimble/Sources/Nimble/Adapters/NMBObjCMatcher.swift @@ -5,7 +5,7 @@ import Foundation public typealias MatcherBlock = (_ actualExpression: Expression, _ failureMessage: FailureMessage) -> Bool public typealias FullMatcherBlock = (_ actualExpression: Expression, _ failureMessage: FailureMessage, _ shouldNotMatch: Bool) -> Bool -public class NMBObjCMatcher : NSObject, NMBMatcher { +public class NMBObjCMatcher: NSObject, NMBMatcher { let _match: MatcherBlock let _doesNotMatch: MatcherBlock let canMatchNil: Bool diff --git a/Carthage/Checkouts/Nimble/Sources/Nimble/Adapters/NimbleXCTestHandler.swift b/Carthage/Checkouts/Nimble/Sources/Nimble/Adapters/NimbleXCTestHandler.swift index 1aba8bc..78e6dd9 100644 --- a/Carthage/Checkouts/Nimble/Sources/Nimble/Adapters/NimbleXCTestHandler.swift +++ b/Carthage/Checkouts/Nimble/Sources/Nimble/Adapters/NimbleXCTestHandler.swift @@ -3,7 +3,7 @@ import XCTest /// Default handler for Nimble. This assertion handler passes failures along to /// XCTest. -public class NimbleXCTestHandler : AssertionHandler { +public class NimbleXCTestHandler: AssertionHandler { public func assert(_ assertion: Bool, message: FailureMessage, location: SourceLocation) { if !assertion { recordFailure("\(message.stringValue)\n", location: location) @@ -29,14 +29,14 @@ public class NimbleShortXCTestHandler: AssertionHandler { /// Fallback handler in case XCTest is unavailable. This assertion handler will abort /// the program if it is invoked. -class NimbleXCTestUnavailableHandler : AssertionHandler { +class NimbleXCTestUnavailableHandler: AssertionHandler { func assert(_ assertion: Bool, message: FailureMessage, location: SourceLocation) { fatalError("XCTest is not available and no custom assertion handler was configured. Aborting.") } } -#if _runtime(_ObjC) - /// Helper class providing access to the currently executing XCTestCase instance, if any +#if !SWIFT_PACKAGE +/// Helper class providing access to the currently executing XCTestCase instance, if any @objc final internal class CurrentTestCaseTracker: NSObject, XCTestObservation { @objc static let sharedInstance = CurrentTestCaseTracker() @@ -52,7 +52,6 @@ class NimbleXCTestUnavailableHandler : AssertionHandler { } #endif - func isXCTestAvailable() -> Bool { #if _runtime(_ObjC) // XCTest is weakly linked and so may not be present @@ -63,7 +62,9 @@ func isXCTestAvailable() -> Bool { } private func recordFailure(_ message: String, location: SourceLocation) { -#if _runtime(_ObjC) +#if SWIFT_PACKAGE + XCTFail("\(message)", file: location.file, line: location.line) +#else if let testCase = CurrentTestCaseTracker.sharedInstance.currentTestCase { testCase.recordFailure(withDescription: message, inFile: location.file, atLine: location.line, expected: true) } else { @@ -71,7 +72,5 @@ private func recordFailure(_ message: String, location: SourceLocation) { "The failure was:\n\"\(message)\"\nIt occurred at: \(location.file):\(location.line)" NSException(name: .internalInconsistencyException, reason: msg, userInfo: nil).raise() } -#else - XCTFail("\(message)\n", file: location.file, line: location.line) #endif } diff --git a/Carthage/Checkouts/Nimble/Sources/Nimble/DSL+Wait.swift b/Carthage/Checkouts/Nimble/Sources/Nimble/DSL+Wait.swift index 619b6dc..f7f373f 100644 --- a/Carthage/Checkouts/Nimble/Sources/Nimble/DSL+Wait.swift +++ b/Carthage/Checkouts/Nimble/Sources/Nimble/DSL+Wait.swift @@ -39,7 +39,7 @@ internal class NMBWait: NSObject { ) capture.tryBlock { do { - try action() { + try action { done(.none) } } catch let e { @@ -70,12 +70,12 @@ internal class NMBWait: NSObject { } } - #if _runtime(_ObjC) - @objc(untilFile:line:action:) + #if SWIFT_PACKAGE internal class func until(_ file: FileString = #file, line: UInt = #line, action: @escaping (() -> Void) -> Void) -> Void { until(timeout: 1, file: file, line: line, action: action) } #else + @objc(untilFile:line:action:) internal class func until(_ file: FileString = #file, line: UInt = #line, action: @escaping (() -> Void) -> Void) -> Void { until(timeout: 1, file: file, line: line, action: action) } diff --git a/Carthage/Checkouts/Nimble/Sources/Nimble/Expectation.swift b/Carthage/Checkouts/Nimble/Sources/Nimble/Expectation.swift index 16d7c3b..c5978f4 100644 --- a/Carthage/Checkouts/Nimble/Sources/Nimble/Expectation.swift +++ b/Carthage/Checkouts/Nimble/Sources/Nimble/Expectation.swift @@ -1,8 +1,7 @@ import Foundation internal func expressionMatches(_ expression: Expression, matcher: U, to: String, description: String?) -> (Bool, FailureMessage) - where U: Matcher, U.ValueType == T -{ + where U: Matcher, U.ValueType == T { let msg = FailureMessage() msg.userDescription = description msg.to = to @@ -19,8 +18,7 @@ internal func expressionMatches(_ expression: Expression, matcher: U, t } internal func expressionDoesNotMatch(_ expression: Expression, matcher: U, toNot: String, description: String?) -> (Bool, FailureMessage) - where U: Matcher, U.ValueType == T -{ + where U: Matcher, U.ValueType == T { let msg = FailureMessage() msg.userDescription = description msg.to = toNot @@ -47,16 +45,14 @@ public struct Expectation { /// Tests the actual value using a matcher to match. public func to(_ matcher: U, description: String? = nil) - where U: Matcher, U.ValueType == T - { + where U: Matcher, U.ValueType == T { let (pass, msg) = expressionMatches(expression, matcher: matcher, to: "to", description: description) verify(pass, msg) } /// Tests the actual value using a matcher to not match. public func toNot(_ matcher: U, description: String? = nil) - where U: Matcher, U.ValueType == T - { + where U: Matcher, U.ValueType == T { let (pass, msg) = expressionDoesNotMatch(expression, matcher: matcher, toNot: "to not", description: description) verify(pass, msg) } @@ -65,8 +61,7 @@ public struct Expectation { /// /// Alias to toNot(). public func notTo(_ matcher: U, description: String? = nil) - where U: Matcher, U.ValueType == T - { + where U: Matcher, U.ValueType == T { toNot(matcher, description: description) } diff --git a/Carthage/Checkouts/Nimble/Sources/Nimble/Expression.swift b/Carthage/Checkouts/Nimble/Sources/Nimble/Expression.swift index 8ba53e4..f7afffe 100644 --- a/Carthage/Checkouts/Nimble/Sources/Nimble/Expression.swift +++ b/Carthage/Checkouts/Nimble/Sources/Nimble/Expression.swift @@ -5,7 +5,7 @@ import Foundation internal func memoizedClosure(_ closure: @escaping () throws -> T) -> (Bool) throws -> T { var cache: T? return ({ withoutCaching in - if (withoutCaching || cache == nil) { + if withoutCaching || cache == nil { cache = try closure() } return cache! diff --git a/Carthage/Checkouts/Nimble/Sources/Nimble/FailureMessage.swift b/Carthage/Checkouts/Nimble/Sources/Nimble/FailureMessage.swift index 2d245e5..24b6c8f 100644 --- a/Carthage/Checkouts/Nimble/Sources/Nimble/FailureMessage.swift +++ b/Carthage/Checkouts/Nimble/Sources/Nimble/FailureMessage.swift @@ -59,7 +59,7 @@ public class FailureMessage: NSObject { if let userDescription = userDescription { return "\(userDescription)\n\(value)" } - + return value } } diff --git a/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/AllPass.swift b/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/AllPass.swift index 3a9258d..73e79d3 100644 --- a/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/AllPass.swift +++ b/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/AllPass.swift @@ -1,36 +1,31 @@ import Foundation -public func allPass +public func allPass (_ passFunc: @escaping (T?) -> Bool) -> NonNilMatcherFunc - where U: Sequence, U.Iterator.Element == T -{ + where U: Sequence, U.Iterator.Element == T { return allPass("pass a condition", passFunc) } -public func allPass +public func allPass (_ passName: String, _ passFunc: @escaping (T?) -> Bool) -> NonNilMatcherFunc - where U: Sequence, U.Iterator.Element == T -{ - return createAllPassMatcher() { - expression, failureMessage in + where U: Sequence, U.Iterator.Element == T { + return createAllPassMatcher { expression, failureMessage in failureMessage.postfixMessage = passName return passFunc(try expression.evaluate()) } } -public func allPass +public func allPass (_ matcher: V) -> NonNilMatcherFunc - where U: Sequence, V: Matcher, U.Iterator.Element == V.ValueType -{ - return createAllPassMatcher() { + where U: Sequence, V: Matcher, U.Iterator.Element == V.ValueType { + return createAllPassMatcher { try matcher.matches($0, failureMessage: $1) } } -private func createAllPassMatcher +private func createAllPassMatcher (_ elementEvaluator: @escaping (Expression, FailureMessage) throws -> Bool) -> NonNilMatcherFunc - where U: Sequence, U.Iterator.Element == T -{ + where U: Sequence, U.Iterator.Element == T { return NonNilMatcherFunc { actualExpression, failureMessage in failureMessage.actualValue = nil if let actualValue = try actualExpression.evaluate() { @@ -62,7 +57,7 @@ extension NMBObjCMatcher { let location = actualExpression.location let actualValue = try! actualExpression.evaluate() var nsObjects = [NSObject]() - + var collectionIsUsable = true if let value = actualValue as? NSFastEnumeration { let generator = NSFastEnumerationIterator(value) @@ -77,7 +72,7 @@ extension NMBObjCMatcher { } else { collectionIsUsable = false } - + if !collectionIsUsable { failureMessage.postfixMessage = "allPass only works with NSFastEnumeration (NSArray, NSSet, ...) of NSObjects" @@ -85,12 +80,11 @@ extension NMBObjCMatcher { failureMessage.to = "" return false } - + let expr = Expression(expression: ({ nsObjects }), location: location) let elementEvaluator: (Expression, FailureMessage) -> Bool = { expression, failureMessage in - return matcher.matches( - {try! expression.evaluate()}, failureMessage: failureMessage, location: expr.location) + return matcher.matches({try! expression.evaluate()}, failureMessage: failureMessage, location: expr.location) } return try! createAllPassMatcher(elementEvaluator).matches( expr, failureMessage: failureMessage) diff --git a/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/AsyncMatcherWrapper.swift b/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/AsyncMatcherWrapper.swift index 6b89c76..b971ccc 100644 --- a/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/AsyncMatcherWrapper.swift +++ b/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/AsyncMatcherWrapper.swift @@ -8,8 +8,7 @@ public struct AsyncDefaults { } internal struct AsyncMatcherWrapper: Matcher - where U: Matcher, U.ValueType == T -{ + where U: Matcher, U.ValueType == T { let fullMatcher: U let timeoutInterval: TimeInterval let pollInterval: TimeInterval @@ -31,7 +30,7 @@ internal struct AsyncMatcherWrapper: Matcher fnName: fnName) { try self.fullMatcher.matches(uncachedExpression, failureMessage: failureMessage) } - switch (result) { + switch result { case let .completed(isSuccessful): return isSuccessful case .timedOut: return false case let .errorThrown(error): @@ -48,7 +47,7 @@ internal struct AsyncMatcherWrapper: Matcher } } - func doesNotMatch(_ actualExpression: Expression, failureMessage: FailureMessage) -> Bool { + func doesNotMatch(_ actualExpression: Expression, failureMessage: FailureMessage) -> Bool { let uncachedExpression = actualExpression.withoutCaching() let result = pollBlock( pollInterval: pollInterval, @@ -58,7 +57,7 @@ internal struct AsyncMatcherWrapper: Matcher fnName: "expect(...).toEventuallyNot(...)") { try self.fullMatcher.doesNotMatch(uncachedExpression, failureMessage: failureMessage) } - switch (result) { + switch result { case let .completed(isSuccessful): return isSuccessful case .timedOut: return false case let .errorThrown(error): @@ -78,7 +77,6 @@ internal struct AsyncMatcherWrapper: Matcher private let toEventuallyRequiresClosureError = FailureMessage(stringValue: "expect(...).toEventually(...) requires an explicit closure (eg - expect { ... }.toEventually(...) )\nSwift 1.2 @autoclosure behavior has changed in an incompatible way for Nimble to function") - extension Expectation { /// Tests the actual value using a matcher to match by checking continuously /// at each pollInterval until the timeout is reached. @@ -87,8 +85,7 @@ extension Expectation { /// This function manages the main run loop (`NSRunLoop.mainRunLoop()`) while this function /// is executing. Any attempts to touch the run loop may cause non-deterministic behavior. public func toEventually(_ matcher: U, timeout: TimeInterval = AsyncDefaults.Timeout, pollInterval: TimeInterval = AsyncDefaults.PollInterval, description: String? = nil) - where U: Matcher, U.ValueType == T - { + where U: Matcher, U.ValueType == T { if expression.isClosure { let (pass, msg) = expressionMatches( expression, @@ -112,8 +109,7 @@ extension Expectation { /// This function manages the main run loop (`NSRunLoop.mainRunLoop()`) while this function /// is executing. Any attempts to touch the run loop may cause non-deterministic behavior. public func toEventuallyNot(_ matcher: U, timeout: TimeInterval = AsyncDefaults.Timeout, pollInterval: TimeInterval = AsyncDefaults.PollInterval, description: String? = nil) - where U: Matcher, U.ValueType == T - { + where U: Matcher, U.ValueType == T { if expression.isClosure { let (pass, msg) = expressionDoesNotMatch( expression, @@ -139,8 +135,7 @@ extension Expectation { /// This function manages the main run loop (`NSRunLoop.mainRunLoop()`) while this function /// is executing. Any attempts to touch the run loop may cause non-deterministic behavior. public func toNotEventually(_ matcher: U, timeout: TimeInterval = AsyncDefaults.Timeout, pollInterval: TimeInterval = AsyncDefaults.PollInterval, description: String? = nil) - where U: Matcher, U.ValueType == T - { + where U: Matcher, U.ValueType == T { return toEventuallyNot(matcher, timeout: timeout, pollInterval: pollInterval, description: description) } } diff --git a/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/BeAKindOf.swift b/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/BeAKindOf.swift index 99b8f8f..f636a72 100644 --- a/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/BeAKindOf.swift +++ b/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/BeAKindOf.swift @@ -1,17 +1,27 @@ import Foundation -#if _runtime(_ObjC) - -// A Nimble matcher that catches attempts to use beAKindOf with non Objective-C types -public func beAKindOf(_ expectedClass: Any) -> NonNilMatcherFunc { +/// A Nimble matcher that succeeds when the actual value is an instance of the given class. +public func beAKindOf(_ expectedType: T.Type) -> NonNilMatcherFunc { return NonNilMatcherFunc {actualExpression, failureMessage in - failureMessage.stringValue = "beAKindOf only works on Objective-C types since" - + " the Swift compiler will automatically type check Swift-only types." - + " This expectation is redundant." - return false + failureMessage.postfixMessage = "be a kind of \(String(describing: expectedType))" + let instance = try actualExpression.evaluate() + guard let validInstance = instance else { + failureMessage.actualValue = "" + return false + } + + failureMessage.actualValue = "<\(String(describing: type(of: validInstance))) instance>" + + guard validInstance is T else { + return false + } + + return true } } +#if _runtime(_ObjC) + /// A Nimble matcher that succeeds when the actual value is an instance of the given class. /// @see beAnInstanceOf if you want to match against the exact class public func beAKindOf(_ expectedClass: AnyClass) -> NonNilMatcherFunc { diff --git a/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/BeAnInstanceOf.swift b/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/BeAnInstanceOf.swift index 2298c78..07ce3d3 100644 --- a/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/BeAnInstanceOf.swift +++ b/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/BeAnInstanceOf.swift @@ -1,11 +1,21 @@ import Foundation -// A Nimble matcher that catches attempts to use beAnInstanceOf with non Objective-C types -public func beAnInstanceOf(_ expectedClass: Any) -> NonNilMatcherFunc { +/// A Nimble matcher that succeeds when the actual value is an _exact_ instance of the given class. +public func beAnInstanceOf(_ expectedType: T.Type) -> NonNilMatcherFunc { return NonNilMatcherFunc {actualExpression, failureMessage in - failureMessage.stringValue = "beAnInstanceOf only works on Objective-C types since" - + " the Swift compiler will automatically type check Swift-only types." - + " This expectation is redundant." + failureMessage.postfixMessage = "be an instance of \(String(describing: expectedType))" + let instance = try actualExpression.evaluate() + guard let validInstance = instance else { + failureMessage.actualValue = "" + return false + } + + failureMessage.actualValue = "<\(String(describing: type(of: validInstance))) instance>" + + if type(of: validInstance) == expectedType { + return true + } + return false } } diff --git a/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/BeCloseTo.swift b/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/BeCloseTo.swift index 48e9895..95c52cf 100644 --- a/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/BeCloseTo.swift +++ b/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/BeCloseTo.swift @@ -29,7 +29,7 @@ public func beCloseTo(_ expectedValue: NMBDoubleConvertible, within delta: Doubl } #if _runtime(_ObjC) -public class NMBObjCBeCloseToMatcher : NSObject, NMBMatcher { +public class NMBObjCBeCloseToMatcher: NSObject, NMBMatcher { var _expected: NSNumber var _delta: CDouble init(expected: NSNumber, within: CDouble) { @@ -106,7 +106,7 @@ public func ≈(lhs: Expectation, rhs: (expected: NMBDoubl lhs.to(beCloseTo(rhs.expected, within: rhs.delta)) } -public func ==(lhs: Expectation, rhs: (expected: NMBDoubleConvertible, delta: Double)) { +public func == (lhs: Expectation, rhs: (expected: NMBDoubleConvertible, delta: Double)) { lhs.to(beCloseTo(rhs.expected, within: rhs.delta)) } diff --git a/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/BeEmpty.swift b/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/BeEmpty.swift index 19df0d2..2ea2cdb 100644 --- a/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/BeEmpty.swift +++ b/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/BeEmpty.swift @@ -1,6 +1,5 @@ import Foundation - /// A Nimble matcher that succeeds when a value is "empty". For collections, this /// means the are no items in that collection. For strings, it is an empty string. public func beEmpty() -> NonNilMatcherFunc { diff --git a/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/BeGreaterThan.swift b/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/BeGreaterThan.swift index 1345199..c7eb84c 100644 --- a/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/BeGreaterThan.swift +++ b/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/BeGreaterThan.swift @@ -1,6 +1,5 @@ import Foundation - /// A Nimble matcher that succeeds when the actual value is greater than the expected value. public func beGreaterThan(_ expectedValue: T?) -> NonNilMatcherFunc { return NonNilMatcherFunc { actualExpression, failureMessage in @@ -26,7 +25,7 @@ public func >(lhs: Expectation, rhs: T) { lhs.to(beGreaterThan(rhs)) } -public func >(lhs: Expectation, rhs: NMBComparable?) { +public func > (lhs: Expectation, rhs: NMBComparable?) { lhs.to(beGreaterThan(rhs)) } diff --git a/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/BeIdenticalTo.swift b/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/BeIdenticalTo.swift index ca3357b..8df7e5f 100644 --- a/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/BeIdenticalTo.swift +++ b/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/BeIdenticalTo.swift @@ -1,6 +1,5 @@ import Foundation - /// A Nimble matcher that succeeds when the actual value is the same instance /// as the expected instance. public func beIdenticalTo(_ expected: Any?) -> NonNilMatcherFunc { @@ -20,10 +19,10 @@ public func beIdenticalTo(_ expected: Any?) -> NonNilMatcherFunc { } } -public func ===(lhs: Expectation, rhs: Any?) { +public func === (lhs: Expectation, rhs: Any?) { lhs.to(beIdenticalTo(rhs)) } -public func !==(lhs: Expectation, rhs: Any?) { +public func !== (lhs: Expectation, rhs: Any?) { lhs.toNot(beIdenticalTo(rhs)) } diff --git a/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/BeLessThan.swift b/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/BeLessThan.swift index fbcd7c7..5bbbf36 100644 --- a/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/BeLessThan.swift +++ b/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/BeLessThan.swift @@ -25,7 +25,7 @@ public func <(lhs: Expectation, rhs: T) { lhs.to(beLessThan(rhs)) } -public func <(lhs: Expectation, rhs: NMBComparable?) { +public func < (lhs: Expectation, rhs: NMBComparable?) { lhs.to(beLessThan(rhs)) } diff --git a/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/BeVoid.swift b/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/BeVoid.swift index 8f86265..92a8d43 100644 --- a/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/BeVoid.swift +++ b/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/BeVoid.swift @@ -9,10 +9,10 @@ public func beVoid() -> MatcherFunc<()> { } } -public func ==(lhs: Expectation<()>, rhs: ()) { +public func == (lhs: Expectation<()>, rhs: ()) { lhs.to(beVoid()) } -public func !=(lhs: Expectation<()>, rhs: ()) { +public func != (lhs: Expectation<()>, rhs: ()) { lhs.toNot(beVoid()) -} \ No newline at end of file +} diff --git a/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/BeginWith.swift b/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/BeginWith.swift index ef6c603..31cbe5d 100644 --- a/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/BeginWith.swift +++ b/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/BeginWith.swift @@ -1,11 +1,9 @@ import Foundation - /// A Nimble matcher that succeeds when the actual sequence's first element /// is equal to the expected value. public func beginWith(_ startingElement: T) -> NonNilMatcherFunc - where S.Iterator.Element == T -{ + where S.Iterator.Element == T { return NonNilMatcherFunc { actualExpression, failureMessage in failureMessage.postfixMessage = "begin with <\(startingElement)>" if let actualValue = try actualExpression.evaluate() { diff --git a/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/Contain.swift b/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/Contain.swift index 4400d30..5053642 100644 --- a/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/Contain.swift +++ b/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/Contain.swift @@ -2,14 +2,12 @@ import Foundation /// A Nimble matcher that succeeds when the actual sequence contains the expected value. public func contain(_ items: T...) -> NonNilMatcherFunc - where S.Iterator.Element == T -{ + where S.Iterator.Element == T { return contain(items) } public func contain(_ items: [T]) -> NonNilMatcherFunc - where S.Iterator.Element == T -{ + where S.Iterator.Element == T { return NonNilMatcherFunc { actualExpression, failureMessage in failureMessage.postfixMessage = "contain <\(arrayAsString(items))>" if let actual = try actualExpression.evaluate() { diff --git a/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/ContainElementSatisfying.swift b/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/ContainElementSatisfying.swift new file mode 100644 index 0000000..ae8cca2 --- /dev/null +++ b/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/ContainElementSatisfying.swift @@ -0,0 +1,59 @@ +import Foundation + +public func containElementSatisfying(_ predicate: @escaping ((T) -> Bool), _ predicateDescription: String = "") -> NonNilMatcherFunc where S.Iterator.Element == T { + + return NonNilMatcherFunc { actualExpression, failureMessage in + failureMessage.actualValue = nil + + if predicateDescription == "" { + failureMessage.postfixMessage = "find object in collection that satisfies predicate" + } else { + failureMessage.postfixMessage = "find object in collection \(predicateDescription)" + } + + if let sequence = try actualExpression.evaluate() { + for object in sequence { + if predicate(object) { + return true + } + } + + return false + } + + return false + } +} + +#if _runtime(_ObjC) + extension NMBObjCMatcher { + public class func containElementSatisfyingMatcher(_ predicate: @escaping ((NSObject) -> Bool)) -> NMBObjCMatcher { + return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in + let value = try! actualExpression.evaluate() + guard let enumeration = value as? NSFastEnumeration else { + failureMessage.postfixMessage = "containElementSatisfying must be provided an NSFastEnumeration object" + failureMessage.actualValue = nil + failureMessage.expected = "" + failureMessage.to = "" + return false + } + + let iterator = NSFastEnumerationIterator(enumeration) + while let item = iterator.next() { + guard let object = item as? NSObject else { + continue + } + + if predicate(object) { + return true + } + } + + failureMessage.actualValue = nil + failureMessage.postfixMessage = "" + failureMessage.to = "to find object in collection that satisfies predicate" + return false + } + } + } +#endif diff --git a/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/EndWith.swift b/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/EndWith.swift index b96e96c..00c7e20 100644 --- a/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/EndWith.swift +++ b/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/EndWith.swift @@ -1,11 +1,9 @@ import Foundation - /// A Nimble matcher that succeeds when the actual sequence's last element /// is equal to the expected value. public func endWith(_ endingElement: T) -> NonNilMatcherFunc - where S.Iterator.Element == T -{ + where S.Iterator.Element == T { return NonNilMatcherFunc { actualExpression, failureMessage in failureMessage.postfixMessage = "end with <\(endingElement)>" @@ -17,7 +15,7 @@ public func endWith(_ endingElement: T) -> NonNilMatc lastItem = item item = actualGenerator.next() } while(item != nil) - + return lastItem == endingElement } return false @@ -43,7 +41,6 @@ public func endWith(_ endingElement: Any) -> NonNilMatcherFunc(_ expectedValue: [T?]) -> NonNilMatcherFunc<[T?] if expectedValue.count != actualValue.count { return false } - + for (index, item) in actualValue.enumerated() { let otherItem = expectedValue[index] if item == nil && otherItem == nil { @@ -74,12 +74,12 @@ public func equal(_ expectedValue: [T?]) -> NonNilMatcherFunc<[T?] return false } } - + return true } else { failureMessage.postfixActual = " (use beNil() to match nils)" } - + return false } } @@ -146,11 +146,11 @@ public func !=(lhs: Expectation<[T]>, rhs: [T]?) { lhs.toNot(equal(rhs)) } -public func ==(lhs: Expectation>, rhs: Set?) { +public func == (lhs: Expectation>, rhs: Set?) { lhs.to(equal(rhs)) } -public func !=(lhs: Expectation>, rhs: Set?) { +public func != (lhs: Expectation>, rhs: Set?) { lhs.toNot(equal(rhs)) } diff --git a/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/Match.swift b/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/Match.swift index 3ad5fb5..7e80331 100644 --- a/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/Match.swift +++ b/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/Match.swift @@ -5,7 +5,7 @@ import Foundation public func match(_ expectedValue: String?) -> NonNilMatcherFunc { return NonNilMatcherFunc { actualExpression, failureMessage in failureMessage.postfixMessage = "match <\(stringify(expectedValue))>" - + if let actual = try actualExpression.evaluate() { if let regexp = expectedValue { return actual.range(of: regexp, options: .regularExpression) != nil diff --git a/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/MatcherProtocols.swift b/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/MatcherProtocols.swift index ac1eb9d..3f27ec1 100644 --- a/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/MatcherProtocols.swift +++ b/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/MatcherProtocols.swift @@ -57,12 +57,12 @@ extension NSDictionary : NMBCollection {} #if _runtime(_ObjC) /// Protocol for types that support beginWith(), endWith(), beEmpty() matchers -@objc public protocol NMBOrderedCollection : NMBCollection { +@objc public protocol NMBOrderedCollection: NMBCollection { @objc(objectAtIndex:) func object(at index: Int) -> Any } #else -public protocol NMBOrderedCollection : NMBCollection { +public protocol NMBOrderedCollection: NMBCollection { func object(at index: Int) -> Any } #endif diff --git a/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/PostNotification.swift b/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/PostNotification.swift index 84b9d49..ac8ee5a 100644 --- a/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/PostNotification.swift +++ b/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/PostNotification.swift @@ -15,9 +15,9 @@ internal class NotificationCollector { } func startObserving() { - self.token = self.notificationCenter.addObserver(forName: nil, object: nil, queue: nil) { + self.token = self.notificationCenter.addObserver(forName: nil, object: nil, queue: nil) { [weak self] n in // linux-swift gets confused by .append(n) - [weak self] n in self?.observedNotifications.append(n) + self?.observedNotifications.append(n) } } diff --git a/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/RaisesException.swift b/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/RaisesException.swift index 09e28c7..2867a1b 100644 --- a/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/RaisesException.swift +++ b/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/RaisesException.swift @@ -97,11 +97,11 @@ internal func exceptionMatchesNonNilFieldsOrClosure( } } } - + return matches } -public class NMBObjCRaiseExceptionMatcher : NSObject, NMBMatcher { +public class NMBObjCRaiseExceptionMatcher: NSObject, NMBMatcher { internal var _name: String? internal var _reason: String? internal var _userInfo: NSDictionary? diff --git a/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/SatisfyAnyOf.swift b/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/SatisfyAnyOf.swift index b24b3ec..6cef4c2 100644 --- a/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/SatisfyAnyOf.swift +++ b/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/SatisfyAnyOf.swift @@ -2,15 +2,13 @@ import Foundation /// A Nimble matcher that succeeds when the actual value matches with any of the matchers /// provided in the variable list of matchers. -public func satisfyAnyOf(_ matchers: U...) -> NonNilMatcherFunc - where U: Matcher, U.ValueType == T -{ +public func satisfyAnyOf(_ matchers: U...) -> NonNilMatcherFunc + where U: Matcher, U.ValueType == T { return satisfyAnyOf(matchers) } -internal func satisfyAnyOf(_ matchers: [U]) -> NonNilMatcherFunc - where U: Matcher, U.ValueType == T -{ +internal func satisfyAnyOf(_ matchers: [U]) -> NonNilMatcherFunc + where U: Matcher, U.ValueType == T { return NonNilMatcherFunc { actualExpression, failureMessage in let postfixMessages = NSMutableArray() var matches = false @@ -30,11 +28,11 @@ internal func satisfyAnyOf(_ matchers: [U]) -> NonNilMatcherFunc } } -public func ||(left: NonNilMatcherFunc, right: NonNilMatcherFunc) -> NonNilMatcherFunc { +public func || (left: NonNilMatcherFunc, right: NonNilMatcherFunc) -> NonNilMatcherFunc { return satisfyAnyOf(left, right) } -public func ||(left: MatcherFunc, right: MatcherFunc) -> NonNilMatcherFunc { +public func || (left: MatcherFunc, right: MatcherFunc) -> NonNilMatcherFunc { return satisfyAnyOf(left, right) } @@ -46,18 +44,17 @@ extension NMBObjCMatcher { failureMessage.stringValue = "satisfyAnyOf must be called with at least one matcher" return false } - + var elementEvaluators = [NonNilMatcherFunc]() for matcher in matchers { let elementEvaluator: (Expression, FailureMessage) -> Bool = { expression, failureMessage in - return matcher.matches( - {try! expression.evaluate()}, failureMessage: failureMessage, location: actualExpression.location) + return matcher.matches({try! expression.evaluate()}, failureMessage: failureMessage, location: actualExpression.location) } - + elementEvaluators.append(NonNilMatcherFunc(elementEvaluator)) } - + return try! satisfyAnyOf(elementEvaluators).matches(actualExpression, failureMessage: failureMessage) } } diff --git a/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/ThrowAssertion.swift b/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/ThrowAssertion.swift index 67f9cf6..c847a1a 100644 --- a/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/ThrowAssertion.swift +++ b/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/ThrowAssertion.swift @@ -5,12 +5,12 @@ public func throwAssertion() -> MatcherFunc { #if arch(x86_64) && _runtime(_ObjC) && !SWIFT_PACKAGE failureMessage.postfixMessage = "throw an assertion" failureMessage.actualValue = nil - + var succeeded = true - + let caughtException: BadInstructionException? = catchBadInstruction { #if os(tvOS) - if (!NimbleEnvironment.activeInstance.suppressTVOSAssertionWarning) { + if !NimbleEnvironment.activeInstance.suppressTVOSAssertionWarning { print() print("[Nimble Warning]: If you're getting stuck on a debugger breakpoint for a " + "fatal error while using throwAssertion(), please disable 'Debug Executable' " + @@ -36,11 +36,11 @@ public func throwAssertion() -> MatcherFunc { if !succeeded { return false } - + if caughtException == nil { return false } - + return true #elseif SWIFT_PACKAGE fatalError("The throwAssertion Nimble matcher does not currently support Swift CLI." + diff --git a/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/ThrowError.swift b/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/ThrowError.swift index 8c9b91b..151eb9a 100644 --- a/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/ThrowError.swift +++ b/Carthage/Checkouts/Nimble/Sources/Nimble/Matchers/ThrowError.swift @@ -39,14 +39,14 @@ public func throwError( public func throwError( closure: ((Error) -> Void)? = nil) -> MatcherFunc { return MatcherFunc { actualExpression, failureMessage in - + var actualError: Error? do { _ = try actualExpression.evaluate() } catch let catchedError { actualError = catchedError } - + setFailureMessageForError(failureMessage, actualError: actualError, closure: closure) return errorMatchesNonNilFieldsOrClosure(actualError, closure: closure) } diff --git a/Carthage/Checkouts/Nimble/Sources/Nimble/Utils/Async.swift b/Carthage/Checkouts/Nimble/Sources/Nimble/Utils/Async.swift index c902692..943fd30 100644 --- a/Carthage/Checkouts/Nimble/Sources/Nimble/Utils/Async.swift +++ b/Carthage/Checkouts/Nimble/Sources/Nimble/Utils/Async.swift @@ -179,7 +179,7 @@ internal class AwaitPromiseBuilder { trigger.timeoutSource.scheduleOneshot( deadline: DispatchTime.now() + timeoutInterval, leeway: timeoutLeeway) - trigger.timeoutSource.setEventHandler() { + trigger.timeoutSource.setEventHandler { guard self.promise.asyncResult.isIncomplete() else { return } let timedOutSem = DispatchSemaphore(value: 0) let semTimedOutOrBlocked = DispatchSemaphore(value: 0) @@ -287,7 +287,7 @@ internal class Awaiter { let timeoutSource = createTimerSource(timeoutQueue) var completionCount = 0 let trigger = AwaitTrigger(timeoutSource: timeoutSource, actionSource: nil) { - try closure() { + try closure { completionCount += 1 nimblePrecondition( completionCount < 2, @@ -314,7 +314,7 @@ internal class Awaiter { let trigger = AwaitTrigger(timeoutSource: timeoutSource, actionSource: asyncSource) { let interval = DispatchTimeInterval.nanoseconds(Int(pollInterval * TimeInterval(NSEC_PER_SEC))) asyncSource.scheduleRepeating(deadline: .now(), interval: interval, leeway: pollLeeway) - asyncSource.setEventHandler() { + asyncSource.setEventHandler { do { if let result = try closure() { if promise.resolveResult(.completed(result)) { diff --git a/Carthage/Checkouts/Nimble/Sources/Nimble/Utils/Errors.swift b/Carthage/Checkouts/Nimble/Sources/Nimble/Utils/Errors.swift index d424c98..f376505 100644 --- a/Carthage/Checkouts/Nimble/Sources/Nimble/Utils/Errors.swift +++ b/Carthage/Checkouts/Nimble/Sources/Nimble/Utils/Errors.swift @@ -44,8 +44,7 @@ internal func errorMatchesExpectedError( internal func errorMatchesExpectedError( _ actualError: Error, expectedError: T) -> Bool - where T: Equatable -{ + where T: Equatable { if let actualError = actualError as? T { return actualError == expectedError } diff --git a/Carthage/Checkouts/Nimble/Sources/Nimble/Utils/SourceLocation.swift b/Carthage/Checkouts/Nimble/Sources/Nimble/Utils/SourceLocation.swift index a7279aa..4e37aef 100644 --- a/Carthage/Checkouts/Nimble/Sources/Nimble/Utils/SourceLocation.swift +++ b/Carthage/Checkouts/Nimble/Sources/Nimble/Utils/SourceLocation.swift @@ -5,13 +5,13 @@ import Foundation // stdlib, and because recent versions of the XCTest overlay require `StaticString` // when calling `XCTFail`. Under the Objective-C runtime (i.e. building on Mac), we // have to use `String` instead because StaticString can't be generated from Objective-C -#if _runtime(_ObjC) -public typealias FileString = String -#else +#if SWIFT_PACKAGE public typealias FileString = StaticString +#else +public typealias FileString = String #endif -public final class SourceLocation : NSObject { +public final class SourceLocation: NSObject { public let file: FileString public let line: UInt diff --git a/Carthage/Checkouts/Nimble/Sources/Nimble/Utils/Stringers.swift b/Carthage/Checkouts/Nimble/Sources/Nimble/Utils/Stringers.swift index 012e1e3..8a15c4c 100644 --- a/Carthage/Checkouts/Nimble/Sources/Nimble/Utils/Stringers.swift +++ b/Carthage/Checkouts/Nimble/Sources/Nimble/Utils/Stringers.swift @@ -1,6 +1,5 @@ import Foundation - internal func identityAsString(_ value: Any?) -> String { let anyObject: AnyObject? #if os(Linux) @@ -51,7 +50,7 @@ extension NSNumber: TestOutputStringConvertible { // the travis CI build on linux. public var testDescription: String { let description = self.description - + if description.contains(".") { // Travis linux swiftpm build doesn't like casting String to NSString, // which is why this annoying nested initializer thing is here. @@ -87,14 +86,14 @@ extension AnySequence: TestOutputStringConvertible { let generator = self.makeIterator() var strings = [String]() var value: AnySequence.Iterator.Element? - + repeat { value = generator.next() if let value = value { strings.append(stringify(value)) } } while value != nil - + let list = strings.joined(separator: ", ") return "[\(list)]" } @@ -149,11 +148,11 @@ public func stringify(_ value: T) -> String { if let value = value as? TestOutputStringConvertible { return value.testDescription } - + if let value = value as? CustomDebugStringConvertible { return value.debugDescription } - + return String(describing: value) } diff --git a/Carthage/Checkouts/Nimble/Sources/NimbleObjectiveC/DSL.h b/Carthage/Checkouts/Nimble/Sources/NimbleObjectiveC/DSL.h index 54677ee..2089607 100644 --- a/Carthage/Checkouts/Nimble/Sources/NimbleObjectiveC/DSL.h +++ b/Carthage/Checkouts/Nimble/Sources/NimbleObjectiveC/DSL.h @@ -322,6 +322,10 @@ NIMBLE_EXPORT id NMB_containWithNilTermination(id itemOrSubstring, . #define contain(...) NMB_contain(__VA_ARGS__) #endif +NIMBLE_EXPORT id NMB_containElementSatisfying(BOOL(^predicate)(id)); +NIMBLE_SHORT(id containElementSatisfying(BOOL(^predicate)(id)), + NMB_containElementSatisfying(predicate)); + NIMBLE_EXPORT id NMB_endWith(id itemElementOrSubstring); NIMBLE_SHORT(id endWith(id itemElementOrSubstring), NMB_endWith(itemElementOrSubstring)); diff --git a/Carthage/Checkouts/Nimble/Sources/NimbleObjectiveC/DSL.m b/Carthage/Checkouts/Nimble/Sources/NimbleObjectiveC/DSL.m index cd93ddd..31ff810 100644 --- a/Carthage/Checkouts/Nimble/Sources/NimbleObjectiveC/DSL.m +++ b/Carthage/Checkouts/Nimble/Sources/NimbleObjectiveC/DSL.m @@ -113,6 +113,10 @@ NIMBLE_EXPORT void NMB_failWithMessage(NSString *msg, NSString *file, NSUInteger return [NMBObjCMatcher containMatcher:itemOrSubstringArray]; } +NIMBLE_EXPORT id NMB_containElementSatisfying(BOOL(^predicate)(id)) { + return [NMBObjCMatcher containElementSatisfyingMatcher:predicate]; +} + NIMBLE_EXPORT id NMB_endWith(id itemElementOrSubstring) { return [NMBObjCMatcher endWithMatcher:itemElementOrSubstring]; } diff --git a/Carthage/Checkouts/Nimble/Sources/NimbleObjectiveC/NMBExceptionCapture.h b/Carthage/Checkouts/Nimble/Sources/NimbleObjectiveC/NMBExceptionCapture.h index e0ec05a..d2a54d2 100644 --- a/Carthage/Checkouts/Nimble/Sources/NimbleObjectiveC/NMBExceptionCapture.h +++ b/Carthage/Checkouts/Nimble/Sources/NimbleObjectiveC/NMBExceptionCapture.h @@ -4,7 +4,7 @@ @interface NMBExceptionCapture : NSObject - (nonnull instancetype)initWithHandler:(void(^ _Nullable)(NSException * _Nonnull))handler finally:(void(^ _Nullable)())finally; -- (void)tryBlock:(void(^ _Nonnull)())unsafeBlock NS_SWIFT_NAME(tryBlock(_:)); +- (void)tryBlock:(__attribute__((noescape)) void(^ _Nonnull)())unsafeBlock NS_SWIFT_NAME(tryBlock(_:)); @end diff --git a/Carthage/Checkouts/Nimble/Tests/LinuxMain.swift b/Carthage/Checkouts/Nimble/Tests/LinuxMain.swift index 4210ef0..16c6953 100644 --- a/Carthage/Checkouts/Nimble/Tests/LinuxMain.swift +++ b/Carthage/Checkouts/Nimble/Tests/LinuxMain.swift @@ -10,7 +10,7 @@ XCTMain([ // Matchers testCase(AllPassTest.allTests), - // testCase(BeAKindOfTest.allTests), + testCase(BeAKindOfSwiftTest.allTests), testCase(BeAnInstanceOfTest.allTests), testCase(BeCloseToTest.allTests), testCase(BeginWithTest.allTests), diff --git a/Carthage/Checkouts/Nimble/Tests/NimbleTests/AsynchronousTest.swift b/Carthage/Checkouts/Nimble/Tests/NimbleTests/AsynchronousTest.swift index ff78d47..cafa67e 100644 --- a/Carthage/Checkouts/Nimble/Tests/NimbleTests/AsynchronousTest.swift +++ b/Carthage/Checkouts/Nimble/Tests/NimbleTests/AsynchronousTest.swift @@ -61,12 +61,12 @@ final class AsyncTest: XCTestCase, XCTestCaseProvider { var value = 0 - let sleepThenSetValueTo: (Int) -> () = { newValue in + let sleepThenSetValueTo: (Int) -> Void = { newValue in Thread.sleep(forTimeInterval: 1.1) value = newValue } - var asyncOperation: () -> () = { sleepThenSetValueTo(1) } + var asyncOperation: () -> Void = { sleepThenSetValueTo(1) } if #available(OSX 10.10, *) { DispatchQueue.global().async(execute: asyncOperation) @@ -98,7 +98,7 @@ final class AsyncTest: XCTestCase, XCTestCaseProvider { func testWaitUntilTimesOutIfNotCalled() { failsWithErrorMessage("Waited more than 1.0 second") { - waitUntil(timeout: 1) { done in return } + waitUntil(timeout: 1) { _ in return } } } @@ -106,7 +106,7 @@ final class AsyncTest: XCTestCase, XCTestCaseProvider { var waiting = true failsWithErrorMessage("Waited more than 0.01 seconds") { waitUntil(timeout: 0.01) { done in - let asyncOperation: () -> () = { + let asyncOperation: () -> Void = { Thread.sleep(forTimeInterval: 0.1) done() waiting = false @@ -187,7 +187,7 @@ final class AsyncTest: XCTestCase, XCTestCaseProvider { func testWaitUntilMustBeInMainThread() { #if !SWIFT_PACKAGE var executedAsyncBlock: Bool = false - let asyncOperation: () -> () = { + let asyncOperation: () -> Void = { expect { waitUntil { done in done() } }.to(raiseException(named: "InvalidNimbleAPIUsage")) @@ -205,7 +205,7 @@ final class AsyncTest: XCTestCase, XCTestCaseProvider { func testToEventuallyMustBeInMainThread() { #if !SWIFT_PACKAGE var executedAsyncBlock: Bool = false - let asyncOperation: () -> () = { + let asyncOperation: () -> Void = { expect { expect(1).toEventually(equal(2)) }.to(raiseException(named: "InvalidNimbleAPIUsage")) diff --git a/Carthage/Checkouts/Nimble/Tests/NimbleTests/Helpers/XCTestCaseProvider.swift b/Carthage/Checkouts/Nimble/Tests/NimbleTests/Helpers/XCTestCaseProvider.swift index f300d47..40d9760 100644 --- a/Carthage/Checkouts/Nimble/Tests/NimbleTests/Helpers/XCTestCaseProvider.swift +++ b/Carthage/Checkouts/Nimble/Tests/NimbleTests/Helpers/XCTestCaseProvider.swift @@ -24,7 +24,7 @@ public protocol XCTestCaseProvider: XCTestCaseProviderStatic, XCTestCaseNameProv extension XCTestCaseProvider where Self: XCTestCaseProviderStatic { var allTestNames: [String] { - return type(of: self).allTests.map({ name, test in + return type(of: self).allTests.map({ name, _ in return name }) } diff --git a/Carthage/Checkouts/Nimble/Tests/NimbleTests/Helpers/utils.swift b/Carthage/Checkouts/Nimble/Tests/NimbleTests/Helpers/utils.swift index 0b33ea6..bb552ef 100644 --- a/Carthage/Checkouts/Nimble/Tests/NimbleTests/Helpers/utils.swift +++ b/Carthage/Checkouts/Nimble/Tests/NimbleTests/Helpers/utils.swift @@ -66,7 +66,7 @@ func failsWithErrorMessageForNil(_ message: String, file: FileString = #file, li } } -public class NimbleHelper : NSObject { +public class NimbleHelper: NSObject { public class func expectFailureMessage(_ message: NSString, block: @escaping () -> Void, file: FileString, line: UInt) { failsWithErrorMessage(String(describing: message), file: file, line: line, preferOriginalSourceLocation: true, closure: block) } diff --git a/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/AllPassTest.swift b/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/AllPassTest.swift index 0f4327a..2050881 100644 --- a/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/AllPassTest.swift +++ b/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/AllPassTest.swift @@ -55,35 +55,35 @@ final class AllPassTest: XCTestCase, XCTestCaseProvider { } func testAllPassArray() { - expect([1,2,3,4]).to(allPass({$0 < 5})) - expect([1,2,3,4]).toNot(allPass({$0 > 5})) + expect([1, 2, 3, 4]).to(allPass({$0 < 5})) + expect([1, 2, 3, 4]).toNot(allPass({$0 > 5})) failsWithErrorMessage( "expected to all pass a condition, but failed first at element <3> in <[1, 2, 3, 4]>") { - expect([1,2,3,4]).to(allPass({$0 < 3})) + expect([1, 2, 3, 4]).to(allPass({$0 < 3})) } failsWithErrorMessage("expected to not all pass a condition") { - expect([1,2,3,4]).toNot(allPass({$0 < 5})) + expect([1, 2, 3, 4]).toNot(allPass({$0 < 5})) } failsWithErrorMessage( "expected to all be something, but failed first at element <3> in <[1, 2, 3, 4]>") { - expect([1,2,3,4]).to(allPass("be something", {$0 < 3})) + expect([1, 2, 3, 4]).to(allPass("be something", {$0 < 3})) } failsWithErrorMessage("expected to not all be something") { - expect([1,2,3,4]).toNot(allPass("be something", {$0 < 5})) + expect([1, 2, 3, 4]).toNot(allPass("be something", {$0 < 5})) } } func testAllPassMatcher() { - expect([1,2,3,4]).to(allPass(beLessThan(5))) - expect([1,2,3,4]).toNot(allPass(beGreaterThan(5))) - + expect([1, 2, 3, 4]).to(allPass(beLessThan(5))) + expect([1, 2, 3, 4]).toNot(allPass(beGreaterThan(5))) + failsWithErrorMessage( "expected to all be less than <3>, but failed first at element <3> in <[1, 2, 3, 4]>") { - expect([1,2,3,4]).to(allPass(beLessThan(3))) + expect([1, 2, 3, 4]).to(allPass(beLessThan(3))) } failsWithErrorMessage("expected to not all be less than <5>") { - expect([1,2,3,4]).toNot(allPass(beLessThan(5))) + expect([1, 2, 3, 4]).toNot(allPass(beLessThan(5))) } } @@ -107,14 +107,14 @@ final class AllPassTest: XCTestCase, XCTestCaseProvider { } func testAllPassSet() { - expect(Set([1,2,3,4])).to(allPass({$0 < 5})) - expect(Set([1,2,3,4])).toNot(allPass({$0 > 5})) + expect(Set([1, 2, 3, 4])).to(allPass({$0 < 5})) + expect(Set([1, 2, 3, 4])).toNot(allPass({$0 > 5})) failsWithErrorMessage("expected to not all pass a condition") { - expect(Set([1,2,3,4])).toNot(allPass({$0 < 5})) + expect(Set([1, 2, 3, 4])).toNot(allPass({$0 < 5})) } failsWithErrorMessage("expected to not all be something") { - expect(Set([1,2,3,4])).toNot(allPass("be something", {$0 < 5})) + expect(Set([1, 2, 3, 4])).toNot(allPass("be something", {$0 < 5})) } } diff --git a/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/BeAKindOfTest.swift b/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/BeAKindOfTest.swift index 121ecbd..ea16913 100644 --- a/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/BeAKindOfTest.swift +++ b/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/BeAKindOfTest.swift @@ -1,16 +1,66 @@ +import Foundation import XCTest import Nimble -#if _runtime(_ObjC) +fileprivate class TestNull: NSNull {} +fileprivate protocol TestProtocol {} +fileprivate class TestClassConformingToProtocol: TestProtocol {} +fileprivate struct TestStructConformingToProtocol: TestProtocol {} + +final class BeAKindOfSwiftTest: XCTestCase, XCTestCaseProvider { + static var allTests: [(String, (BeAKindOfSwiftTest) -> () throws -> Void)] { + return [ + ("testPositiveMatch", testPositiveMatch), + ("testFailureMessages", testFailureMessages), + ] + } + + enum TestEnum { + case one, two + } + + func testPositiveMatch() { + expect(1).to(beAKindOf(Int.self)) + expect(1).toNot(beAKindOf(String.self)) + expect("turtle string").to(beAKindOf(String.self)) + expect("turtle string").toNot(beAKindOf(TestClassConformingToProtocol.self)) + + expect(TestEnum.one).to(beAKindOf(TestEnum.self)) -class TestNull : NSNull {} + let testProtocolClass = TestClassConformingToProtocol() + expect(testProtocolClass).to(beAKindOf(TestClassConformingToProtocol.self)) + expect(testProtocolClass).to(beAKindOf(TestProtocol.self)) + expect(testProtocolClass).toNot(beAKindOf(TestStructConformingToProtocol.self)) -final class BeAKindOfTest: XCTestCase, XCTestCaseProvider { - static var allTests: [(String, (BeAKindOfTest) -> () throws -> Void)] { + let testProtocolStruct = TestStructConformingToProtocol() + expect(testProtocolStruct).to(beAKindOf(TestStructConformingToProtocol.self)) + expect(testProtocolStruct).to(beAKindOf(TestProtocol.self)) + expect(testProtocolStruct).toNot(beAKindOf(TestClassConformingToProtocol.self)) + } + + func testFailureMessages() { + failsWithErrorMessage("expected to not be a kind of Int, got ") { + expect(1).toNot(beAKindOf(Int.self)) + } + + let testClass = TestClassConformingToProtocol() + failsWithErrorMessage("expected to not be a kind of \(String(describing: TestProtocol.self)), got <\(String(describing: TestClassConformingToProtocol.self)) instance>") { + expect(testClass).toNot(beAKindOf(TestProtocol.self)) + } + + failsWithErrorMessage("expected to be a kind of String, got ") { + expect(1).to(beAKindOf(String.self)) + } + } +} + +#if _runtime(_ObjC) + +final class BeAKindOfObjCTest: XCTestCase, XCTestCaseProvider { + static var allTests: [(String, (BeAKindOfObjCTest) -> () throws -> Void)] { return [ ("testPositiveMatch", testPositiveMatch), ("testFailureMessages", testFailureMessages), - ("testSwiftTypesFailureMessages", testSwiftTypesFailureMessages), ] } @@ -34,23 +84,6 @@ final class BeAKindOfTest: XCTestCase, XCTestCaseProvider { expect(NSNumber(value:1)).toNot(beAKindOf(NSNumber.self)) } } - - func testSwiftTypesFailureMessages() { - enum TestEnum { - case one, two - } - failsWithErrorMessage("beAKindOf only works on Objective-C types since the Swift compiler" - + " will automatically type check Swift-only types. This expectation is redundant.") { - expect(1).to(beAKindOf(Int.self)) - } - failsWithErrorMessage("beAKindOf only works on Objective-C types since the Swift compiler" - + " will automatically type check Swift-only types. This expectation is redundant.") { - expect("test").to(beAKindOf(String.self)) - } - failsWithErrorMessage("beAKindOf only works on Objective-C types since the Swift compiler" - + " will automatically type check Swift-only types. This expectation is redundant.") { - expect(TestEnum.one).to(beAKindOf(TestEnum.self)) - } - } } + #endif diff --git a/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/BeAnInstanceOfTest.swift b/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/BeAnInstanceOfTest.swift index c4a4954..0660a75 100644 --- a/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/BeAnInstanceOfTest.swift +++ b/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/BeAnInstanceOfTest.swift @@ -2,12 +2,17 @@ import Foundation import XCTest import Nimble +fileprivate protocol TestProtocol {} +fileprivate class TestClassConformingToProtocol: TestProtocol {} +fileprivate struct TestStructConformingToProtocol: TestProtocol {} + final class BeAnInstanceOfTest: XCTestCase, XCTestCaseProvider { static var allTests: [(String, (BeAnInstanceOfTest) -> () throws -> Void)] { return [ ("testPositiveMatch", testPositiveMatch), + ("testPositiveMatchSwiftTypes", testPositiveMatchSwiftTypes), ("testFailureMessages", testFailureMessages), - ("testSwiftTypesFailureMessages", testSwiftTypesFailureMessages), + ("testFailureMessagesSwiftTypes", testFailureMessagesSwiftTypes), ] } @@ -16,6 +21,27 @@ final class BeAnInstanceOfTest: XCTestCase, XCTestCaseProvider { expect(NSNumber(value:1)).toNot(beAnInstanceOf(NSDate.self)) } + enum TestEnum { + case one, two + } + + func testPositiveMatchSwiftTypes() { + expect(1).to(beAnInstanceOf(Int.self)) + expect("test").to(beAnInstanceOf(String.self)) + + expect(TestEnum.one).to(beAnInstanceOf(TestEnum.self)) + + let testProtocolClass = TestClassConformingToProtocol() + expect(testProtocolClass).to(beAnInstanceOf(TestClassConformingToProtocol.self)) + expect(testProtocolClass).toNot(beAnInstanceOf(TestProtocol.self)) + expect(testProtocolClass).toNot(beAnInstanceOf(TestStructConformingToProtocol.self)) + + let testProtocolStruct = TestStructConformingToProtocol() + expect(testProtocolStruct).to(beAnInstanceOf(TestStructConformingToProtocol.self)) + expect(testProtocolStruct).toNot(beAnInstanceOf(TestProtocol.self)) + expect(testProtocolStruct).toNot(beAnInstanceOf(TestClassConformingToProtocol.self)) + } + func testFailureMessages() { failsWithErrorMessageForNil("expected to not be an instance of NSNull, got ") { expect(nil as NSNull?).toNot(beAnInstanceOf(NSNull.self)) @@ -35,24 +61,19 @@ final class BeAnInstanceOfTest: XCTestCase, XCTestCaseProvider { expect(NSNumber(value:1)).toNot(beAnInstanceOf(NSNumber.self)) } } - - func testSwiftTypesFailureMessages() { - enum TestEnum { - case one, two - } - failsWithErrorMessage("beAnInstanceOf only works on Objective-C types since the Swift compiler" - + " will automatically type check Swift-only types. This expectation is redundant.") { - expect(1).to(beAnInstanceOf(Int.self)) + func testFailureMessagesSwiftTypes() { + failsWithErrorMessage("expected to not be an instance of Int, got ") { + expect(1).toNot(beAnInstanceOf(Int.self)) } - failsWithErrorMessage("beAnInstanceOf only works on Objective-C types since the Swift compiler" - + " will automatically type check Swift-only types. This expectation is redundant.") { - expect("test").to(beAnInstanceOf(String.self)) + + let testClass = TestClassConformingToProtocol() + failsWithErrorMessage("expected to be an instance of \(String(describing: TestProtocol.self)), got <\(String(describing: TestClassConformingToProtocol.self)) instance>") { + expect(testClass).to(beAnInstanceOf(TestProtocol.self)) } - failsWithErrorMessage("beAnInstanceOf only works on Objective-C types since the Swift compiler" - + " will automatically type check Swift-only types. This expectation is redundant.") { - expect(TestEnum.one).to(beAnInstanceOf(TestEnum.self)) + + failsWithErrorMessage("expected to be an instance of String, got ") { + expect(1).to(beAnInstanceOf(String.self)) } } - } diff --git a/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/BeCloseToTest.swift b/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/BeCloseToTest.swift index c9e9c48..7a7e508 100644 --- a/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/BeCloseToTest.swift +++ b/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/BeCloseToTest.swift @@ -43,12 +43,12 @@ final class BeCloseToTest: XCTestCase, XCTestCaseProvider { expect(NSNumber(value:1.2)).to(beCloseTo(9.300, within: 10)) expect(NSNumber(value:1.2)).to(beCloseTo(NSNumber(value:9.300), within: 10)) expect(1.2).to(beCloseTo(NSNumber(value:9.300), within: 10)) - + failsWithErrorMessage("expected to not be close to <1.2001> (within 1), got <1.2>") { expect(NSNumber(value:1.2)).toNot(beCloseTo(1.2001, within: 1.0)) } } - + func testBeCloseToWithCGFloat() { expect(CGFloat(1.2)).to(beCloseTo(1.2001)) expect(CGFloat(1.2)).to(beCloseTo(CGFloat(1.2001))) @@ -60,7 +60,7 @@ final class BeCloseToTest: XCTestCase, XCTestCaseProvider { func testBeCloseToWithDate() { expect(Date(dateTimeString: "2015-08-26 11:43:00")).to(beCloseTo(Date(dateTimeString: "2015-08-26 11:43:05"), within: 10)) - + failsWithErrorMessage("expected to not be close to <2015-08-26 11:43:00.0050> (within 0.004), got <2015-08-26 11:43:00.0000>") { let expectedDate = Date(dateTimeString: "2015-08-26 11:43:00").addingTimeInterval(0.005) expect(Date(dateTimeString: "2015-08-26 11:43:00")).toNot(beCloseTo(expectedDate, within: 0.004)) @@ -79,7 +79,7 @@ final class BeCloseToTest: XCTestCase, XCTestCaseProvider { func testBeCloseToOperator() { expect(1.2) ≈ 1.2001 expect(1.2 as CDouble) ≈ 1.2001 - + failsWithErrorMessage("expected to be close to <1.2002> (within 0.0001), got <1.2>") { expect(1.2) ≈ 1.2002 } @@ -88,7 +88,7 @@ final class BeCloseToTest: XCTestCase, XCTestCaseProvider { func testBeCloseToWithinOperator() { expect(1.2) ≈ (9.300, 10) expect(1.2) == (9.300, 10) - + failsWithErrorMessage("expected to be close to <1> (within 0.1), got <1.2>") { expect(1.2) ≈ (1.0, 0.1) } @@ -96,11 +96,11 @@ final class BeCloseToTest: XCTestCase, XCTestCaseProvider { expect(1.2) == (1.0, 0.1) } } - + func testPlusMinusOperator() { expect(1.2) ≈ 9.300 ± 10 expect(1.2) == 9.300 ± 10 - + failsWithErrorMessage("expected to be close to <1> (within 0.1), got <1.2>") { expect(1.2) ≈ 1.0 ± 0.1 } @@ -149,7 +149,7 @@ final class BeCloseToTest: XCTestCase, XCTestCaseProvider { func testBeCloseToArray() { expect([0.0, 1.1, 2.2]) ≈ [0.0001, 1.1001, 2.2001] expect([0.0, 1.1, 2.2]).to(beCloseTo([0.1, 1.2, 2.3], within: 0.1)) - + failsWithErrorMessage("expected to be close to <[0, 1]> (each within 0.0001), got <[0, 1.1]>") { expect([0.0, 1.1]) ≈ [0.0, 1.0] } diff --git a/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/BeEmptyTest.swift b/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/BeEmptyTest.swift index d7f35aa..7c4abf3 100644 --- a/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/BeEmptyTest.swift +++ b/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/BeEmptyTest.swift @@ -22,7 +22,7 @@ final class BeEmptyTest: XCTestCase, XCTestCaseProvider { expect(NSDictionary(object: 1, forKey: 1 as NSNumber) as? [Int:Int]).toNot(beEmpty()) #endif - expect(Dictionary()).to(beEmpty()) + expect([Int: Int]()).to(beEmpty()) expect(["hi": 1]).toNot(beEmpty()) #if _runtime(_ObjC) @@ -59,17 +59,17 @@ final class BeEmptyTest: XCTestCase, XCTestCaseProvider { } failsWithErrorMessage("expected to not be empty, got <{()}>") { - expect(NSSet()).toNot(beEmpty()); + expect(NSSet()).toNot(beEmpty()) } failsWithErrorMessage("expected to be empty, got <{(1)}>") { - expect(NSSet(object: NSNumber(value: 1))).to(beEmpty()); + expect(NSSet(object: NSNumber(value: 1))).to(beEmpty()) } failsWithErrorMessage("expected to not be empty, got <()>") { - expect(NSIndexSet()).toNot(beEmpty()); + expect(NSIndexSet()).toNot(beEmpty()) } failsWithErrorMessage("expected to be empty, got <(1)>") { - expect(NSIndexSet(index: 1)).to(beEmpty()); + expect(NSIndexSet(index: 1)).to(beEmpty()) } failsWithErrorMessage("expected to not be empty, got <>") { diff --git a/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/BeGreaterThanTest.swift b/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/BeGreaterThanTest.swift index b7dbf47..6da2c0c 100644 --- a/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/BeGreaterThanTest.swift +++ b/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/BeGreaterThanTest.swift @@ -9,7 +9,7 @@ final class BeGreaterThanTest: XCTestCase, XCTestCaseProvider { ("testGreaterThanOperator", testGreaterThanOperator), ] } - + func testGreaterThan() { expect(10).to(beGreaterThan(2)) expect(1).toNot(beGreaterThan(2)) diff --git a/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/BeIdenticalToObjectTest.swift b/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/BeIdenticalToObjectTest.swift index a598bfb..923fa76 100644 --- a/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/BeIdenticalToObjectTest.swift +++ b/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/BeIdenticalToObjectTest.swift @@ -21,11 +21,11 @@ final class BeIdenticalToObjectTest: XCTestCase, XCTestCaseProvider { func testBeIdenticalToPositive() { expect(self.testObjectA).to(beIdenticalTo(testObjectA)) } - + func testBeIdenticalToNegative() { expect(self.testObjectA).toNot(beIdenticalTo(testObjectB)) } - + func testBeIdenticalToPositiveMessage() { let message = String(describing: NSString(format: "expected to be identical to <%p>, got <%p>", unsafeBitCast(testObjectB, to: Int.self), unsafeBitCast(testObjectA, to: Int.self))) @@ -33,7 +33,7 @@ final class BeIdenticalToObjectTest: XCTestCase, XCTestCaseProvider { expect(self.testObjectA).to(beIdenticalTo(self.testObjectB)) } } - + func testBeIdenticalToNegativeMessage() { let message = String(describing: NSString(format: "expected to not be identical to <%p>, got <%p>", unsafeBitCast(testObjectA, to: Int.self), unsafeBitCast(testObjectA, to: Int.self))) @@ -55,7 +55,7 @@ final class BeIdenticalToObjectTest: XCTestCase, XCTestCaseProvider { expect(nil as BeIdenticalToObjectTester?).toNot(beIdenticalTo(self.testObjectA)) } } - + func testOperators() { expect(self.testObjectA) === testObjectA expect(self.testObjectA) !== testObjectB diff --git a/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/BeIdenticalToTest.swift b/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/BeIdenticalToTest.swift index a68260a..6092988 100644 --- a/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/BeIdenticalToTest.swift +++ b/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/BeIdenticalToTest.swift @@ -10,7 +10,7 @@ final class BeIdenticalToTest: XCTestCase, XCTestCaseProvider { ("testBeIdenticalToPositiveMessage", testBeIdenticalToPositiveMessage), ("testBeIdenticalToNegativeMessage", testBeIdenticalToNegativeMessage), ("testOperators", testOperators), - ("testBeAlias", testBeAlias) + ("testBeAlias", testBeAlias), ] } diff --git a/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/BeLogicalTest.swift b/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/BeLogicalTest.swift index 9b8735c..947a1b4 100644 --- a/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/BeLogicalTest.swift +++ b/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/BeLogicalTest.swift @@ -2,7 +2,7 @@ import XCTest import Nimble import Foundation -enum ConvertsToBool : ExpressibleByBooleanLiteral, CustomStringConvertible { +enum ConvertsToBool: ExpressibleByBooleanLiteral, CustomStringConvertible { case trueLike, falseLike typealias BooleanLiteralType = Bool @@ -14,14 +14,14 @@ enum ConvertsToBool : ExpressibleByBooleanLiteral, CustomStringConvertible { } } - var boolValue : Bool { + var boolValue: Bool { switch self { case .trueLike: return true case .falseLike: return false } } - var description : String { + var description: String { switch self { case .trueLike: return "TrueLike" case .falseLike: return "FalseLike" @@ -29,7 +29,7 @@ enum ConvertsToBool : ExpressibleByBooleanLiteral, CustomStringConvertible { } } -final class BeTruthyTest : XCTestCase, XCTestCaseProvider { +final class BeTruthyTest: XCTestCase, XCTestCaseProvider { static var allTests: [(String, (BeTruthyTest) -> () throws -> Void)] { return [ ("testShouldMatchNonNilTypes", testShouldMatchNonNilTypes), @@ -122,7 +122,7 @@ final class BeTruthyTest : XCTestCase, XCTestCaseProvider { } } -final class BeTrueTest : XCTestCase, XCTestCaseProvider { +final class BeTrueTest: XCTestCase, XCTestCaseProvider { static var allTests: [(String, (BeTrueTest) -> () throws -> Void)] { return [ ("testShouldMatchTrue", testShouldMatchTrue), @@ -158,7 +158,7 @@ final class BeTrueTest : XCTestCase, XCTestCaseProvider { } } -final class BeFalsyTest : XCTestCase, XCTestCaseProvider { +final class BeFalsyTest: XCTestCase, XCTestCaseProvider { static var allTests: [(String, (BeFalsyTest) -> () throws -> Void)] { return [ ("testShouldMatchNilTypes", testShouldMatchNilTypes), @@ -233,7 +233,7 @@ final class BeFalsyTest : XCTestCase, XCTestCaseProvider { } } -final class BeFalseTest : XCTestCase, XCTestCaseProvider { +final class BeFalseTest: XCTestCase, XCTestCaseProvider { static var allTests: [(String, (BeFalseTest) -> () throws -> Void)] { return [ ("testShouldNotMatchTrue", testShouldNotMatchTrue), diff --git a/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/BeNilTest.swift b/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/BeNilTest.swift index 78cade0..69f4185 100644 --- a/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/BeNilTest.swift +++ b/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/BeNilTest.swift @@ -8,7 +8,7 @@ final class BeNilTest: XCTestCase, XCTestCaseProvider { ] } - func producesNil() -> Array? { + func producesNil() -> [Int]? { return nil } diff --git a/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/ContainElementSatisfyingTest.swift b/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/ContainElementSatisfyingTest.swift new file mode 100644 index 0000000..a9fe80e --- /dev/null +++ b/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/ContainElementSatisfyingTest.swift @@ -0,0 +1,86 @@ +import Foundation +import XCTest +import Nimble + +final class ContainElementSatisfyingTest: XCTestCase, XCTestCaseProvider { + static var allTests: [(String, (ContainElementSatisfyingTest) -> () throws -> Void)] { + return [ + ("testContainElementSatisfying", testContainElementSatisfying), + ("testContainElementSatisfyingDefaultErrorMessage", testContainElementSatisfyingDefaultErrorMessage), + ("testContainElementSatisfyingSpecificErrorMessage", testContainElementSatisfyingSpecificErrorMessage), + ("testContainElementSatisfyingNegativeCase", + testContainElementSatisfyingNegativeCase), + ("testContainElementSatisfyingNegativeCaseDefaultErrorMessage", + testContainElementSatisfyingNegativeCaseDefaultErrorMessage), + ("testContainElementSatisfyingNegativeCaseSpecificErrorMessage", + testContainElementSatisfyingNegativeCaseSpecificErrorMessage), + ] + } + + func testContainElementSatisfying() { + var orderIndifferentArray = [1, 2, 3] + expect(orderIndifferentArray).to(containElementSatisfying({ number in + return number == 1 + })) + expect(orderIndifferentArray).to(containElementSatisfying({ number in + return number == 2 + })) + expect(orderIndifferentArray).to(containElementSatisfying({ number in + return number == 3 + })) + + orderIndifferentArray = [3, 1, 2] + expect(orderIndifferentArray).to(containElementSatisfying({ number in + return number == 1 + })) + expect(orderIndifferentArray).to(containElementSatisfying({ number in + return number == 2 + })) + expect(orderIndifferentArray).to(containElementSatisfying({ number in + return number == 3 + })) + } + + func testContainElementSatisfyingDefaultErrorMessage() { + let orderIndifferentArray = [1, 2, 3] + failsWithErrorMessage("expected to find object in collection that satisfies predicate") { + expect(orderIndifferentArray).to(containElementSatisfying({ number in + return number == 4 + })) + } + } + + func testContainElementSatisfyingSpecificErrorMessage() { + let orderIndifferentArray = [1, 2, 3] + failsWithErrorMessage("expected to find object in collection equal to 4") { + expect(orderIndifferentArray).to(containElementSatisfying({ number in + return number == 4 + }, "equal to 4")) + } + } + + func testContainElementSatisfyingNegativeCase() { + let orderIndifferentArray = ["puppies", "kittens", "turtles"] + expect(orderIndifferentArray).toNot(containElementSatisfying({ string in + return string == "armadillos" + })) + } + + func testContainElementSatisfyingNegativeCaseDefaultErrorMessage() { + let orderIndifferentArray = ["puppies", "kittens", "turtles"] + failsWithErrorMessage("expected to not find object in collection that satisfies predicate") { + expect(orderIndifferentArray).toNot(containElementSatisfying({ string in + return string == "kittens" + })) + } + } + + func testContainElementSatisfyingNegativeCaseSpecificErrorMessage() { + let orderIndifferentArray = ["puppies", "kittens", "turtles"] + failsWithErrorMessage("expected to not find object in collection equal to 'kittens'") { + expect(orderIndifferentArray).toNot(containElementSatisfying({ string in + return string == "kittens" + }, "equal to 'kittens'")) + } + } +} diff --git a/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/ContainTest.swift b/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/ContainTest.swift index 6b20d15..93b0331 100644 --- a/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/ContainTest.swift +++ b/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/ContainTest.swift @@ -16,7 +16,7 @@ final class ContainTest: XCTestCase, XCTestCaseProvider { func testContain() { expect([1, 2, 3]).to(contain(1)) expect([1, 2, 3] as [CInt]).to(contain(1 as CInt)) - expect([1, 2, 3] as Array).to(contain(1 as CInt)) + expect([1, 2, 3] as [CInt]).toNot(contain(4 as CInt)) expect(["foo", "bar", "baz"]).to(contain("baz")) expect([1, 2, 3]).toNot(contain(4)) expect(["foo", "bar", "baz"]).toNot(contain("ba")) diff --git a/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/EqualTest.swift b/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/EqualTest.swift index a66a784..102e8e1 100644 --- a/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/EqualTest.swift +++ b/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/EqualTest.swift @@ -45,11 +45,11 @@ final class EqualTest: XCTestCase, XCTestCaseProvider { expect([1, 2, 3]).toNot(equal([1, 2])) expect([1, 2, 3]).toNot(equal([1, 2, 4])) - let array1: Array = [1, 2, 3] - let array2: Array = [1, 2, 3] + let array1: [Int] = [1, 2, 3] + let array2: [Int] = [1, 2, 3] expect(array1).to(equal(array2)) expect(array1).to(equal([1, 2, 3])) - expect(array1).toNot(equal([1, 2] as Array)) + expect(array1).toNot(equal([1, 2] as [Int])) #if _runtime(_ObjC) expect(NSArray(array: [1, 2, 3])).to(equal(NSArray(array: [1, 2, 3]))) @@ -182,9 +182,9 @@ final class EqualTest: XCTestCase, XCTestCaseProvider { } func testOperatorEqualityWithArrays() { - let array1: Array = [1, 2, 3] - let array2: Array = [1, 2, 3] - let array3: Array = [1, 2] + let array1: [Int] = [1, 2, 3] + let array2: [Int] = [1, 2, 3] + let array3: [Int] = [1, 2] expect(array1) == array2 expect(array1) != array3 } @@ -203,31 +203,31 @@ final class EqualTest: XCTestCase, XCTestCaseProvider { expect(1).toNot(equal(nil)) } - + func testArrayOfOptionalsEquality() { - let array1: Array = [1, nil, 3] - let array2: Array = [nil, 2, 3] - let array3: Array = [1, nil, 3] - + let array1: [Int?] = [1, nil, 3] + let array2: [Int?] = [nil, 2, 3] + let array3: [Int?] = [1, nil, 3] + expect(array1).toNot(equal(array2)) expect(array1).to(equal(array3)) expect(array2).toNot(equal(array3)) - - let allNils1: Array = [nil, nil, nil, nil] - let allNils2: Array = [nil, nil, nil, nil] - let notReallyAllNils: Array = [nil, nil, nil, "turtles"] - + + let allNils1: [String?] = [nil, nil, nil, nil] + let allNils2: [String?] = [nil, nil, nil, nil] + let notReallyAllNils: [String?] = [nil, nil, nil, "turtles"] + expect(allNils1).to(equal(allNils2)) expect(allNils1).toNot(equal(notReallyAllNils)) - - let noNils1: Array = [1, 2, 3, 4, 5] - let noNils2: Array = [1, 3, 5, 7, 9] - + + let noNils1: [Int?] = [1, 2, 3, 4, 5] + let noNils2: [Int?] = [1, 3, 5, 7, 9] + expect(noNils1).toNot(equal(noNils2)) - + failsWithErrorMessage("expected to equal <[Optional(1), nil]>, got <[nil, Optional(2)]>") { - let arrayOfOptionalInts: Array = [nil, 2] - let anotherArrayOfOptionalInts: Array = [1, nil] + let arrayOfOptionalInts: [Int?] = [nil, 2] + let anotherArrayOfOptionalInts: [Int?] = [1, nil] expect(arrayOfOptionalInts).to(equal(anotherArrayOfOptionalInts)) return } @@ -236,38 +236,38 @@ final class EqualTest: XCTestCase, XCTestCaseProvider { func testDictionariesWithDifferentSequences() { // see: https://github.com/Quick/Nimble/issues/61 // these dictionaries generate different orderings of sequences. - let result = ["how":1, "think":1, "didnt":2, "because":1, - "interesting":1, "always":1, "right":1, "such":1, - "to":3, "say":1, "cool":1, "you":1, - "weather":3, "be":1, "went":1, "was":2, - "sometimes":1, "and":3, "mind":1, "rain":1, - "whole":1, "everything":1, "weather.":1, "down":1, - "kind":1, "mood.":1, "it":2, "everyday":1, "might":1, - "more":1, "have":2, "person":1, "could":1, "tenth":2, - "night":1, "write":1, "Youd":1, "affects":1, "of":3, - "Who":1, "us":1, "an":1, "I":4, "my":1, "much":2, - "wrong.":1, "peacefully.":1, "amazing":3, "would":4, - "just":1, "grade.":1, "Its":2, "The":2, "had":1, "that":1, - "the":5, "best":1, "but":1, "essay":1, "for":1, "summer":2, - "your":1, "grade":1, "vary":1, "pretty":1, "at":1, "rain.":1, - "about":1, "allow":1, "thought":1, "in":1, "sleep":1, "a":1, - "hot":1, "really":1, "beach":1, "life.":1, "we":1, "although":1] - - let storyCount = ["The":2, "summer":2, "of":3, "tenth":2, "grade":1, - "was":2, "the":5, "best":1, "my":1, "life.":1, "I":4, - "went":1, "to":3, "beach":1, "everyday":1, "and":3, - "we":1, "had":1, "amazing":3, "weather.":1, "weather":3, - "didnt":2, "really":1, "vary":1, "much":2, "always":1, - "pretty":1, "hot":1, "although":1, "sometimes":1, "at":1, - "night":1, "it":2, "would":4, "rain.":1, "mind":1, "rain":1, - "because":1, "cool":1, "everything":1, "down":1, "allow":1, - "us":1, "sleep":1, "peacefully.":1, "Its":2, "how":1, - "affects":1, "your":1, "mood.":1, "Who":1, "have":2, - "thought":1, "that":1, "could":1, "write":1, "a":1, - "whole":1, "essay":1, "just":1, "about":1, "in":1, - "grade.":1, "kind":1, "right":1, "Youd":1, "think":1, - "for":1, "such":1, "an":1, "interesting":1, "person":1, - "might":1, "more":1, "say":1, "but":1, "you":1, "be":1, "wrong.":1] + let result = ["how": 1, "think": 1, "didnt": 2, "because": 1, + "interesting": 1, "always": 1, "right": 1, "such": 1, + "to": 3, "say": 1, "cool": 1, "you": 1, + "weather": 3, "be": 1, "went": 1, "was": 2, + "sometimes": 1, "and": 3, "mind": 1, "rain": 1, + "whole": 1, "everything": 1, "weather.": 1, "down": 1, + "kind": 1, "mood.": 1, "it": 2, "everyday": 1, "might": 1, + "more": 1, "have": 2, "person": 1, "could": 1, "tenth": 2, + "night": 1, "write": 1, "Youd": 1, "affects": 1, "of": 3, + "Who": 1, "us": 1, "an": 1, "I": 4, "my": 1, "much": 2, + "wrong.": 1, "peacefully.": 1, "amazing": 3, "would": 4, + "just": 1, "grade.": 1, "Its": 2, "The": 2, "had": 1, "that": 1, + "the": 5, "best": 1, "but": 1, "essay": 1, "for": 1, "summer": 2, + "your": 1, "grade": 1, "vary": 1, "pretty": 1, "at": 1, "rain.": 1, + "about": 1, "allow": 1, "thought": 1, "in": 1, "sleep": 1, "a": 1, + "hot": 1, "really": 1, "beach": 1, "life.": 1, "we": 1, "although": 1, ] + + let storyCount = ["The": 2, "summer": 2, "of": 3, "tenth": 2, "grade": 1, + "was": 2, "the": 5, "best": 1, "my": 1, "life.": 1, "I": 4, + "went": 1, "to": 3, "beach": 1, "everyday": 1, "and": 3, + "we": 1, "had": 1, "amazing": 3, "weather.": 1, "weather": 3, + "didnt": 2, "really": 1, "vary": 1, "much": 2, "always": 1, + "pretty": 1, "hot": 1, "although": 1, "sometimes": 1, "at": 1, + "night": 1, "it": 2, "would": 4, "rain.": 1, "mind": 1, "rain": 1, + "because": 1, "cool": 1, "everything": 1, "down": 1, "allow": 1, + "us": 1, "sleep": 1, "peacefully.": 1, "Its": 2, "how": 1, + "affects": 1, "your": 1, "mood.": 1, "Who": 1, "have": 2, + "thought": 1, "that": 1, "could": 1, "write": 1, "a": 1, + "whole": 1, "essay": 1, "just": 1, "about": 1, "in": 1, + "grade.": 1, "kind": 1, "right": 1, "Youd": 1, "think": 1, + "for": 1, "such": 1, "an": 1, "interesting": 1, "person": 1, + "might": 1, "more": 1, "say": 1, "but": 1, "you": 1, "be": 1, "wrong.": 1, ] expect(result).to(equal(storyCount)) } diff --git a/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/HaveCountTest.swift b/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/HaveCountTest.swift index de5033d..a0294c3 100644 --- a/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/HaveCountTest.swift +++ b/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/HaveCountTest.swift @@ -24,7 +24,7 @@ final class HaveCountTest: XCTestCase, XCTestCaseProvider { } func testHaveCountForDictionary() { - let dictionary = ["1":1, "2":2, "3":3] + let dictionary = ["1": 1, "2": 2, "3": 3] expect(dictionary).to(haveCount(3)) expect(dictionary).notTo(haveCount(1)) diff --git a/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/MatchTest.swift b/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/MatchTest.swift index 5b6d77f..a95ba56 100644 --- a/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/MatchTest.swift +++ b/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/MatchTest.swift @@ -1,7 +1,7 @@ import XCTest import Nimble -final class MatchTest:XCTestCase, XCTestCaseProvider { +final class MatchTest: XCTestCase, XCTestCaseProvider { static var allTests: [(String, (MatchTest) -> () throws -> Void)] { return [ ("testMatchPositive", testMatchPositive), @@ -15,18 +15,18 @@ final class MatchTest:XCTestCase, XCTestCaseProvider { func testMatchPositive() { expect("11:14").to(match("\\d{2}:\\d{2}")) } - + func testMatchNegative() { expect("hello").toNot(match("\\d{2}:\\d{2}")) } - + func testMatchPositiveMessage() { let message = "expected to match <\\d{2}:\\d{2}>, got " failsWithErrorMessage(message) { expect("hello").to(match("\\d{2}:\\d{2}")) } } - + func testMatchNegativeMessage() { let message = "expected to not match <\\d{2}:\\d{2}>, got <11:14>" failsWithErrorMessage(message) { diff --git a/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/RaisesExceptionTest.swift b/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/RaisesExceptionTest.swift index 302a2f5..20461d9 100644 --- a/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/RaisesExceptionTest.swift +++ b/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/RaisesExceptionTest.swift @@ -93,7 +93,7 @@ final class RaisesExceptionTest: XCTestCase, XCTestCaseProvider { expect(exception.name).to(equal(NSExceptionName(rawValue:"foo"))) }) } - + failsWithErrorMessage("expected to raise exception with name that satisfies block, got no exception") { expect { self.anException }.to(raiseException(named: "foo") { (exception: NSException) in expect(exception.name.rawValue).to(equal("foo")) diff --git a/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/SatisfyAnyOfTest.swift b/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/SatisfyAnyOfTest.swift index 9378956..0bd9495 100644 --- a/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/SatisfyAnyOfTest.swift +++ b/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/SatisfyAnyOfTest.swift @@ -17,19 +17,19 @@ final class SatisfyAnyOfTest: XCTestCase, XCTestCaseProvider { #else expect(2 as NSNumber).toNot(satisfyAnyOf(equal(3 as NSNumber), equal("turtles" as NSString))) #endif - expect([1,2,3]).to(satisfyAnyOf(equal([1,2,3]), allPass({$0 < 4}), haveCount(3))) + expect([1, 2, 3]).to(satisfyAnyOf(equal([1, 2, 3]), allPass({$0 < 4}), haveCount(3))) expect("turtle").toNot(satisfyAnyOf(contain("a"), endWith("magic"))) expect(82.0).toNot(satisfyAnyOf(beLessThan(10.5), beGreaterThan(100.75), beCloseTo(50.1))) expect(false).to(satisfyAnyOf(beTrue(), beFalse())) expect(true).to(satisfyAnyOf(beTruthy(), beFalsy())) - + failsWithErrorMessage( "expected to match one of: {equal <3>}, or {equal <4>}, or {equal <5>}, got 2") { expect(2).to(satisfyAnyOf(equal(3), equal(4), equal(5))) } failsWithErrorMessage( "expected to match one of: {all be less than 4, but failed first at element <5> in <[5, 6, 7]>}, or {equal <[1, 2, 3, 4]>}, got [5, 6, 7]") { - expect([5,6,7]).to(satisfyAnyOf(allPass("be less than 4", {$0 < 4}), equal([1,2,3,4]))) + expect([5, 6, 7]).to(satisfyAnyOf(allPass("be less than 4", {$0 < 4}), equal([1, 2, 3, 4]))) } failsWithErrorMessage( "expected to match one of: {be true}, got false") { @@ -40,7 +40,7 @@ final class SatisfyAnyOfTest: XCTestCase, XCTestCaseProvider { expect(50.10001).toNot(satisfyAnyOf(beLessThan(10.5), beGreaterThan(100.75), beCloseTo(50.1))) } } - + func testOperatorOr() { expect(2).to(equal(2) || equal(3)) #if SUPPORT_IMPLICIT_BRIDGING_CONVERSION diff --git a/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/ThrowAssertionTest.swift b/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/ThrowAssertionTest.swift index c227b1b..9c66fe6 100644 --- a/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/ThrowAssertionTest.swift +++ b/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/ThrowAssertionTest.swift @@ -42,7 +42,7 @@ final class ThrowAssertionTest: XCTestCase, XCTestCaseProvider { var reachedPoint1 = false expect { reachedPoint1 = true }.toNot(throwAssertion()) - + expect(reachedPoint1) == true } diff --git a/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/ThrowErrorTest.swift b/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/ThrowErrorTest.swift index d7cd312..1c7674c 100644 --- a/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/ThrowErrorTest.swift +++ b/Carthage/Checkouts/Nimble/Tests/NimbleTests/Matchers/ThrowErrorTest.swift @@ -1,32 +1,32 @@ import XCTest import Nimble -enum NimbleError : Error { +enum NimbleError: Error { case laugh case cry } -enum EquatableError : Error { +enum EquatableError: Error { case parameterized(x: Int) } extension EquatableError : Equatable { } -func ==(lhs: EquatableError, rhs: EquatableError) -> Bool { +func == (lhs: EquatableError, rhs: EquatableError) -> Bool { switch (lhs, rhs) { case (.parameterized(let l), .parameterized(let r)): return l == r } } -enum CustomDebugStringConvertibleError : Error { +enum CustomDebugStringConvertibleError: Error { case a case b } extension CustomDebugStringConvertibleError : CustomDebugStringConvertible { - var debugDescription : String { + var debugDescription: String { return "code=\(_code)" } } @@ -120,13 +120,13 @@ final class ThrowErrorTest: XCTestCase, XCTestCaseProvider { func testNegativeMatchesDoNotCallClosureWithoutError() { failsWithErrorMessage("expected to throw error that satisfies block, got no error") { - expect { return }.to(throwError { error in + expect { return }.to(throwError { _ in fail() }) } - + failsWithErrorMessage("expected to throw error that satisfies block, got no error") { - expect { return }.to(throwError(NimbleError.laugh) { error in + expect { return }.to(throwError(NimbleError.laugh) { _ in fail() }) } diff --git a/Carthage/Checkouts/Nimble/Tests/NimbleTests/SynchronousTests.swift b/Carthage/Checkouts/Nimble/Tests/NimbleTests/SynchronousTests.swift index 6234932..eefd178 100644 --- a/Carthage/Checkouts/Nimble/Tests/NimbleTests/SynchronousTests.swift +++ b/Carthage/Checkouts/Nimble/Tests/NimbleTests/SynchronousTests.swift @@ -47,19 +47,19 @@ final class SynchronousTest: XCTestCase, XCTestCaseProvider { } func testToMatchesIfMatcherReturnsTrue() { - expect(1).to(MatcherFunc { expr, failure in true }) - expect{1}.to(MatcherFunc { expr, failure in true }) + expect(1).to(MatcherFunc { _, _ in true }) + expect {1}.to(MatcherFunc { _, _ in true }) } func testToProvidesActualValueExpression() { var value: Int? - expect(1).to(MatcherFunc { expr, failure in value = try expr.evaluate(); return true }) + 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, failure in + expect { callCount += 1 }.to(MatcherFunc { expr, _ in _ = try expr.evaluate() _ = try expr.evaluate() return true @@ -69,7 +69,7 @@ final class SynchronousTest: XCTestCase, XCTestCaseProvider { func testToProvidesAMemoizedActualValueExpressionIsEvaluatedAtMatcherControl() { var callCount = 0 - expect{ callCount += 1 }.to(MatcherFunc { expr, failure in + expect { callCount += 1 }.to(MatcherFunc { expr, _ in expect(callCount).to(equal(0)) _ = try expr.evaluate() return true @@ -86,19 +86,19 @@ final class SynchronousTest: XCTestCase, XCTestCaseProvider { // repeated tests from to() for toNot() func testToNotMatchesIfMatcherReturnsTrue() { - expect(1).toNot(MatcherFunc { expr, failure in false }) - expect{1}.toNot(MatcherFunc { expr, failure in false }) + expect(1).toNot(MatcherFunc { _, _ in false }) + expect {1}.toNot(MatcherFunc { _, _ in false }) } func testToNotProvidesActualValueExpression() { var value: Int? - expect(1).toNot(MatcherFunc { expr, failure in value = try expr.evaluate(); return false }) + 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, failure in + expect { callCount += 1 }.toNot(MatcherFunc { expr, _ in _ = try expr.evaluate() _ = try expr.evaluate() return false @@ -108,7 +108,7 @@ final class SynchronousTest: XCTestCase, XCTestCaseProvider { func testToNotProvidesAMemoizedActualValueExpressionIsEvaluatedAtMatcherControl() { var callCount = 0 - expect{ callCount += 1 }.toNot(MatcherFunc { expr, failure in + expect { callCount += 1 }.toNot(MatcherFunc { expr, _ in expect(callCount).to(equal(0)) _ = try expr.evaluate() return false @@ -118,12 +118,11 @@ final class SynchronousTest: XCTestCase, XCTestCaseProvider { func testToNotNegativeMatches() { failsWithErrorMessage("expected to not match, got <1>") { - expect(1).toNot(MatcherFunc { expr, failure in true }) + expect(1).toNot(MatcherFunc { _, _ in true }) } } - func testNotToMatchesLikeToNot() { - expect(1).notTo(MatcherFunc { expr, failure in false }) + expect(1).notTo(MatcherFunc { _, _ in false }) } } diff --git a/Carthage/Checkouts/Nimble/Tests/NimbleTests/UserDescriptionTest.swift b/Carthage/Checkouts/Nimble/Tests/NimbleTests/UserDescriptionTest.swift index e22d64e..9bb64b6 100644 --- a/Carthage/Checkouts/Nimble/Tests/NimbleTests/UserDescriptionTest.swift +++ b/Carthage/Checkouts/Nimble/Tests/NimbleTests/UserDescriptionTest.swift @@ -12,31 +12,31 @@ final class UserDescriptionTest: XCTestCase, XCTestCaseProvider { ("testToNotEventuallyMatch_CustomFailureMessage", testToNotEventuallyMatch_CustomFailureMessage), ] } - + func testToMatcher_CustomFailureMessage() { failsWithErrorMessage( "These aren't equal!\n" + "expected to match, got <1>") { - expect(1).to(MatcherFunc { expr, failure in false }, description: "These aren't equal!") + expect(1).to(MatcherFunc { _, _ in false }, description: "These aren't equal!") } } - + func testNotToMatcher_CustomFailureMessage() { failsWithErrorMessage( "These aren't equal!\n" + "expected to not match, got <1>") { - expect(1).notTo(MatcherFunc { expr, failure in true }, description: "These aren't equal!") + expect(1).notTo(MatcherFunc { _, _ in true }, description: "These aren't equal!") } } - + func testToNotMatcher_CustomFailureMessage() { failsWithErrorMessage( "These aren't equal!\n" + "expected to not match, got <1>") { - expect(1).toNot(MatcherFunc { expr, failure in true }, description: "These aren't equal!") + expect(1).toNot(MatcherFunc { _, _ in true }, description: "These aren't equal!") } } - + func testToEventuallyMatch_CustomFailureMessage() { failsWithErrorMessage( "These aren't eventually equal!\n" + @@ -44,7 +44,7 @@ final class UserDescriptionTest: XCTestCase, XCTestCaseProvider { expect { 0 }.toEventually(equal(1), description: "These aren't eventually equal!") } } - + func testToEventuallyNotMatch_CustomFailureMessage() { failsWithErrorMessage( "These are eventually equal!\n" + @@ -52,7 +52,7 @@ final class UserDescriptionTest: XCTestCase, XCTestCaseProvider { expect { 1 }.toEventuallyNot(equal(1), description: "These are eventually equal!") } } - + func testToNotEventuallyMatch_CustomFailureMessage() { failsWithErrorMessage( "These are eventually equal!\n" + diff --git a/Carthage/Checkouts/Nimble/Tests/NimbleTests/objc/ObjCContainElementSatisfying.m b/Carthage/Checkouts/Nimble/Tests/NimbleTests/objc/ObjCContainElementSatisfying.m new file mode 100644 index 0000000..b15d6c3 --- /dev/null +++ b/Carthage/Checkouts/Nimble/Tests/NimbleTests/objc/ObjCContainElementSatisfying.m @@ -0,0 +1,64 @@ +#import +#import "NimbleSpecHelper.h" + +@interface ObjCContainElementSatisfyingTest : XCTestCase + +@end + +@implementation ObjCContainElementSatisfyingTest + +- (void)testPassingMatches { + NSArray *orderIndifferentArray = @[@1, @2, @3]; + expect(orderIndifferentArray).to(containElementSatisfying(^BOOL(id object) { + return [object isEqualToNumber:@1]; + })); + expect(orderIndifferentArray).to(containElementSatisfying(^BOOL(id object) { + return [object isEqualToNumber:@2]; + })); + expect(orderIndifferentArray).to(containElementSatisfying(^BOOL(id object) { + return [object isEqualToNumber:@3]; + })); + + orderIndifferentArray = @[@3, @1, @2]; + expect(orderIndifferentArray).to(containElementSatisfying(^BOOL(id object) { + return [object isEqualToNumber:@1]; + })); + expect(orderIndifferentArray).to(containElementSatisfying(^BOOL(id object) { + return [object isEqualToNumber:@2]; + })); + expect(orderIndifferentArray).to(containElementSatisfying(^BOOL(id object) { + return [object isEqualToNumber:@3]; + })); + + NSSet *orderIndifferentSet = [NSSet setWithObjects:@"turtle test", @"turtle assessment", nil]; + expect(orderIndifferentSet).to(containElementSatisfying(^BOOL(id object) { + return [object isEqualToString:@"turtle assessment"]; + })); +} + +- (void)testFailingMatches { + expectFailureMessage(@"expected to find object in collection that satisfies predicate", ^{ + expect(@[@1]).to(containElementSatisfying(^BOOL(id object) { + return [object isEqualToNumber:@2]; + })); + }); + expectFailureMessage(@"containElementSatisfying must be provided an NSFastEnumeration object", ^{ + expect((nil)).to(containElementSatisfying(^BOOL(id object) { + return [object isEqualToNumber:@3]; + })); + }); + expectFailureMessage(@"containElementSatisfying must be provided an NSFastEnumeration object", ^{ + expect((@3)).to(containElementSatisfying(^BOOL(id object) { + return [object isEqualToNumber:@3]; + })); + }); +} + +- (void)testNegativeCases { + NSArray *orderIndifferentArray = @[@"puppies", @"kittens", @"turtles"]; + expect(orderIndifferentArray).toNot(containElementSatisfying(^BOOL(id object) { + return [object isEqualToString:@"armadillos"]; + })); +} + +@end diff --git a/Carthage/Checkouts/Nimble/Tests/NimbleTests/objc/ObjCRaiseExceptionTest.m b/Carthage/Checkouts/Nimble/Tests/NimbleTests/objc/ObjCRaiseExceptionTest.m index d84915a..e64c2f2 100644 --- a/Carthage/Checkouts/Nimble/Tests/NimbleTests/objc/ObjCRaiseExceptionTest.m +++ b/Carthage/Checkouts/Nimble/Tests/NimbleTests/objc/ObjCRaiseExceptionTest.m @@ -141,7 +141,7 @@ - (void)testNegativeMatchesWithNegativeBlocks { userInfo:@{@"key": @"value"}]; NSString *outerFailureMessage; - NSString const *innerFailureMessage = @"expected to equal , got "; + NSString *const innerFailureMessage = @"expected to equal , got "; outerFailureMessage = @"expected to raise exception with name that satisfies block, got NSException { name=NSExceptionName(_rawValue: NSInvalidArgumentException), reason='No food', userInfo=[AnyHashable(\"key\"): value] }"; expectFailureMessages((@[outerFailureMessage, innerFailureMessage]), ^{ expectAction(^{ [exception raise]; }).to(raiseException().