Skip to content

Commit

Permalink
Move c99ExtendedIdentifier extension from NSString to String
Browse files Browse the repository at this point in the history
  • Loading branch information
jwfriese committed Jan 1, 2019
1 parent 7b1d0d1 commit 6f95c8c
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 18 deletions.
16 changes: 8 additions & 8 deletions Quick.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,9 @@
DAEB6B9A1943873100289F44 /* Quick.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DAEB6B8E1943873100289F44 /* Quick.framework */; };
DAF28BC31A4DB8EC00A5D9BF /* FocusedTests+ObjC.m in Sources */ = {isa = PBXBuildFile; fileRef = DAF28BC21A4DB8EC00A5D9BF /* FocusedTests+ObjC.m */; };
DAF28BC41A4DB8EC00A5D9BF /* FocusedTests+ObjC.m in Sources */ = {isa = PBXBuildFile; fileRef = DAF28BC21A4DB8EC00A5D9BF /* FocusedTests+ObjC.m */; };
DED3036B1DF6C66B0041394E /* NSString+C99ExtendedIdentifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = DED3036A1DF6C66B0041394E /* NSString+C99ExtendedIdentifier.swift */; };
DED3036C1DF6C66B0041394E /* NSString+C99ExtendedIdentifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = DED3036A1DF6C66B0041394E /* NSString+C99ExtendedIdentifier.swift */; };
DED3036D1DF6C66B0041394E /* NSString+C99ExtendedIdentifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = DED3036A1DF6C66B0041394E /* NSString+C99ExtendedIdentifier.swift */; };
DED3036B1DF6C66B0041394E /* String+C99ExtendedIdentifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = DED3036A1DF6C66B0041394E /* String+C99ExtendedIdentifier.swift */; };
DED3036C1DF6C66B0041394E /* String+C99ExtendedIdentifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = DED3036A1DF6C66B0041394E /* String+C99ExtendedIdentifier.swift */; };
DED3036D1DF6C66B0041394E /* String+C99ExtendedIdentifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = DED3036A1DF6C66B0041394E /* String+C99ExtendedIdentifier.swift */; };
DED3037D1DF6CF140041394E /* BundleModuleNameTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DED3037C1DF6CF140041394E /* BundleModuleNameTests.swift */; };
DED3037E1DF6CF140041394E /* BundleModuleNameTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DED3037C1DF6CF140041394E /* BundleModuleNameTests.swift */; };
DED3037F1DF6CF140041394E /* BundleModuleNameTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DED3037C1DF6CF140041394E /* BundleModuleNameTests.swift */; };
Expand Down Expand Up @@ -557,7 +557,7 @@
DAEB6B991943873100289F44 /* Quick - macOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Quick - macOSTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
DAEB6B9F1943873100289F44 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
DAF28BC21A4DB8EC00A5D9BF /* FocusedTests+ObjC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "FocusedTests+ObjC.m"; sourceTree = "<group>"; };
DED3036A1DF6C66B0041394E /* NSString+C99ExtendedIdentifier.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSString+C99ExtendedIdentifier.swift"; sourceTree = "<group>"; };
DED3036A1DF6C66B0041394E /* String+C99ExtendedIdentifier.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "String+C99ExtendedIdentifier.swift"; sourceTree = "<group>"; };
DED3037C1DF6CF140041394E /* BundleModuleNameTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BundleModuleNameTests.swift; sourceTree = "<group>"; };
F8100E901A1E4447007595ED /* Nimble.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Nimble.framework; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
Expand Down Expand Up @@ -899,7 +899,7 @@
CE57CEDA1C430BD200D63004 /* QuickTestSuite.swift */,
CE57CED91C430BD200D63004 /* QuickSelectedTestSuiteBuilder.swift */,
CE57CED81C430BD200D63004 /* NSBundle+CurrentTestBundle.swift */,
DED3036A1DF6C66B0041394E /* NSString+C99ExtendedIdentifier.swift */,
DED3036A1DF6C66B0041394E /* String+C99ExtendedIdentifier.swift */,
CE57CEDB1C430BD200D63004 /* URL+FileName.swift */,
34C586071C4AC5E500D4F057 /* ErrorUtility.swift */,
DAEB6B911943873100289F44 /* Supporting Files */,
Expand Down Expand Up @@ -1432,7 +1432,7 @@
34C5860A1C4AC5E500D4F057 /* ErrorUtility.swift in Sources */,
1F118D041BDCA536005013A2 /* Example.swift in Sources */,
1F118CFF1BDCA536005013A2 /* QCKDSL.m in Sources */,
DED3036D1DF6C66B0041394E /* NSString+C99ExtendedIdentifier.swift in Sources */,
DED3036D1DF6C66B0041394E /* String+C99ExtendedIdentifier.swift in Sources */,
CE590E211C431FE400253D19 /* NSBundle+CurrentTestBundle.swift in Sources */,
1F118D071BDCA536005013A2 /* Callsite.swift in Sources */,
CE590E231C431FE400253D19 /* XCTestSuite+QuickTestSuiteBuilder.m in Sources */,
Expand Down Expand Up @@ -1515,7 +1515,7 @@
34C586091C4AC5E500D4F057 /* ErrorUtility.swift in Sources */,
DA408BE719FF5599005DF92A /* SuiteHooks.swift in Sources */,
34F375BA19515CA700CE1B99 /* QuickSpec.m in Sources */,
DED3036C1DF6C66B0041394E /* NSString+C99ExtendedIdentifier.swift in Sources */,
DED3036C1DF6C66B0041394E /* String+C99ExtendedIdentifier.swift in Sources */,
CE590E1C1C431FE300253D19 /* NSBundle+CurrentTestBundle.swift in Sources */,
DAE7150119FF6A62005905B8 /* QuickConfiguration.m in Sources */,
CE590E1E1C431FE300253D19 /* XCTestSuite+QuickTestSuiteBuilder.m in Sources */,
Expand Down Expand Up @@ -1638,7 +1638,7 @@
DA02C91919A8073100093156 /* ExampleMetadata.swift in Sources */,
CE57CEDF1C430BD200D63004 /* QuickTestSuite.swift in Sources */,
34C586081C4AC5E500D4F057 /* ErrorUtility.swift in Sources */,
DED3036B1DF6C66B0041394E /* NSString+C99ExtendedIdentifier.swift in Sources */,
DED3036B1DF6C66B0041394E /* String+C99ExtendedIdentifier.swift in Sources */,
DA408BE619FF5599005DF92A /* SuiteHooks.swift in Sources */,
34F375B919515CA700CE1B99 /* QuickSpec.m in Sources */,
CE57CEE11C430BD200D63004 /* XCTestSuite+QuickTestSuiteBuilder.m in Sources */,
Expand Down
2 changes: 1 addition & 1 deletion Sources/Quick/DSL/World+DSL.swift
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ extension World {
}

@objc(pendingWithDescription:file:line:closure:)
private func objc_pending(_ description: String, file: String, line: UInt, closure: @escaping () -> Void) {
internal func objc_pending(_ description: String, file: String, line: UInt, closure: @escaping () -> Void) {
pending(description, file: file, line: line, closure: closure)
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion Sources/Quick/Example.swift
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ final public class Example: _ExampleBase {

internal var uniqueIdentifier: String {
guard let uniqueIdentifier = group?.uniqueIdentifier(forExample: self) else {
return (description as NSString).c99ExtendedIdentifier
return description.c99ExtendedIdentifier
}

return uniqueIdentifier
Expand Down
2 changes: 1 addition & 1 deletion Sources/Quick/ExampleGroup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ final public class ExampleGroup: NSObject {
}

private func deduplicateIdentifier(_ identifier: String) -> String {
var uniqueIdentifier = (identifier as NSString).c99ExtendedIdentifier
var uniqueIdentifier = identifier.c99ExtendedIdentifier
let baseUniqueIdentifier = uniqueIdentifier
var identifyingTag = 2
while allExampleUniqueIdentifiers.contains(uniqueIdentifier) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
import Foundation

extension NSString {
extension String {
private static var invalidCharacters: CharacterSet = {
var invalidCharacters = CharacterSet()

Expand All @@ -21,17 +20,22 @@ extension NSString {
return invalidCharacters
}()

/// This API is not meant to be used outside Quick, so will be unavailable in
/// a next major version.
@objc(qck_c99ExtendedIdentifier)
public var c99ExtendedIdentifier: String {
let validComponents = components(separatedBy: NSString.invalidCharacters)
var c99ExtendedIdentifier: String {
let validComponents = components(separatedBy: String.invalidCharacters)
let result = validComponents.joined(separator: "_")

return result.isEmpty ? "_" : result
}
}

#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
public extension NSString {
@objc(qck_c99ExtendedIdentifier)
public var c99ExtendedIdentifier: String {
return (self as String).c99ExtendedIdentifier
}
}

/// Extension methods or properties for NSObject subclasses are invisible from
/// the Objective-C runtime on static linking unless the consumers add `-ObjC`
/// linker flag, so let's make a wrapper class to mitigate that situation.
Expand Down

0 comments on commit 6f95c8c

Please sign in to comment.