├── .gitignore ├── Assertions.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcshareddata │ └── xcschemes │ ├── Assertions-Mac.xcscheme │ └── Assertions-iOS.xcscheme ├── Assertions.xcworkspace └── contents.xcworkspacedata ├── Assertions ├── Assertions.h ├── Assertions.swift └── Info.plist ├── AssertionsTests ├── AssertionsTests.swift └── Info.plist ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | xcuserdata 3 | *.xcuserdatad 4 | *.xccheckout 5 | *.mode* 6 | *.pbxuser 7 | -------------------------------------------------------------------------------- /Assertions.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | D400DBED1A9C0747009C1318 /* AssertionsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4F1C40F1A8FE39F0087648A /* AssertionsTests.swift */; }; 11 | D400DBEE1A9C0747009C1318 /* AssertionsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4F1C40F1A8FE39F0087648A /* AssertionsTests.swift */; }; 12 | D4C2EDE61A98DD7D00054FAA /* Assertions.h in Headers */ = {isa = PBXBuildFile; fileRef = D4C2EDE51A98DD7D00054FAA /* Assertions.h */; settings = {ATTRIBUTES = (Public, ); }; }; 13 | D4C2EDEC1A98DD7D00054FAA /* Assertions.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D4C2EDE11A98DD7D00054FAA /* Assertions.framework */; }; 14 | D4C2EDFA1A98DE2B00054FAA /* Assertions.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4F1C4191A8FE3F00087648A /* Assertions.swift */; }; 15 | D4C2EDFB1A98DED000054FAA /* Assertions.h in Headers */ = {isa = PBXBuildFile; fileRef = D4C2EDE51A98DD7D00054FAA /* Assertions.h */; settings = {ATTRIBUTES = (Public, ); }; }; 16 | D4F1C4091A8FE39F0087648A /* Assertions.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D4F1C3F81A8FE39F0087648A /* Assertions.framework */; }; 17 | D4F1C41A1A8FE3F00087648A /* Assertions.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4F1C4191A8FE3F00087648A /* Assertions.swift */; }; 18 | /* End PBXBuildFile section */ 19 | 20 | /* Begin PBXContainerItemProxy section */ 21 | D4C2EDED1A98DD7D00054FAA /* PBXContainerItemProxy */ = { 22 | isa = PBXContainerItemProxy; 23 | containerPortal = D4F1C3EF1A8FE39F0087648A /* Project object */; 24 | proxyType = 1; 25 | remoteGlobalIDString = D4C2EDE01A98DD7D00054FAA; 26 | remoteInfo = Assertions; 27 | }; 28 | D4F1C40A1A8FE39F0087648A /* PBXContainerItemProxy */ = { 29 | isa = PBXContainerItemProxy; 30 | containerPortal = D4F1C3EF1A8FE39F0087648A /* Project object */; 31 | proxyType = 1; 32 | remoteGlobalIDString = D4F1C3F71A8FE39F0087648A; 33 | remoteInfo = Assertions; 34 | }; 35 | /* End PBXContainerItemProxy section */ 36 | 37 | /* Begin PBXFileReference section */ 38 | D4C2EDE11A98DD7D00054FAA /* Assertions.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Assertions.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 39 | D4C2EDE41A98DD7D00054FAA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 40 | D4C2EDE51A98DD7D00054FAA /* Assertions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Assertions.h; sourceTree = ""; }; 41 | D4C2EDEB1A98DD7D00054FAA /* Assertions-iOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Assertions-iOSTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; 42 | D4C2EDF11A98DD7D00054FAA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 43 | D4C2EDF21A98DD7D00054FAA /* AssertionsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AssertionsTests.swift; sourceTree = ""; }; 44 | D4F1C3F81A8FE39F0087648A /* Assertions.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Assertions.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 45 | D4F1C3FC1A8FE39F0087648A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 46 | D4F1C3FD1A8FE39F0087648A /* Assertions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Assertions.h; sourceTree = ""; }; 47 | D4F1C4081A8FE39F0087648A /* Assertions-MacTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Assertions-MacTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; 48 | D4F1C40E1A8FE39F0087648A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 49 | D4F1C40F1A8FE39F0087648A /* AssertionsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AssertionsTests.swift; sourceTree = ""; }; 50 | D4F1C4191A8FE3F00087648A /* Assertions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Assertions.swift; sourceTree = ""; }; 51 | /* End PBXFileReference section */ 52 | 53 | /* Begin PBXFrameworksBuildPhase section */ 54 | D4C2EDDD1A98DD7D00054FAA /* Frameworks */ = { 55 | isa = PBXFrameworksBuildPhase; 56 | buildActionMask = 2147483647; 57 | files = ( 58 | ); 59 | runOnlyForDeploymentPostprocessing = 0; 60 | }; 61 | D4C2EDE81A98DD7D00054FAA /* Frameworks */ = { 62 | isa = PBXFrameworksBuildPhase; 63 | buildActionMask = 2147483647; 64 | files = ( 65 | D4C2EDEC1A98DD7D00054FAA /* Assertions.framework in Frameworks */, 66 | ); 67 | runOnlyForDeploymentPostprocessing = 0; 68 | }; 69 | D4F1C3F41A8FE39F0087648A /* Frameworks */ = { 70 | isa = PBXFrameworksBuildPhase; 71 | buildActionMask = 2147483647; 72 | files = ( 73 | ); 74 | runOnlyForDeploymentPostprocessing = 0; 75 | }; 76 | D4F1C4051A8FE39F0087648A /* Frameworks */ = { 77 | isa = PBXFrameworksBuildPhase; 78 | buildActionMask = 2147483647; 79 | files = ( 80 | D4F1C4091A8FE39F0087648A /* Assertions.framework in Frameworks */, 81 | ); 82 | runOnlyForDeploymentPostprocessing = 0; 83 | }; 84 | /* End PBXFrameworksBuildPhase section */ 85 | 86 | /* Begin PBXGroup section */ 87 | D4C2EDE21A98DD7D00054FAA /* Assertions */ = { 88 | isa = PBXGroup; 89 | children = ( 90 | D4C2EDE51A98DD7D00054FAA /* Assertions.h */, 91 | D4C2EDE31A98DD7D00054FAA /* Supporting Files */, 92 | ); 93 | path = Assertions; 94 | sourceTree = ""; 95 | }; 96 | D4C2EDE31A98DD7D00054FAA /* Supporting Files */ = { 97 | isa = PBXGroup; 98 | children = ( 99 | D4C2EDE41A98DD7D00054FAA /* Info.plist */, 100 | ); 101 | name = "Supporting Files"; 102 | sourceTree = ""; 103 | }; 104 | D4C2EDEF1A98DD7D00054FAA /* AssertionsTests */ = { 105 | isa = PBXGroup; 106 | children = ( 107 | D4C2EDF21A98DD7D00054FAA /* AssertionsTests.swift */, 108 | D4C2EDF01A98DD7D00054FAA /* Supporting Files */, 109 | ); 110 | path = AssertionsTests; 111 | sourceTree = ""; 112 | }; 113 | D4C2EDF01A98DD7D00054FAA /* Supporting Files */ = { 114 | isa = PBXGroup; 115 | children = ( 116 | D4C2EDF11A98DD7D00054FAA /* Info.plist */, 117 | ); 118 | name = "Supporting Files"; 119 | sourceTree = ""; 120 | }; 121 | D4F1C3EE1A8FE39F0087648A = { 122 | isa = PBXGroup; 123 | children = ( 124 | D4F1C3FA1A8FE39F0087648A /* Assertions */, 125 | D4F1C40C1A8FE39F0087648A /* AssertionsTests */, 126 | D4C2EDE21A98DD7D00054FAA /* Assertions */, 127 | D4C2EDEF1A98DD7D00054FAA /* AssertionsTests */, 128 | D4F1C3F91A8FE39F0087648A /* Products */, 129 | ); 130 | sourceTree = ""; 131 | usesTabs = 1; 132 | }; 133 | D4F1C3F91A8FE39F0087648A /* Products */ = { 134 | isa = PBXGroup; 135 | children = ( 136 | D4F1C3F81A8FE39F0087648A /* Assertions.framework */, 137 | D4F1C4081A8FE39F0087648A /* Assertions-MacTests.xctest */, 138 | D4C2EDE11A98DD7D00054FAA /* Assertions.framework */, 139 | D4C2EDEB1A98DD7D00054FAA /* Assertions-iOSTests.xctest */, 140 | ); 141 | name = Products; 142 | sourceTree = ""; 143 | }; 144 | D4F1C3FA1A8FE39F0087648A /* Assertions */ = { 145 | isa = PBXGroup; 146 | children = ( 147 | D4F1C3FD1A8FE39F0087648A /* Assertions.h */, 148 | D4F1C4191A8FE3F00087648A /* Assertions.swift */, 149 | D4F1C3FB1A8FE39F0087648A /* Supporting Files */, 150 | ); 151 | path = Assertions; 152 | sourceTree = ""; 153 | }; 154 | D4F1C3FB1A8FE39F0087648A /* Supporting Files */ = { 155 | isa = PBXGroup; 156 | children = ( 157 | D4F1C3FC1A8FE39F0087648A /* Info.plist */, 158 | ); 159 | name = "Supporting Files"; 160 | sourceTree = ""; 161 | }; 162 | D4F1C40C1A8FE39F0087648A /* AssertionsTests */ = { 163 | isa = PBXGroup; 164 | children = ( 165 | D4F1C40F1A8FE39F0087648A /* AssertionsTests.swift */, 166 | D4F1C40D1A8FE39F0087648A /* Supporting Files */, 167 | ); 168 | path = AssertionsTests; 169 | sourceTree = ""; 170 | }; 171 | D4F1C40D1A8FE39F0087648A /* Supporting Files */ = { 172 | isa = PBXGroup; 173 | children = ( 174 | D4F1C40E1A8FE39F0087648A /* Info.plist */, 175 | ); 176 | name = "Supporting Files"; 177 | sourceTree = ""; 178 | }; 179 | /* End PBXGroup section */ 180 | 181 | /* Begin PBXHeadersBuildPhase section */ 182 | D4C2EDDE1A98DD7D00054FAA /* Headers */ = { 183 | isa = PBXHeadersBuildPhase; 184 | buildActionMask = 2147483647; 185 | files = ( 186 | D4C2EDE61A98DD7D00054FAA /* Assertions.h in Headers */, 187 | ); 188 | runOnlyForDeploymentPostprocessing = 0; 189 | }; 190 | D4F1C3F51A8FE39F0087648A /* Headers */ = { 191 | isa = PBXHeadersBuildPhase; 192 | buildActionMask = 2147483647; 193 | files = ( 194 | D4C2EDFB1A98DED000054FAA /* Assertions.h in Headers */, 195 | ); 196 | runOnlyForDeploymentPostprocessing = 0; 197 | }; 198 | /* End PBXHeadersBuildPhase section */ 199 | 200 | /* Begin PBXNativeTarget section */ 201 | D4C2EDE01A98DD7D00054FAA /* Assertions-iOS */ = { 202 | isa = PBXNativeTarget; 203 | buildConfigurationList = D4C2EDF81A98DD7D00054FAA /* Build configuration list for PBXNativeTarget "Assertions-iOS" */; 204 | buildPhases = ( 205 | D4C2EDDC1A98DD7D00054FAA /* Sources */, 206 | D4C2EDDD1A98DD7D00054FAA /* Frameworks */, 207 | D4C2EDDE1A98DD7D00054FAA /* Headers */, 208 | D4C2EDDF1A98DD7D00054FAA /* Resources */, 209 | ); 210 | buildRules = ( 211 | ); 212 | dependencies = ( 213 | ); 214 | name = "Assertions-iOS"; 215 | productName = Assertions; 216 | productReference = D4C2EDE11A98DD7D00054FAA /* Assertions.framework */; 217 | productType = "com.apple.product-type.framework"; 218 | }; 219 | D4C2EDEA1A98DD7D00054FAA /* Assertions-iOSTests */ = { 220 | isa = PBXNativeTarget; 221 | buildConfigurationList = D4C2EDF91A98DD7D00054FAA /* Build configuration list for PBXNativeTarget "Assertions-iOSTests" */; 222 | buildPhases = ( 223 | D4C2EDE71A98DD7D00054FAA /* Sources */, 224 | D4C2EDE81A98DD7D00054FAA /* Frameworks */, 225 | D4C2EDE91A98DD7D00054FAA /* Resources */, 226 | ); 227 | buildRules = ( 228 | ); 229 | dependencies = ( 230 | D4C2EDEE1A98DD7D00054FAA /* PBXTargetDependency */, 231 | ); 232 | name = "Assertions-iOSTests"; 233 | productName = AssertionsTests; 234 | productReference = D4C2EDEB1A98DD7D00054FAA /* Assertions-iOSTests.xctest */; 235 | productType = "com.apple.product-type.bundle.unit-test"; 236 | }; 237 | D4F1C3F71A8FE39F0087648A /* Assertions-Mac */ = { 238 | isa = PBXNativeTarget; 239 | buildConfigurationList = D4F1C4131A8FE39F0087648A /* Build configuration list for PBXNativeTarget "Assertions-Mac" */; 240 | buildPhases = ( 241 | D4F1C3F31A8FE39F0087648A /* Sources */, 242 | D4F1C3F41A8FE39F0087648A /* Frameworks */, 243 | D4F1C3F51A8FE39F0087648A /* Headers */, 244 | D4F1C3F61A8FE39F0087648A /* Resources */, 245 | ); 246 | buildRules = ( 247 | ); 248 | dependencies = ( 249 | ); 250 | name = "Assertions-Mac"; 251 | productName = Assertions; 252 | productReference = D4F1C3F81A8FE39F0087648A /* Assertions.framework */; 253 | productType = "com.apple.product-type.framework"; 254 | }; 255 | D4F1C4071A8FE39F0087648A /* Assertions-MacTests */ = { 256 | isa = PBXNativeTarget; 257 | buildConfigurationList = D4F1C4161A8FE39F0087648A /* Build configuration list for PBXNativeTarget "Assertions-MacTests" */; 258 | buildPhases = ( 259 | D4F1C4041A8FE39F0087648A /* Sources */, 260 | D4F1C4051A8FE39F0087648A /* Frameworks */, 261 | D4F1C4061A8FE39F0087648A /* Resources */, 262 | ); 263 | buildRules = ( 264 | ); 265 | dependencies = ( 266 | D4F1C40B1A8FE39F0087648A /* PBXTargetDependency */, 267 | ); 268 | name = "Assertions-MacTests"; 269 | productName = AssertionsTests; 270 | productReference = D4F1C4081A8FE39F0087648A /* Assertions-MacTests.xctest */; 271 | productType = "com.apple.product-type.bundle.unit-test"; 272 | }; 273 | /* End PBXNativeTarget section */ 274 | 275 | /* Begin PBXProject section */ 276 | D4F1C3EF1A8FE39F0087648A /* Project object */ = { 277 | isa = PBXProject; 278 | attributes = { 279 | LastSwiftUpdateCheck = 0700; 280 | LastUpgradeCheck = 0720; 281 | ORGANIZATIONNAME = "Rob Rix"; 282 | TargetAttributes = { 283 | D4C2EDE01A98DD7D00054FAA = { 284 | CreatedOnToolsVersion = 6.3; 285 | }; 286 | D4C2EDEA1A98DD7D00054FAA = { 287 | CreatedOnToolsVersion = 6.3; 288 | }; 289 | D4F1C3F71A8FE39F0087648A = { 290 | CreatedOnToolsVersion = 6.3; 291 | }; 292 | D4F1C4071A8FE39F0087648A = { 293 | CreatedOnToolsVersion = 6.3; 294 | }; 295 | }; 296 | }; 297 | buildConfigurationList = D4F1C3F21A8FE39F0087648A /* Build configuration list for PBXProject "Assertions" */; 298 | compatibilityVersion = "Xcode 3.2"; 299 | developmentRegion = English; 300 | hasScannedForEncodings = 0; 301 | knownRegions = ( 302 | en, 303 | ); 304 | mainGroup = D4F1C3EE1A8FE39F0087648A; 305 | productRefGroup = D4F1C3F91A8FE39F0087648A /* Products */; 306 | projectDirPath = ""; 307 | projectRoot = ""; 308 | targets = ( 309 | D4F1C3F71A8FE39F0087648A /* Assertions-Mac */, 310 | D4F1C4071A8FE39F0087648A /* Assertions-MacTests */, 311 | D4C2EDE01A98DD7D00054FAA /* Assertions-iOS */, 312 | D4C2EDEA1A98DD7D00054FAA /* Assertions-iOSTests */, 313 | ); 314 | }; 315 | /* End PBXProject section */ 316 | 317 | /* Begin PBXResourcesBuildPhase section */ 318 | D4C2EDDF1A98DD7D00054FAA /* Resources */ = { 319 | isa = PBXResourcesBuildPhase; 320 | buildActionMask = 2147483647; 321 | files = ( 322 | ); 323 | runOnlyForDeploymentPostprocessing = 0; 324 | }; 325 | D4C2EDE91A98DD7D00054FAA /* Resources */ = { 326 | isa = PBXResourcesBuildPhase; 327 | buildActionMask = 2147483647; 328 | files = ( 329 | ); 330 | runOnlyForDeploymentPostprocessing = 0; 331 | }; 332 | D4F1C3F61A8FE39F0087648A /* Resources */ = { 333 | isa = PBXResourcesBuildPhase; 334 | buildActionMask = 2147483647; 335 | files = ( 336 | ); 337 | runOnlyForDeploymentPostprocessing = 0; 338 | }; 339 | D4F1C4061A8FE39F0087648A /* Resources */ = { 340 | isa = PBXResourcesBuildPhase; 341 | buildActionMask = 2147483647; 342 | files = ( 343 | ); 344 | runOnlyForDeploymentPostprocessing = 0; 345 | }; 346 | /* End PBXResourcesBuildPhase section */ 347 | 348 | /* Begin PBXSourcesBuildPhase section */ 349 | D4C2EDDC1A98DD7D00054FAA /* Sources */ = { 350 | isa = PBXSourcesBuildPhase; 351 | buildActionMask = 2147483647; 352 | files = ( 353 | D4C2EDFA1A98DE2B00054FAA /* Assertions.swift in Sources */, 354 | ); 355 | runOnlyForDeploymentPostprocessing = 0; 356 | }; 357 | D4C2EDE71A98DD7D00054FAA /* Sources */ = { 358 | isa = PBXSourcesBuildPhase; 359 | buildActionMask = 2147483647; 360 | files = ( 361 | D400DBEE1A9C0747009C1318 /* AssertionsTests.swift in Sources */, 362 | ); 363 | runOnlyForDeploymentPostprocessing = 0; 364 | }; 365 | D4F1C3F31A8FE39F0087648A /* Sources */ = { 366 | isa = PBXSourcesBuildPhase; 367 | buildActionMask = 2147483647; 368 | files = ( 369 | D4F1C41A1A8FE3F00087648A /* Assertions.swift in Sources */, 370 | ); 371 | runOnlyForDeploymentPostprocessing = 0; 372 | }; 373 | D4F1C4041A8FE39F0087648A /* Sources */ = { 374 | isa = PBXSourcesBuildPhase; 375 | buildActionMask = 2147483647; 376 | files = ( 377 | D400DBED1A9C0747009C1318 /* AssertionsTests.swift in Sources */, 378 | ); 379 | runOnlyForDeploymentPostprocessing = 0; 380 | }; 381 | /* End PBXSourcesBuildPhase section */ 382 | 383 | /* Begin PBXTargetDependency section */ 384 | D4C2EDEE1A98DD7D00054FAA /* PBXTargetDependency */ = { 385 | isa = PBXTargetDependency; 386 | target = D4C2EDE01A98DD7D00054FAA /* Assertions-iOS */; 387 | targetProxy = D4C2EDED1A98DD7D00054FAA /* PBXContainerItemProxy */; 388 | }; 389 | D4F1C40B1A8FE39F0087648A /* PBXTargetDependency */ = { 390 | isa = PBXTargetDependency; 391 | target = D4F1C3F71A8FE39F0087648A /* Assertions-Mac */; 392 | targetProxy = D4F1C40A1A8FE39F0087648A /* PBXContainerItemProxy */; 393 | }; 394 | /* End PBXTargetDependency section */ 395 | 396 | /* Begin XCBuildConfiguration section */ 397 | D4C2EDF41A98DD7D00054FAA /* Debug */ = { 398 | isa = XCBuildConfiguration; 399 | buildSettings = { 400 | APPLICATION_EXTENSION_API_ONLY = NO; 401 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 402 | DEFINES_MODULE = YES; 403 | DYLIB_COMPATIBILITY_VERSION = 1; 404 | DYLIB_CURRENT_VERSION = 1; 405 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 406 | FRAMEWORK_SEARCH_PATHS = "$(PLATFORM_DIR)/Developer/Library/Frameworks"; 407 | GCC_PREPROCESSOR_DEFINITIONS = ( 408 | "DEBUG=1", 409 | "$(inherited)", 410 | ); 411 | INFOPLIST_FILE = Assertions/Info.plist; 412 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 413 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 414 | OTHER_LDFLAGS = ( 415 | "-framework", 416 | XCTest, 417 | ); 418 | PRODUCT_NAME = Assertions; 419 | SDKROOT = iphoneos; 420 | SKIP_INSTALL = YES; 421 | TARGETED_DEVICE_FAMILY = "1,2"; 422 | }; 423 | name = Debug; 424 | }; 425 | D4C2EDF51A98DD7D00054FAA /* Release */ = { 426 | isa = XCBuildConfiguration; 427 | buildSettings = { 428 | APPLICATION_EXTENSION_API_ONLY = NO; 429 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 430 | COPY_PHASE_STRIP = NO; 431 | DEFINES_MODULE = YES; 432 | DYLIB_COMPATIBILITY_VERSION = 1; 433 | DYLIB_CURRENT_VERSION = 1; 434 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 435 | FRAMEWORK_SEARCH_PATHS = "$(PLATFORM_DIR)/Developer/Library/Frameworks"; 436 | INFOPLIST_FILE = Assertions/Info.plist; 437 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 438 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 439 | OTHER_LDFLAGS = ( 440 | "-framework", 441 | XCTest, 442 | ); 443 | PRODUCT_NAME = Assertions; 444 | SDKROOT = iphoneos; 445 | SKIP_INSTALL = YES; 446 | TARGETED_DEVICE_FAMILY = "1,2"; 447 | VALIDATE_PRODUCT = YES; 448 | }; 449 | name = Release; 450 | }; 451 | D4C2EDF61A98DD7D00054FAA /* Debug */ = { 452 | isa = XCBuildConfiguration; 453 | buildSettings = { 454 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 455 | FRAMEWORK_SEARCH_PATHS = ( 456 | "$(SDKROOT)/Developer/Library/Frameworks", 457 | "$(inherited)", 458 | ); 459 | GCC_PREPROCESSOR_DEFINITIONS = ( 460 | "DEBUG=1", 461 | "$(inherited)", 462 | ); 463 | INFOPLIST_FILE = AssertionsTests/Info.plist; 464 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 465 | PRODUCT_BUNDLE_IDENTIFIER = "com.antitypical.$(PRODUCT_NAME:rfc1034identifier)"; 466 | PRODUCT_NAME = "$(TARGET_NAME)"; 467 | SDKROOT = iphoneos; 468 | }; 469 | name = Debug; 470 | }; 471 | D4C2EDF71A98DD7D00054FAA /* Release */ = { 472 | isa = XCBuildConfiguration; 473 | buildSettings = { 474 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 475 | COPY_PHASE_STRIP = NO; 476 | FRAMEWORK_SEARCH_PATHS = ( 477 | "$(SDKROOT)/Developer/Library/Frameworks", 478 | "$(inherited)", 479 | ); 480 | INFOPLIST_FILE = AssertionsTests/Info.plist; 481 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 482 | PRODUCT_BUNDLE_IDENTIFIER = "com.antitypical.$(PRODUCT_NAME:rfc1034identifier)"; 483 | PRODUCT_NAME = "$(TARGET_NAME)"; 484 | SDKROOT = iphoneos; 485 | VALIDATE_PRODUCT = YES; 486 | }; 487 | name = Release; 488 | }; 489 | D4F1C4111A8FE39F0087648A /* Debug */ = { 490 | isa = XCBuildConfiguration; 491 | buildSettings = { 492 | ALWAYS_SEARCH_USER_PATHS = NO; 493 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 494 | CLANG_CXX_LIBRARY = "libc++"; 495 | CLANG_ENABLE_MODULES = YES; 496 | CLANG_ENABLE_OBJC_ARC = YES; 497 | CLANG_WARN_BOOL_CONVERSION = YES; 498 | CLANG_WARN_CONSTANT_CONVERSION = YES; 499 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 500 | CLANG_WARN_EMPTY_BODY = YES; 501 | CLANG_WARN_ENUM_CONVERSION = YES; 502 | CLANG_WARN_INT_CONVERSION = YES; 503 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 504 | CLANG_WARN_UNREACHABLE_CODE = YES; 505 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 506 | COPY_PHASE_STRIP = NO; 507 | CURRENT_PROJECT_VERSION = 1; 508 | DEBUG_INFORMATION_FORMAT = dwarf; 509 | ENABLE_STRICT_OBJC_MSGSEND = YES; 510 | ENABLE_TESTABILITY = YES; 511 | GCC_C_LANGUAGE_STANDARD = gnu99; 512 | GCC_DYNAMIC_NO_PIC = NO; 513 | GCC_OPTIMIZATION_LEVEL = 0; 514 | GCC_PREPROCESSOR_DEFINITIONS = ( 515 | "DEBUG=1", 516 | "$(inherited)", 517 | ); 518 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 519 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 520 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 521 | GCC_WARN_UNDECLARED_SELECTOR = YES; 522 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 523 | GCC_WARN_UNUSED_FUNCTION = YES; 524 | GCC_WARN_UNUSED_VARIABLE = YES; 525 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 526 | MACOSX_DEPLOYMENT_TARGET = 10.9; 527 | MTL_ENABLE_DEBUG_INFO = YES; 528 | ONLY_ACTIVE_ARCH = YES; 529 | PRODUCT_BUNDLE_IDENTIFIER = "com.antitypical.$(PRODUCT_NAME:rfc1034identifier)"; 530 | SDKROOT = macosx; 531 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 532 | VERSIONING_SYSTEM = "apple-generic"; 533 | VERSION_INFO_PREFIX = ""; 534 | }; 535 | name = Debug; 536 | }; 537 | D4F1C4121A8FE39F0087648A /* Release */ = { 538 | isa = XCBuildConfiguration; 539 | buildSettings = { 540 | ALWAYS_SEARCH_USER_PATHS = NO; 541 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 542 | CLANG_CXX_LIBRARY = "libc++"; 543 | CLANG_ENABLE_MODULES = YES; 544 | CLANG_ENABLE_OBJC_ARC = YES; 545 | CLANG_WARN_BOOL_CONVERSION = YES; 546 | CLANG_WARN_CONSTANT_CONVERSION = YES; 547 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 548 | CLANG_WARN_EMPTY_BODY = YES; 549 | CLANG_WARN_ENUM_CONVERSION = YES; 550 | CLANG_WARN_INT_CONVERSION = YES; 551 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 552 | CLANG_WARN_UNREACHABLE_CODE = YES; 553 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 554 | COPY_PHASE_STRIP = YES; 555 | CURRENT_PROJECT_VERSION = 1; 556 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 557 | ENABLE_NS_ASSERTIONS = NO; 558 | ENABLE_STRICT_OBJC_MSGSEND = YES; 559 | GCC_C_LANGUAGE_STANDARD = gnu99; 560 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 561 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 562 | GCC_WARN_UNDECLARED_SELECTOR = YES; 563 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 564 | GCC_WARN_UNUSED_FUNCTION = YES; 565 | GCC_WARN_UNUSED_VARIABLE = YES; 566 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 567 | MACOSX_DEPLOYMENT_TARGET = 10.9; 568 | MTL_ENABLE_DEBUG_INFO = NO; 569 | PRODUCT_BUNDLE_IDENTIFIER = "com.antitypical.$(PRODUCT_NAME:rfc1034identifier)"; 570 | SDKROOT = macosx; 571 | VERSIONING_SYSTEM = "apple-generic"; 572 | VERSION_INFO_PREFIX = ""; 573 | }; 574 | name = Release; 575 | }; 576 | D4F1C4141A8FE39F0087648A /* Debug */ = { 577 | isa = XCBuildConfiguration; 578 | buildSettings = { 579 | APPLICATION_EXTENSION_API_ONLY = NO; 580 | CLANG_ENABLE_MODULES = YES; 581 | COMBINE_HIDPI_IMAGES = YES; 582 | DEFINES_MODULE = YES; 583 | DYLIB_COMPATIBILITY_VERSION = 1; 584 | DYLIB_CURRENT_VERSION = 1; 585 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 586 | FRAMEWORK_SEARCH_PATHS = "$(PLATFORM_DIR)/Developer/Library/Frameworks"; 587 | FRAMEWORK_VERSION = A; 588 | INFOPLIST_FILE = Assertions/Info.plist; 589 | INSTALL_PATH = "@rpath"; 590 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; 591 | MACOSX_DEPLOYMENT_TARGET = 10.9; 592 | OTHER_LDFLAGS = ( 593 | "-framework", 594 | XCTest, 595 | ); 596 | PRODUCT_NAME = Assertions; 597 | SKIP_INSTALL = YES; 598 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 599 | VALID_ARCHS = x86_64; 600 | }; 601 | name = Debug; 602 | }; 603 | D4F1C4151A8FE39F0087648A /* Release */ = { 604 | isa = XCBuildConfiguration; 605 | buildSettings = { 606 | APPLICATION_EXTENSION_API_ONLY = NO; 607 | CLANG_ENABLE_MODULES = YES; 608 | COMBINE_HIDPI_IMAGES = YES; 609 | DEFINES_MODULE = YES; 610 | DYLIB_COMPATIBILITY_VERSION = 1; 611 | DYLIB_CURRENT_VERSION = 1; 612 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 613 | FRAMEWORK_SEARCH_PATHS = "$(PLATFORM_DIR)/Developer/Library/Frameworks"; 614 | FRAMEWORK_VERSION = A; 615 | INFOPLIST_FILE = Assertions/Info.plist; 616 | INSTALL_PATH = "@rpath"; 617 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; 618 | MACOSX_DEPLOYMENT_TARGET = 10.9; 619 | OTHER_LDFLAGS = ( 620 | "-framework", 621 | XCTest, 622 | ); 623 | PRODUCT_NAME = Assertions; 624 | SKIP_INSTALL = YES; 625 | VALID_ARCHS = x86_64; 626 | }; 627 | name = Release; 628 | }; 629 | D4F1C4171A8FE39F0087648A /* Debug */ = { 630 | isa = XCBuildConfiguration; 631 | buildSettings = { 632 | COMBINE_HIDPI_IMAGES = YES; 633 | FRAMEWORK_SEARCH_PATHS = ( 634 | "$(DEVELOPER_FRAMEWORKS_DIR)", 635 | "$(inherited)", 636 | ); 637 | GCC_PREPROCESSOR_DEFINITIONS = ( 638 | "DEBUG=1", 639 | "$(inherited)", 640 | ); 641 | INFOPLIST_FILE = AssertionsTests/Info.plist; 642 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; 643 | PRODUCT_BUNDLE_IDENTIFIER = "com.antitypical.$(PRODUCT_NAME:rfc1034identifier)"; 644 | PRODUCT_NAME = "$(TARGET_NAME)"; 645 | }; 646 | name = Debug; 647 | }; 648 | D4F1C4181A8FE39F0087648A /* Release */ = { 649 | isa = XCBuildConfiguration; 650 | buildSettings = { 651 | COMBINE_HIDPI_IMAGES = YES; 652 | COPY_PHASE_STRIP = NO; 653 | FRAMEWORK_SEARCH_PATHS = ( 654 | "$(DEVELOPER_FRAMEWORKS_DIR)", 655 | "$(inherited)", 656 | ); 657 | INFOPLIST_FILE = AssertionsTests/Info.plist; 658 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; 659 | PRODUCT_BUNDLE_IDENTIFIER = "com.antitypical.$(PRODUCT_NAME:rfc1034identifier)"; 660 | PRODUCT_NAME = "$(TARGET_NAME)"; 661 | }; 662 | name = Release; 663 | }; 664 | /* End XCBuildConfiguration section */ 665 | 666 | /* Begin XCConfigurationList section */ 667 | D4C2EDF81A98DD7D00054FAA /* Build configuration list for PBXNativeTarget "Assertions-iOS" */ = { 668 | isa = XCConfigurationList; 669 | buildConfigurations = ( 670 | D4C2EDF41A98DD7D00054FAA /* Debug */, 671 | D4C2EDF51A98DD7D00054FAA /* Release */, 672 | ); 673 | defaultConfigurationIsVisible = 0; 674 | defaultConfigurationName = Release; 675 | }; 676 | D4C2EDF91A98DD7D00054FAA /* Build configuration list for PBXNativeTarget "Assertions-iOSTests" */ = { 677 | isa = XCConfigurationList; 678 | buildConfigurations = ( 679 | D4C2EDF61A98DD7D00054FAA /* Debug */, 680 | D4C2EDF71A98DD7D00054FAA /* Release */, 681 | ); 682 | defaultConfigurationIsVisible = 0; 683 | defaultConfigurationName = Release; 684 | }; 685 | D4F1C3F21A8FE39F0087648A /* Build configuration list for PBXProject "Assertions" */ = { 686 | isa = XCConfigurationList; 687 | buildConfigurations = ( 688 | D4F1C4111A8FE39F0087648A /* Debug */, 689 | D4F1C4121A8FE39F0087648A /* Release */, 690 | ); 691 | defaultConfigurationIsVisible = 0; 692 | defaultConfigurationName = Release; 693 | }; 694 | D4F1C4131A8FE39F0087648A /* Build configuration list for PBXNativeTarget "Assertions-Mac" */ = { 695 | isa = XCConfigurationList; 696 | buildConfigurations = ( 697 | D4F1C4141A8FE39F0087648A /* Debug */, 698 | D4F1C4151A8FE39F0087648A /* Release */, 699 | ); 700 | defaultConfigurationIsVisible = 0; 701 | defaultConfigurationName = Release; 702 | }; 703 | D4F1C4161A8FE39F0087648A /* Build configuration list for PBXNativeTarget "Assertions-MacTests" */ = { 704 | isa = XCConfigurationList; 705 | buildConfigurations = ( 706 | D4F1C4171A8FE39F0087648A /* Debug */, 707 | D4F1C4181A8FE39F0087648A /* Release */, 708 | ); 709 | defaultConfigurationIsVisible = 0; 710 | defaultConfigurationName = Release; 711 | }; 712 | /* End XCConfigurationList section */ 713 | }; 714 | rootObject = D4F1C3EF1A8FE39F0087648A /* Project object */; 715 | } 716 | -------------------------------------------------------------------------------- /Assertions.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Assertions.xcodeproj/xcshareddata/xcschemes/Assertions-Mac.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 47 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 65 | 66 | 67 | 68 | 78 | 79 | 85 | 86 | 87 | 88 | 89 | 90 | 96 | 97 | 103 | 104 | 105 | 106 | 108 | 109 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /Assertions.xcodeproj/xcshareddata/xcschemes/Assertions-iOS.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 47 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 65 | 66 | 67 | 68 | 78 | 79 | 85 | 86 | 87 | 88 | 89 | 90 | 96 | 97 | 103 | 104 | 105 | 106 | 108 | 109 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /Assertions.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Assertions/Assertions.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 Rob Rix. All rights reserved. 2 | 3 | /// Project version number for Assertions. 4 | extern double AssertionsVersionNumber; 5 | 6 | /// Project version string for Assertions. 7 | extern const unsigned char AssertionsVersionString[]; 8 | 9 | -------------------------------------------------------------------------------- /Assertions/Assertions.swift: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 Rob Rix. All rights reserved. 2 | 3 | // MARK: - Matching 4 | 5 | /// Asserts that a binary function matches two operands. 6 | /// 7 | /// This is useful for asserting the equality of collections which only define equality for Equatable element types. 8 | /// 9 | /// assert(x, ==, y) 10 | public func assert(@autoclosure expression1: () throws -> T?, _ test: (T, T) -> Bool, @autoclosure _ expression2: () -> T, message: String = "", file: String = __FILE__, line: UInt = __LINE__) -> T? { 11 | return assertExpected(expression1, test, expression2(), message, file, line) 12 | } 13 | 14 | /// Asserts that a binary function matches two operands. 15 | /// 16 | /// This is useful for asserting the equality of collections which only define equality for Equatable element types. 17 | /// 18 | /// assert(x, ==, y) 19 | public func assert(@autoclosure expression1: () throws -> T, _ test: (T, U) -> Bool, @autoclosure _ expression2: () -> U, message: String = "", file: String = __FILE__, line: UInt = __LINE__) -> T? { 20 | return assertExpected(expression1, test, expression2(), message, file, line) 21 | } 22 | 23 | /// Asserts that a curried binary function matches two operands. 24 | /// 25 | /// This is useful for asserting that some method applies to the receiver on the left and the operand on the right. 26 | /// 27 | /// assert(Set([ 1, 2, 3 ]), Set.contains, 3) 28 | public func assert(@autoclosure expression1: () throws -> T?, _ test: T -> U -> Bool, @autoclosure _ expression2: () -> U, message: String = "", file: String = __FILE__, line: UInt = __LINE__) -> T? { 29 | return assertExpected(expression1, { x, y in test(x)(y) }, expression2(), message, file, line) 30 | } 31 | 32 | /// Asserts the truth of a predicate applied to a value. 33 | /// 34 | /// This is useful for asserting that a value has some property or other. 35 | /// 36 | /// assert("", { $0.isEmpty }) 37 | public func assert(@autoclosure expression: () throws -> T?, message: String = "", file: String = __FILE__, line: UInt = __LINE__, _ test: T -> Bool) -> T? { 38 | return assertPredicate(expression, test, message, file, line) 39 | } 40 | 41 | 42 | // MARK: - Equality 43 | 44 | /// Asserts the equality of two Equatable values. 45 | /// 46 | /// Returns the value, if equal and non-nil. 47 | public func assertEqual(@autoclosure expression1: () throws -> T?, @autoclosure _ expression2: () -> T?, _ message: String = "", _ file: String = __FILE__, _ line: UInt = __LINE__) -> T? { 48 | return assertExpected(expression1, { $0 == $1 }, expression2(), message, file, line) 49 | } 50 | 51 | 52 | /// Asserts the equality of two arrays of Equatable values. 53 | /// 54 | /// Returns the array, if equal and non-nil. 55 | public func assertEqual(@autoclosure expression1: () throws -> [T]?, @autoclosure _ expression2: () -> [T]?, _ message: String = "", _ file: String = __FILE__, _ line: UInt = __LINE__) -> [T]? { 56 | return assertExpected(expression1, ==, expression2(), message, file, line) 57 | } 58 | 59 | 60 | /// Asserts the equality of two dictionaries of Equatable values. 61 | /// 62 | /// Returns the dictionary, if equal and non-nil. 63 | public func assertEqual(@autoclosure expression1: () throws -> [T: U]?, @autoclosure _ expression2: () -> [T: U]?, _ message: String = "", _ file: String = __FILE__, _ line: UInt = __LINE__) -> [T: U]? { 64 | return assertExpected(expression1, ==, expression2(), message, file, line) 65 | } 66 | 67 | 68 | // MARK: - Nil/non-nil 69 | 70 | /// Asserts that a value is nil. 71 | public func assertNil(@autoclosure expression: () -> T?, _ message: String = "", file: String = __FILE__, line: UInt = __LINE__) -> Bool { 72 | return expression().map { failure("\(String(reflecting: $0)) is not nil. " + message, file: file, line: line) } ?? true 73 | } 74 | 75 | /// Asserts that a value is not nil. 76 | public func assertNotNil(@autoclosure expression: () throws -> T?, _ message: String = "", file: String = __FILE__, line: UInt = __LINE__) -> T? { 77 | return assertPredicate(expression, { $0 != nil }, "is nil. " + message, file, line) 78 | } 79 | 80 | 81 | // MARK: - Failure 82 | 83 | /// Logs a failed assertion. 84 | /// 85 | /// Returns nil, for use in `x ?? failure(…)` expressions. 86 | public func failure(message: String, file: String = __FILE__, line: UInt = __LINE__) -> T? { 87 | XCTFail(message, file: file, line: line) 88 | return nil 89 | } 90 | 91 | /// Logs a failed assertion. 92 | /// 93 | /// Returns nil, for use in `x ?? failure(…)` expressions. 94 | public func failure(message: String, file: String = __FILE__, line: UInt = __LINE__) -> Bool { 95 | XCTFail(message, file: file, line: line) 96 | return false 97 | } 98 | 99 | 100 | // MARK: - Implementation details 101 | 102 | private func assertPredicate(@noescape actual: () throws -> T?, _ predicate: T -> Bool, _ message: String, _ file: String, _ line: UInt) -> T? { 103 | do { 104 | let actual = try actual() 105 | switch actual { 106 | case let .Some(x) where predicate(x): 107 | return actual 108 | default: 109 | return failure(message, file: file, line: line) 110 | } 111 | } catch { 112 | return failure("caught error: '\(error)' \(message)", file: file, line: line) 113 | } 114 | } 115 | 116 | private func assertExpected(@noescape actual: () throws -> T?, _ match: (T, U) -> Bool, _ expected: U?, _ message: String, _ file: String, _ line: UInt) -> T? { 117 | do { 118 | let actual = try actual() 119 | switch (actual, expected) { 120 | case (.None, .None): 121 | return actual 122 | case let (.Some(x), .Some(y)) where match(x, y): 123 | return actual 124 | case let (.Some(x), .Some(y)): 125 | return failure("\(String(reflecting: x)) did not match \(String(reflecting: y)). " + message, file: file, line: line) 126 | case let (.Some(x), .None): 127 | return failure("\(String(reflecting: x)) did not match nil. " + message, file: file, line: line) 128 | case let (.None, .Some(y)): 129 | return failure("nil did not match \(String(reflecting: y)). " + message, file: file, line: line) 130 | } 131 | } catch { 132 | return failure("caught error: '\(error)' \(message)", file: file, line: line) 133 | } 134 | } 135 | 136 | 137 | // MARK: - Imports 138 | 139 | import XCTest 140 | -------------------------------------------------------------------------------- /Assertions/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.0.1 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSHumanReadableCopyright 24 | Copyright © 2015 Rob Rix. All rights reserved. 25 | NSPrincipalClass 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /AssertionsTests/AssertionsTests.swift: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 Rob Rix. All rights reserved. 2 | 3 | final class AssertionsTests: XCTestCase { 4 | func testAssertingWithOptionalArrays() { 5 | let array: [Int]? = [1, 2, 3] 6 | assert(array, ==, [1, 2, 3]) 7 | // XCTAssertEqual(array, [1, 2, 3]) // => error: value of optional type '[Int]?' not unwrapped; did you mean to use '!' or '?'? 8 | } 9 | 10 | func testAssertingWithOptionalArraysFailure() { 11 | let array: [Int]? = [1, 2, 3] 12 | assertFailure { 13 | assert(array, ==, [1, 2, 3, 4]) 14 | } 15 | } 16 | 17 | 18 | func testAssertingWithOptionalStrings() { 19 | let string: String? = "hello" 20 | assert(string, ==, "hello") 21 | } 22 | 23 | func testAssertingWithOptionalStringsFailure() { 24 | let string: String? = "hello" 25 | assertFailure { 26 | assert(string, ==, "hello!") 27 | } 28 | } 29 | 30 | 31 | func testAssertingWithMethods() { 32 | let set: Set? = Set([1, 2, 3]) 33 | assert(set, Set.contains, 3) 34 | } 35 | 36 | func testAssertingWithMethodsFailure() { 37 | let set: Set? = Set([1, 2, 3]) 38 | assertFailure { 39 | assert(set, Set.contains, 4) 40 | } 41 | } 42 | 43 | 44 | func testAssertingPropertyWithPredicate() { 45 | let string: String? = "" 46 | assert(string, { $0.isEmpty }) 47 | } 48 | 49 | func testAssertingPropertyWithPredicateFailure() { 50 | let string: String? = "1" 51 | assertFailure { 52 | assert(string, { $0.isEmpty }) 53 | } 54 | } 55 | 56 | 57 | func testAssertingThrowingMatcher() { 58 | assert(try getStringReturns(), ==, "") 59 | } 60 | 61 | func testAssertingThrowingMatcherFailure() { 62 | assertFailure { 63 | assert(try getStringThrows(), ==, "") 64 | } 65 | } 66 | 67 | func testAssertingThrowingPropertyWithPredicate() { 68 | assert(try getStringReturns(), { $0.isEmpty }) 69 | } 70 | 71 | func testAssertingThrowingPropertyWithPredicateFailure() { 72 | assertFailure { 73 | assert(try getStringThrows(), { $0.isEmpty }) 74 | } 75 | } 76 | 77 | 78 | func testAssertingNilOfEquatableType() { 79 | let x: Int? = nil 80 | assert(x, ==, nil) 81 | } 82 | 83 | func testAssertingNilOfEquatableTypeFailure() { 84 | let x: Int? = 1 85 | assertFailure { 86 | assert(x, ==, nil) 87 | } 88 | } 89 | 90 | func testAssertingNonNilOfEquatableType() { 91 | let x: Int? = 1 92 | assert(x, !=, nil) 93 | } 94 | 95 | func testAssertingNonNilOfEquatableTypeFailure() { 96 | let x: Int? = nil 97 | assertFailure(x, !=, nil) 98 | } 99 | 100 | 101 | // MARK: Throwing functions 102 | 103 | private func getStringReturns() throws -> String { 104 | return "" 105 | } 106 | 107 | private func getStringThrows() throws -> String { 108 | throw NSError(domain: "com.antitypical.Assertions", code: -1, userInfo: [:]) 109 | } 110 | 111 | 112 | // MARK: Testing assertion failures 113 | 114 | /// Assert that `test` causes an assertion failure. 115 | func assertFailure(file: String = __FILE__, line: UInt = __LINE__, @noescape _ test: () throws -> T) -> (message: String, file: String, line: UInt, expected: Bool)? { 116 | do { 117 | let previous = expectFailure 118 | expectFailure = true 119 | try test() 120 | expectFailure = previous 121 | if let result = failure { 122 | return result 123 | } else { 124 | return Assertions.failure("expected the assertion to fail", file: file, line: line) 125 | } 126 | } catch { 127 | return Assertions.failure("error: \(error)", file: file, line: line) 128 | } 129 | } 130 | 131 | /// Workaround for http://www.openradar.me/19996972 132 | func assertFailure(@autoclosure expression1: () -> T, _ test: (T, T) -> Bool, @autoclosure _ expression2: () -> T, message: String = "", file: String = __FILE__, line: UInt = __LINE__) -> (message: String, file: String, line: UInt, expected: Bool)? { 133 | return assertFailure { 134 | assert(expression1(), test, expression2(), message: message, file: file, line: line) 135 | } 136 | } 137 | 138 | private var expectFailure: Bool = false 139 | private var failure: (message: String, file: String, line: UInt, expected: Bool)? = nil 140 | 141 | override func recordFailureWithDescription(message: String, inFile file: String, atLine line: UInt, expected: Bool) { 142 | if expectFailure { 143 | failure = (message: message, file: file, line: line, expected: expected) 144 | } else { 145 | super.recordFailureWithDescription(message, inFile: file, atLine: line, expected: expected) 146 | } 147 | } 148 | } 149 | 150 | 151 | // MARK: - Imports 152 | 153 | import Assertions 154 | import XCTest 155 | -------------------------------------------------------------------------------- /AssertionsTests/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 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Rob Rix 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Assertions 2 | 3 | This is a Swift µframework providing simple, flexible assertions for XCTest in Swift. 4 | 5 | _Requires Swift 1.2 (Xcode 6.3)_ 6 | 7 | ## Use 8 | 9 | Assert that an optional array is equal to another array: 10 | 11 | ```swift 12 | let array: [Int]? = [1, 2, 3] 13 | assert(maybeAnArray(), ==, [1, 2, 3]) 14 | ``` 15 | 16 | If you tried to use `XCTAssertEqual`, you’d have to unwrap the optional first: 17 | 18 | ```swift 19 | XCTAssertEqual(array, [1, 2, 3]) 20 | // => error: value of optional type '[Int]?' not unwrapped; did you mean to use '!' or '?'? 21 | ``` 22 | 23 | This works great with optionals of other types, too: 24 | 25 | ```swift 26 | let string: String? = "hello" 27 | assert(string, ==, "hello") 28 | ``` 29 | 30 | Here, too, `XCTAssertEqual` would force you to unwrap the optional: 31 | 32 | ```swift 33 | XCTAssertEqual(string, "hello") 34 | // => error: cannot find an overload for 'XCTAssertEqual' that accepts an argument list of type '(String?, String)' 35 | ``` 36 | 37 | You can also pass in methods: 38 | 39 | ```swift 40 | let set: Set? = Set([1, 2, 3]) 41 | assert(set, Set.contains, 3) 42 | ``` 43 | 44 | And you can use the predicate form for any other test you might want to write: 45 | 46 | ```swift 47 | let string: String? = "" 48 | assert(string, { $0.isEmpty }) 49 | ``` 50 | 51 | These last two are approximately equivalent to using Swift’s optional chaining, but you might find them handy. 52 | 53 | 54 | ## Integration 55 | 56 | 1. Add this repo as a submodule in e.g. `External/Assertions`: 57 | 58 | git submodule add https://github.com/robrix/Assertions.git External/Assertions 59 | 2. Drag `Assertions.xcodeproj` into your `.xcworkspace`/`.xcodeproj`. 60 | 3. Add `Assertions.framework` to your test target’s `Link Binary With Libraries` build phase. 61 | --------------------------------------------------------------------------------