├── .ColorPicker.podspec.swp ├── .gitignore ├── .swift-version ├── .travis.yml ├── ColorPicker.podspec ├── Example ├── ColorPicker.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcshareddata │ │ └── xcschemes │ │ ├── ColorPicker-Example.xcscheme │ │ └── ColorPicker.xcscheme ├── ColorPicker.xcworkspace │ └── contents.xcworkspacedata ├── ColorPicker │ ├── AppDelegate.swift │ ├── Base.lproj │ │ ├── LaunchScreen.xib │ │ └── Main.storyboard │ ├── Images.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Info.plist │ └── ViewController.swift ├── Podfile ├── Podfile.lock ├── Pods │ ├── Local Podspecs │ │ └── ColorPicker.podspec.json │ ├── Manifest.lock │ ├── Nimble │ │ ├── LICENSE.md │ │ ├── README.md │ │ └── Sources │ │ │ ├── Lib │ │ │ └── CwlPreconditionTesting │ │ │ │ ├── CwlCatchException │ │ │ │ └── CwlCatchException │ │ │ │ │ ├── CwlCatchException.h │ │ │ │ │ ├── CwlCatchException.m │ │ │ │ │ └── CwlCatchException.swift │ │ │ │ └── CwlPreconditionTesting │ │ │ │ ├── CwlBadInstructionException.swift │ │ │ │ ├── CwlCatchBadInstruction.h │ │ │ │ ├── CwlCatchBadInstruction.m │ │ │ │ ├── CwlCatchBadInstruction.swift │ │ │ │ ├── CwlDarwinDefinitions.swift │ │ │ │ ├── mach_excServer.c │ │ │ │ └── mach_excServer.h │ │ │ ├── Nimble │ │ │ ├── Adapters │ │ │ │ ├── AdapterProtocols.swift │ │ │ │ ├── AssertionDispatcher.swift │ │ │ │ ├── AssertionRecorder.swift │ │ │ │ ├── NMBExpectation.swift │ │ │ │ ├── NMBObjCMatcher.swift │ │ │ │ ├── NimbleEnvironment.swift │ │ │ │ └── NimbleXCTestHandler.swift │ │ │ ├── DSL+Wait.swift │ │ │ ├── DSL.swift │ │ │ ├── Expectation.swift │ │ │ ├── Expression.swift │ │ │ ├── FailureMessage.swift │ │ │ ├── Matchers │ │ │ │ ├── AllPass.swift │ │ │ │ ├── AsyncMatcherWrapper.swift │ │ │ │ ├── BeAKindOf.swift │ │ │ │ ├── BeAnInstanceOf.swift │ │ │ │ ├── BeCloseTo.swift │ │ │ │ ├── BeEmpty.swift │ │ │ │ ├── BeGreaterThan.swift │ │ │ │ ├── BeGreaterThanOrEqualTo.swift │ │ │ │ ├── BeIdenticalTo.swift │ │ │ │ ├── BeLessThan.swift │ │ │ │ ├── BeLessThanOrEqual.swift │ │ │ │ ├── BeLogical.swift │ │ │ │ ├── BeNil.swift │ │ │ │ ├── BeVoid.swift │ │ │ │ ├── BeginWith.swift │ │ │ │ ├── Contain.swift │ │ │ │ ├── EndWith.swift │ │ │ │ ├── Equal.swift │ │ │ │ ├── HaveCount.swift │ │ │ │ ├── Match.swift │ │ │ │ ├── MatchError.swift │ │ │ │ ├── MatcherFunc.swift │ │ │ │ ├── MatcherProtocols.swift │ │ │ │ ├── PostNotification.swift │ │ │ │ ├── RaisesException.swift │ │ │ │ ├── SatisfyAnyOf.swift │ │ │ │ ├── ThrowAssertion.swift │ │ │ │ └── ThrowError.swift │ │ │ ├── Nimble.h │ │ │ └── Utils │ │ │ │ ├── Async.swift │ │ │ │ ├── Errors.swift │ │ │ │ ├── Functional.swift │ │ │ │ ├── SourceLocation.swift │ │ │ │ └── Stringers.swift │ │ │ └── NimbleObjectiveC │ │ │ ├── CurrentTestCaseTracker.h │ │ │ ├── DSL.h │ │ │ ├── DSL.m │ │ │ ├── NMBExceptionCapture.h │ │ │ ├── NMBExceptionCapture.m │ │ │ ├── NMBStringify.h │ │ │ ├── NMBStringify.m │ │ │ └── XCTestObservationCenter+Register.m │ ├── Pods.xcodeproj │ │ └── project.pbxproj │ ├── Quick │ │ ├── LICENSE │ │ ├── README.md │ │ └── Sources │ │ │ ├── Quick │ │ │ ├── Callsite.swift │ │ │ ├── Configuration │ │ │ │ └── Configuration.swift │ │ │ ├── DSL │ │ │ │ ├── DSL.swift │ │ │ │ └── World+DSL.swift │ │ │ ├── ErrorUtility.swift │ │ │ ├── Example.swift │ │ │ ├── ExampleGroup.swift │ │ │ ├── ExampleMetadata.swift │ │ │ ├── Filter.swift │ │ │ ├── Hooks │ │ │ │ ├── Closures.swift │ │ │ │ ├── ExampleHooks.swift │ │ │ │ ├── HooksPhase.swift │ │ │ │ └── SuiteHooks.swift │ │ │ ├── NSBundle+CurrentTestBundle.swift │ │ │ ├── QuickSelectedTestSuiteBuilder.swift │ │ │ ├── QuickTestSuite.swift │ │ │ ├── URL+FileName.swift │ │ │ └── World.swift │ │ │ └── QuickObjectiveC │ │ │ ├── Configuration │ │ │ ├── QuickConfiguration.h │ │ │ └── QuickConfiguration.m │ │ │ ├── DSL │ │ │ ├── QCKDSL.h │ │ │ ├── QCKDSL.m │ │ │ └── World+DSL.h │ │ │ ├── NSString+QCKSelectorName.h │ │ │ ├── NSString+QCKSelectorName.m │ │ │ ├── Quick.h │ │ │ ├── QuickSpec.h │ │ │ ├── QuickSpec.m │ │ │ ├── World.h │ │ │ └── XCTestSuite+QuickTestSuiteBuilder.m │ └── Target Support Files │ │ ├── ColorPicker │ │ ├── ColorPicker-dummy.m │ │ ├── ColorPicker-prefix.pch │ │ ├── ColorPicker-umbrella.h │ │ ├── ColorPicker.modulemap │ │ ├── ColorPicker.xcconfig │ │ ├── Info.plist │ │ └── ResourceBundle-ColorPicker-Info.plist │ │ ├── Nimble │ │ ├── Info.plist │ │ ├── Nimble-dummy.m │ │ ├── Nimble-prefix.pch │ │ ├── Nimble-umbrella.h │ │ ├── Nimble.modulemap │ │ └── Nimble.xcconfig │ │ ├── Pods-ColorPicker_Example │ │ ├── Info.plist │ │ ├── Pods-ColorPicker_Example-acknowledgements.markdown │ │ ├── Pods-ColorPicker_Example-acknowledgements.plist │ │ ├── Pods-ColorPicker_Example-dummy.m │ │ ├── Pods-ColorPicker_Example-frameworks.sh │ │ ├── Pods-ColorPicker_Example-resources.sh │ │ ├── Pods-ColorPicker_Example-umbrella.h │ │ ├── Pods-ColorPicker_Example.debug.xcconfig │ │ ├── Pods-ColorPicker_Example.modulemap │ │ └── Pods-ColorPicker_Example.release.xcconfig │ │ ├── Pods-ColorPicker_Tests │ │ ├── Info.plist │ │ ├── Pods-ColorPicker_Tests-acknowledgements.markdown │ │ ├── Pods-ColorPicker_Tests-acknowledgements.plist │ │ ├── Pods-ColorPicker_Tests-dummy.m │ │ ├── Pods-ColorPicker_Tests-frameworks.sh │ │ ├── Pods-ColorPicker_Tests-resources.sh │ │ ├── Pods-ColorPicker_Tests-umbrella.h │ │ ├── Pods-ColorPicker_Tests.debug.xcconfig │ │ ├── Pods-ColorPicker_Tests.modulemap │ │ └── Pods-ColorPicker_Tests.release.xcconfig │ │ └── Quick │ │ ├── Info.plist │ │ ├── Quick-dummy.m │ │ ├── Quick-prefix.pch │ │ ├── Quick-umbrella.h │ │ ├── Quick.modulemap │ │ └── Quick.xcconfig └── Tests │ ├── Info.plist │ ├── TestsButtonPicker.swift │ └── TestsColorPicker.swift ├── LICENSE ├── Pod ├── Assets │ └── .gitkeep └── Classes │ ├── .gitkeep │ ├── ButtonConfiguration.swift │ ├── ColorPicker.swift │ ├── ColorPickerButton.swift │ ├── ColorPickerSelection.swift │ ├── Extension.swift │ └── WarpSelectionAnimation.swift ├── README.md ├── _Pods.xcodeproj └── sample.gif /.ColorPicker.podspec.swp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambas/ColorPicker/904046c50e15594d697bf8d86b791c9ca888ce9b/.ColorPicker.podspec.swp -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # OS X 2 | .DS_Store 3 | 4 | # Xcode 5 | build/ 6 | *.pbxuser 7 | !default.pbxuser 8 | *.mode1v3 9 | !default.mode1v3 10 | *.mode2v3 11 | !default.mode2v3 12 | *.perspectivev3 13 | !default.perspectivev3 14 | xcuserdata 15 | *.xccheckout 16 | profile 17 | *.moved-aside 18 | DerivedData 19 | *.hmap 20 | *.ipa 21 | 22 | # Bundler 23 | .bundle 24 | 25 | Carthage 26 | # We recommend against adding the Pods directory to your .gitignore. However 27 | # you should judge for yourself, the pros and cons are mentioned at: 28 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 29 | # 30 | # Note: if you ignore the Pods directory, make sure to uncomment 31 | # `pod install` in .travis.yml 32 | # 33 | # Pods/ 34 | -------------------------------------------------------------------------------- /.swift-version: -------------------------------------------------------------------------------- 1 | 3.0 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: swift 2 | os: osx 3 | osx_image: xcode8.2 4 | install: 5 | - gem install xcpretty 6 | 7 | xcode_workspace: Example/ColorPicker.xcworkspace 8 | xcode_scheme: ColorPicker 9 | 10 | script: 11 | - set -o pipefail 12 | 13 | after_success: 14 | - bash <(curl -s https://codecov.io/bash) 15 | -------------------------------------------------------------------------------- /ColorPicker.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # Be sure to run `pod lib lint ColorPicker.podspec' to ensure this is a 3 | # valid spec before submitting. 4 | # 5 | # Any lines starting with a # are optional, but their use is encouraged 6 | # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html 7 | # 8 | 9 | Pod::Spec.new do |s| 10 | s.name = "ColorPicker" 11 | s.version = "0.1.2" 12 | s.summary = "Simple Color Picker writen with Swift." 13 | 14 | # This description is used to generate tags and improve search results. 15 | # * Think: What does it do? Why did you write it? What is the focus? 16 | # * Try to keep it short, snappy and to the point. 17 | # * Write the description between the DESC delimiters below. 18 | # * Finally, don't worry about the indent, CocoaPods strips it! 19 | s.description = "Simple Color Picker writen with Swift you can select you color set by yourself" 20 | 21 | 22 | s.homepage = "https://github.com/ambas/ColorPicker" 23 | # s.screenshots = "www.example.com/screenshots_1", "www.example.com/screenshots_2" 24 | s.license = 'MIT' 25 | s.author = { "Ambas" => "ambaschobsanti@gmail.com" } 26 | s.source = { :git => "https://github.com/ambas/ColorPicker.git", :tag => s.version.to_s } 27 | # s.social_media_url = 'https://twitter.com/' 28 | 29 | s.platform = :ios, '10.0' 30 | s.requires_arc = true 31 | 32 | s.source_files = 'Pod/Classes/**/*' 33 | # s.resource_bundles = { 34 | # 'ColorPicker' => ['Pod/Assets/*.png'] 35 | # } 36 | 37 | # s.public_header_files = 'Pod/Classes/**/*.h' 38 | # s.frameworks = 'UIKit', 'MapKit' 39 | # s.dependency 'AFNetworking', '~> 2.3' 40 | end 41 | -------------------------------------------------------------------------------- /Example/ColorPicker.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Example/ColorPicker.xcodeproj/xcshareddata/xcschemes/ColorPicker.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 49 | 50 | 51 | 52 | 53 | 54 | 64 | 65 | 71 | 72 | 73 | 74 | 75 | 76 | 82 | 83 | 89 | 90 | 91 | 92 | 94 | 95 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /Example/ColorPicker.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Example/ColorPicker/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // ColorPicker 4 | // 5 | // Created by Ambas on 12/21/2015. 6 | // Copyright (c) 2015 Ambas. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 17 | // Override point for customization after application launch. 18 | return true 19 | } 20 | } 21 | 22 | -------------------------------------------------------------------------------- /Example/ColorPicker/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 21 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /Example/ColorPicker/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Example/ColorPicker/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /Example/ColorPicker/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // ColorPicker 4 | // 5 | // Created by Ambas on 12/21/2015. 6 | // Copyright (c) 2015 Ambas. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import ColorPicker 11 | 12 | class ViewController: UIViewController, ColorPickerDelegate { 13 | 14 | @IBOutlet weak var colorPicker: ColorPickerListView! 15 | @IBOutlet weak var alignmentOption: UISegmentedControl! 16 | @IBOutlet weak var colorView: UIView! 17 | @IBOutlet weak var allowDeselectSwitch: UISwitch! 18 | 19 | override func viewDidLoad() { 20 | super.viewDidLoad() 21 | colorPicker.colorPickerDelegate = self 22 | } 23 | 24 | @IBAction func didChangeAlignMent(_ alignmentOption: UISegmentedControl) { 25 | switch alignmentOption.selectedSegmentIndex { 26 | case 0: 27 | colorPicker.alignment = "left" 28 | case 1: 29 | colorPicker.alignment = "center" 30 | case 2: 31 | colorPicker.alignment = "right" 32 | default: 33 | colorPicker.alignment = "left" 34 | } 35 | } 36 | 37 | @IBAction func addColor(_ sender: AnyObject) { 38 | var colors = colorPicker.colors 39 | colors.append("#5EB566") 40 | colorPicker.colors = colors 41 | } 42 | 43 | @IBAction func removeColor(_ sender: AnyObject) { 44 | var colors = colorPicker.colors 45 | colors.popLast() 46 | colorPicker.colors = colors 47 | } 48 | 49 | func colorPicker(_ colorPicker: ColorPickerListView, selectedColor: String) { 50 | colorView.backgroundColor = UIColor.colorWithHexString(selectedColor) 51 | } 52 | 53 | func colorPicker(_ colorPicker: ColorPickerListView, deselectedColor: String) { 54 | colorView.backgroundColor = UIColor.white 55 | } 56 | 57 | 58 | 59 | @IBAction func changeAllowDeselect(_ allowDeselectSwitch: UISwitch) { 60 | colorPicker.allowsDeselection = allowDeselectSwitch.isOn 61 | } 62 | } 63 | 64 | -------------------------------------------------------------------------------- /Example/Podfile: -------------------------------------------------------------------------------- 1 | source 'https://github.com/CocoaPods/Specs.git' 2 | use_frameworks! 3 | 4 | target 'ColorPicker_Example' do 5 | pod "ColorPicker" , :path => "../" 6 | end 7 | 8 | target 'ColorPicker_Tests' do 9 | pod "ColorPicker" , :path => "../" 10 | 11 | pod 'Quick' 12 | pod 'Nimble' 13 | end 14 | -------------------------------------------------------------------------------- /Example/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - ColorPicker (0.1.0) 3 | - Nimble (5.1.1) 4 | - Quick (1.0.0) 5 | 6 | DEPENDENCIES: 7 | - ColorPicker (from `../`) 8 | - Nimble 9 | - Quick 10 | 11 | EXTERNAL SOURCES: 12 | ColorPicker: 13 | :path: "../" 14 | 15 | SPEC CHECKSUMS: 16 | ColorPicker: 1ee53dfe987944561815ad70e9811df942126979 17 | Nimble: 415e3aa3267e7bc2c96b05fa814ddea7bb686a29 18 | Quick: 8024e4a47e6cc03a9d5245ef0948264fc6d27cff 19 | 20 | PODFILE CHECKSUM: a0f7e0110ed32fe4e4216e3c0cb2468b50a257be 21 | 22 | COCOAPODS: 1.1.1 23 | -------------------------------------------------------------------------------- /Example/Pods/Local Podspecs/ColorPicker.podspec.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ColorPicker", 3 | "version": "0.1.0", 4 | "summary": "Simple Color Picker writen with Swift.", 5 | "description": "Simple Color Picker writen with Swift you can select you color set by yourself", 6 | "homepage": "https://github.com/ambas/ColorPicker", 7 | "license": "MIT", 8 | "authors": { 9 | "Ambas": "ambaschobsanti@gmail.com" 10 | }, 11 | "source": { 12 | "git": "https://github.com/ambas/ColorPicker.git", 13 | "tag": "0.1.0" 14 | }, 15 | "platforms": { 16 | "ios": "8.0" 17 | }, 18 | "requires_arc": true, 19 | "source_files": "Pod/Classes/**/*", 20 | "resource_bundles": { 21 | "ColorPicker": [ 22 | "Pod/Assets/*.png" 23 | ] 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Example/Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - ColorPicker (0.1.0) 3 | - Nimble (5.1.1) 4 | - Quick (1.0.0) 5 | 6 | DEPENDENCIES: 7 | - ColorPicker (from `../`) 8 | - Nimble 9 | - Quick 10 | 11 | EXTERNAL SOURCES: 12 | ColorPicker: 13 | :path: "../" 14 | 15 | SPEC CHECKSUMS: 16 | ColorPicker: 1ee53dfe987944561815ad70e9811df942126979 17 | Nimble: 415e3aa3267e7bc2c96b05fa814ddea7bb686a29 18 | Quick: 8024e4a47e6cc03a9d5245ef0948264fc6d27cff 19 | 20 | PODFILE CHECKSUM: a0f7e0110ed32fe4e4216e3c0cb2468b50a257be 21 | 22 | COCOAPODS: 1.1.1 23 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Lib/CwlPreconditionTesting/CwlCatchException/CwlCatchException/CwlCatchException.h: -------------------------------------------------------------------------------- 1 | // 2 | // CwlCatchException.h 3 | // CwlCatchException 4 | // 5 | // Created by Matt Gallagher on 2016/01/10. 6 | // Copyright © 2016 Matt Gallagher ( http://cocoawithlove.com ). All rights reserved. 7 | // 8 | // Permission to use, copy, modify, and/or distribute this software for any 9 | // purpose with or without fee is hereby granted, provided that the above 10 | // copyright notice and this permission notice appear in all copies. 11 | // 12 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 15 | // SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR 18 | // IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | // 20 | 21 | #import 22 | 23 | //! Project version number for CwlCatchException. 24 | FOUNDATION_EXPORT double CwlCatchExceptionVersionNumber; 25 | 26 | //! Project version string for CwlCatchException. 27 | FOUNDATION_EXPORT const unsigned char CwlCatchExceptionVersionString[]; 28 | 29 | __attribute__((visibility("hidden"))) 30 | NSException* __nullable catchExceptionOfKind(Class __nonnull type, __attribute__((noescape)) void (^ __nonnull inBlock)()); 31 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Lib/CwlPreconditionTesting/CwlCatchException/CwlCatchException/CwlCatchException.m: -------------------------------------------------------------------------------- 1 | // 2 | // CwlCatchException.m 3 | // CwlAssertionTesting 4 | // 5 | // Created by Matt Gallagher on 2016/01/10. 6 | // Copyright © 2016 Matt Gallagher ( http://cocoawithlove.com ). All rights reserved. 7 | // 8 | // Permission to use, copy, modify, and/or distribute this software for any 9 | // purpose with or without fee is hereby granted, provided that the above 10 | // copyright notice and this permission notice appear in all copies. 11 | // 12 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 15 | // SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR 18 | // IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | // 20 | 21 | #import "CwlCatchException.h" 22 | 23 | __attribute__((visibility("hidden"))) 24 | NSException* catchExceptionOfKind(Class __nonnull type, __attribute__((noescape)) void (^ __nonnull inBlock)()) { 25 | @try { 26 | inBlock(); 27 | } @catch (NSException *exception) { 28 | if ([exception isKindOfClass:type]) { 29 | return exception; 30 | } else { 31 | @throw; 32 | } 33 | } 34 | return nil; 35 | } 36 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Lib/CwlPreconditionTesting/CwlCatchException/CwlCatchException/CwlCatchException.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CwlCatchException.swift 3 | // CwlAssertionTesting 4 | // 5 | // Created by Matt Gallagher on 2016/01/10. 6 | // Copyright © 2016 Matt Gallagher ( http://cocoawithlove.com ). All rights reserved. 7 | // 8 | // Permission to use, copy, modify, and/or distribute this software for any 9 | // purpose with or without fee is hereby granted, provided that the above 10 | // copyright notice and this permission notice appear in all copies. 11 | // 12 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 15 | // SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR 18 | // IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | // 20 | 21 | import Foundation 22 | 23 | // 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. 24 | private func catchReturnTypeConverter(_ type: T.Type, block: () -> Void) -> T? { 25 | return catchExceptionOfKind(type, block) as? T 26 | } 27 | 28 | extension NSException { 29 | public static func catchException(in block: () -> Void) -> Self? { 30 | return catchReturnTypeConverter(self, block: block) 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlBadInstructionException.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CwlBadInstructionException.swift 3 | // CwlPreconditionTesting 4 | // 5 | // Created by Matt Gallagher on 2016/01/10. 6 | // Copyright © 2016 Matt Gallagher ( http://cocoawithlove.com ). All rights reserved. 7 | // 8 | // Permission to use, copy, modify, and/or distribute this software for any 9 | // purpose with or without fee is hereby granted, provided that the above 10 | // copyright notice and this permission notice appear in all copies. 11 | // 12 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 15 | // SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR 18 | // IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | // 20 | 21 | import Foundation 22 | 23 | private func raiseBadInstructionException() { 24 | BadInstructionException().raise() 25 | } 26 | 27 | /// 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. 28 | @objc public class BadInstructionException: NSException { 29 | static var name: String = "com.cocoawithlove.BadInstruction" 30 | 31 | init() { 32 | super.init(name: NSExceptionName(rawValue: BadInstructionException.name), reason: nil, userInfo: nil) 33 | } 34 | 35 | required public init?(coder aDecoder: NSCoder) { 36 | super.init(coder: aDecoder) 37 | } 38 | 39 | /// 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. 40 | 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 { 41 | 42 | #if arch(x86_64) 43 | // Make sure we've been given enough memory 44 | if old_stateCnt != x86_THREAD_STATE64_COUNT || new_stateCnt.pointee < x86_THREAD_STATE64_COUNT { 45 | return KERN_INVALID_ARGUMENT 46 | } 47 | 48 | // Read the old thread state 49 | var state = old_state.withMemoryRebound(to: x86_thread_state64_t.self, capacity: 1) { return $0.pointee } 50 | 51 | // 1. Decrement the stack pointer 52 | state.__rsp -= __uint64_t(MemoryLayout.size) 53 | 54 | // 2. Save the old Instruction Pointer to the stack. 55 | if let pointer = UnsafeMutablePointer<__uint64_t>(bitPattern: UInt(state.__rsp)) { 56 | pointer.pointee = state.__rip 57 | } else { 58 | return KERN_INVALID_ARGUMENT 59 | } 60 | 61 | // 3. Set the Instruction Pointer to the new function's address 62 | var f: @convention(c) () -> Void = raiseBadInstructionException 63 | withUnsafePointer(to: &f) { 64 | state.__rip = $0.withMemoryRebound(to: __uint64_t.self, capacity: 1) { return $0.pointee } 65 | } 66 | 67 | // Write the new thread state 68 | new_state.withMemoryRebound(to: x86_thread_state64_t.self, capacity: 1) { $0.pointee = state } 69 | new_stateCnt.pointee = x86_THREAD_STATE64_COUNT 70 | 71 | return KERN_SUCCESS 72 | #else 73 | fatalError("Unavailable for this CPU architecture") 74 | #endif 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlCatchBadInstruction.h: -------------------------------------------------------------------------------- 1 | // 2 | // CwlCatchBadInstruction.h 3 | // CwlPreconditionTesting 4 | // 5 | // Created by Matt Gallagher on 2016/01/10. 6 | // Copyright © 2016 Matt Gallagher ( http://cocoawithlove.com ). All rights reserved. 7 | // 8 | // Permission to use, copy, modify, and/or distribute this software for any 9 | // purpose with or without fee is hereby granted, provided that the above 10 | // copyright notice and this permission notice appear in all copies. 11 | // 12 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 15 | // SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR 18 | // IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | // 20 | 21 | #if defined(__x86_64__) 22 | 23 | #import 24 | #import 25 | 26 | NS_ASSUME_NONNULL_BEGIN 27 | 28 | // 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. 29 | typedef struct 30 | { 31 | mach_msg_header_t Head; 32 | /* start of the kernel processed data */ 33 | mach_msg_body_t msgh_body; 34 | mach_msg_port_descriptor_t thread; 35 | mach_msg_port_descriptor_t task; 36 | /* end of the kernel processed data */ 37 | NDR_record_t NDR; 38 | exception_type_t exception; 39 | mach_msg_type_number_t codeCnt; 40 | int64_t code[2]; 41 | int flavor; 42 | mach_msg_type_number_t old_stateCnt; 43 | natural_t old_state[224]; 44 | } request_mach_exception_raise_t; 45 | 46 | // 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. 47 | typedef struct 48 | { 49 | mach_msg_header_t Head; 50 | NDR_record_t NDR; 51 | kern_return_t RetCode; 52 | int flavor; 53 | mach_msg_type_number_t new_stateCnt; 54 | natural_t new_state[224]; 55 | } reply_mach_exception_raise_state_t; 56 | 57 | extern boolean_t mach_exc_server(mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP); 58 | 59 | NS_ASSUME_NONNULL_END 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlCatchBadInstruction.m: -------------------------------------------------------------------------------- 1 | // 2 | // CwlCatchBadInstruction.m 3 | // CwlPreconditionTesting 4 | // 5 | // Created by Matt Gallagher on 2016/01/10. 6 | // Copyright © 2016 Matt Gallagher ( http://cocoawithlove.com ). All rights reserved. 7 | // 8 | // Permission to use, copy, modify, and/or distribute this software for any 9 | // purpose with or without fee is hereby granted, provided that the above 10 | // copyright notice and this permission notice appear in all copies. 11 | // 12 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 15 | // SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR 18 | // IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | // 20 | 21 | #if defined(__x86_64__) 22 | 23 | #import "CwlCatchBadInstruction.h" 24 | 25 | // Assuming the "PRODUCT_NAME" macro is defined, this will create the name of the Swift generated header file 26 | #define STRINGIZE_NO_EXPANSION(A) #A 27 | #define STRINGIZE_WITH_EXPANSION(A) STRINGIZE_NO_EXPANSION(A) 28 | #define SWIFT_INCLUDE STRINGIZE_WITH_EXPANSION(PRODUCT_NAME-Swift.h) 29 | 30 | // Include the Swift generated header file 31 | #import SWIFT_INCLUDE 32 | 33 | /// A basic function that receives callbacks from mach_exc_server and relays them to the Swift implemented BadInstructionException.catch_mach_exception_raise_state. 34 | 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) { 35 | 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]; 36 | } 37 | 38 | // The mach port should be configured so that this function is never used. 39 | 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) { 40 | assert(false); 41 | return KERN_FAILURE; 42 | } 43 | 44 | // The mach port should be configured so that this function is never used. 45 | 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) { 46 | assert(false); 47 | return KERN_FAILURE; 48 | } 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Lib/CwlPreconditionTesting/CwlPreconditionTesting/CwlDarwinDefinitions.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CwlDarwinDefinitions.swift 3 | // CwlPreconditionTesting 4 | // 5 | // Created by Matt Gallagher on 2016/01/10. 6 | // Copyright © 2016 Matt Gallagher ( http://cocoawithlove.com ). All rights reserved. 7 | // 8 | // Permission to use, copy, modify, and/or distribute this software for any 9 | // purpose with or without fee is hereby granted, provided that the above 10 | // copyright notice and this permission notice appear in all copies. 11 | // 12 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 15 | // SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR 18 | // IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | // 20 | 21 | import Darwin 22 | 23 | #if arch(x86_64) 24 | 25 | // From /usr/include/mach/port.h 26 | // #define MACH_PORT_RIGHT_RECEIVE ((mach_port_right_t) 1) 27 | let MACH_PORT_RIGHT_RECEIVE: mach_port_right_t = 1 28 | 29 | // From /usr/include/mach/message.h 30 | // #define MACH_MSG_TYPE_MAKE_SEND 20 /* Must hold receive right */ 31 | // #define MACH_MSGH_BITS_REMOTE(bits) \ 32 | // ((bits) & MACH_MSGH_BITS_REMOTE_MASK) 33 | // #define MACH_MSGH_BITS(remote, local) /* legacy */ \ 34 | // ((remote) | ((local) << 8)) 35 | let MACH_MSG_TYPE_MAKE_SEND: UInt32 = 20 36 | func MACH_MSGH_BITS_REMOTE(_ bits: UInt32) -> UInt32 { return bits & UInt32(MACH_MSGH_BITS_REMOTE_MASK) } 37 | func MACH_MSGH_BITS(_ remote: UInt32, _ local: UInt32) -> UInt32 { return ((remote) | ((local) << 8)) } 38 | 39 | // From /usr/include/mach/exception_types.h 40 | // #define EXC_BAD_INSTRUCTION 2 /* Instruction failed */ 41 | // #define EXC_MASK_BAD_INSTRUCTION (1 << EXC_BAD_INSTRUCTION) 42 | // #define EXCEPTION_DEFAULT 1 43 | let EXC_BAD_INSTRUCTION: UInt32 = 2 44 | let EXC_MASK_BAD_INSTRUCTION: UInt32 = 1 << EXC_BAD_INSTRUCTION 45 | let EXCEPTION_DEFAULT: Int32 = 1 46 | 47 | // From /usr/include/mach/i386/thread_status.h 48 | // #define THREAD_STATE_NONE 13 49 | // #define x86_THREAD_STATE64_COUNT ((mach_msg_type_number_t) \ 50 | // ( sizeof (x86_thread_state64_t) / sizeof (int) )) 51 | let THREAD_STATE_NONE: Int32 = 13 52 | let x86_THREAD_STATE64_COUNT = UInt32(MemoryLayout.size / MemoryLayout.size) 53 | 54 | let EXC_TYPES_COUNT = 14 55 | struct execTypesCountTuple { 56 | // From /usr/include/mach/i386/exception.h 57 | // #define EXC_TYPES_COUNT 14 /* incl. illegal exception 0 */ 58 | 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) 59 | init() { 60 | } 61 | } 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Adapters/AdapterProtocols.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// Protocol for the assertion handler that Nimble uses for all expectations. 4 | public protocol AssertionHandler { 5 | func assert(_ assertion: Bool, message: FailureMessage, location: SourceLocation) 6 | } 7 | 8 | /// Global backing interface for assertions that Nimble creates. 9 | /// Defaults to a private test handler that passes through to XCTest. 10 | /// 11 | /// If XCTest is not available, you must assign your own assertion handler 12 | /// before using any matchers, otherwise Nimble will abort the program. 13 | /// 14 | /// @see AssertionHandler 15 | public var NimbleAssertionHandler: AssertionHandler = { () -> AssertionHandler in 16 | return isXCTestAvailable() ? NimbleXCTestHandler() : NimbleXCTestUnavailableHandler() 17 | }() 18 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Adapters/AssertionDispatcher.swift: -------------------------------------------------------------------------------- 1 | 2 | /// AssertionDispatcher allows multiple AssertionHandlers to receive 3 | /// assertion messages. 4 | /// 5 | /// @warning Does not fully dispatch if one of the handlers raises an exception. 6 | /// This is possible with XCTest-based assertion handlers. 7 | /// 8 | public class AssertionDispatcher: AssertionHandler { 9 | let handlers: [AssertionHandler] 10 | 11 | public init(handlers: [AssertionHandler]) { 12 | self.handlers = handlers 13 | } 14 | 15 | public func assert(_ assertion: Bool, message: FailureMessage, location: SourceLocation) { 16 | for handler in handlers { 17 | handler.assert(assertion, message: message, location: location) 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Adapters/AssertionRecorder.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// A data structure that stores information about an assertion when 4 | /// AssertionRecorder is set as the Nimble assertion handler. 5 | /// 6 | /// @see AssertionRecorder 7 | /// @see AssertionHandler 8 | public struct AssertionRecord: CustomStringConvertible { 9 | /// Whether the assertion succeeded or failed 10 | public let success: Bool 11 | /// The failure message the assertion would display on failure. 12 | public let message: FailureMessage 13 | /// The source location the expectation occurred on. 14 | public let location: SourceLocation 15 | 16 | public var description: String { 17 | return "AssertionRecord { success=\(success), message='\(message.stringValue)', location=\(location) }" 18 | } 19 | } 20 | 21 | /// An AssertionHandler that silently records assertions that Nimble makes. 22 | /// This is useful for testing failure messages for matchers. 23 | /// 24 | /// @see AssertionHandler 25 | public class AssertionRecorder : AssertionHandler { 26 | /// All the assertions that were captured by this recorder 27 | public var assertions = [AssertionRecord]() 28 | 29 | public init() {} 30 | 31 | public func assert(_ assertion: Bool, message: FailureMessage, location: SourceLocation) { 32 | assertions.append( 33 | AssertionRecord( 34 | success: assertion, 35 | message: message, 36 | location: location)) 37 | } 38 | } 39 | 40 | /// Allows you to temporarily replace the current Nimble assertion handler with 41 | /// the one provided for the scope of the closure. 42 | /// 43 | /// Once the closure finishes, then the original Nimble assertion handler is restored. 44 | /// 45 | /// @see AssertionHandler 46 | public func withAssertionHandler(_ tempAssertionHandler: AssertionHandler, closure: @escaping () throws -> Void) { 47 | let environment = NimbleEnvironment.activeInstance 48 | let oldRecorder = environment.assertionHandler 49 | let capturer = NMBExceptionCapture(handler: nil, finally: ({ 50 | environment.assertionHandler = oldRecorder 51 | })) 52 | environment.assertionHandler = tempAssertionHandler 53 | capturer.tryBlock { 54 | try! closure() 55 | } 56 | } 57 | 58 | /// Captures expectations that occur in the given closure. Note that all 59 | /// expectations will still go through to the default Nimble handler. 60 | /// 61 | /// This can be useful if you want to gather information about expectations 62 | /// that occur within a closure. 63 | /// 64 | /// @param silently expectations are no longer send to the default Nimble 65 | /// assertion handler when this is true. Defaults to false. 66 | /// 67 | /// @see gatherFailingExpectations 68 | public func gatherExpectations(silently: Bool = false, closure: @escaping () -> Void) -> [AssertionRecord] { 69 | let previousRecorder = NimbleEnvironment.activeInstance.assertionHandler 70 | let recorder = AssertionRecorder() 71 | let handlers: [AssertionHandler] 72 | 73 | if silently { 74 | handlers = [recorder] 75 | } else { 76 | handlers = [recorder, previousRecorder] 77 | } 78 | 79 | let dispatcher = AssertionDispatcher(handlers: handlers) 80 | withAssertionHandler(dispatcher, closure: closure) 81 | return recorder.assertions 82 | } 83 | 84 | /// Captures failed expectations that occur in the given closure. Note that all 85 | /// expectations will still go through to the default Nimble handler. 86 | /// 87 | /// This can be useful if you want to gather information about failed 88 | /// expectations that occur within a closure. 89 | /// 90 | /// @param silently expectations are no longer send to the default Nimble 91 | /// assertion handler when this is true. Defaults to false. 92 | /// 93 | /// @see gatherExpectations 94 | /// @see raiseException source for an example use case. 95 | public func gatherFailingExpectations(silently: Bool = false, closure: @escaping () -> Void) -> [AssertionRecord] { 96 | let assertions = gatherExpectations(silently: silently, closure: closure) 97 | return assertions.filter { assertion in 98 | !assertion.success 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Adapters/NMBExpectation.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | #if _runtime(_ObjC) 4 | 5 | internal struct ObjCMatcherWrapper : Matcher { 6 | let matcher: NMBMatcher 7 | 8 | func matches(_ actualExpression: Expression, failureMessage: FailureMessage) -> Bool { 9 | return matcher.matches( 10 | ({ try! actualExpression.evaluate() }), 11 | failureMessage: failureMessage, 12 | location: actualExpression.location) 13 | } 14 | 15 | func doesNotMatch(_ actualExpression: Expression, failureMessage: FailureMessage) -> Bool { 16 | return matcher.doesNotMatch( 17 | ({ try! actualExpression.evaluate() }), 18 | failureMessage: failureMessage, 19 | location: actualExpression.location) 20 | } 21 | } 22 | 23 | // Equivalent to Expectation, but for Nimble's Objective-C interface 24 | public class NMBExpectation : NSObject { 25 | internal let _actualBlock: () -> NSObject! 26 | internal var _negative: Bool 27 | internal let _file: FileString 28 | internal let _line: UInt 29 | internal var _timeout: TimeInterval = 1.0 30 | 31 | public init(actualBlock: @escaping () -> NSObject!, negative: Bool, file: FileString, line: UInt) { 32 | self._actualBlock = actualBlock 33 | self._negative = negative 34 | self._file = file 35 | self._line = line 36 | } 37 | 38 | private var expectValue: Expectation { 39 | return expect(_file, line: _line){ 40 | self._actualBlock() as NSObject? 41 | } 42 | } 43 | 44 | public var withTimeout: (TimeInterval) -> NMBExpectation { 45 | return ({ timeout in self._timeout = timeout 46 | return self 47 | }) 48 | } 49 | 50 | public var to: (NMBMatcher) -> Void { 51 | return ({ matcher in 52 | self.expectValue.to(ObjCMatcherWrapper(matcher: matcher)) 53 | }) 54 | } 55 | 56 | public var toWithDescription: (NMBMatcher, String) -> Void { 57 | return ({ matcher, description in 58 | self.expectValue.to(ObjCMatcherWrapper(matcher: matcher), description: description) 59 | }) 60 | } 61 | 62 | public var toNot: (NMBMatcher) -> Void { 63 | return ({ matcher in 64 | self.expectValue.toNot( 65 | ObjCMatcherWrapper(matcher: matcher) 66 | ) 67 | }) 68 | } 69 | 70 | public var toNotWithDescription: (NMBMatcher, String) -> Void { 71 | return ({ matcher, description in 72 | self.expectValue.toNot( 73 | ObjCMatcherWrapper(matcher: matcher), description: description 74 | ) 75 | }) 76 | } 77 | 78 | public var notTo: (NMBMatcher) -> Void { return toNot } 79 | 80 | public var notToWithDescription: (NMBMatcher, String) -> Void { return toNotWithDescription } 81 | 82 | public var toEventually: (NMBMatcher) -> Void { 83 | return ({ matcher in 84 | self.expectValue.toEventually( 85 | ObjCMatcherWrapper(matcher: matcher), 86 | timeout: self._timeout, 87 | description: nil 88 | ) 89 | }) 90 | } 91 | 92 | public var toEventuallyWithDescription: (NMBMatcher, String) -> Void { 93 | return ({ matcher, description in 94 | self.expectValue.toEventually( 95 | ObjCMatcherWrapper(matcher: matcher), 96 | timeout: self._timeout, 97 | description: description 98 | ) 99 | }) 100 | } 101 | 102 | public var toEventuallyNot: (NMBMatcher) -> Void { 103 | return ({ matcher in 104 | self.expectValue.toEventuallyNot( 105 | ObjCMatcherWrapper(matcher: matcher), 106 | timeout: self._timeout, 107 | description: nil 108 | ) 109 | }) 110 | } 111 | 112 | public var toEventuallyNotWithDescription: (NMBMatcher, String) -> Void { 113 | return ({ matcher, description in 114 | self.expectValue.toEventuallyNot( 115 | ObjCMatcherWrapper(matcher: matcher), 116 | timeout: self._timeout, 117 | description: description 118 | ) 119 | }) 120 | } 121 | 122 | public var toNotEventually: (NMBMatcher) -> Void { return toEventuallyNot } 123 | 124 | public var toNotEventuallyWithDescription: (NMBMatcher, String) -> Void { return toEventuallyNotWithDescription } 125 | 126 | public class func failWithMessage(_ message: String, file: FileString, line: UInt) { 127 | fail(message, location: SourceLocation(file: file, line: line)) 128 | } 129 | } 130 | 131 | #endif 132 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Adapters/NMBObjCMatcher.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | #if _runtime(_ObjC) 4 | 5 | public typealias MatcherBlock = (_ actualExpression: Expression, _ failureMessage: FailureMessage) -> Bool 6 | public typealias FullMatcherBlock = (_ actualExpression: Expression, _ failureMessage: FailureMessage, _ shouldNotMatch: Bool) -> Bool 7 | 8 | public class NMBObjCMatcher : NSObject, NMBMatcher { 9 | let _match: MatcherBlock 10 | let _doesNotMatch: MatcherBlock 11 | let canMatchNil: Bool 12 | 13 | public init(canMatchNil: Bool, matcher: @escaping MatcherBlock, notMatcher: @escaping MatcherBlock) { 14 | self.canMatchNil = canMatchNil 15 | self._match = matcher 16 | self._doesNotMatch = notMatcher 17 | } 18 | 19 | public convenience init(matcher: @escaping MatcherBlock) { 20 | self.init(canMatchNil: true, matcher: matcher) 21 | } 22 | 23 | public convenience init(canMatchNil: Bool, matcher: @escaping MatcherBlock) { 24 | self.init(canMatchNil: canMatchNil, matcher: matcher, notMatcher: ({ actualExpression, failureMessage in 25 | return !matcher(actualExpression, failureMessage) 26 | })) 27 | } 28 | 29 | public convenience init(matcher: @escaping FullMatcherBlock) { 30 | self.init(canMatchNil: true, matcher: matcher) 31 | } 32 | 33 | public convenience init(canMatchNil: Bool, matcher: @escaping FullMatcherBlock) { 34 | self.init(canMatchNil: canMatchNil, matcher: ({ actualExpression, failureMessage in 35 | return matcher(actualExpression, failureMessage, false) 36 | }), notMatcher: ({ actualExpression, failureMessage in 37 | return matcher(actualExpression, failureMessage, true) 38 | })) 39 | } 40 | 41 | private func canMatch(_ actualExpression: Expression, failureMessage: FailureMessage) -> Bool { 42 | do { 43 | if !canMatchNil { 44 | if try actualExpression.evaluate() == nil { 45 | failureMessage.postfixActual = " (use beNil() to match nils)" 46 | return false 47 | } 48 | } 49 | } catch let error { 50 | failureMessage.actualValue = "an unexpected error thrown: \(error)" 51 | return false 52 | } 53 | return true 54 | } 55 | 56 | public func matches(_ actualBlock: @escaping () -> NSObject!, failureMessage: FailureMessage, location: SourceLocation) -> Bool { 57 | let expr = Expression(expression: actualBlock, location: location) 58 | let result = _match( 59 | expr, 60 | failureMessage) 61 | if self.canMatch(Expression(expression: actualBlock, location: location), failureMessage: failureMessage) { 62 | return result 63 | } else { 64 | return false 65 | } 66 | } 67 | 68 | public func doesNotMatch(_ actualBlock: @escaping () -> NSObject!, failureMessage: FailureMessage, location: SourceLocation) -> Bool { 69 | let expr = Expression(expression: actualBlock, location: location) 70 | let result = _doesNotMatch( 71 | expr, 72 | failureMessage) 73 | if self.canMatch(Expression(expression: actualBlock, location: location), failureMessage: failureMessage) { 74 | return result 75 | } else { 76 | return false 77 | } 78 | } 79 | } 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Adapters/NimbleEnvironment.swift: -------------------------------------------------------------------------------- 1 | import Dispatch 2 | import Foundation 3 | 4 | /// "Global" state of Nimble is stored here. Only DSL functions should access / be aware of this 5 | /// class' existance 6 | internal class NimbleEnvironment { 7 | static var activeInstance: NimbleEnvironment { 8 | get { 9 | let env = Thread.current.threadDictionary["NimbleEnvironment"] 10 | if let env = env as? NimbleEnvironment { 11 | return env 12 | } else { 13 | let newEnv = NimbleEnvironment() 14 | self.activeInstance = newEnv 15 | return newEnv 16 | } 17 | } 18 | set { 19 | Thread.current.threadDictionary["NimbleEnvironment"] = newValue 20 | } 21 | } 22 | 23 | // TODO: eventually migrate the global to this environment value 24 | var assertionHandler: AssertionHandler { 25 | get { return NimbleAssertionHandler } 26 | set { NimbleAssertionHandler = newValue } 27 | } 28 | 29 | var suppressTVOSAssertionWarning: Bool = false 30 | var awaiter: Awaiter 31 | 32 | init() { 33 | let timeoutQueue: DispatchQueue 34 | if #available(OSX 10.10, *) { 35 | timeoutQueue = DispatchQueue.global(qos: .userInitiated) 36 | } else { 37 | timeoutQueue = DispatchQueue.global(priority: .high) 38 | } 39 | 40 | awaiter = Awaiter( 41 | waitLock: AssertionWaitLock(), 42 | asyncQueue: .main, 43 | timeoutQueue: timeoutQueue) 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Adapters/NimbleXCTestHandler.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | import XCTest 3 | 4 | /// Default handler for Nimble. This assertion handler passes failures along to 5 | /// XCTest. 6 | public class NimbleXCTestHandler : AssertionHandler { 7 | public func assert(_ assertion: Bool, message: FailureMessage, location: SourceLocation) { 8 | if !assertion { 9 | recordFailure("\(message.stringValue)\n", location: location) 10 | } 11 | } 12 | } 13 | 14 | /// Alternative handler for Nimble. This assertion handler passes failures along 15 | /// to XCTest by attempting to reduce the failure message size. 16 | public class NimbleShortXCTestHandler: AssertionHandler { 17 | public func assert(_ assertion: Bool, message: FailureMessage, location: SourceLocation) { 18 | if !assertion { 19 | let msg: String 20 | if let actual = message.actualValue { 21 | msg = "got: \(actual) \(message.postfixActual)" 22 | } else { 23 | msg = "expected \(message.to) \(message.postfixMessage)" 24 | } 25 | recordFailure("\(msg)\n", location: location) 26 | } 27 | } 28 | } 29 | 30 | /// Fallback handler in case XCTest is unavailable. This assertion handler will abort 31 | /// the program if it is invoked. 32 | class NimbleXCTestUnavailableHandler : AssertionHandler { 33 | func assert(_ assertion: Bool, message: FailureMessage, location: SourceLocation) { 34 | fatalError("XCTest is not available and no custom assertion handler was configured. Aborting.") 35 | } 36 | } 37 | 38 | #if _runtime(_ObjC) 39 | /// Helper class providing access to the currently executing XCTestCase instance, if any 40 | @objc final internal class CurrentTestCaseTracker: NSObject, XCTestObservation { 41 | @objc static let sharedInstance = CurrentTestCaseTracker() 42 | 43 | private(set) var currentTestCase: XCTestCase? 44 | 45 | @objc func testCaseWillStart(_ testCase: XCTestCase) { 46 | currentTestCase = testCase 47 | } 48 | 49 | @objc func testCaseDidFinish(_ testCase: XCTestCase) { 50 | currentTestCase = nil 51 | } 52 | } 53 | #endif 54 | 55 | 56 | func isXCTestAvailable() -> Bool { 57 | #if _runtime(_ObjC) 58 | // XCTest is weakly linked and so may not be present 59 | return NSClassFromString("XCTestCase") != nil 60 | #else 61 | return true 62 | #endif 63 | } 64 | 65 | private func recordFailure(_ message: String, location: SourceLocation) { 66 | #if _runtime(_ObjC) 67 | if let testCase = CurrentTestCaseTracker.sharedInstance.currentTestCase { 68 | testCase.recordFailure(withDescription: message, inFile: location.file, atLine: location.line, expected: true) 69 | } else { 70 | let msg = "Attempted to report a test failure to XCTest while no test case was running. " + 71 | "The failure was:\n\"\(message)\"\nIt occurred at: \(location.file):\(location.line)" 72 | NSException(name: .internalInconsistencyException, reason: msg, userInfo: nil).raise() 73 | } 74 | #else 75 | XCTFail("\(message)\n", file: location.file, line: location.line) 76 | #endif 77 | } 78 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/DSL.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// Make an expectation on a given actual value. The value given is lazily evaluated. 4 | public func expect(_ expression: @autoclosure @escaping () throws -> T?, file: FileString = #file, line: UInt = #line) -> Expectation { 5 | return Expectation( 6 | expression: Expression( 7 | expression: expression, 8 | location: SourceLocation(file: file, line: line), 9 | isClosure: true)) 10 | } 11 | 12 | /// Make an expectation on a given actual value. The closure is lazily invoked. 13 | public func expect(_ file: FileString = #file, line: UInt = #line, expression: @escaping () throws -> T?) -> Expectation { 14 | return Expectation( 15 | expression: Expression( 16 | expression: expression, 17 | location: SourceLocation(file: file, line: line), 18 | isClosure: true)) 19 | } 20 | 21 | /// Always fails the test with a message and a specified location. 22 | public func fail(_ message: String, location: SourceLocation) { 23 | let handler = NimbleEnvironment.activeInstance.assertionHandler 24 | handler.assert(false, message: FailureMessage(stringValue: message), location: location) 25 | } 26 | 27 | /// Always fails the test with a message. 28 | public func fail(_ message: String, file: FileString = #file, line: UInt = #line) { 29 | fail(message, location: SourceLocation(file: file, line: line)) 30 | } 31 | 32 | /// Always fails the test. 33 | public func fail(_ file: FileString = #file, line: UInt = #line) { 34 | fail("fail() always fails", file: file, line: line) 35 | } 36 | 37 | /// Like Swift's precondition(), but raises NSExceptions instead of sigaborts 38 | internal func nimblePrecondition( 39 | _ expr: @autoclosure() -> Bool, 40 | _ name: @autoclosure() -> String, 41 | _ message: @autoclosure() -> String, 42 | file: StaticString = #file, 43 | line: UInt = #line) { 44 | let result = expr() 45 | if !result { 46 | #if _runtime(_ObjC) 47 | let e = NSException( 48 | name: NSExceptionName(name()), 49 | reason: message(), 50 | userInfo: nil) 51 | e.raise() 52 | #else 53 | preconditionFailure("\(name()) - \(message())", file: file, line: line) 54 | #endif 55 | } 56 | } 57 | 58 | internal func internalError(_ msg: String, file: FileString = #file, line: UInt = #line) -> Never { 59 | fatalError( 60 | "Nimble Bug Found: \(msg) at \(file):\(line).\n" + 61 | "Please file a bug to Nimble: https://github.com/Quick/Nimble/issues with the " + 62 | "code snippet that caused this error." 63 | ) 64 | } 65 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Expectation.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | internal func expressionMatches(_ expression: Expression, matcher: U, to: String, description: String?) -> (Bool, FailureMessage) 4 | where U: Matcher, U.ValueType == T 5 | { 6 | let msg = FailureMessage() 7 | msg.userDescription = description 8 | msg.to = to 9 | do { 10 | let pass = try matcher.matches(expression, failureMessage: msg) 11 | if msg.actualValue == "" { 12 | msg.actualValue = "<\(stringify(try expression.evaluate()))>" 13 | } 14 | return (pass, msg) 15 | } catch let error { 16 | msg.actualValue = "an unexpected error thrown: <\(error)>" 17 | return (false, msg) 18 | } 19 | } 20 | 21 | internal func expressionDoesNotMatch(_ expression: Expression, matcher: U, toNot: String, description: String?) -> (Bool, FailureMessage) 22 | where U: Matcher, U.ValueType == T 23 | { 24 | let msg = FailureMessage() 25 | msg.userDescription = description 26 | msg.to = toNot 27 | do { 28 | let pass = try matcher.doesNotMatch(expression, failureMessage: msg) 29 | if msg.actualValue == "" { 30 | msg.actualValue = "<\(stringify(try expression.evaluate()))>" 31 | } 32 | return (pass, msg) 33 | } catch let error { 34 | msg.actualValue = "an unexpected error thrown: <\(error)>" 35 | return (false, msg) 36 | } 37 | } 38 | 39 | public struct Expectation { 40 | 41 | public let expression: Expression 42 | 43 | public func verify(_ pass: Bool, _ message: FailureMessage) { 44 | let handler = NimbleEnvironment.activeInstance.assertionHandler 45 | handler.assert(pass, message: message, location: expression.location) 46 | } 47 | 48 | /// Tests the actual value using a matcher to match. 49 | public func to(_ matcher: U, description: String? = nil) 50 | where U: Matcher, U.ValueType == T 51 | { 52 | let (pass, msg) = expressionMatches(expression, matcher: matcher, to: "to", description: description) 53 | verify(pass, msg) 54 | } 55 | 56 | /// Tests the actual value using a matcher to not match. 57 | public func toNot(_ matcher: U, description: String? = nil) 58 | where U: Matcher, U.ValueType == T 59 | { 60 | let (pass, msg) = expressionDoesNotMatch(expression, matcher: matcher, toNot: "to not", description: description) 61 | verify(pass, msg) 62 | } 63 | 64 | /// Tests the actual value using a matcher to not match. 65 | /// 66 | /// Alias to toNot(). 67 | public func notTo(_ matcher: U, description: String? = nil) 68 | where U: Matcher, U.ValueType == T 69 | { 70 | toNot(matcher, description: description) 71 | } 72 | 73 | // see: 74 | // - AsyncMatcherWrapper for extension 75 | // - NMBExpectation for Objective-C interface 76 | } 77 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Expression.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | // Memoizes the given closure, only calling the passed 4 | // closure once; even if repeat calls to the returned closure 5 | internal func memoizedClosure(_ closure: @escaping () throws -> T) -> (Bool) throws -> T { 6 | var cache: T? 7 | return ({ withoutCaching in 8 | if (withoutCaching || cache == nil) { 9 | cache = try closure() 10 | } 11 | return cache! 12 | }) 13 | } 14 | 15 | /// Expression represents the closure of the value inside expect(...). 16 | /// Expressions are memoized by default. This makes them safe to call 17 | /// evaluate() multiple times without causing a re-evaluation of the underlying 18 | /// closure. 19 | /// 20 | /// @warning Since the closure can be any code, Objective-C code may choose 21 | /// to raise an exception. Currently, Expression does not memoize 22 | /// exception raising. 23 | /// 24 | /// This provides a common consumable API for matchers to utilize to allow 25 | /// Nimble to change internals to how the captured closure is managed. 26 | public struct Expression { 27 | internal let _expression: (Bool) throws -> T? 28 | internal let _withoutCaching: Bool 29 | public let location: SourceLocation 30 | public let isClosure: Bool 31 | 32 | /// Creates a new expression struct. Normally, expect(...) will manage this 33 | /// creation process. The expression is memoized. 34 | /// 35 | /// @param expression The closure that produces a given value. 36 | /// @param location The source location that this closure originates from. 37 | /// @param isClosure A bool indicating if the captured expression is a 38 | /// closure or internally produced closure. Some matchers 39 | /// may require closures. For example, toEventually() 40 | /// requires an explicit closure. This gives Nimble 41 | /// flexibility if @autoclosure behavior changes between 42 | /// Swift versions. Nimble internals always sets this true. 43 | public init(expression: @escaping () throws -> T?, location: SourceLocation, isClosure: Bool = true) { 44 | self._expression = memoizedClosure(expression) 45 | self.location = location 46 | self._withoutCaching = false 47 | self.isClosure = isClosure 48 | } 49 | 50 | /// Creates a new expression struct. Normally, expect(...) will manage this 51 | /// creation process. 52 | /// 53 | /// @param expression The closure that produces a given value. 54 | /// @param location The source location that this closure originates from. 55 | /// @param withoutCaching Indicates if the struct should memoize the given 56 | /// closure's result. Subsequent evaluate() calls will 57 | /// not call the given closure if this is true. 58 | /// @param isClosure A bool indicating if the captured expression is a 59 | /// closure or internally produced closure. Some matchers 60 | /// may require closures. For example, toEventually() 61 | /// requires an explicit closure. This gives Nimble 62 | /// flexibility if @autoclosure behavior changes between 63 | /// Swift versions. Nimble internals always sets this true. 64 | public init(memoizedExpression: @escaping (Bool) throws -> T?, location: SourceLocation, withoutCaching: Bool, isClosure: Bool = true) { 65 | self._expression = memoizedExpression 66 | self.location = location 67 | self._withoutCaching = withoutCaching 68 | self.isClosure = isClosure 69 | } 70 | 71 | /// Returns a new Expression from the given expression. Identical to a map() 72 | /// on this type. This should be used only to typecast the Expression's 73 | /// closure value. 74 | /// 75 | /// The returned expression will preserve location and isClosure. 76 | /// 77 | /// @param block The block that can cast the current Expression value to a 78 | /// new type. 79 | public func cast(_ block: @escaping (T?) throws -> U?) -> Expression { 80 | return Expression(expression: ({ try block(self.evaluate()) }), location: self.location, isClosure: self.isClosure) 81 | } 82 | 83 | public func evaluate() throws -> T? { 84 | return try self._expression(_withoutCaching) 85 | } 86 | 87 | public func withoutCaching() -> Expression { 88 | return Expression(memoizedExpression: self._expression, location: location, withoutCaching: true, isClosure: isClosure) 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/FailureMessage.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// Encapsulates the failure message that matchers can report to the end user. 4 | /// 5 | /// This is shared state between Nimble and matchers that mutate this value. 6 | public class FailureMessage: NSObject { 7 | public var expected: String = "expected" 8 | public var actualValue: String? = "" // empty string -> use default; nil -> exclude 9 | public var to: String = "to" 10 | public var postfixMessage: String = "match" 11 | public var postfixActual: String = "" 12 | /// An optional message that will be appended as a new line and provides additional details 13 | /// about the failure. This message will only be visible in the issue navigator / in logs but 14 | /// not directly in the source editor since only a single line is presented there. 15 | public var extendedMessage: String? = nil 16 | public var userDescription: String? = nil 17 | 18 | public var stringValue: String { 19 | get { 20 | if let value = _stringValueOverride { 21 | return value 22 | } else { 23 | return computeStringValue() 24 | } 25 | } 26 | set { 27 | _stringValueOverride = newValue 28 | } 29 | } 30 | 31 | internal var _stringValueOverride: String? 32 | 33 | public override init() { 34 | } 35 | 36 | public init(stringValue: String) { 37 | _stringValueOverride = stringValue 38 | } 39 | 40 | internal func stripNewlines(_ str: String) -> String { 41 | let whitespaces = CharacterSet.whitespacesAndNewlines 42 | return str 43 | .components(separatedBy: "\n") 44 | .map { line in line.trimmingCharacters(in: whitespaces) } 45 | .joined(separator: "") 46 | } 47 | 48 | internal func computeStringValue() -> String { 49 | var value = "\(expected) \(to) \(postfixMessage)" 50 | if let actualValue = actualValue { 51 | value = "\(expected) \(to) \(postfixMessage), got \(actualValue)\(postfixActual)" 52 | } 53 | value = stripNewlines(value) 54 | 55 | if let extendedMessage = extendedMessage { 56 | value += "\n\(stripNewlines(extendedMessage))" 57 | } 58 | 59 | if let userDescription = userDescription { 60 | return "\(userDescription)\n\(value)" 61 | } 62 | 63 | return value 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Matchers/AllPass.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | public func allPass 4 | (_ passFunc: @escaping (T?) -> Bool) -> NonNilMatcherFunc 5 | where U: Sequence, U.Iterator.Element == T 6 | { 7 | return allPass("pass a condition", passFunc) 8 | } 9 | 10 | public func allPass 11 | (_ passName: String, _ passFunc: @escaping (T?) -> Bool) -> NonNilMatcherFunc 12 | where U: Sequence, U.Iterator.Element == T 13 | { 14 | return createAllPassMatcher() { 15 | expression, failureMessage in 16 | failureMessage.postfixMessage = passName 17 | return passFunc(try expression.evaluate()) 18 | } 19 | } 20 | 21 | public func allPass 22 | (_ matcher: V) -> NonNilMatcherFunc 23 | where U: Sequence, V: Matcher, U.Iterator.Element == V.ValueType 24 | { 25 | return createAllPassMatcher() { 26 | try matcher.matches($0, failureMessage: $1) 27 | } 28 | } 29 | 30 | private func createAllPassMatcher 31 | (_ elementEvaluator: @escaping (Expression, FailureMessage) throws -> Bool) -> NonNilMatcherFunc 32 | where U: Sequence, U.Iterator.Element == T 33 | { 34 | return NonNilMatcherFunc { actualExpression, failureMessage in 35 | failureMessage.actualValue = nil 36 | if let actualValue = try actualExpression.evaluate() { 37 | for currentElement in actualValue { 38 | let exp = Expression( 39 | expression: {currentElement}, location: actualExpression.location) 40 | if try !elementEvaluator(exp, failureMessage) { 41 | failureMessage.postfixMessage = 42 | "all \(failureMessage.postfixMessage)," 43 | + " but failed first at element <\(stringify(currentElement))>" 44 | + " in <\(stringify(actualValue))>" 45 | return false 46 | } 47 | } 48 | failureMessage.postfixMessage = "all \(failureMessage.postfixMessage)" 49 | } else { 50 | failureMessage.postfixMessage = "all pass (use beNil() to match nils)" 51 | return false 52 | } 53 | 54 | return true 55 | } 56 | } 57 | 58 | #if _runtime(_ObjC) 59 | extension NMBObjCMatcher { 60 | public class func allPassMatcher(_ matcher: NMBObjCMatcher) -> NMBObjCMatcher { 61 | return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in 62 | let location = actualExpression.location 63 | let actualValue = try! actualExpression.evaluate() 64 | var nsObjects = [NSObject]() 65 | 66 | var collectionIsUsable = true 67 | if let value = actualValue as? NSFastEnumeration { 68 | let generator = NSFastEnumerationIterator(value) 69 | while let obj = generator.next() { 70 | if let nsObject = obj as? NSObject { 71 | nsObjects.append(nsObject) 72 | } else { 73 | collectionIsUsable = false 74 | break 75 | } 76 | } 77 | } else { 78 | collectionIsUsable = false 79 | } 80 | 81 | if !collectionIsUsable { 82 | failureMessage.postfixMessage = 83 | "allPass only works with NSFastEnumeration (NSArray, NSSet, ...) of NSObjects" 84 | failureMessage.expected = "" 85 | failureMessage.to = "" 86 | return false 87 | } 88 | 89 | let expr = Expression(expression: ({ nsObjects }), location: location) 90 | let elementEvaluator: (Expression, FailureMessage) -> Bool = { 91 | expression, failureMessage in 92 | return matcher.matches( 93 | {try! expression.evaluate()}, failureMessage: failureMessage, location: expr.location) 94 | } 95 | return try! createAllPassMatcher(elementEvaluator).matches( 96 | expr, failureMessage: failureMessage) 97 | } 98 | } 99 | } 100 | #endif 101 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Matchers/BeAKindOf.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | #if _runtime(_ObjC) 4 | 5 | // A Nimble matcher that catches attempts to use beAKindOf with non Objective-C types 6 | public func beAKindOf(_ expectedClass: Any) -> NonNilMatcherFunc { 7 | return NonNilMatcherFunc {actualExpression, failureMessage in 8 | failureMessage.stringValue = "beAKindOf only works on Objective-C types since" 9 | + " the Swift compiler will automatically type check Swift-only types." 10 | + " This expectation is redundant." 11 | return false 12 | } 13 | } 14 | 15 | /// A Nimble matcher that succeeds when the actual value is an instance of the given class. 16 | /// @see beAnInstanceOf if you want to match against the exact class 17 | public func beAKindOf(_ expectedClass: AnyClass) -> NonNilMatcherFunc { 18 | return NonNilMatcherFunc { actualExpression, failureMessage in 19 | let instance = try actualExpression.evaluate() 20 | if let validInstance = instance { 21 | failureMessage.actualValue = "<\(String(describing: type(of: validInstance))) instance>" 22 | } else { 23 | failureMessage.actualValue = "" 24 | } 25 | failureMessage.postfixMessage = "be a kind of \(String(describing: expectedClass))" 26 | return instance != nil && instance!.isKind(of: expectedClass) 27 | } 28 | } 29 | 30 | extension NMBObjCMatcher { 31 | public class func beAKindOfMatcher(_ expected: AnyClass) -> NMBMatcher { 32 | return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in 33 | return try! beAKindOf(expected).matches(actualExpression, failureMessage: failureMessage) 34 | } 35 | } 36 | } 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Matchers/BeAnInstanceOf.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | // A Nimble matcher that catches attempts to use beAnInstanceOf with non Objective-C types 4 | public func beAnInstanceOf(_ expectedClass: Any) -> NonNilMatcherFunc { 5 | return NonNilMatcherFunc {actualExpression, failureMessage in 6 | failureMessage.stringValue = "beAnInstanceOf only works on Objective-C types since" 7 | + " the Swift compiler will automatically type check Swift-only types." 8 | + " This expectation is redundant." 9 | return false 10 | } 11 | } 12 | 13 | /// A Nimble matcher that succeeds when the actual value is an instance of the given class. 14 | /// @see beAKindOf if you want to match against subclasses 15 | public func beAnInstanceOf(_ expectedClass: AnyClass) -> NonNilMatcherFunc { 16 | return NonNilMatcherFunc { actualExpression, failureMessage in 17 | let instance = try actualExpression.evaluate() 18 | if let validInstance = instance { 19 | failureMessage.actualValue = "<\(String(describing: type(of: validInstance))) instance>" 20 | } else { 21 | failureMessage.actualValue = "" 22 | } 23 | failureMessage.postfixMessage = "be an instance of \(String(describing: expectedClass))" 24 | #if _runtime(_ObjC) 25 | return instance != nil && instance!.isMember(of: expectedClass) 26 | #else 27 | return instance != nil && type(of: instance!) == expectedClass 28 | #endif 29 | } 30 | } 31 | 32 | #if _runtime(_ObjC) 33 | extension NMBObjCMatcher { 34 | public class func beAnInstanceOfMatcher(_ expected: AnyClass) -> NMBMatcher { 35 | return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in 36 | return try! beAnInstanceOf(expected).matches(actualExpression, failureMessage: failureMessage) 37 | } 38 | } 39 | } 40 | #endif 41 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Matchers/BeEmpty.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | 4 | /// A Nimble matcher that succeeds when a value is "empty". For collections, this 5 | /// means the are no items in that collection. For strings, it is an empty string. 6 | public func beEmpty() -> NonNilMatcherFunc { 7 | return NonNilMatcherFunc { actualExpression, failureMessage in 8 | failureMessage.postfixMessage = "be empty" 9 | let actualSeq = try actualExpression.evaluate() 10 | if actualSeq == nil { 11 | return true 12 | } 13 | var generator = actualSeq!.makeIterator() 14 | return generator.next() == nil 15 | } 16 | } 17 | 18 | /// A Nimble matcher that succeeds when a value is "empty". For collections, this 19 | /// means the are no items in that collection. For strings, it is an empty string. 20 | public func beEmpty() -> NonNilMatcherFunc { 21 | return NonNilMatcherFunc { actualExpression, failureMessage in 22 | failureMessage.postfixMessage = "be empty" 23 | let actualString = try actualExpression.evaluate() 24 | return actualString == nil || NSString(string: actualString!).length == 0 25 | } 26 | } 27 | 28 | /// A Nimble matcher that succeeds when a value is "empty". For collections, this 29 | /// means the are no items in that collection. For NSString instances, it is an empty string. 30 | public func beEmpty() -> NonNilMatcherFunc { 31 | return NonNilMatcherFunc { actualExpression, failureMessage in 32 | failureMessage.postfixMessage = "be empty" 33 | let actualString = try actualExpression.evaluate() 34 | return actualString == nil || actualString!.length == 0 35 | } 36 | } 37 | 38 | // Without specific overrides, beEmpty() is ambiguous for NSDictionary, NSArray, 39 | // etc, since they conform to Sequence as well as NMBCollection. 40 | 41 | /// A Nimble matcher that succeeds when a value is "empty". For collections, this 42 | /// means the are no items in that collection. For strings, it is an empty string. 43 | public func beEmpty() -> NonNilMatcherFunc { 44 | return NonNilMatcherFunc { actualExpression, failureMessage in 45 | failureMessage.postfixMessage = "be empty" 46 | let actualDictionary = try actualExpression.evaluate() 47 | return actualDictionary == nil || actualDictionary!.count == 0 48 | } 49 | } 50 | 51 | /// A Nimble matcher that succeeds when a value is "empty". For collections, this 52 | /// means the are no items in that collection. For strings, it is an empty string. 53 | public func beEmpty() -> NonNilMatcherFunc { 54 | return NonNilMatcherFunc { actualExpression, failureMessage in 55 | failureMessage.postfixMessage = "be empty" 56 | let actualArray = try actualExpression.evaluate() 57 | return actualArray == nil || actualArray!.count == 0 58 | } 59 | } 60 | 61 | /// A Nimble matcher that succeeds when a value is "empty". For collections, this 62 | /// means the are no items in that collection. For strings, it is an empty string. 63 | public func beEmpty() -> NonNilMatcherFunc { 64 | return NonNilMatcherFunc { actualExpression, failureMessage in 65 | failureMessage.postfixMessage = "be empty" 66 | let actual = try actualExpression.evaluate() 67 | return actual == nil || actual!.count == 0 68 | } 69 | } 70 | 71 | #if _runtime(_ObjC) 72 | extension NMBObjCMatcher { 73 | public class func beEmptyMatcher() -> NMBObjCMatcher { 74 | return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in 75 | let location = actualExpression.location 76 | let actualValue = try! actualExpression.evaluate() 77 | failureMessage.postfixMessage = "be empty" 78 | if let value = actualValue as? NMBCollection { 79 | let expr = Expression(expression: ({ value as NMBCollection }), location: location) 80 | return try! beEmpty().matches(expr, failureMessage: failureMessage) 81 | } else if let value = actualValue as? NSString { 82 | let expr = Expression(expression: ({ value as String }), location: location) 83 | return try! beEmpty().matches(expr, failureMessage: failureMessage) 84 | } else if let actualValue = actualValue { 85 | failureMessage.postfixMessage = "be empty (only works for NSArrays, NSSets, NSIndexSets, NSDictionaries, NSHashTables, and NSStrings)" 86 | failureMessage.actualValue = "\(String(describing: type(of: actualValue))) type" 87 | } 88 | return false 89 | } 90 | } 91 | } 92 | #endif 93 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Matchers/BeGreaterThan.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | 4 | /// A Nimble matcher that succeeds when the actual value is greater than the expected value. 5 | public func beGreaterThan(_ expectedValue: T?) -> NonNilMatcherFunc { 6 | return NonNilMatcherFunc { actualExpression, failureMessage in 7 | failureMessage.postfixMessage = "be greater than <\(stringify(expectedValue))>" 8 | if let actual = try actualExpression.evaluate(), let expected = expectedValue { 9 | return actual > expected 10 | } 11 | return false 12 | } 13 | } 14 | 15 | /// A Nimble matcher that succeeds when the actual value is greater than the expected value. 16 | public func beGreaterThan(_ expectedValue: NMBComparable?) -> NonNilMatcherFunc { 17 | return NonNilMatcherFunc { actualExpression, failureMessage in 18 | failureMessage.postfixMessage = "be greater than <\(stringify(expectedValue))>" 19 | let actualValue = try actualExpression.evaluate() 20 | let matches = actualValue != nil && actualValue!.NMB_compare(expectedValue) == ComparisonResult.orderedDescending 21 | return matches 22 | } 23 | } 24 | 25 | public func >(lhs: Expectation, rhs: T) { 26 | lhs.to(beGreaterThan(rhs)) 27 | } 28 | 29 | public func >(lhs: Expectation, rhs: NMBComparable?) { 30 | lhs.to(beGreaterThan(rhs)) 31 | } 32 | 33 | #if _runtime(_ObjC) 34 | extension NMBObjCMatcher { 35 | public class func beGreaterThanMatcher(_ expected: NMBComparable?) -> NMBObjCMatcher { 36 | return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in 37 | let expr = actualExpression.cast { $0 as? NMBComparable } 38 | return try! beGreaterThan(expected).matches(expr, failureMessage: failureMessage) 39 | } 40 | } 41 | } 42 | #endif 43 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Matchers/BeGreaterThanOrEqualTo.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// A Nimble matcher that succeeds when the actual value is greater than 4 | /// or equal to the expected value. 5 | public func beGreaterThanOrEqualTo(_ expectedValue: T?) -> NonNilMatcherFunc { 6 | return NonNilMatcherFunc { actualExpression, failureMessage in 7 | failureMessage.postfixMessage = "be greater than or equal to <\(stringify(expectedValue))>" 8 | let actualValue = try actualExpression.evaluate() 9 | if let actual = actualValue, let expected = expectedValue { 10 | return actual >= expected 11 | } 12 | return false 13 | } 14 | } 15 | 16 | /// A Nimble matcher that succeeds when the actual value is greater than 17 | /// or equal to the expected value. 18 | public func beGreaterThanOrEqualTo(_ expectedValue: T?) -> NonNilMatcherFunc { 19 | return NonNilMatcherFunc { actualExpression, failureMessage in 20 | failureMessage.postfixMessage = "be greater than or equal to <\(stringify(expectedValue))>" 21 | let actualValue = try actualExpression.evaluate() 22 | let matches = actualValue != nil && actualValue!.NMB_compare(expectedValue) != ComparisonResult.orderedAscending 23 | return matches 24 | } 25 | } 26 | 27 | public func >=(lhs: Expectation, rhs: T) { 28 | lhs.to(beGreaterThanOrEqualTo(rhs)) 29 | } 30 | 31 | public func >=(lhs: Expectation, rhs: T) { 32 | lhs.to(beGreaterThanOrEqualTo(rhs)) 33 | } 34 | 35 | #if _runtime(_ObjC) 36 | extension NMBObjCMatcher { 37 | public class func beGreaterThanOrEqualToMatcher(_ expected: NMBComparable?) -> NMBObjCMatcher { 38 | return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in 39 | let expr = actualExpression.cast { $0 as? NMBComparable } 40 | return try! beGreaterThanOrEqualTo(expected).matches(expr, failureMessage: failureMessage) 41 | } 42 | } 43 | } 44 | #endif 45 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Matchers/BeIdenticalTo.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | 4 | /// A Nimble matcher that succeeds when the actual value is the same instance 5 | /// as the expected instance. 6 | public func beIdenticalTo(_ expected: Any?) -> NonNilMatcherFunc { 7 | return NonNilMatcherFunc { actualExpression, failureMessage in 8 | #if os(Linux) 9 | let actual = try actualExpression.evaluate() as? AnyObject 10 | #else 11 | let actual = try actualExpression.evaluate() as AnyObject? 12 | #endif 13 | failureMessage.actualValue = "\(identityAsString(actual))" 14 | failureMessage.postfixMessage = "be identical to \(identityAsString(expected))" 15 | #if os(Linux) 16 | return actual === (expected as? AnyObject) && actual !== nil 17 | #else 18 | return actual === (expected as AnyObject?) && actual !== nil 19 | #endif 20 | } 21 | } 22 | 23 | public func ===(lhs: Expectation, rhs: Any?) { 24 | lhs.to(beIdenticalTo(rhs)) 25 | } 26 | public func !==(lhs: Expectation, rhs: Any?) { 27 | lhs.toNot(beIdenticalTo(rhs)) 28 | } 29 | 30 | /// A Nimble matcher that succeeds when the actual value is the same instance 31 | /// as the expected instance. 32 | /// 33 | /// Alias for "beIdenticalTo". 34 | public func be(_ expected: Any?) -> NonNilMatcherFunc { 35 | return beIdenticalTo(expected) 36 | } 37 | 38 | #if _runtime(_ObjC) 39 | extension NMBObjCMatcher { 40 | public class func beIdenticalToMatcher(_ expected: NSObject?) -> NMBObjCMatcher { 41 | return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in 42 | let aExpr = actualExpression.cast { $0 as Any? } 43 | return try! beIdenticalTo(expected).matches(aExpr, failureMessage: failureMessage) 44 | } 45 | } 46 | } 47 | #endif 48 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Matchers/BeLessThan.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// A Nimble matcher that succeeds when the actual value is less than the expected value. 4 | public func beLessThan(_ expectedValue: T?) -> NonNilMatcherFunc { 5 | return NonNilMatcherFunc { actualExpression, failureMessage in 6 | failureMessage.postfixMessage = "be less than <\(stringify(expectedValue))>" 7 | if let actual = try actualExpression.evaluate(), let expected = expectedValue { 8 | return actual < expected 9 | } 10 | return false 11 | } 12 | } 13 | 14 | /// A Nimble matcher that succeeds when the actual value is less than the expected value. 15 | public func beLessThan(_ expectedValue: NMBComparable?) -> NonNilMatcherFunc { 16 | return NonNilMatcherFunc { actualExpression, failureMessage in 17 | failureMessage.postfixMessage = "be less than <\(stringify(expectedValue))>" 18 | let actualValue = try actualExpression.evaluate() 19 | let matches = actualValue != nil && actualValue!.NMB_compare(expectedValue) == ComparisonResult.orderedAscending 20 | return matches 21 | } 22 | } 23 | 24 | public func <(lhs: Expectation, rhs: T) { 25 | lhs.to(beLessThan(rhs)) 26 | } 27 | 28 | public func <(lhs: Expectation, rhs: NMBComparable?) { 29 | lhs.to(beLessThan(rhs)) 30 | } 31 | 32 | #if _runtime(_ObjC) 33 | extension NMBObjCMatcher { 34 | public class func beLessThanMatcher(_ expected: NMBComparable?) -> NMBObjCMatcher { 35 | return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in 36 | let expr = actualExpression.cast { $0 as? NMBComparable } 37 | return try! beLessThan(expected).matches(expr, failureMessage: failureMessage) 38 | } 39 | } 40 | } 41 | #endif 42 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Matchers/BeLessThanOrEqual.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// A Nimble matcher that succeeds when the actual value is less than 4 | /// or equal to the expected value. 5 | public func beLessThanOrEqualTo(_ expectedValue: T?) -> NonNilMatcherFunc { 6 | return NonNilMatcherFunc { actualExpression, failureMessage in 7 | failureMessage.postfixMessage = "be less than or equal to <\(stringify(expectedValue))>" 8 | if let actual = try actualExpression.evaluate(), let expected = expectedValue { 9 | return actual <= expected 10 | } 11 | return false 12 | } 13 | } 14 | 15 | /// A Nimble matcher that succeeds when the actual value is less than 16 | /// or equal to the expected value. 17 | public func beLessThanOrEqualTo(_ expectedValue: T?) -> NonNilMatcherFunc { 18 | return NonNilMatcherFunc { actualExpression, failureMessage in 19 | failureMessage.postfixMessage = "be less than or equal to <\(stringify(expectedValue))>" 20 | let actualValue = try actualExpression.evaluate() 21 | return actualValue != nil && actualValue!.NMB_compare(expectedValue) != ComparisonResult.orderedDescending 22 | } 23 | } 24 | 25 | public func <=(lhs: Expectation, rhs: T) { 26 | lhs.to(beLessThanOrEqualTo(rhs)) 27 | } 28 | 29 | public func <=(lhs: Expectation, rhs: T) { 30 | lhs.to(beLessThanOrEqualTo(rhs)) 31 | } 32 | 33 | #if _runtime(_ObjC) 34 | extension NMBObjCMatcher { 35 | public class func beLessThanOrEqualToMatcher(_ expected: NMBComparable?) -> NMBObjCMatcher { 36 | return NMBObjCMatcher(canMatchNil:false) { actualExpression, failureMessage in 37 | let expr = actualExpression.cast { $0 as? NMBComparable } 38 | return try! beLessThanOrEqualTo(expected).matches(expr, failureMessage: failureMessage) 39 | } 40 | } 41 | } 42 | #endif 43 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Matchers/BeNil.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// A Nimble matcher that succeeds when the actual value is nil. 4 | public func beNil() -> MatcherFunc { 5 | return MatcherFunc { actualExpression, failureMessage in 6 | failureMessage.postfixMessage = "be nil" 7 | let actualValue = try actualExpression.evaluate() 8 | return actualValue == nil 9 | } 10 | } 11 | 12 | #if _runtime(_ObjC) 13 | extension NMBObjCMatcher { 14 | public class func beNilMatcher() -> NMBObjCMatcher { 15 | return NMBObjCMatcher { actualExpression, failureMessage in 16 | return try! beNil().matches(actualExpression, failureMessage: failureMessage) 17 | } 18 | } 19 | } 20 | #endif 21 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Matchers/BeVoid.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// A Nimble matcher that succeeds when the actual value is Void. 4 | public func beVoid() -> MatcherFunc<()> { 5 | return MatcherFunc { actualExpression, failureMessage in 6 | failureMessage.postfixMessage = "be void" 7 | let actualValue: ()? = try actualExpression.evaluate() 8 | return actualValue != nil 9 | } 10 | } 11 | 12 | public func ==(lhs: Expectation<()>, rhs: ()) { 13 | lhs.to(beVoid()) 14 | } 15 | 16 | public func !=(lhs: Expectation<()>, rhs: ()) { 17 | lhs.toNot(beVoid()) 18 | } -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Matchers/BeginWith.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | 4 | /// A Nimble matcher that succeeds when the actual sequence's first element 5 | /// is equal to the expected value. 6 | public func beginWith(_ startingElement: T) -> NonNilMatcherFunc 7 | where S.Iterator.Element == T 8 | { 9 | return NonNilMatcherFunc { actualExpression, failureMessage in 10 | failureMessage.postfixMessage = "begin with <\(startingElement)>" 11 | if let actualValue = try actualExpression.evaluate() { 12 | var actualGenerator = actualValue.makeIterator() 13 | return actualGenerator.next() == startingElement 14 | } 15 | return false 16 | } 17 | } 18 | 19 | /// A Nimble matcher that succeeds when the actual collection's first element 20 | /// is equal to the expected object. 21 | public func beginWith(_ startingElement: Any) -> NonNilMatcherFunc { 22 | return NonNilMatcherFunc { actualExpression, failureMessage in 23 | failureMessage.postfixMessage = "begin with <\(startingElement)>" 24 | guard let collection = try actualExpression.evaluate() else { return false } 25 | guard collection.count > 0 else { return false } 26 | #if os(Linux) 27 | guard let collectionValue = collection.object(at: 0) as? NSObject else { 28 | return false 29 | } 30 | #else 31 | let collectionValue = collection.object(at: 0) as AnyObject 32 | #endif 33 | return collectionValue.isEqual(startingElement) 34 | } 35 | } 36 | 37 | /// A Nimble matcher that succeeds when the actual string contains expected substring 38 | /// where the expected substring's location is zero. 39 | public func beginWith(_ startingSubstring: String) -> NonNilMatcherFunc { 40 | return NonNilMatcherFunc { actualExpression, failureMessage in 41 | failureMessage.postfixMessage = "begin with <\(startingSubstring)>" 42 | if let actual = try actualExpression.evaluate() { 43 | let range = actual.range(of: startingSubstring) 44 | return range != nil && range!.lowerBound == actual.startIndex 45 | } 46 | return false 47 | } 48 | } 49 | 50 | #if _runtime(_ObjC) 51 | extension NMBObjCMatcher { 52 | public class func beginWithMatcher(_ expected: Any) -> NMBObjCMatcher { 53 | return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in 54 | let actual = try! actualExpression.evaluate() 55 | if let _ = actual as? String { 56 | let expr = actualExpression.cast { $0 as? String } 57 | return try! beginWith(expected as! String).matches(expr, failureMessage: failureMessage) 58 | } else { 59 | let expr = actualExpression.cast { $0 as? NMBOrderedCollection } 60 | return try! beginWith(expected).matches(expr, failureMessage: failureMessage) 61 | } 62 | } 63 | } 64 | } 65 | #endif 66 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Matchers/Contain.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// A Nimble matcher that succeeds when the actual sequence contains the expected value. 4 | public func contain(_ items: T...) -> NonNilMatcherFunc 5 | where S.Iterator.Element == T 6 | { 7 | return contain(items) 8 | } 9 | 10 | public func contain(_ items: [T]) -> NonNilMatcherFunc 11 | where S.Iterator.Element == T 12 | { 13 | return NonNilMatcherFunc { actualExpression, failureMessage in 14 | failureMessage.postfixMessage = "contain <\(arrayAsString(items))>" 15 | if let actual = try actualExpression.evaluate() { 16 | return items.all { 17 | return actual.contains($0) 18 | } 19 | } 20 | return false 21 | } 22 | } 23 | 24 | /// A Nimble matcher that succeeds when the actual string contains the expected substring. 25 | public func contain(_ substrings: String...) -> NonNilMatcherFunc { 26 | return contain(substrings) 27 | } 28 | 29 | public func contain(_ substrings: [String]) -> NonNilMatcherFunc { 30 | return NonNilMatcherFunc { actualExpression, failureMessage in 31 | failureMessage.postfixMessage = "contain <\(arrayAsString(substrings))>" 32 | if let actual = try actualExpression.evaluate() { 33 | return substrings.all { 34 | let range = actual.range(of: $0) 35 | return range != nil && !range!.isEmpty 36 | } 37 | } 38 | return false 39 | } 40 | } 41 | 42 | /// A Nimble matcher that succeeds when the actual string contains the expected substring. 43 | public func contain(_ substrings: NSString...) -> NonNilMatcherFunc { 44 | return contain(substrings) 45 | } 46 | 47 | public func contain(_ substrings: [NSString]) -> NonNilMatcherFunc { 48 | return NonNilMatcherFunc { actualExpression, failureMessage in 49 | failureMessage.postfixMessage = "contain <\(arrayAsString(substrings))>" 50 | if let actual = try actualExpression.evaluate() { 51 | return substrings.all { actual.range(of: $0.description).length != 0 } 52 | } 53 | return false 54 | } 55 | } 56 | 57 | /// A Nimble matcher that succeeds when the actual collection contains the expected object. 58 | public func contain(_ items: Any?...) -> NonNilMatcherFunc { 59 | return contain(items) 60 | } 61 | 62 | public func contain(_ items: [Any?]) -> NonNilMatcherFunc { 63 | return NonNilMatcherFunc { actualExpression, failureMessage in 64 | failureMessage.postfixMessage = "contain <\(arrayAsString(items))>" 65 | guard let actual = try actualExpression.evaluate() else { return false } 66 | return items.all { item in 67 | return item != nil && actual.contains(item!) 68 | } 69 | } 70 | } 71 | 72 | #if _runtime(_ObjC) 73 | extension NMBObjCMatcher { 74 | public class func containMatcher(_ expected: [NSObject]) -> NMBObjCMatcher { 75 | return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in 76 | let location = actualExpression.location 77 | let actualValue = try! actualExpression.evaluate() 78 | if let value = actualValue as? NMBContainer { 79 | let expr = Expression(expression: ({ value as NMBContainer }), location: location) 80 | 81 | // A straightforward cast on the array causes this to crash, so we have to cast the individual items 82 | let expectedOptionals: [Any?] = expected.map({ $0 as Any? }) 83 | return try! contain(expectedOptionals).matches(expr, failureMessage: failureMessage) 84 | } else if let value = actualValue as? NSString { 85 | let expr = Expression(expression: ({ value as String }), location: location) 86 | return try! contain(expected as! [String]).matches(expr, failureMessage: failureMessage) 87 | } else if actualValue != nil { 88 | failureMessage.postfixMessage = "contain <\(arrayAsString(expected))> (only works for NSArrays, NSSets, NSHashTables, and NSStrings)" 89 | } else { 90 | failureMessage.postfixMessage = "contain <\(arrayAsString(expected))>" 91 | } 92 | return false 93 | } 94 | } 95 | } 96 | #endif 97 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Matchers/EndWith.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | 4 | /// A Nimble matcher that succeeds when the actual sequence's last element 5 | /// is equal to the expected value. 6 | public func endWith(_ endingElement: T) -> NonNilMatcherFunc 7 | where S.Iterator.Element == T 8 | { 9 | return NonNilMatcherFunc { actualExpression, failureMessage in 10 | failureMessage.postfixMessage = "end with <\(endingElement)>" 11 | 12 | if let actualValue = try actualExpression.evaluate() { 13 | var actualGenerator = actualValue.makeIterator() 14 | var lastItem: T? 15 | var item: T? 16 | repeat { 17 | lastItem = item 18 | item = actualGenerator.next() 19 | } while(item != nil) 20 | 21 | return lastItem == endingElement 22 | } 23 | return false 24 | } 25 | } 26 | 27 | /// A Nimble matcher that succeeds when the actual collection's last element 28 | /// is equal to the expected object. 29 | public func endWith(_ endingElement: Any) -> NonNilMatcherFunc { 30 | return NonNilMatcherFunc { actualExpression, failureMessage in 31 | failureMessage.postfixMessage = "end with <\(endingElement)>" 32 | guard let collection = try actualExpression.evaluate() else { return false } 33 | guard collection.count > 0 else { return false } 34 | #if os(Linux) 35 | guard let collectionValue = collection.object(at: collection.count - 1) as? NSObject else { 36 | return false 37 | } 38 | #else 39 | let collectionValue = collection.object(at: collection.count - 1) as AnyObject 40 | #endif 41 | 42 | return collectionValue.isEqual(endingElement) 43 | } 44 | } 45 | 46 | 47 | /// A Nimble matcher that succeeds when the actual string contains the expected substring 48 | /// where the expected substring's location is the actual string's length minus the 49 | /// expected substring's length. 50 | public func endWith(_ endingSubstring: String) -> NonNilMatcherFunc { 51 | return NonNilMatcherFunc { actualExpression, failureMessage in 52 | failureMessage.postfixMessage = "end with <\(endingSubstring)>" 53 | if let collection = try actualExpression.evaluate() { 54 | return collection.hasSuffix(endingSubstring) 55 | } 56 | return false 57 | } 58 | } 59 | 60 | #if _runtime(_ObjC) 61 | extension NMBObjCMatcher { 62 | public class func endWithMatcher(_ expected: Any) -> NMBObjCMatcher { 63 | return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in 64 | let actual = try! actualExpression.evaluate() 65 | if let _ = actual as? String { 66 | let expr = actualExpression.cast { $0 as? String } 67 | return try! endWith(expected as! String).matches(expr, failureMessage: failureMessage) 68 | } else { 69 | let expr = actualExpression.cast { $0 as? NMBOrderedCollection } 70 | return try! endWith(expected).matches(expr, failureMessage: failureMessage) 71 | } 72 | } 73 | } 74 | } 75 | #endif 76 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Matchers/HaveCount.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | // The `haveCount` matchers do not print the full string representation of the collection value, 4 | // instead they only print the type name and the expected count. This makes it easier to understand 5 | // the reason for failed expectations. See: https://github.com/Quick/Nimble/issues/308. 6 | // The representation of the collection content is provided in a new line as an `extendedMessage`. 7 | 8 | /// A Nimble matcher that succeeds when the actual Collection's count equals 9 | /// the expected value 10 | public func haveCount(_ expectedValue: T.IndexDistance) -> NonNilMatcherFunc { 11 | return NonNilMatcherFunc { actualExpression, failureMessage in 12 | if let actualValue = try actualExpression.evaluate() { 13 | failureMessage.postfixMessage = "have \(prettyCollectionType(actualValue)) with count \(stringify(expectedValue))" 14 | let result = expectedValue == actualValue.count 15 | failureMessage.actualValue = "\(actualValue.count)" 16 | failureMessage.extendedMessage = "Actual Value: \(stringify(actualValue))" 17 | return result 18 | } else { 19 | return false 20 | } 21 | } 22 | } 23 | 24 | /// A Nimble matcher that succeeds when the actual collection's count equals 25 | /// the expected value 26 | public func haveCount(_ expectedValue: Int) -> MatcherFunc { 27 | return MatcherFunc { actualExpression, failureMessage in 28 | if let actualValue = try actualExpression.evaluate() { 29 | failureMessage.postfixMessage = "have \(prettyCollectionType(actualValue)) with count \(stringify(expectedValue))" 30 | let result = expectedValue == actualValue.count 31 | failureMessage.actualValue = "\(actualValue.count)" 32 | failureMessage.extendedMessage = "Actual Value: \(stringify(actualValue))" 33 | return result 34 | } else { 35 | return false 36 | } 37 | } 38 | } 39 | 40 | #if _runtime(_ObjC) 41 | extension NMBObjCMatcher { 42 | public class func haveCountMatcher(_ expected: NSNumber) -> NMBObjCMatcher { 43 | return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in 44 | let location = actualExpression.location 45 | let actualValue = try! actualExpression.evaluate() 46 | if let value = actualValue as? NMBCollection { 47 | let expr = Expression(expression: ({ value as NMBCollection}), location: location) 48 | return try! haveCount(expected.intValue).matches(expr, failureMessage: failureMessage) 49 | } else if let actualValue = actualValue { 50 | failureMessage.postfixMessage = "get type of NSArray, NSSet, NSDictionary, or NSHashTable" 51 | failureMessage.actualValue = "\(String(describing: type(of: actualValue)))" 52 | } 53 | return false 54 | } 55 | } 56 | } 57 | #endif 58 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Matchers/Match.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// A Nimble matcher that succeeds when the actual string satisfies the regular expression 4 | /// described by the expected string. 5 | public func match(_ expectedValue: String?) -> NonNilMatcherFunc { 6 | return NonNilMatcherFunc { actualExpression, failureMessage in 7 | failureMessage.postfixMessage = "match <\(stringify(expectedValue))>" 8 | 9 | if let actual = try actualExpression.evaluate() { 10 | if let regexp = expectedValue { 11 | return actual.range(of: regexp, options: .regularExpression) != nil 12 | } 13 | } 14 | 15 | return false 16 | } 17 | } 18 | 19 | #if _runtime(_ObjC) 20 | 21 | extension NMBObjCMatcher { 22 | public class func matchMatcher(_ expected: NSString) -> NMBMatcher { 23 | return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in 24 | let actual = actualExpression.cast { $0 as? String } 25 | return try! match(expected.description).matches(actual, failureMessage: failureMessage) 26 | } 27 | } 28 | } 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Matchers/MatchError.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// A Nimble matcher that succeeds when the actual expression evaluates to an 4 | /// error from the specified case. 5 | /// 6 | /// Errors are tried to be compared by their implementation of Equatable, 7 | /// otherwise they fallback to comparision by _domain and _code. 8 | public func matchError(_ error: T) -> NonNilMatcherFunc { 9 | return NonNilMatcherFunc { actualExpression, failureMessage in 10 | let actualError: Error? = try actualExpression.evaluate() 11 | 12 | setFailureMessageForError(failureMessage, postfixMessageVerb: "match", actualError: actualError, error: error) 13 | return errorMatchesNonNilFieldsOrClosure(actualError, error: error) 14 | } 15 | } 16 | 17 | /// A Nimble matcher that succeeds when the actual expression evaluates to an 18 | /// error of the specified type 19 | public func matchError(_ errorType: T.Type) -> NonNilMatcherFunc { 20 | return NonNilMatcherFunc { actualExpression, failureMessage in 21 | let actualError: Error? = try actualExpression.evaluate() 22 | 23 | setFailureMessageForError(failureMessage, postfixMessageVerb: "match", actualError: actualError, errorType: errorType) 24 | return errorMatchesNonNilFieldsOrClosure(actualError, errorType: errorType) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Matchers/MatcherFunc.swift: -------------------------------------------------------------------------------- 1 | /// A convenience API to build matchers that don't need special negation 2 | /// behavior. The toNot() behavior is the negation of to(). 3 | /// 4 | /// @see NonNilMatcherFunc if you prefer to have this matcher fail when nil 5 | /// values are recieved in an expectation. 6 | /// 7 | /// You may use this when implementing your own custom matchers. 8 | /// 9 | /// Use the Matcher protocol instead of this type to accept custom matchers as 10 | /// input parameters. 11 | /// @see allPass for an example that uses accepts other matchers as input. 12 | public struct MatcherFunc: Matcher { 13 | public let matcher: (Expression, FailureMessage) throws -> Bool 14 | 15 | public init(_ matcher: @escaping (Expression, FailureMessage) throws -> Bool) { 16 | self.matcher = matcher 17 | } 18 | 19 | public func matches(_ actualExpression: Expression, failureMessage: FailureMessage) throws -> Bool { 20 | return try matcher(actualExpression, failureMessage) 21 | } 22 | 23 | public func doesNotMatch(_ actualExpression: Expression, failureMessage: FailureMessage) throws -> Bool { 24 | return try !matcher(actualExpression, failureMessage) 25 | } 26 | } 27 | 28 | /// A convenience API to build matchers that don't need special negation 29 | /// behavior. The toNot() behavior is the negation of to(). 30 | /// 31 | /// Unlike MatcherFunc, this will always fail if an expectation contains nil. 32 | /// This applies regardless of using to() or toNot(). 33 | /// 34 | /// You may use this when implementing your own custom matchers. 35 | /// 36 | /// Use the Matcher protocol instead of this type to accept custom matchers as 37 | /// input parameters. 38 | /// @see allPass for an example that uses accepts other matchers as input. 39 | public struct NonNilMatcherFunc: Matcher { 40 | public let matcher: (Expression, FailureMessage) throws -> Bool 41 | 42 | public init(_ matcher: @escaping (Expression, FailureMessage) throws -> Bool) { 43 | self.matcher = matcher 44 | } 45 | 46 | public func matches(_ actualExpression: Expression, failureMessage: FailureMessage) throws -> Bool { 47 | let pass = try matcher(actualExpression, failureMessage) 48 | if try attachNilErrorIfNeeded(actualExpression, failureMessage: failureMessage) { 49 | return false 50 | } 51 | return pass 52 | } 53 | 54 | public func doesNotMatch(_ actualExpression: Expression, failureMessage: FailureMessage) throws -> Bool { 55 | let pass = try !matcher(actualExpression, failureMessage) 56 | if try attachNilErrorIfNeeded(actualExpression, failureMessage: failureMessage) { 57 | return false 58 | } 59 | return pass 60 | } 61 | 62 | internal func attachNilErrorIfNeeded(_ actualExpression: Expression, failureMessage: FailureMessage) throws -> Bool { 63 | if try actualExpression.evaluate() == nil { 64 | failureMessage.postfixActual = " (use beNil() to match nils)" 65 | return true 66 | } 67 | return false 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Matchers/PostNotification.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | internal class NotificationCollector { 4 | private(set) var observedNotifications: [Notification] 5 | private let notificationCenter: NotificationCenter 6 | #if _runtime(_ObjC) 7 | private var token: AnyObject? 8 | #else 9 | private var token: NSObjectProtocol? 10 | #endif 11 | 12 | required init(notificationCenter: NotificationCenter) { 13 | self.notificationCenter = notificationCenter 14 | self.observedNotifications = [] 15 | } 16 | 17 | func startObserving() { 18 | self.token = self.notificationCenter.addObserver(forName: nil, object: nil, queue: nil) { 19 | // linux-swift gets confused by .append(n) 20 | [weak self] n in self?.observedNotifications.append(n) 21 | } 22 | } 23 | 24 | deinit { 25 | #if _runtime(_ObjC) 26 | if let token = self.token { 27 | self.notificationCenter.removeObserver(token) 28 | } 29 | #else 30 | if let token = self.token as? AnyObject { 31 | self.notificationCenter.removeObserver(token) 32 | } 33 | #endif 34 | } 35 | } 36 | 37 | private let mainThread = pthread_self() 38 | 39 | let notificationCenterDefault = NotificationCenter.default 40 | 41 | public func postNotifications( 42 | _ notificationsMatcher: T, 43 | fromNotificationCenter center: NotificationCenter = notificationCenterDefault) 44 | -> MatcherFunc 45 | where T: Matcher, T.ValueType == [Notification] 46 | { 47 | let _ = mainThread // Force lazy-loading of this value 48 | let collector = NotificationCollector(notificationCenter: center) 49 | collector.startObserving() 50 | var once: Bool = false 51 | return MatcherFunc { actualExpression, failureMessage in 52 | let collectorNotificationsExpression = Expression(memoizedExpression: { _ in 53 | return collector.observedNotifications 54 | }, location: actualExpression.location, withoutCaching: true) 55 | 56 | assert(pthread_equal(mainThread, pthread_self()) != 0, "Only expecting closure to be evaluated on main thread.") 57 | if !once { 58 | once = true 59 | _ = try actualExpression.evaluate() 60 | } 61 | 62 | let match = try notificationsMatcher.matches(collectorNotificationsExpression, failureMessage: failureMessage) 63 | if collector.observedNotifications.isEmpty { 64 | failureMessage.actualValue = "no notifications" 65 | } else { 66 | failureMessage.actualValue = "<\(stringify(collector.observedNotifications))>" 67 | } 68 | return match 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Matchers/SatisfyAnyOf.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// A Nimble matcher that succeeds when the actual value matches with any of the matchers 4 | /// provided in the variable list of matchers. 5 | public func satisfyAnyOf(_ matchers: U...) -> NonNilMatcherFunc 6 | where U: Matcher, U.ValueType == T 7 | { 8 | return satisfyAnyOf(matchers) 9 | } 10 | 11 | internal func satisfyAnyOf(_ matchers: [U]) -> NonNilMatcherFunc 12 | where U: Matcher, U.ValueType == T 13 | { 14 | return NonNilMatcherFunc { actualExpression, failureMessage in 15 | let postfixMessages = NSMutableArray() 16 | var matches = false 17 | for matcher in matchers { 18 | if try matcher.matches(actualExpression, failureMessage: failureMessage) { 19 | matches = true 20 | } 21 | postfixMessages.add(NSString(string: "{\(failureMessage.postfixMessage)}")) 22 | } 23 | 24 | failureMessage.postfixMessage = "match one of: " + postfixMessages.componentsJoined(by: ", or ") 25 | if let actualValue = try actualExpression.evaluate() { 26 | failureMessage.actualValue = "\(actualValue)" 27 | } 28 | 29 | return matches 30 | } 31 | } 32 | 33 | public func ||(left: NonNilMatcherFunc, right: NonNilMatcherFunc) -> NonNilMatcherFunc { 34 | return satisfyAnyOf(left, right) 35 | } 36 | 37 | public func ||(left: MatcherFunc, right: MatcherFunc) -> NonNilMatcherFunc { 38 | return satisfyAnyOf(left, right) 39 | } 40 | 41 | #if _runtime(_ObjC) 42 | extension NMBObjCMatcher { 43 | public class func satisfyAnyOfMatcher(_ matchers: [NMBObjCMatcher]) -> NMBObjCMatcher { 44 | return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in 45 | if matchers.isEmpty { 46 | failureMessage.stringValue = "satisfyAnyOf must be called with at least one matcher" 47 | return false 48 | } 49 | 50 | var elementEvaluators = [NonNilMatcherFunc]() 51 | for matcher in matchers { 52 | let elementEvaluator: (Expression, FailureMessage) -> Bool = { 53 | expression, failureMessage in 54 | return matcher.matches( 55 | {try! expression.evaluate()}, failureMessage: failureMessage, location: actualExpression.location) 56 | } 57 | 58 | elementEvaluators.append(NonNilMatcherFunc(elementEvaluator)) 59 | } 60 | 61 | return try! satisfyAnyOf(elementEvaluators).matches(actualExpression, failureMessage: failureMessage) 62 | } 63 | } 64 | } 65 | #endif 66 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Matchers/ThrowAssertion.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | public func throwAssertion() -> MatcherFunc { 4 | return MatcherFunc { actualExpression, failureMessage in 5 | #if arch(x86_64) && _runtime(_ObjC) && !SWIFT_PACKAGE 6 | failureMessage.postfixMessage = "throw an assertion" 7 | failureMessage.actualValue = nil 8 | 9 | var succeeded = true 10 | 11 | let caughtException: BadInstructionException? = catchBadInstruction { 12 | #if os(tvOS) 13 | if (!NimbleEnvironment.activeInstance.suppressTVOSAssertionWarning) { 14 | print() 15 | print("[Nimble Warning]: If you're getting stuck on a debugger breakpoint for a " + 16 | "fatal error while using throwAssertion(), please disable 'Debug Executable' " + 17 | "in your scheme. Go to 'Edit Scheme > Test > Info' and uncheck " + 18 | "'Debug Executable'. If you've already done that, suppress this warning " + 19 | "by setting `NimbleEnvironment.activeInstance.suppressTVOSAssertionWarning = true`. " + 20 | "This is required because the standard methods of catching assertions " + 21 | "(mach APIs) are unavailable for tvOS. Instead, the same mechanism the " + 22 | "debugger uses is the fallback method for tvOS." 23 | ) 24 | print() 25 | NimbleEnvironment.activeInstance.suppressTVOSAssertionWarning = true 26 | } 27 | #endif 28 | do { 29 | try actualExpression.evaluate() 30 | } catch let error { 31 | succeeded = false 32 | failureMessage.postfixMessage += "; threw error instead <\(error)>" 33 | } 34 | } 35 | 36 | if !succeeded { 37 | return false 38 | } 39 | 40 | if caughtException == nil { 41 | return false 42 | } 43 | 44 | return true 45 | #elseif SWIFT_PACKAGE 46 | fatalError("The throwAssertion Nimble matcher does not currently support Swift CLI." + 47 | " You can silence this error by placing the test case inside an #if !SWIFT_PACKAGE" + 48 | " conditional statement") 49 | #else 50 | fatalError("The throwAssertion Nimble matcher can only run on x86_64 platforms with " + 51 | "Objective-C (e.g. Mac, iPhone 5s or later simulators). You can silence this error " + 52 | "by placing the test case inside an #if arch(x86_64) or _runtime(_ObjC) conditional statement") 53 | #endif 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Matchers/ThrowError.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /// A Nimble matcher that succeeds when the actual expression throws an 4 | /// error of the specified type or from the specified case. 5 | /// 6 | /// Errors are tried to be compared by their implementation of Equatable, 7 | /// otherwise they fallback to comparision by _domain and _code. 8 | /// 9 | /// Alternatively, you can pass a closure to do any arbitrary custom matching 10 | /// to the thrown error. The closure only gets called when an error was thrown. 11 | /// 12 | /// nil arguments indicates that the matcher should not attempt to match against 13 | /// that parameter. 14 | public func throwError( 15 | _ error: T? = nil, 16 | errorType: T.Type? = nil, 17 | closure: ((T) -> Void)? = nil) -> MatcherFunc { 18 | return MatcherFunc { actualExpression, failureMessage in 19 | 20 | var actualError: Error? 21 | do { 22 | _ = try actualExpression.evaluate() 23 | } catch let catchedError { 24 | actualError = catchedError 25 | } 26 | 27 | setFailureMessageForError(failureMessage, actualError: actualError, error: error, errorType: errorType, closure: closure) 28 | return errorMatchesNonNilFieldsOrClosure(actualError, error: error, errorType: errorType, closure: closure) 29 | } 30 | } 31 | 32 | /// A Nimble matcher that succeeds when the actual expression throws any 33 | /// error or when the passed closures' arbitrary custom matching succeeds. 34 | /// 35 | /// This duplication to it's generic adequate is required to allow to receive 36 | /// values of the existential type `Error` in the closure. 37 | /// 38 | /// The closure only gets called when an error was thrown. 39 | public func throwError( 40 | closure: ((Error) -> Void)? = nil) -> MatcherFunc { 41 | return MatcherFunc { actualExpression, failureMessage in 42 | 43 | var actualError: Error? 44 | do { 45 | _ = try actualExpression.evaluate() 46 | } catch let catchedError { 47 | actualError = catchedError 48 | } 49 | 50 | setFailureMessageForError(failureMessage, actualError: actualError, closure: closure) 51 | return errorMatchesNonNilFieldsOrClosure(actualError, closure: closure) 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Nimble.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "NMBExceptionCapture.h" 3 | #import "NMBStringify.h" 4 | #import "DSL.h" 5 | 6 | #import "CwlCatchException.h" 7 | #import "CwlCatchBadInstruction.h" 8 | 9 | #if !TARGET_OS_TV 10 | #import "mach_excServer.h" 11 | #endif 12 | 13 | FOUNDATION_EXPORT double NimbleVersionNumber; 14 | FOUNDATION_EXPORT const unsigned char NimbleVersionString[]; 15 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Utils/Functional.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | extension Sequence { 4 | internal func all(_ fn: (Iterator.Element) -> Bool) -> Bool { 5 | for item in self { 6 | if !fn(item) { 7 | return false 8 | } 9 | } 10 | return true 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/Nimble/Utils/SourceLocation.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | // Ideally we would always use `StaticString` as the type for tracking the file name 4 | // that expectations originate from, for consistency with `assert` etc. from the 5 | // stdlib, and because recent versions of the XCTest overlay require `StaticString` 6 | // when calling `XCTFail`. Under the Objective-C runtime (i.e. building on Mac), we 7 | // have to use `String` instead because StaticString can't be generated from Objective-C 8 | #if _runtime(_ObjC) 9 | public typealias FileString = String 10 | #else 11 | public typealias FileString = StaticString 12 | #endif 13 | 14 | public final class SourceLocation : NSObject { 15 | public let file: FileString 16 | public let line: UInt 17 | 18 | override init() { 19 | file = "Unknown File" 20 | line = 0 21 | } 22 | 23 | init(file: FileString, line: UInt) { 24 | self.file = file 25 | self.line = line 26 | } 27 | 28 | override public var description: String { 29 | return "\(file):\(line)" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/NimbleObjectiveC/CurrentTestCaseTracker.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | SWIFT_CLASS("_TtC6Nimble22CurrentTestCaseTracker") 5 | @interface CurrentTestCaseTracker : NSObject 6 | + (CurrentTestCaseTracker *)sharedInstance; 7 | @end 8 | 9 | @interface CurrentTestCaseTracker (Register) @end 10 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/NimbleObjectiveC/NMBExceptionCapture.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface NMBExceptionCapture : NSObject 5 | 6 | - (nonnull instancetype)initWithHandler:(void(^ _Nullable)(NSException * _Nonnull))handler finally:(void(^ _Nullable)())finally; 7 | - (void)tryBlock:(void(^ _Nonnull)())unsafeBlock NS_SWIFT_NAME(tryBlock(_:)); 8 | 9 | @end 10 | 11 | typedef void(^NMBSourceCallbackBlock)(BOOL successful); 12 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/NimbleObjectiveC/NMBExceptionCapture.m: -------------------------------------------------------------------------------- 1 | #import "NMBExceptionCapture.h" 2 | 3 | @interface NMBExceptionCapture () 4 | @property (nonatomic, copy) void(^ _Nullable handler)(NSException * _Nullable); 5 | @property (nonatomic, copy) void(^ _Nullable finally)(); 6 | @end 7 | 8 | @implementation NMBExceptionCapture 9 | 10 | - (nonnull instancetype)initWithHandler:(void(^ _Nullable)(NSException * _Nonnull))handler finally:(void(^ _Nullable)())finally { 11 | self = [super init]; 12 | if (self) { 13 | self.handler = handler; 14 | self.finally = finally; 15 | } 16 | return self; 17 | } 18 | 19 | - (void)tryBlock:(void(^ _Nonnull)())unsafeBlock { 20 | @try { 21 | unsafeBlock(); 22 | } 23 | @catch (NSException *exception) { 24 | if (self.handler) { 25 | self.handler(exception); 26 | } 27 | } 28 | @finally { 29 | if (self.finally) { 30 | self.finally(); 31 | } 32 | } 33 | } 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/NimbleObjectiveC/NMBStringify.h: -------------------------------------------------------------------------------- 1 | @class NSString; 2 | 3 | /** 4 | * Returns a string appropriate for displaying in test output 5 | * from the provided value. 6 | * 7 | * @param value A value that will show up in a test's output. 8 | * 9 | * @return The string that is returned can be 10 | * customized per type by conforming a type to the `TestOutputStringConvertible` 11 | * protocol. When stringifying a non-`TestOutputStringConvertible` type, this 12 | * function will return the value's debug description and then its 13 | * normal description if available and in that order. Otherwise it 14 | * will return the result of constructing a string from the value. 15 | * 16 | * @see `TestOutputStringConvertible` 17 | */ 18 | extern NSString *_Nonnull NMBStringify(id _Nullable anyObject) __attribute__((warn_unused_result)); 19 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/NimbleObjectiveC/NMBStringify.m: -------------------------------------------------------------------------------- 1 | #import "NMBStringify.h" 2 | #import 3 | 4 | NSString *_Nonnull NMBStringify(id _Nullable anyObject) { 5 | return [NMBStringer stringify:anyObject]; 6 | } 7 | -------------------------------------------------------------------------------- /Example/Pods/Nimble/Sources/NimbleObjectiveC/XCTestObservationCenter+Register.m: -------------------------------------------------------------------------------- 1 | #import "CurrentTestCaseTracker.h" 2 | #import 3 | #import 4 | 5 | #pragma mark - Method Swizzling 6 | 7 | /// Swaps the implementations between two instance methods. 8 | /// 9 | /// @param class The class containing `originalSelector`. 10 | /// @param originalSelector Original method to replace. 11 | /// @param replacementSelector Replacement method. 12 | void swizzleSelectors(Class class, SEL originalSelector, SEL replacementSelector) { 13 | Method originalMethod = class_getInstanceMethod(class, originalSelector); 14 | Method replacementMethod = class_getInstanceMethod(class, replacementSelector); 15 | 16 | BOOL didAddMethod = 17 | class_addMethod(class, 18 | originalSelector, 19 | method_getImplementation(replacementMethod), 20 | method_getTypeEncoding(replacementMethod)); 21 | 22 | if (didAddMethod) { 23 | class_replaceMethod(class, 24 | replacementSelector, 25 | method_getImplementation(originalMethod), 26 | method_getTypeEncoding(originalMethod)); 27 | } else { 28 | method_exchangeImplementations(originalMethod, replacementMethod); 29 | } 30 | } 31 | 32 | #pragma mark - Private 33 | 34 | @interface XCTestObservationCenter (Private) 35 | - (void)_addLegacyTestObserver:(id)observer; 36 | @end 37 | 38 | @implementation XCTestObservationCenter (Register) 39 | 40 | /// Uses objc method swizzling to register `CurrentTestCaseTracker` as a test observer. This is necessary 41 | /// because Xcode 7.3 introduced timing issues where if a custom `XCTestObservation` is registered too early 42 | /// it suppresses all console output (generated by `XCTestLog`), breaking any tools that depend on this output. 43 | /// This approach waits to register our custom test observer until XCTest adds its first "legacy" observer, 44 | /// falling back to registering after the first normal observer if this private method ever changes. 45 | + (void)load { 46 | if (class_getInstanceMethod([self class], @selector(_addLegacyTestObserver:))) { 47 | // Swizzle -_addLegacyTestObserver: 48 | swizzleSelectors([self class], @selector(_addLegacyTestObserver:), @selector(NMB_original__addLegacyTestObserver:)); 49 | } else { 50 | // Swizzle -addTestObserver:, only if -_addLegacyTestObserver: is not implemented 51 | swizzleSelectors([self class], @selector(addTestObserver:), @selector(NMB_original_addTestObserver:)); 52 | } 53 | } 54 | 55 | #pragma mark - Replacement Methods 56 | 57 | /// Registers `CurrentTestCaseTracker` as a test observer after `XCTestLog` has been added. 58 | - (void)NMB_original__addLegacyTestObserver:(id)observer { 59 | [self NMB_original__addLegacyTestObserver:observer]; 60 | 61 | static dispatch_once_t onceToken; 62 | dispatch_once(&onceToken, ^{ 63 | [self addTestObserver:[CurrentTestCaseTracker sharedInstance]]; 64 | }); 65 | } 66 | 67 | /// Registers `CurrentTestCaseTracker` as a test observer after `XCTestLog` has been added. 68 | /// This method is only used if `-_addLegacyTestObserver:` is not impelemented. (added in Xcode 7.3) 69 | - (void)NMB_original_addTestObserver:(id)observer { 70 | [self NMB_original_addTestObserver:observer]; 71 | 72 | static dispatch_once_t onceToken; 73 | dispatch_once(&onceToken, ^{ 74 | [self NMB_original_addTestObserver:[CurrentTestCaseTracker sharedInstance]]; 75 | }); 76 | } 77 | 78 | @end 79 | -------------------------------------------------------------------------------- /Example/Pods/Quick/README.md: -------------------------------------------------------------------------------- 1 | ![](http://f.cl.ly/items/0r1E192C1R0b2g2Q3h2w/QuickLogo_Color.png) 2 | 3 | [![Build Status](https://travis-ci.org/Quick/Quick.svg?branch=master)](https://travis-ci.org/Quick/Quick) 4 | 5 | Quick is a behavior-driven development framework for Swift and Objective-C. 6 | Inspired by [RSpec](https://github.com/rspec/rspec), [Specta](https://github.com/specta/specta), and [Ginkgo](https://github.com/onsi/ginkgo). 7 | 8 | ![](https://raw.githubusercontent.com/Quick/Assets/master/Screenshots/QuickSpec%20screenshot.png) 9 | 10 | ```swift 11 | // Swift 12 | 13 | import Quick 14 | import Nimble 15 | 16 | class TableOfContentsSpec: QuickSpec { 17 | override func spec() { 18 | describe("the 'Documentation' directory") { 19 | it("has everything you need to get started") { 20 | let sections = Directory("Documentation").sections 21 | expect(sections).to(contain("Organized Tests with Quick Examples and Example Groups")) 22 | expect(sections).to(contain("Installing Quick")) 23 | } 24 | 25 | context("if it doesn't have what you're looking for") { 26 | it("needs to be updated") { 27 | let you = You(awesome: true) 28 | expect{you.submittedAnIssue}.toEventually(beTruthy()) 29 | } 30 | } 31 | } 32 | } 33 | } 34 | ``` 35 | #### Nimble 36 | Quick comes together with [Nimble](https://github.com/Quick/Nimble) — a matcher framework for your tests. You can learn why `XCTAssert()` statements make your expectations unclear and how to fix that using Nimble assertions [here](./Documentation/en-us/NimbleAssertions.md). 37 | 38 | ## Swift Version 39 | 40 | Certain versions of Quick and Nimble only support certain versions of Swift. Depending on which version of Swift your project uses, you should use specific versions of Quick and Nimble. Use the table below to determine which versions of Quick and Nimble are compatible with your project. 41 | 42 | |Swift version |Quick version |Nimble version | 43 | |:--------------------|:---------------|:--------------| 44 | |Swift 3 |v0.10.0 or later|v5.0.0 or later| 45 | |Swift 2.2 / Swift 2.3|v0.9.3 |v4.1.0 | 46 | 47 | ## Documentation 48 | 49 | All documentation can be found in the [Documentation folder](./Documentation), including [detailed installation instructions](./Documentation/en-us/InstallingQuick.md) for CocoaPods, Carthage, Git submodules, and more. For example, you can install Quick and [Nimble](https://github.com/Quick/Nimble) using CocoaPods by adding the following to your Podfile: 50 | 51 | ```rb 52 | # Podfile 53 | 54 | use_frameworks! 55 | 56 | def testing_pods 57 | pod 'Quick' 58 | pod 'Nimble' 59 | end 60 | 61 | target 'MyTests' do 62 | testing_pods 63 | end 64 | 65 | target 'MyUITests' do 66 | testing_pods 67 | end 68 | ``` 69 | 70 | ## Projects using Quick 71 | 72 | Many apps use both Quick and Nimble however, as they are not included in the app binary, neither appear in “Top Used Libraries” blog posts. Therefore, it would be greatly appreciated to remind contributors that their efforts are valued by compiling a list of organizations and projects that use them. 73 | 74 | Does your organization or project use Quick and Nimble? If yes, [please add your project to the list](https://github.com/Quick/Quick/wiki/Projects-using-Quick). 75 | 76 | ## Who uses Quick 77 | 78 | Similar to projects using Quick, it would be nice to hear why people use Quick and Nimble. Are there features you love? Are there features that are just okay? Are there some features we have that no one uses? 79 | 80 | Have something positive to say about Quick (or Nimble)? If yes, [provide a testimonial here](https://github.com/Quick/Quick/wiki/Who-uses-Quick). 81 | 82 | 83 | ## License 84 | 85 | Apache 2.0 license. See the [`LICENSE`](LICENSE) file for details. 86 | -------------------------------------------------------------------------------- /Example/Pods/Quick/Sources/Quick/Callsite.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /** 4 | An object encapsulating the file and line number at which 5 | a particular example is defined. 6 | */ 7 | final public class Callsite: NSObject { 8 | /** 9 | The absolute path of the file in which an example is defined. 10 | */ 11 | public let file: String 12 | 13 | /** 14 | The line number on which an example is defined. 15 | */ 16 | public let line: UInt 17 | 18 | internal init(file: String, line: UInt) { 19 | self.file = file 20 | self.line = line 21 | } 22 | } 23 | 24 | /** 25 | Returns a boolean indicating whether two Callsite objects are equal. 26 | If two callsites are in the same file and on the same line, they must be equal. 27 | */ 28 | public func == (lhs: Callsite, rhs: Callsite) -> Bool { 29 | return lhs.file == rhs.file && lhs.line == rhs.line 30 | } 31 | -------------------------------------------------------------------------------- /Example/Pods/Quick/Sources/Quick/ErrorUtility.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | internal func raiseError(_ message: String) -> Never { 4 | #if _runtime(_ObjC) 5 | NSException(name: .internalInconsistencyException, reason: message, userInfo: nil).raise() 6 | #endif 7 | 8 | // This won't be reached when ObjC is available and the exception above is raisd 9 | fatalError(message) 10 | } 11 | -------------------------------------------------------------------------------- /Example/Pods/Quick/Sources/Quick/Example.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | private var numberOfExamplesRun = 0 4 | 5 | /** 6 | Examples, defined with the `it` function, use assertions to 7 | demonstrate how code should behave. These are like "tests" in XCTest. 8 | */ 9 | final public class Example: NSObject { 10 | /** 11 | A boolean indicating whether the example is a shared example; 12 | i.e.: whether it is an example defined with `itBehavesLike`. 13 | */ 14 | public var isSharedExample = false 15 | 16 | /** 17 | The site at which the example is defined. 18 | This must be set correctly in order for Xcode to highlight 19 | the correct line in red when reporting a failure. 20 | */ 21 | public var callsite: Callsite 22 | 23 | weak internal var group: ExampleGroup? 24 | 25 | private let internalDescription: String 26 | private let closure: () -> () 27 | private let flags: FilterFlags 28 | 29 | internal init(description: String, callsite: Callsite, flags: FilterFlags, closure: @escaping () -> ()) { 30 | self.internalDescription = description 31 | self.closure = closure 32 | self.callsite = callsite 33 | self.flags = flags 34 | } 35 | 36 | public override var description: String { 37 | return internalDescription 38 | } 39 | 40 | /** 41 | The example name. A name is a concatenation of the name of 42 | the example group the example belongs to, followed by the 43 | description of the example itself. 44 | 45 | The example name is used to generate a test method selector 46 | to be displayed in Xcode's test navigator. 47 | */ 48 | public var name: String { 49 | guard let groupName = group?.name else { return description } 50 | return "\(groupName), \(description)" 51 | } 52 | 53 | /** 54 | Executes the example closure, as well as all before and after 55 | closures defined in the its surrounding example groups. 56 | */ 57 | public func run() { 58 | let world = World.sharedWorld 59 | 60 | if numberOfExamplesRun == 0 { 61 | world.suiteHooks.executeBefores() 62 | } 63 | 64 | let exampleMetadata = ExampleMetadata(example: self, exampleIndex: numberOfExamplesRun) 65 | world.currentExampleMetadata = exampleMetadata 66 | 67 | world.exampleHooks.executeBefores(exampleMetadata) 68 | group!.phase = .beforesExecuting 69 | for before in group!.befores { 70 | before(exampleMetadata) 71 | } 72 | group!.phase = .beforesFinished 73 | 74 | closure() 75 | 76 | group!.phase = .aftersExecuting 77 | for after in group!.afters { 78 | after(exampleMetadata) 79 | } 80 | group!.phase = .aftersFinished 81 | world.exampleHooks.executeAfters(exampleMetadata) 82 | 83 | numberOfExamplesRun += 1 84 | 85 | if !world.isRunningAdditionalSuites && numberOfExamplesRun >= world.includedExampleCount { 86 | world.suiteHooks.executeAfters() 87 | } 88 | } 89 | 90 | /** 91 | Evaluates the filter flags set on this example and on the example groups 92 | this example belongs to. Flags set on the example are trumped by flags on 93 | the example group it belongs to. Flags on inner example groups are trumped 94 | by flags on outer example groups. 95 | */ 96 | internal var filterFlags: FilterFlags { 97 | var aggregateFlags = flags 98 | for (key, value) in group!.filterFlags { 99 | aggregateFlags[key] = value 100 | } 101 | return aggregateFlags 102 | } 103 | } 104 | 105 | /** 106 | Returns a boolean indicating whether two Example objects are equal. 107 | If two examples are defined at the exact same callsite, they must be equal. 108 | */ 109 | public func == (lhs: Example, rhs: Example) -> Bool { 110 | return lhs.callsite == rhs.callsite 111 | } 112 | -------------------------------------------------------------------------------- /Example/Pods/Quick/Sources/Quick/ExampleGroup.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /** 4 | Example groups are logical groupings of examples, defined with 5 | the `describe` and `context` functions. Example groups can share 6 | setup and teardown code. 7 | */ 8 | final public class ExampleGroup: NSObject { 9 | weak internal var parent: ExampleGroup? 10 | internal let hooks = ExampleHooks() 11 | 12 | internal var phase: HooksPhase = .nothingExecuted 13 | 14 | private let internalDescription: String 15 | private let flags: FilterFlags 16 | private let isInternalRootExampleGroup: Bool 17 | private var childGroups = [ExampleGroup]() 18 | private var childExamples = [Example]() 19 | 20 | internal init(description: String, flags: FilterFlags, isInternalRootExampleGroup: Bool = false) { 21 | self.internalDescription = description 22 | self.flags = flags 23 | self.isInternalRootExampleGroup = isInternalRootExampleGroup 24 | } 25 | 26 | public override var description: String { 27 | return internalDescription 28 | } 29 | 30 | /** 31 | Returns a list of examples that belong to this example group, 32 | or to any of its descendant example groups. 33 | */ 34 | public var examples: [Example] { 35 | var examples = childExamples 36 | for group in childGroups { 37 | examples.append(contentsOf: group.examples) 38 | } 39 | return examples 40 | } 41 | 42 | internal var name: String? { 43 | if let parent = parent { 44 | guard let name = parent.name else { return description } 45 | return "\(name), \(description)" 46 | } else { 47 | return isInternalRootExampleGroup ? nil : description 48 | } 49 | } 50 | 51 | internal var filterFlags: FilterFlags { 52 | var aggregateFlags = flags 53 | walkUp() { (group: ExampleGroup) -> () in 54 | for (key, value) in group.flags { 55 | aggregateFlags[key] = value 56 | } 57 | } 58 | return aggregateFlags 59 | } 60 | 61 | internal var befores: [BeforeExampleWithMetadataClosure] { 62 | var closures = Array(hooks.befores.reversed()) 63 | walkUp() { (group: ExampleGroup) -> () in 64 | closures.append(contentsOf: Array(group.hooks.befores.reversed())) 65 | } 66 | return Array(closures.reversed()) 67 | } 68 | 69 | internal var afters: [AfterExampleWithMetadataClosure] { 70 | var closures = hooks.afters 71 | walkUp() { (group: ExampleGroup) -> () in 72 | closures.append(contentsOf: group.hooks.afters) 73 | } 74 | return closures 75 | } 76 | 77 | internal func walkDownExamples(_ callback: (_ example: Example) -> ()) { 78 | for example in childExamples { 79 | callback(example) 80 | } 81 | for group in childGroups { 82 | group.walkDownExamples(callback) 83 | } 84 | } 85 | 86 | internal func appendExampleGroup(_ group: ExampleGroup) { 87 | group.parent = self 88 | childGroups.append(group) 89 | } 90 | 91 | internal func appendExample(_ example: Example) { 92 | example.group = self 93 | childExamples.append(example) 94 | } 95 | 96 | private func walkUp(_ callback: (_ group: ExampleGroup) -> ()) { 97 | var group = self 98 | while let parent = group.parent { 99 | callback(parent) 100 | group = parent 101 | } 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /Example/Pods/Quick/Sources/Quick/ExampleMetadata.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /** 4 | A class that encapsulates information about an example, 5 | including the index at which the example was executed, as 6 | well as the example itself. 7 | */ 8 | final public class ExampleMetadata: NSObject { 9 | /** 10 | The example for which this metadata was collected. 11 | */ 12 | public let example: Example 13 | 14 | /** 15 | The index at which this example was executed in the 16 | test suite. 17 | */ 18 | public let exampleIndex: Int 19 | 20 | internal init(example: Example, exampleIndex: Int) { 21 | self.example = example 22 | self.exampleIndex = exampleIndex 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Example/Pods/Quick/Sources/Quick/Filter.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | /** 4 | A mapping of string keys to booleans that can be used to 5 | filter examples or example groups. For example, a "focused" 6 | example would have the flags [Focused: true]. 7 | */ 8 | public typealias FilterFlags = [String: Bool] 9 | 10 | /** 11 | A namespace for filter flag keys, defined primarily to make the 12 | keys available in Objective-C. 13 | */ 14 | final public class Filter: NSObject { 15 | /** 16 | Example and example groups with [Focused: true] are included in test runs, 17 | excluding all other examples without this flag. Use this to only run one or 18 | two tests that you're currently focusing on. 19 | */ 20 | public class var focused: String { 21 | return "focused" 22 | } 23 | 24 | /** 25 | Example and example groups with [Pending: true] are excluded from test runs. 26 | Use this to temporarily suspend examples that you know do not pass yet. 27 | */ 28 | public class var pending: String { 29 | return "pending" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Example/Pods/Quick/Sources/Quick/Hooks/Closures.swift: -------------------------------------------------------------------------------- 1 | // MARK: Example Hooks 2 | 3 | /** 4 | A closure executed before an example is run. 5 | */ 6 | public typealias BeforeExampleClosure = () -> () 7 | 8 | /** 9 | A closure executed before an example is run. The closure is given example metadata, 10 | which contains information about the example that is about to be run. 11 | */ 12 | public typealias BeforeExampleWithMetadataClosure = (_ exampleMetadata: ExampleMetadata) -> () 13 | 14 | /** 15 | A closure executed after an example is run. 16 | */ 17 | public typealias AfterExampleClosure = BeforeExampleClosure 18 | 19 | /** 20 | A closure executed after an example is run. The closure is given example metadata, 21 | which contains information about the example that has just finished running. 22 | */ 23 | public typealias AfterExampleWithMetadataClosure = BeforeExampleWithMetadataClosure 24 | 25 | // MARK: Suite Hooks 26 | 27 | /** 28 | A closure executed before any examples are run. 29 | */ 30 | public typealias BeforeSuiteClosure = () -> () 31 | 32 | /** 33 | A closure executed after all examples have finished running. 34 | */ 35 | public typealias AfterSuiteClosure = BeforeSuiteClosure 36 | -------------------------------------------------------------------------------- /Example/Pods/Quick/Sources/Quick/Hooks/ExampleHooks.swift: -------------------------------------------------------------------------------- 1 | /** 2 | A container for closures to be executed before and after each example. 3 | */ 4 | final internal class ExampleHooks { 5 | internal var befores: [BeforeExampleWithMetadataClosure] = [] 6 | internal var afters: [AfterExampleWithMetadataClosure] = [] 7 | internal var phase: HooksPhase = .nothingExecuted 8 | 9 | internal func appendBefore(_ closure: @escaping BeforeExampleWithMetadataClosure) { 10 | befores.append(closure) 11 | } 12 | 13 | internal func appendBefore(_ closure: @escaping BeforeExampleClosure) { 14 | befores.append { (exampleMetadata: ExampleMetadata) in closure() } 15 | } 16 | 17 | internal func appendAfter(_ closure: @escaping AfterExampleWithMetadataClosure) { 18 | afters.append(closure) 19 | } 20 | 21 | internal func appendAfter(_ closure: @escaping AfterExampleClosure) { 22 | afters.append { (exampleMetadata: ExampleMetadata) in closure() } 23 | } 24 | 25 | internal func executeBefores(_ exampleMetadata: ExampleMetadata) { 26 | phase = .beforesExecuting 27 | for before in befores { 28 | before(exampleMetadata) 29 | } 30 | 31 | phase = .beforesFinished 32 | } 33 | 34 | internal func executeAfters(_ exampleMetadata: ExampleMetadata) { 35 | phase = .aftersExecuting 36 | for after in afters { 37 | after(exampleMetadata) 38 | } 39 | 40 | phase = .aftersFinished 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Example/Pods/Quick/Sources/Quick/Hooks/HooksPhase.swift: -------------------------------------------------------------------------------- 1 | /** 2 | A description of the execution cycle of the current example with 3 | respect to the hooks of that example. 4 | */ 5 | internal enum HooksPhase { 6 | case nothingExecuted 7 | case beforesExecuting 8 | case beforesFinished 9 | case aftersExecuting 10 | case aftersFinished 11 | } 12 | -------------------------------------------------------------------------------- /Example/Pods/Quick/Sources/Quick/Hooks/SuiteHooks.swift: -------------------------------------------------------------------------------- 1 | /** 2 | A container for closures to be executed before and after all examples. 3 | */ 4 | final internal class SuiteHooks { 5 | internal var befores: [BeforeSuiteClosure] = [] 6 | internal var afters: [AfterSuiteClosure] = [] 7 | internal var phase: HooksPhase = .nothingExecuted 8 | 9 | internal func appendBefore(_ closure: @escaping BeforeSuiteClosure) { 10 | befores.append(closure) 11 | } 12 | 13 | internal func appendAfter(_ closure: @escaping AfterSuiteClosure) { 14 | afters.append(closure) 15 | } 16 | 17 | internal func executeBefores() { 18 | phase = .beforesExecuting 19 | for before in befores { 20 | before() 21 | } 22 | phase = .beforesFinished 23 | } 24 | 25 | internal func executeAfters() { 26 | phase = .aftersExecuting 27 | for after in afters { 28 | after() 29 | } 30 | phase = .aftersFinished 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Example/Pods/Quick/Sources/Quick/NSBundle+CurrentTestBundle.swift: -------------------------------------------------------------------------------- 1 | #if os(OSX) || os(iOS) || os(watchOS) || os(tvOS) 2 | 3 | import Foundation 4 | 5 | extension Bundle { 6 | 7 | /** 8 | Locates the first bundle with a '.xctest' file extension. 9 | */ 10 | internal static var currentTestBundle: Bundle? { 11 | return allBundles.first { $0.bundlePath.hasSuffix(".xctest") } 12 | } 13 | 14 | } 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /Example/Pods/Quick/Sources/Quick/QuickSelectedTestSuiteBuilder.swift: -------------------------------------------------------------------------------- 1 | #if os(OSX) || os(iOS) || os(watchOS) || os(tvOS) 2 | import Foundation 3 | 4 | /** 5 | Responsible for building a "Selected tests" suite. This corresponds to a single 6 | spec, and all its examples. 7 | */ 8 | internal class QuickSelectedTestSuiteBuilder: QuickTestSuiteBuilder { 9 | 10 | /** 11 | The test spec class to run. 12 | */ 13 | let testCaseClass: AnyClass! 14 | 15 | /** 16 | For Objective-C classes, returns the class name. For Swift classes without, 17 | an explicit Objective-C name, returns a module-namespaced class name 18 | (e.g., "FooTests.FooSpec"). 19 | */ 20 | var testSuiteClassName: String { 21 | return NSStringFromClass(testCaseClass) 22 | } 23 | 24 | /** 25 | Given a test case name: 26 | 27 | FooSpec/testFoo 28 | 29 | Optionally constructs a test suite builder for the named test case class 30 | in the running test bundle. 31 | 32 | If no test bundle can be found, or the test case class can't be found, 33 | initialization fails and returns `nil`. 34 | */ 35 | init?(forTestCaseWithName name: String) { 36 | guard let testCaseClass = testCaseClassForTestCaseWithName(name) else { 37 | self.testCaseClass = nil 38 | return nil 39 | } 40 | 41 | self.testCaseClass = testCaseClass 42 | } 43 | 44 | /** 45 | Returns a `QuickTestSuite` that runs the associated test case class. 46 | */ 47 | func buildTestSuite() -> QuickTestSuite { 48 | return QuickTestSuite(forTestCaseClass: testCaseClass) 49 | } 50 | 51 | } 52 | 53 | /** 54 | Searches `Bundle.allBundles()` for an xctest bundle, then looks up the named 55 | test case class in that bundle. 56 | 57 | Returns `nil` if a bundle or test case class cannot be found. 58 | */ 59 | private func testCaseClassForTestCaseWithName(_ name: String) -> AnyClass? { 60 | func extractClassName(_ name: String) -> String? { 61 | return name.components(separatedBy: "/").first 62 | } 63 | 64 | guard let className = extractClassName(name) else { return nil } 65 | guard let bundle = Bundle.currentTestBundle else { return nil } 66 | 67 | if let testCaseClass = bundle.classNamed(className) { return testCaseClass } 68 | 69 | let bundleFileName = bundle.bundleURL.fileName 70 | let moduleName = bundleFileName.replacingOccurrences(of: " ", with: "_") 71 | 72 | return NSClassFromString("\(moduleName).\(className)") 73 | } 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /Example/Pods/Quick/Sources/Quick/QuickTestSuite.swift: -------------------------------------------------------------------------------- 1 | #if os(OSX) || os(iOS) || os(watchOS) || os(tvOS) 2 | 3 | import XCTest 4 | 5 | /** 6 | This protocol defines the role of an object that builds test suites. 7 | */ 8 | internal protocol QuickTestSuiteBuilder { 9 | 10 | /** 11 | Construct a `QuickTestSuite` instance with the appropriate test cases added as tests. 12 | 13 | Subsequent calls to this method should return equivalent test suites. 14 | */ 15 | func buildTestSuite() -> QuickTestSuite 16 | 17 | } 18 | 19 | /** 20 | A base class for a class cluster of Quick test suites, that should correctly 21 | build dynamic test suites for XCTest to execute. 22 | */ 23 | public class QuickTestSuite: XCTestSuite { 24 | 25 | private static var builtTestSuites: Set = Set() 26 | 27 | /** 28 | Construct a test suite for a specific, selected subset of test cases (rather 29 | than the default, which as all test cases). 30 | 31 | If this method is called multiple times for the same test case class, e.g.. 32 | 33 | FooSpec/testFoo 34 | FooSpec/testBar 35 | 36 | It is expected that the first call should return a valid test suite, and 37 | all subsequent calls should return `nil`. 38 | */ 39 | public static func selectedTestSuite(forTestCaseWithName name: String) -> QuickTestSuite? { 40 | guard let builder = QuickSelectedTestSuiteBuilder(forTestCaseWithName: name) else { return nil } 41 | 42 | if builtTestSuites.contains(builder.testSuiteClassName) { 43 | return nil 44 | } else { 45 | builtTestSuites.insert(builder.testSuiteClassName) 46 | return builder.buildTestSuite() 47 | } 48 | } 49 | 50 | } 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /Example/Pods/Quick/Sources/Quick/URL+FileName.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | extension URL { 4 | 5 | /** 6 | Returns the path file name without file extension. 7 | */ 8 | var fileName: String { 9 | return self.deletingPathExtension().lastPathComponent 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /Example/Pods/Quick/Sources/QuickObjectiveC/Configuration/QuickConfiguration.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class Configuration; 4 | 5 | /** 6 | Subclass QuickConfiguration and override the +[QuickConfiguration configure:] 7 | method in order to configure how Quick behaves when running specs, or to define 8 | shared examples that are used across spec files. 9 | */ 10 | @interface QuickConfiguration : NSObject 11 | 12 | /** 13 | This method is executed on each subclass of this class before Quick runs 14 | any examples. You may override this method on as many subclasses as you like, but 15 | there is no guarantee as to the order in which these methods are executed. 16 | 17 | You can override this method in order to: 18 | 19 | 1. Configure how Quick behaves, by modifying properties on the Configuration object. 20 | Setting the same properties in several methods has undefined behavior. 21 | 22 | 2. Define shared examples using `sharedExamples`. 23 | 24 | @param configuration A mutable object that is used to configure how Quick behaves on 25 | a framework level. For details on all the options, see the 26 | documentation in Configuration.swift. 27 | */ 28 | + (void)configure:(Configuration *)configuration; 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /Example/Pods/Quick/Sources/QuickObjectiveC/Configuration/QuickConfiguration.m: -------------------------------------------------------------------------------- 1 | #import "QuickConfiguration.h" 2 | #import "World.h" 3 | #import 4 | 5 | typedef void (^QCKClassEnumerationBlock)(Class klass); 6 | 7 | /** 8 | Finds all direct subclasses of the given class and passes them to the block provided. 9 | The classes are iterated over in the order that objc_getClassList returns them. 10 | 11 | @param klass The base class to find subclasses of. 12 | @param block A block that takes a Class. This block will be executed once for each subclass of klass. 13 | */ 14 | void qck_enumerateSubclasses(Class klass, QCKClassEnumerationBlock block) { 15 | Class *classes = NULL; 16 | int classesCount = objc_getClassList(NULL, 0); 17 | 18 | if (classesCount > 0) { 19 | classes = (Class *)calloc(sizeof(Class), classesCount); 20 | classesCount = objc_getClassList(classes, classesCount); 21 | 22 | Class subclass, superclass; 23 | for(int i = 0; i < classesCount; i++) { 24 | subclass = classes[i]; 25 | superclass = class_getSuperclass(subclass); 26 | if (superclass == klass && block) { 27 | block(subclass); 28 | } 29 | } 30 | 31 | free(classes); 32 | } 33 | } 34 | 35 | @implementation QuickConfiguration 36 | 37 | #pragma mark - Object Lifecycle 38 | 39 | /** 40 | QuickConfiguration is not meant to be instantiated; it merely provides a hook 41 | for users to configure how Quick behaves. Raise an exception if an instance of 42 | QuickConfiguration is created. 43 | */ 44 | - (instancetype)init { 45 | NSString *className = NSStringFromClass([self class]); 46 | NSString *selectorName = NSStringFromSelector(@selector(configure:)); 47 | [NSException raise:NSInternalInconsistencyException 48 | format:@"%@ is not meant to be instantiated; " 49 | @"subclass %@ and override %@ to configure Quick.", 50 | className, className, selectorName]; 51 | return nil; 52 | } 53 | 54 | #pragma mark - NSObject Overrides 55 | 56 | /** 57 | Hook into when QuickConfiguration is initialized in the runtime in order to 58 | call +[QuickConfiguration configure:] on each of its subclasses. 59 | */ 60 | + (void)initialize { 61 | // Only enumerate over the subclasses of QuickConfiguration, not any of its subclasses. 62 | if ([self class] == [QuickConfiguration class]) { 63 | 64 | // Only enumerate over subclasses once, even if +[QuickConfiguration initialize] 65 | // were to be called several times. This is necessary because +[QuickSpec initialize] 66 | // manually calls +[QuickConfiguration initialize]. 67 | static dispatch_once_t onceToken; 68 | dispatch_once(&onceToken, ^{ 69 | qck_enumerateSubclasses([QuickConfiguration class], ^(__unsafe_unretained Class klass) { 70 | [[World sharedWorld] configure:^(Configuration *configuration) { 71 | [klass configure:configuration]; 72 | }]; 73 | }); 74 | [[World sharedWorld] finalizeConfiguration]; 75 | }); 76 | } 77 | } 78 | 79 | #pragma mark - Public Interface 80 | 81 | + (void)configure:(Configuration *)configuration { } 82 | 83 | @end 84 | -------------------------------------------------------------------------------- /Example/Pods/Quick/Sources/QuickObjectiveC/DSL/QCKDSL.m: -------------------------------------------------------------------------------- 1 | #import "QCKDSL.h" 2 | #import "World.h" 3 | #import "World+DSL.h" 4 | 5 | void qck_beforeSuite(QCKDSLEmptyBlock closure) { 6 | [[World sharedWorld] beforeSuite:closure]; 7 | } 8 | 9 | void qck_afterSuite(QCKDSLEmptyBlock closure) { 10 | [[World sharedWorld] afterSuite:closure]; 11 | } 12 | 13 | void qck_sharedExamples(NSString *name, QCKDSLSharedExampleBlock closure) { 14 | [[World sharedWorld] sharedExamples:name closure:closure]; 15 | } 16 | 17 | void qck_describe(NSString *description, QCKDSLEmptyBlock closure) { 18 | [[World sharedWorld] describe:description flags:@{} closure:closure]; 19 | } 20 | 21 | void qck_context(NSString *description, QCKDSLEmptyBlock closure) { 22 | qck_describe(description, closure); 23 | } 24 | 25 | void qck_beforeEach(QCKDSLEmptyBlock closure) { 26 | [[World sharedWorld] beforeEach:closure]; 27 | } 28 | 29 | void qck_beforeEachWithMetadata(QCKDSLExampleMetadataBlock closure) { 30 | [[World sharedWorld] beforeEachWithMetadata:closure]; 31 | } 32 | 33 | void qck_afterEach(QCKDSLEmptyBlock closure) { 34 | [[World sharedWorld] afterEach:closure]; 35 | } 36 | 37 | void qck_afterEachWithMetadata(QCKDSLExampleMetadataBlock closure) { 38 | [[World sharedWorld] afterEachWithMetadata:closure]; 39 | } 40 | 41 | QCKItBlock qck_it_builder(NSDictionary *flags, NSString *file, NSUInteger line) { 42 | return ^(NSString *description, QCKDSLEmptyBlock closure) { 43 | [[World sharedWorld] itWithDescription:description 44 | flags:flags 45 | file:file 46 | line:line 47 | closure:closure]; 48 | }; 49 | } 50 | 51 | QCKItBehavesLikeBlock qck_itBehavesLike_builder(NSDictionary *flags, NSString *file, NSUInteger line) { 52 | return ^(NSString *name, QCKDSLSharedExampleContext context) { 53 | [[World sharedWorld] itBehavesLikeSharedExampleNamed:name 54 | sharedExampleContext:context 55 | flags:flags 56 | file:file 57 | line:line]; 58 | }; 59 | } 60 | 61 | void qck_pending(NSString *description, QCKDSLEmptyBlock closure) { 62 | [[World sharedWorld] pending:description closure:closure]; 63 | } 64 | 65 | void qck_xdescribe(NSString *description, QCKDSLEmptyBlock closure) { 66 | [[World sharedWorld] xdescribe:description flags:@{} closure:closure]; 67 | } 68 | 69 | void qck_xcontext(NSString *description, QCKDSLEmptyBlock closure) { 70 | qck_xdescribe(description, closure); 71 | } 72 | 73 | void qck_fdescribe(NSString *description, QCKDSLEmptyBlock closure) { 74 | [[World sharedWorld] fdescribe:description flags:@{} closure:closure]; 75 | } 76 | 77 | void qck_fcontext(NSString *description, QCKDSLEmptyBlock closure) { 78 | qck_fdescribe(description, closure); 79 | } 80 | -------------------------------------------------------------------------------- /Example/Pods/Quick/Sources/QuickObjectiveC/DSL/World+DSL.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface World (SWIFT_EXTENSION(Quick)) 4 | - (void)beforeSuite:(void (^ __nonnull)(void))closure; 5 | - (void)afterSuite:(void (^ __nonnull)(void))closure; 6 | - (void)sharedExamples:(NSString * __nonnull)name closure:(void (^ __nonnull)(NSDictionary * __nonnull (^ __nonnull)(void)))closure; 7 | - (void)describe:(NSString * __nonnull)description flags:(NSDictionary * __nonnull)flags closure:(void (^ __nonnull)(void))closure; 8 | - (void)context:(NSString * __nonnull)description flags:(NSDictionary * __nonnull)flags closure:(void (^ __nonnull)(void))closure; 9 | - (void)fdescribe:(NSString * __nonnull)description flags:(NSDictionary * __nonnull)flags closure:(void (^ __nonnull)(void))closure; 10 | - (void)xdescribe:(NSString * __nonnull)description flags:(NSDictionary * __nonnull)flags closure:(void (^ __nonnull)(void))closure; 11 | - (void)beforeEach:(void (^ __nonnull)(void))closure; 12 | - (void)beforeEachWithMetadata:(void (^ __nonnull)(ExampleMetadata * __nonnull))closure; 13 | - (void)afterEach:(void (^ __nonnull)(void))closure; 14 | - (void)afterEachWithMetadata:(void (^ __nonnull)(ExampleMetadata * __nonnull))closure; 15 | - (void)itWithDescription:(NSString * __nonnull)description flags:(NSDictionary * __nonnull)flags file:(NSString * __nonnull)file line:(NSUInteger)line closure:(void (^ __nonnull)(void))closure; 16 | - (void)fitWithDescription:(NSString * __nonnull)description flags:(NSDictionary * __nonnull)flags file:(NSString * __nonnull)file line:(NSUInteger)line closure:(void (^ __nonnull)(void))closure; 17 | - (void)xitWithDescription:(NSString * __nonnull)description flags:(NSDictionary * __nonnull)flags file:(NSString * __nonnull)file line:(NSUInteger)line closure:(void (^ __nonnull)(void))closure; 18 | - (void)itBehavesLikeSharedExampleNamed:(NSString * __nonnull)name sharedExampleContext:(NSDictionary * __nonnull (^ __nonnull)(void))sharedExampleContext flags:(NSDictionary * __nonnull)flags file:(NSString * __nonnull)file line:(NSUInteger)line; 19 | - (void)pending:(NSString * __nonnull)description closure:(void (^ __nonnull)(void))closure; 20 | @end 21 | -------------------------------------------------------------------------------- /Example/Pods/Quick/Sources/QuickObjectiveC/NSString+QCKSelectorName.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | /** 4 | QuickSpec converts example names into test methods. 5 | Those test methods need valid selector names, which means no whitespace, 6 | control characters, etc. This category gives NSString objects an easy way 7 | to replace those illegal characters with underscores. 8 | */ 9 | @interface NSString (QCKSelectorName) 10 | 11 | /** 12 | Returns a string with underscores in place of all characters that cannot 13 | be included in a selector (SEL) name. 14 | */ 15 | @property (nonatomic, readonly) NSString *qck_selectorName; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /Example/Pods/Quick/Sources/QuickObjectiveC/NSString+QCKSelectorName.m: -------------------------------------------------------------------------------- 1 | #import "NSString+QCKSelectorName.h" 2 | 3 | @implementation NSString (QCKSelectorName) 4 | 5 | - (NSString *)qck_selectorName { 6 | static NSMutableCharacterSet *invalidCharacters = nil; 7 | static dispatch_once_t onceToken; 8 | dispatch_once(&onceToken, ^{ 9 | invalidCharacters = [NSMutableCharacterSet new]; 10 | 11 | NSCharacterSet *whitespaceCharacterSet = [NSCharacterSet whitespaceCharacterSet]; 12 | NSCharacterSet *newlineCharacterSet = [NSCharacterSet newlineCharacterSet]; 13 | NSCharacterSet *illegalCharacterSet = [NSCharacterSet illegalCharacterSet]; 14 | NSCharacterSet *controlCharacterSet = [NSCharacterSet controlCharacterSet]; 15 | NSCharacterSet *punctuationCharacterSet = [NSCharacterSet punctuationCharacterSet]; 16 | NSCharacterSet *nonBaseCharacterSet = [NSCharacterSet nonBaseCharacterSet]; 17 | NSCharacterSet *symbolCharacterSet = [NSCharacterSet symbolCharacterSet]; 18 | 19 | [invalidCharacters formUnionWithCharacterSet:whitespaceCharacterSet]; 20 | [invalidCharacters formUnionWithCharacterSet:newlineCharacterSet]; 21 | [invalidCharacters formUnionWithCharacterSet:illegalCharacterSet]; 22 | [invalidCharacters formUnionWithCharacterSet:controlCharacterSet]; 23 | [invalidCharacters formUnionWithCharacterSet:punctuationCharacterSet]; 24 | [invalidCharacters formUnionWithCharacterSet:nonBaseCharacterSet]; 25 | [invalidCharacters formUnionWithCharacterSet:symbolCharacterSet]; 26 | }); 27 | 28 | NSArray *validComponents = [self componentsSeparatedByCharactersInSet:invalidCharacters]; 29 | 30 | NSString *result = [validComponents componentsJoinedByString:@"_"]; 31 | 32 | return ([result length] == 0 33 | ? @"_" 34 | : result); 35 | } 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /Example/Pods/Quick/Sources/QuickObjectiveC/Quick.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | //! Project version number for Quick. 4 | FOUNDATION_EXPORT double QuickVersionNumber; 5 | 6 | //! Project version string for Quick. 7 | FOUNDATION_EXPORT const unsigned char QuickVersionString[]; 8 | 9 | #import "QuickSpec.h" 10 | #import "QCKDSL.h" 11 | #import "QuickConfiguration.h" 12 | -------------------------------------------------------------------------------- /Example/Pods/Quick/Sources/QuickObjectiveC/QuickSpec.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | /** 4 | QuickSpec is a base class all specs written in Quick inherit from. 5 | They need to inherit from QuickSpec, a subclass of XCTestCase, in 6 | order to be discovered by the XCTest framework. 7 | 8 | XCTest automatically compiles a list of XCTestCase subclasses included 9 | in the test target. It iterates over each class in that list, and creates 10 | a new instance of that class for each test method. It then creates an 11 | "invocation" to execute that test method. The invocation is an instance of 12 | NSInvocation, which represents a single message send in Objective-C. 13 | The invocation is set on the XCTestCase instance, and the test is run. 14 | 15 | Most of the code in QuickSpec is dedicated to hooking into XCTest events. 16 | First, when the spec is first loaded and before it is sent any messages, 17 | the +[NSObject initialize] method is called. QuickSpec overrides this method 18 | to call +[QuickSpec spec]. This builds the example group stacks and 19 | registers them with Quick.World, a global register of examples. 20 | 21 | Then, XCTest queries QuickSpec for a list of test methods. Normally, XCTest 22 | automatically finds all methods whose selectors begin with the string "test". 23 | However, QuickSpec overrides this default behavior by implementing the 24 | +[XCTestCase testInvocations] method. This method iterates over each example 25 | registered in Quick.World, defines a new method for that example, and 26 | returns an invocation to call that method to XCTest. Those invocations are 27 | the tests that are run by XCTest. Their selector names are displayed in 28 | the Xcode test navigation bar. 29 | */ 30 | @interface QuickSpec : XCTestCase 31 | 32 | /** 33 | Override this method in your spec to define a set of example groups 34 | and examples. 35 | 36 | @code 37 | override func spec() { 38 | describe("winter") { 39 | it("is coming") { 40 | // ... 41 | } 42 | } 43 | } 44 | @endcode 45 | 46 | See DSL.swift for more information on what syntax is available. 47 | */ 48 | - (void)spec; 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /Example/Pods/Quick/Sources/QuickObjectiveC/World.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class ExampleGroup; 4 | @class ExampleMetadata; 5 | 6 | SWIFT_CLASS("_TtC5Quick5World") 7 | @interface World 8 | 9 | @property (nonatomic) ExampleGroup * __nullable currentExampleGroup; 10 | @property (nonatomic) ExampleMetadata * __nullable currentExampleMetadata; 11 | @property (nonatomic) BOOL isRunningAdditionalSuites; 12 | + (World * __nonnull)sharedWorld; 13 | - (void)configure:(void (^ __nonnull)(Configuration * __nonnull))closure; 14 | - (void)finalizeConfiguration; 15 | - (ExampleGroup * __nonnull)rootExampleGroupForSpecClass:(Class __nonnull)cls; 16 | - (NSArray * __nonnull)examplesForSpecClass:(Class __nonnull)specClass; 17 | - (void)performWithCurrentExampleGroup:(ExampleGroup * __nonnull)group closure:(void (^ __nonnull)(void))closure; 18 | @end 19 | -------------------------------------------------------------------------------- /Example/Pods/Quick/Sources/QuickObjectiveC/XCTestSuite+QuickTestSuiteBuilder.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import 4 | 5 | @interface XCTestSuite (QuickTestSuiteBuilder) 6 | @end 7 | 8 | @implementation XCTestSuite (QuickTestSuiteBuilder) 9 | 10 | /** 11 | In order to ensure we can correctly build dynamic test suites, we need to 12 | replace some of the default test suite constructors. 13 | */ 14 | + (void)load { 15 | Method testCaseWithName = class_getClassMethod(self, @selector(testSuiteForTestCaseWithName:)); 16 | Method hooked_testCaseWithName = class_getClassMethod(self, @selector(qck_hooked_testSuiteForTestCaseWithName:)); 17 | method_exchangeImplementations(testCaseWithName, hooked_testCaseWithName); 18 | } 19 | 20 | /** 21 | The `+testSuiteForTestCaseWithName:` method is called when a specific test case 22 | class is run from the Xcode test navigator. If the built test suite is `nil`, 23 | Xcode will not run any tests for that test case. 24 | 25 | Given if the following test case class is run from the Xcode test navigator: 26 | 27 | FooSpec 28 | testFoo 29 | testBar 30 | 31 | XCTest will invoke this once per test case, with test case names following this format: 32 | 33 | FooSpec/testFoo 34 | FooSpec/testBar 35 | */ 36 | + (nullable instancetype)qck_hooked_testSuiteForTestCaseWithName:(nonnull NSString *)name { 37 | return [QuickTestSuite selectedTestSuiteForTestCaseWithName:name]; 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/ColorPicker/ColorPicker-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_ColorPicker : NSObject 3 | @end 4 | @implementation PodsDummy_ColorPicker 5 | @end 6 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/ColorPicker/ColorPicker-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | 5 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/ColorPicker/ColorPicker-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | 5 | 6 | FOUNDATION_EXPORT double ColorPickerVersionNumber; 7 | FOUNDATION_EXPORT const unsigned char ColorPickerVersionString[]; 8 | 9 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/ColorPicker/ColorPicker.modulemap: -------------------------------------------------------------------------------- 1 | framework module ColorPicker { 2 | umbrella header "ColorPicker-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/ColorPicker/ColorPicker.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = $PODS_CONFIGURATION_BUILD_DIR/ColorPicker 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Public" 4 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" 5 | PODS_BUILD_DIR = $BUILD_DIR 6 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 7 | PODS_ROOT = ${SRCROOT} 8 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 9 | SKIP_INSTALL = YES 10 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/ColorPicker/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 0.1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/ColorPicker/ResourceBundle-ColorPicker-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleIdentifier 8 | ${PRODUCT_BUNDLE_IDENTIFIER} 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundleName 12 | ${PRODUCT_NAME} 13 | CFBundlePackageType 14 | BNDL 15 | CFBundleShortVersionString 16 | 0.1.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1 21 | NSPrincipalClass 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Nimble/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 5.1.1 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Nimble/Nimble-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Nimble : NSObject 3 | @end 4 | @implementation PodsDummy_Nimble 5 | @end 6 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Nimble/Nimble-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | 5 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Nimble/Nimble-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | 5 | #import "CwlCatchException.h" 6 | #import "CwlCatchBadInstruction.h" 7 | #import "mach_excServer.h" 8 | #import "Nimble.h" 9 | #import "DSL.h" 10 | #import "NMBExceptionCapture.h" 11 | #import "NMBStringify.h" 12 | 13 | FOUNDATION_EXPORT double NimbleVersionNumber; 14 | FOUNDATION_EXPORT const unsigned char NimbleVersionString[]; 15 | 16 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Nimble/Nimble.modulemap: -------------------------------------------------------------------------------- 1 | framework module Nimble { 2 | umbrella header "Nimble-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Nimble/Nimble.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = $PODS_CONFIGURATION_BUILD_DIR/Nimble 2 | ENABLE_BITCODE = NO 3 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$(PLATFORM_DIR)/Developer/Library/Frameworks" 4 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 5 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Public" 6 | OTHER_LDFLAGS = -weak-lswiftXCTest -weak_framework "XCTest" 7 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" 8 | PODS_BUILD_DIR = $BUILD_DIR 9 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 10 | PODS_ROOT = ${SRCROOT} 11 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 12 | SKIP_INSTALL = YES 13 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-ColorPicker_Example/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-ColorPicker_Example/Pods-ColorPicker_Example-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | 4 | ## ColorPicker 5 | 6 | Copyright (c) 2015 Ambas 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in 16 | all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | THE SOFTWARE. 25 | 26 | Generated by CocoaPods - https://cocoapods.org 27 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-ColorPicker_Example/Pods-ColorPicker_Example-acknowledgements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreferenceSpecifiers 6 | 7 | 8 | FooterText 9 | This application makes use of the following third party libraries: 10 | Title 11 | Acknowledgements 12 | Type 13 | PSGroupSpecifier 14 | 15 | 16 | FooterText 17 | Copyright (c) 2015 Ambas <ambaschobsanti@gmail.com> 18 | 19 | Permission is hereby granted, free of charge, to any person obtaining a copy 20 | of this software and associated documentation files (the "Software"), to deal 21 | in the Software without restriction, including without limitation the rights 22 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 23 | copies of the Software, and to permit persons to whom the Software is 24 | furnished to do so, subject to the following conditions: 25 | 26 | The above copyright notice and this permission notice shall be included in 27 | all copies or substantial portions of the Software. 28 | 29 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 30 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 31 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 32 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 33 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 34 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 35 | THE SOFTWARE. 36 | 37 | License 38 | MIT 39 | Title 40 | ColorPicker 41 | Type 42 | PSGroupSpecifier 43 | 44 | 45 | FooterText 46 | Generated by CocoaPods - https://cocoapods.org 47 | Title 48 | 49 | Type 50 | PSGroupSpecifier 51 | 52 | 53 | StringsTable 54 | Acknowledgements 55 | Title 56 | Acknowledgements 57 | 58 | 59 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-ColorPicker_Example/Pods-ColorPicker_Example-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_ColorPicker_Example : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_ColorPicker_Example 5 | @end 6 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-ColorPicker_Example/Pods-ColorPicker_Example-frameworks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 5 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 6 | 7 | SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" 8 | 9 | install_framework() 10 | { 11 | if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then 12 | local source="${BUILT_PRODUCTS_DIR}/$1" 13 | elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then 14 | local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")" 15 | elif [ -r "$1" ]; then 16 | local source="$1" 17 | fi 18 | 19 | local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 20 | 21 | if [ -L "${source}" ]; then 22 | echo "Symlinked..." 23 | source="$(readlink "${source}")" 24 | fi 25 | 26 | # use filter instead of exclude so missing patterns dont' throw errors 27 | echo "rsync -av --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\"" 28 | rsync -av --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}" 29 | 30 | local basename 31 | basename="$(basename -s .framework "$1")" 32 | binary="${destination}/${basename}.framework/${basename}" 33 | if ! [ -r "$binary" ]; then 34 | binary="${destination}/${basename}" 35 | fi 36 | 37 | # Strip invalid architectures so "fat" simulator / device frameworks work on device 38 | if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then 39 | strip_invalid_archs "$binary" 40 | fi 41 | 42 | # Resign the code if required by the build settings to avoid unstable apps 43 | code_sign_if_enabled "${destination}/$(basename "$1")" 44 | 45 | # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7. 46 | if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then 47 | local swift_runtime_libs 48 | swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]}) 49 | for lib in $swift_runtime_libs; do 50 | echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\"" 51 | rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}" 52 | code_sign_if_enabled "${destination}/${lib}" 53 | done 54 | fi 55 | } 56 | 57 | # Signs a framework with the provided identity 58 | code_sign_if_enabled() { 59 | if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then 60 | # Use the current code_sign_identitiy 61 | echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" 62 | echo "/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements \"$1\"" 63 | /usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements "$1" 64 | fi 65 | } 66 | 67 | # Strip invalid architectures 68 | strip_invalid_archs() { 69 | binary="$1" 70 | # Get architectures for current file 71 | archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)" 72 | stripped="" 73 | for arch in $archs; do 74 | if ! [[ "${VALID_ARCHS}" == *"$arch"* ]]; then 75 | # Strip non-valid architectures in-place 76 | lipo -remove "$arch" -output "$binary" "$binary" || exit 1 77 | stripped="$stripped $arch" 78 | fi 79 | done 80 | if [[ "$stripped" ]]; then 81 | echo "Stripped $binary of architectures:$stripped" 82 | fi 83 | } 84 | 85 | 86 | if [[ "$CONFIGURATION" == "Debug" ]]; then 87 | install_framework "$BUILT_PRODUCTS_DIR/ColorPicker/ColorPicker.framework" 88 | fi 89 | if [[ "$CONFIGURATION" == "Release" ]]; then 90 | install_framework "$BUILT_PRODUCTS_DIR/ColorPicker/ColorPicker.framework" 91 | fi 92 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-ColorPicker_Example/Pods-ColorPicker_Example-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | 5 | 6 | FOUNDATION_EXPORT double Pods_ColorPicker_ExampleVersionNumber; 7 | FOUNDATION_EXPORT const unsigned char Pods_ColorPicker_ExampleVersionString[]; 8 | 9 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-ColorPicker_Example/Pods-ColorPicker_Example.debug.xcconfig: -------------------------------------------------------------------------------- 1 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES 2 | EMBEDDED_CONTENT_CONTAINS_SWIFT = YES 3 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/ColorPicker" 4 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 5 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 6 | OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/ColorPicker/ColorPicker.framework/Headers" 7 | OTHER_LDFLAGS = $(inherited) -framework "ColorPicker" 8 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" 9 | PODS_BUILD_DIR = $BUILD_DIR 10 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 11 | PODS_ROOT = ${SRCROOT}/Pods 12 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-ColorPicker_Example/Pods-ColorPicker_Example.modulemap: -------------------------------------------------------------------------------- 1 | framework module Pods_ColorPicker_Example { 2 | umbrella header "Pods-ColorPicker_Example-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-ColorPicker_Example/Pods-ColorPicker_Example.release.xcconfig: -------------------------------------------------------------------------------- 1 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES 2 | EMBEDDED_CONTENT_CONTAINS_SWIFT = YES 3 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/ColorPicker" 4 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 5 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 6 | OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/ColorPicker/ColorPicker.framework/Headers" 7 | OTHER_LDFLAGS = $(inherited) -framework "ColorPicker" 8 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" 9 | PODS_BUILD_DIR = $BUILD_DIR 10 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 11 | PODS_ROOT = ${SRCROOT}/Pods 12 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-ColorPicker_Tests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-ColorPicker_Tests/Pods-ColorPicker_Tests-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_ColorPicker_Tests : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_ColorPicker_Tests 5 | @end 6 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-ColorPicker_Tests/Pods-ColorPicker_Tests-frameworks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 5 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 6 | 7 | SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" 8 | 9 | install_framework() 10 | { 11 | if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then 12 | local source="${BUILT_PRODUCTS_DIR}/$1" 13 | elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then 14 | local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")" 15 | elif [ -r "$1" ]; then 16 | local source="$1" 17 | fi 18 | 19 | local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 20 | 21 | if [ -L "${source}" ]; then 22 | echo "Symlinked..." 23 | source="$(readlink "${source}")" 24 | fi 25 | 26 | # use filter instead of exclude so missing patterns dont' throw errors 27 | echo "rsync -av --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\"" 28 | rsync -av --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}" 29 | 30 | local basename 31 | basename="$(basename -s .framework "$1")" 32 | binary="${destination}/${basename}.framework/${basename}" 33 | if ! [ -r "$binary" ]; then 34 | binary="${destination}/${basename}" 35 | fi 36 | 37 | # Strip invalid architectures so "fat" simulator / device frameworks work on device 38 | if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then 39 | strip_invalid_archs "$binary" 40 | fi 41 | 42 | # Resign the code if required by the build settings to avoid unstable apps 43 | code_sign_if_enabled "${destination}/$(basename "$1")" 44 | 45 | # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7. 46 | if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then 47 | local swift_runtime_libs 48 | swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]}) 49 | for lib in $swift_runtime_libs; do 50 | echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\"" 51 | rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}" 52 | code_sign_if_enabled "${destination}/${lib}" 53 | done 54 | fi 55 | } 56 | 57 | # Signs a framework with the provided identity 58 | code_sign_if_enabled() { 59 | if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then 60 | # Use the current code_sign_identitiy 61 | echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" 62 | echo "/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements \"$1\"" 63 | /usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements "$1" 64 | fi 65 | } 66 | 67 | # Strip invalid architectures 68 | strip_invalid_archs() { 69 | binary="$1" 70 | # Get architectures for current file 71 | archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)" 72 | stripped="" 73 | for arch in $archs; do 74 | if ! [[ "${VALID_ARCHS}" == *"$arch"* ]]; then 75 | # Strip non-valid architectures in-place 76 | lipo -remove "$arch" -output "$binary" "$binary" || exit 1 77 | stripped="$stripped $arch" 78 | fi 79 | done 80 | if [[ "$stripped" ]]; then 81 | echo "Stripped $binary of architectures:$stripped" 82 | fi 83 | } 84 | 85 | 86 | if [[ "$CONFIGURATION" == "Debug" ]]; then 87 | install_framework "$BUILT_PRODUCTS_DIR/ColorPicker/ColorPicker.framework" 88 | install_framework "$BUILT_PRODUCTS_DIR/Nimble/Nimble.framework" 89 | install_framework "$BUILT_PRODUCTS_DIR/Quick/Quick.framework" 90 | fi 91 | if [[ "$CONFIGURATION" == "Release" ]]; then 92 | install_framework "$BUILT_PRODUCTS_DIR/ColorPicker/ColorPicker.framework" 93 | install_framework "$BUILT_PRODUCTS_DIR/Nimble/Nimble.framework" 94 | install_framework "$BUILT_PRODUCTS_DIR/Quick/Quick.framework" 95 | fi 96 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-ColorPicker_Tests/Pods-ColorPicker_Tests-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | 5 | 6 | FOUNDATION_EXPORT double Pods_ColorPicker_TestsVersionNumber; 7 | FOUNDATION_EXPORT const unsigned char Pods_ColorPicker_TestsVersionString[]; 8 | 9 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-ColorPicker_Tests/Pods-ColorPicker_Tests.debug.xcconfig: -------------------------------------------------------------------------------- 1 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES 2 | EMBEDDED_CONTENT_CONTAINS_SWIFT = YES 3 | FRAMEWORK_SEARCH_PATHS = $(inherited) $(PLATFORM_DIR)/Developer/Library/Frameworks "$PODS_CONFIGURATION_BUILD_DIR/ColorPicker" "$PODS_CONFIGURATION_BUILD_DIR/Nimble" "$PODS_CONFIGURATION_BUILD_DIR/Quick" 4 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 5 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 6 | OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/ColorPicker/ColorPicker.framework/Headers" -iquote "$PODS_CONFIGURATION_BUILD_DIR/Nimble/Nimble.framework/Headers" -iquote "$PODS_CONFIGURATION_BUILD_DIR/Quick/Quick.framework/Headers" 7 | OTHER_LDFLAGS = $(inherited) -framework "ColorPicker" -framework "Nimble" -framework "Quick" 8 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" 9 | PODS_BUILD_DIR = $BUILD_DIR 10 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 11 | PODS_ROOT = ${SRCROOT}/Pods 12 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-ColorPicker_Tests/Pods-ColorPicker_Tests.modulemap: -------------------------------------------------------------------------------- 1 | framework module Pods_ColorPicker_Tests { 2 | umbrella header "Pods-ColorPicker_Tests-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-ColorPicker_Tests/Pods-ColorPicker_Tests.release.xcconfig: -------------------------------------------------------------------------------- 1 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES 2 | EMBEDDED_CONTENT_CONTAINS_SWIFT = YES 3 | FRAMEWORK_SEARCH_PATHS = $(inherited) $(PLATFORM_DIR)/Developer/Library/Frameworks "$PODS_CONFIGURATION_BUILD_DIR/ColorPicker" "$PODS_CONFIGURATION_BUILD_DIR/Nimble" "$PODS_CONFIGURATION_BUILD_DIR/Quick" 4 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 5 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 6 | OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/ColorPicker/ColorPicker.framework/Headers" -iquote "$PODS_CONFIGURATION_BUILD_DIR/Nimble/Nimble.framework/Headers" -iquote "$PODS_CONFIGURATION_BUILD_DIR/Quick/Quick.framework/Headers" 7 | OTHER_LDFLAGS = $(inherited) -framework "ColorPicker" -framework "Nimble" -framework "Quick" 8 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" 9 | PODS_BUILD_DIR = $BUILD_DIR 10 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 11 | PODS_ROOT = ${SRCROOT}/Pods 12 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Quick/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Quick/Quick-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Quick : NSObject 3 | @end 4 | @implementation PodsDummy_Quick 5 | @end 6 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Quick/Quick-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | 5 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Quick/Quick-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | 5 | #import "QuickConfiguration.h" 6 | #import "QCKDSL.h" 7 | #import "Quick.h" 8 | #import "QuickSpec.h" 9 | 10 | FOUNDATION_EXPORT double QuickVersionNumber; 11 | FOUNDATION_EXPORT const unsigned char QuickVersionString[]; 12 | 13 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Quick/Quick.modulemap: -------------------------------------------------------------------------------- 1 | framework module Quick { 2 | umbrella header "Quick-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Quick/Quick.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = $PODS_CONFIGURATION_BUILD_DIR/Quick 2 | ENABLE_BITCODE = NO 3 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$(PLATFORM_DIR)/Developer/Library/Frameworks" 4 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 5 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Public" 6 | OTHER_LDFLAGS = -framework "XCTest" 7 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" 8 | PODS_BUILD_DIR = $BUILD_DIR 9 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 10 | PODS_ROOT = ${SRCROOT} 11 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 12 | SKIP_INSTALL = YES 13 | -------------------------------------------------------------------------------- /Example/Tests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /Example/Tests/TestsColorPicker.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TestsColorPicker.swift 3 | // ColorPicker 4 | // 5 | // Created by Ambas Chobsanti on 12/29/15. 6 | // Copyright © 2015 CocoaPods. All rights reserved. 7 | // 8 | 9 | import Quick 10 | import Nimble 11 | @testable import ColorPicker 12 | 13 | class ColorPickerSpec: QuickSpec { 14 | override func spec() { 15 | let colors = [ "#3CAEE2", "#C885D0"] 16 | var colorPickerListView: ColorPickerListView! 17 | 18 | beforeEach { () -> () in 19 | colorPickerListView = ColorPickerListView(frame: CGRect(x: 0, y: 0, width: 200, height: 44), colors: colors) 20 | } 21 | 22 | describe("test color picker selection") { 23 | it("should select correct color") { 24 | colorPickerListView.selectColor(colors[0]) 25 | let selectedButton = colorPickerListView.selectedButton! 26 | expect(UIColor(cgColor: selectedButton.roundShape.fillColor!).hexString()) == colors[0] 27 | } 28 | 29 | it("should deselect correct color") { 30 | colorPickerListView.allowsDeselection = true 31 | colorPickerListView.selectColor(colors[0]) 32 | let selectedButton = colorPickerListView.selectedButton! 33 | expect(UIColor(cgColor: selectedButton.roundShape.fillColor!).hexString()) == colors[0] 34 | colorPickerListView.selectColor(colors[0]) 35 | expect(colorPickerListView.selectedButton).to(beNil()) 36 | 37 | } 38 | 39 | it("shoud not deselect when allowDeselect are false") { 40 | colorPickerListView.allowsDeselection = false 41 | colorPickerListView.selectColor(colors[0]) 42 | let selectedButton = colorPickerListView.selectedButton! 43 | expect(UIColor(cgColor: selectedButton.roundShape.fillColor!).hexString()) == colors[0] 44 | colorPickerListView.selectColor(colors[0]) 45 | expect(UIColor(cgColor: selectedButton.roundShape.fillColor!).hexString()) == colors[0] 46 | } 47 | 48 | it("shoud change color when select other color") { 49 | colorPickerListView.selectColor(colors[0]) 50 | var selectedButton = colorPickerListView.selectedButton! 51 | expect(UIColor(cgColor: selectedButton.roundShape.fillColor!).hexString()) == colors[0] 52 | colorPickerListView.selectColor(colors[1]) 53 | selectedButton = colorPickerListView.selectedButton! 54 | expect(UIColor(cgColor: selectedButton.roundShape.fillColor!).hexString()) == colors[1] 55 | } 56 | 57 | it("should have correct buttons when changed colors") { 58 | let newColor = ["#C885D0", "#3CAEE2", "#5EB566", "#FAC16C", "#FA787F", "#A56250"] 59 | colorPickerListView.colors = newColor 60 | let button1 = colorPickerListView.colorButtonAt(4) 61 | expect(UIColor(cgColor: button1.roundShape.fillColor!).hexString()) == newColor[4] 62 | let button2 = colorPickerListView.colorButtonAt(5) 63 | expect(UIColor(cgColor: button2.roundShape.fillColor!).hexString()) == newColor[5] 64 | } 65 | 66 | it("should remove selected button when that color are removed") { 67 | colorPickerListView.selectButtonAtIndex(1) 68 | let selectedButton = colorPickerListView.selectedButton! 69 | expect(UIColor(cgColor: selectedButton.roundShape.fillColor!).hexString()) == colors[1] 70 | let _ = colorPickerListView.colors.popLast() 71 | expect(colorPickerListView.selectedButton).to(beNil()) 72 | } 73 | 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015 Ambas 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /Pod/Assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambas/ColorPicker/904046c50e15594d697bf8d86b791c9ca888ce9b/Pod/Assets/.gitkeep -------------------------------------------------------------------------------- /Pod/Classes/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambas/ColorPicker/904046c50e15594d697bf8d86b791c9ca888ce9b/Pod/Classes/.gitkeep -------------------------------------------------------------------------------- /Pod/Classes/ButtonConfiguration.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ButtonConfiguration.swift 3 | // Pods 4 | // 5 | // Created by Ambas Chobsanti on 12/18/15. 6 | // 7 | // 8 | 9 | import UIKit 10 | 11 | public struct ButtonCofiguration { 12 | public static let pickerButtonRadius = 10.0 13 | } 14 | -------------------------------------------------------------------------------- /Pod/Classes/ColorPickerButton.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ColorPickerButton.swift 3 | // Pods 4 | // 5 | // Created by Ambas Chobsanti on 12/17/15. 6 | // 7 | // 8 | 9 | import UIKit 10 | 11 | open class ColorPickerButton: UIButton { 12 | 13 | let roundShape = CAShapeLayer() 14 | var radius: Double = 0 { 15 | didSet { 16 | roundShape.path = UIBezierPath(ovalIn: CGRect(x: 0, y: 0, width: radius*2, height: radius*2)).cgPath 17 | roundShape.frame = CGRect(x: 0, y: 0, width: radius*2, height: radius*2) 18 | } 19 | } 20 | var color: UIColor = UIColor.black { 21 | didSet { 22 | roundShape.fillColor = color.cgColor 23 | } 24 | } 25 | 26 | public init(frame: CGRect, color: UIColor, radius: Double) { 27 | super.init(frame: frame) 28 | configureShape(radius, color: color) 29 | self.layer.addSublayer(roundShape) 30 | } 31 | 32 | convenience public init(color: UIColor, radius: Double) { 33 | self.init(frame: CGRect.zero, color: color, radius: radius) 34 | } 35 | 36 | convenience public init(color: UIColor) { 37 | self.init(frame: CGRect.zero, color: color, radius: ButtonCofiguration.pickerButtonRadius) 38 | } 39 | 40 | convenience public init(colorHex: String) { 41 | self.init(frame: CGRect.zero, color: UIColor.colorWithHexString(colorHex) ?? .black, radius: ButtonCofiguration.pickerButtonRadius) 42 | } 43 | 44 | required public init?(coder aDecoder: NSCoder) { 45 | super.init(coder: aDecoder) 46 | configureShape(radius, color: color) 47 | } 48 | 49 | open override func layoutSubviews() { 50 | super.layoutSubviews() 51 | roundShape.fillColor = color.cgColor 52 | roundShape.path = UIBezierPath(ovalIn: CGRect(x: 0, y: 0, width: radius*2, height: radius*2)).cgPath 53 | roundShape.bounds.size = CGSize(width: radius*2, height: radius*2) 54 | let center = CGPoint(x: frame.size.width/2, y: frame.size.height/2) 55 | roundShape.position = center 56 | } 57 | 58 | fileprivate func configureShape(_ radius: Double, color: UIColor) { 59 | self.radius = radius 60 | self.color = color 61 | } 62 | 63 | func pickerColor() -> String { 64 | let shapeColor = roundShape.fillColor ?? UIColor.black.cgColor 65 | return UIColor(cgColor: shapeColor).hexString() 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /Pod/Classes/ColorPickerSelection.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ColorPickerSelection.swift 3 | // Pods 4 | // 5 | // Created by Ambas Chobsanti on 12/25/15. 6 | // 7 | // 8 | 9 | protocol ColorPickerSelection { 10 | func colorPicker(_ colorPicker: ColorPickerListView, changeFromIndex: Int, toIndex: Int) 11 | func colorPicker(_ colorPicker: ColorPickerListView, selectedAtIndex: Int) 12 | func colorPicker(_ colorPicker: ColorPickerListView, deselectAtIndex: Int) 13 | func colorPickerPickerLayoutSubviews(_ colorPicker: ColorPickerListView) 14 | } 15 | -------------------------------------------------------------------------------- /Pod/Classes/Extension.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Extension.swift 3 | // Pods 4 | // 5 | // Created by Ambas Chobsanti on 12/25/15. 6 | // 7 | // 8 | 9 | import UIKit 10 | 11 | public extension UIColor { 12 | fileprivate static func component(_ color: String) -> CGFloat { 13 | guard let subString = UInt(color, radix: 16) else { 14 | return CGFloat(UInt("0", radix: 16)!) / 255 15 | } 16 | 17 | return CGFloat(subString) / 255 18 | } 19 | 20 | public static func colorWithHexString(_ hex: String) -> UIColor? { 21 | var cString:String = hex.trimmingCharacters(in: .whitespacesAndNewlines).uppercased() 22 | 23 | if (cString.hasPrefix("#")) { 24 | cString.remove(at: cString.startIndex) 25 | } 26 | 27 | if !cString.isValidHexNumber() { 28 | return nil 29 | } 30 | 31 | if ((cString.characters.count) != 6) { 32 | return nil 33 | } 34 | 35 | var rgbValue:UInt32 = 0 36 | Scanner(string: cString).scanHexInt32(&rgbValue) 37 | 38 | return UIColor( 39 | red: CGFloat((rgbValue & 0xFF0000) >> 16) / 255.0, 40 | green: CGFloat((rgbValue & 0x00FF00) >> 8) / 255.0, 41 | blue: CGFloat(rgbValue & 0x0000FF) / 255.0, 42 | alpha: CGFloat(1.0) 43 | ) 44 | } 45 | 46 | public func hexString() -> String { 47 | var r: CGFloat = 0 48 | var g: CGFloat = 0 49 | var b: CGFloat = 0 50 | self.getRed(&r, green: &g, blue: &b, alpha: nil) 51 | print("\(r)\(g)\(b)") 52 | return [r, g, b].map { String(Int($0 * 255), radix:16) }.reduce("#", +).uppercased() 53 | } 54 | 55 | 56 | } 57 | 58 | extension String { 59 | func subString(_ from: Int, to: Int) -> String { 60 | let range = self.characters.index(self.startIndex, offsetBy: from).. String? { 65 | if let _ = UIColor.colorWithHexString(self) { 66 | return self 67 | } else { 68 | return nil 69 | } 70 | } 71 | 72 | fileprivate func isValidHexNumber() -> Bool { 73 | let chars = NSCharacterSet(charactersIn: "0123456789ABCDEF").inverted 74 | guard self.uppercased().rangeOfCharacter(from: chars) == nil else { 75 | return false 76 | } 77 | return true 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /Pod/Classes/WarpSelectionAnimation.swift: -------------------------------------------------------------------------------- 1 | // 2 | // WarpSelectionAnimation.swift 3 | // Pods 4 | // 5 | // Created by Ambas Chobsanti on 12/25/15. 6 | // 7 | // 8 | 9 | class WarpSelectionAnimation: ColorPickerSelection { 10 | 11 | var selectedRingView: UIView = { 12 | let view = UIView() 13 | view.layer.borderColor = UIColor.colorWithHexString("39B0B8")?.cgColor 14 | view.layer.borderWidth = 2 15 | return view 16 | }() 17 | 18 | var tempRingView: UIView = { 19 | let view = UIView() 20 | view.layer.borderColor = UIColor.colorWithHexString("39B0B8")?.cgColor 21 | view.layer.borderWidth = 2 22 | return view 23 | }() 24 | 25 | func colorPicker(_ colorPicker: ColorPickerListView, changeFromIndex: Int, toIndex: Int) { 26 | self.colorPicker(colorPicker, deselectedAtIndex: changeFromIndex, ringView: selectedRingView) 27 | self.colorPicker(colorPicker, selectedAtIndex: toIndex, ringView: tempRingView) 28 | self.selectedRingView = self.tempRingView 29 | let delayTime = DispatchTime.now() + Double(Int64(0.4 * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC) 30 | DispatchQueue.main.asyncAfter(deadline: delayTime) { 31 | self.selectedRingView = self.tempRingView 32 | self.tempRingView = UIView() 33 | self.tempRingView.layer.borderColor = UIColor.colorWithHexString("39B0B8")?.cgColor 34 | self.tempRingView.layer.borderWidth = 2 35 | } 36 | } 37 | 38 | func colorPicker(_ colorPicker: ColorPickerListView, selectedAtIndex: Int) { 39 | self.colorPicker(colorPicker, selectedAtIndex: selectedAtIndex, ringView: selectedRingView) 40 | } 41 | 42 | func colorPicker(_ colorPicker: ColorPickerListView, deselectAtIndex: Int) { 43 | self.colorPicker(colorPicker, deselectedAtIndex: deselectAtIndex, ringView: selectedRingView) 44 | } 45 | 46 | func colorPickerPickerLayoutSubviews(_ colorPicker: ColorPickerListView) { 47 | guard let selectedButton = colorPicker.selectedButton else { 48 | return 49 | } 50 | selectedRingView.frame = frameFor(selectedButton.roundShape.frame) 51 | selectedRingView.center = selectedButton.center 52 | } 53 | 54 | fileprivate func frameFor(_ buttonFrame: CGRect) -> CGRect { 55 | var ringFrame = buttonFrame 56 | ringFrame.size.height = ringFrame.size.height + 7 57 | ringFrame.size.width = ringFrame.size.width + 7 58 | 59 | return ringFrame 60 | } 61 | 62 | fileprivate func colorPicker(_ colorPicker: ColorPickerListView, selectedAtIndex: Int, ringView: UIView) { 63 | colorPicker.isUserInteractionEnabled = false; 64 | let button = colorPicker.colorButtonAt(selectedAtIndex) 65 | ringView.frame = frameFor(button.roundShape.frame) 66 | ringView.center = button.center 67 | let width = ringView.frame.width 68 | let height = ringView.frame.height 69 | ringView.layer.cornerRadius = width < height ? width / 2.0 : height / 2.0; 70 | colorPicker.insertSubview(ringView, at: 0) 71 | ringView.transform = CGAffineTransform(scaleX: 0.001, y: 0.001) 72 | UIView.animate(withDuration: 0.4, delay: 0, usingSpringWithDamping: 0.4, initialSpringVelocity: 0, options: .curveEaseIn, animations: { () -> Void in 73 | ringView.transform = CGAffineTransform.identity 74 | }) { (isFinished) -> Void in 75 | colorPicker.isUserInteractionEnabled = true 76 | } 77 | } 78 | 79 | fileprivate func colorPicker(_ colorPicker: ColorPickerListView, deselectedAtIndex: Int, ringView: UIView) { 80 | colorPicker.isUserInteractionEnabled = false 81 | UIView.animate(withDuration: 0.4, delay: 0, usingSpringWithDamping: 0.4, initialSpringVelocity: 0, options: .curveEaseIn, animations: { () -> Void in 82 | ringView.transform = CGAffineTransform(scaleX: 0.001, y: 0.001) 83 | }) { (isFinished) -> Void in 84 | ringView.removeFromSuperview() 85 | ringView.transform = CGAffineTransform.identity 86 | colorPicker.isUserInteractionEnabled = true 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ColorPicker 2 | 3 | [![CI Status](http://img.shields.io/travis/ambas/ColorPicker.svg?style=flat)](https://travis-ci.org/ambas/ColorPicker) 4 | [![codecov.io](https://codecov.io/github/ambas/ColorPicker/coverage.svg?branch=master)](https://codecov.io/github/ambas/ColorPicker) 5 | [![Version](https://img.shields.io/cocoapods/v/ColorPicker.svg?style=flat)](http://cocoapods.org/pods/ColorPicker) 6 | [![License](https://img.shields.io/cocoapods/l/ColorPicker.svg?style=flat)](http://cocoapods.org/pods/ColorPicker) 7 | [![Platform](https://img.shields.io/cocoapods/p/ColorPicker.svg?style=flat)](http://cocoapods.org/pods/ColorPicker) 8 | 9 |

10 | 11 | ## Usage 12 | To run the example project, clone the repo, and run `pod install` from the Example directory first. 13 | 14 | ## Requirements 15 | - swift 3.0+ 16 | 17 | ## Installation 18 | 19 | ColorPicker is available through [CocoaPods](http://cocoapods.org). To install 20 | it, simply add the following line to your Podfile: 21 | 22 | ```ruby 23 | pod "ColorPicker" 24 | ``` 25 | 26 | ## Author 27 | 28 | Ambas, ambaschobsanti@gmail.com 29 | 30 | ## License 31 | 32 | ColorPicker is available under the MIT license. See the LICENSE file for more info. 33 | -------------------------------------------------------------------------------- /_Pods.xcodeproj: -------------------------------------------------------------------------------- 1 | Example/Pods/Pods.xcodeproj -------------------------------------------------------------------------------- /sample.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ambas/ColorPicker/904046c50e15594d697bf8d86b791c9ca888ce9b/sample.gif --------------------------------------------------------------------------------