Skip to content

Update for SE-0096 #147

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Sources/XCTest/Private/TestListing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ protocol Listable {
}

private func moduleName(value: Any) -> String {
let moduleAndType = String(reflecting: value.dynamicType)
let moduleAndType = String(reflecting: type(of: value))
return String(moduleAndType.characters.split(separator: ".").first!)
}

Expand All @@ -63,7 +63,7 @@ extension XCTestSuite: Listable {
}

private var listingName: String {
if let childTestCase = tests.first as? XCTestCase, name == String(describing: childTestCase.dynamicType) {
if let childTestCase = tests.first as? XCTestCase, name == String(describing: type(of: childTestCase)) {
return "\(moduleName(value: childTestCase)).\(name)"
} else {
return name
Expand Down
2 changes: 1 addition & 1 deletion Sources/XCTest/Private/WallClockTimeMetric.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ internal final class WallClockTimeMetric: PerformanceMetric {
String(format: "average: %.3f", measurements.average),
String(format: "relative standard deviation: %.3f%%", measurements.relativeStandardDeviation),
"values: [\(measurements.map({ String(format: "%.6f", $0) }).joined(separator: ", "))]",
"performanceMetricID:\(self.dynamicType.name)",
"performanceMetricID:\(type(of: self).name)",
String(format: "maxPercentRelativeStandardDeviation: %.3f%%", maxRelativeStandardDeviation),
String(format: "maxStandardDeviation: %.3f", standardDeviationNegligibilityThreshold),
]
Expand Down
4 changes: 2 additions & 2 deletions Sources/XCTest/Public/XCTestCase+Performance.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public extension XCTestCase {
/// ensure compatibility of tests between swift-corelibs-xctest and Apple
/// XCTest, it is not recommended to pass explicit values for `file` and `line`.
func measure(file: StaticString = #file, line: UInt = #line, block: () -> Void) {
measureMetrics(self.dynamicType.defaultPerformanceMetrics(),
measureMetrics(type(of: self).defaultPerformanceMetrics(),
automaticallyStartMeasuring: true,
file: file,
line: line,
Expand All @@ -66,7 +66,7 @@ public extension XCTestCase {
/// may interfere the API will measure them separately.
///
/// func testMyFunction2_WallClockTime() {
/// measureMetrics(self.dynamicType.defaultPerformanceMetrics(), automaticallyStartMeasuring: false) {
/// measureMetrics(type(of: self).defaultPerformanceMetrics(), automaticallyStartMeasuring: false) {
///
/// // Do setup work that needs to be done for every iteration but
/// // you don't want to measure before the call to `startMeasuring()`
Expand Down
4 changes: 2 additions & 2 deletions Sources/XCTest/Public/XCTestCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public class XCTestCase: XCTest {
/// `-[XCTestCase initWithInvocation:]`, it's rare for anyone outside of
/// XCTest itself to call this initializer.
public required init(name: String, testClosure: @escaping (XCTestCase) throws -> Void) {
_name = "\(self.dynamicType).\(name)"
_name = "\(type(of: self)).\(name)"
self.testClosure = testClosure
}

Expand Down Expand Up @@ -179,7 +179,7 @@ public func testCase<T: XCTestCase>(_ allTests: [(String, (T) -> () -> Void)]) -
private func test<T: XCTestCase>(_ testFunc: @escaping (T) -> () throws -> Void) -> (XCTestCase) throws -> Void {
return { testCaseType in
guard let testCase = testCaseType as? T else {
fatalError("Attempt to invoke test on class \(T.self) with incompatible instance type \(testCaseType.dynamicType)")
fatalError("Attempt to invoke test on class \(T.self) with incompatible instance type \(type(of: testCaseType))")
}

try testFunc(testCase)()
Expand Down