Skip to content

[stdlib] Reinstate some tests #36072

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
Mar 2, 2021
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
24 changes: 17 additions & 7 deletions test/stdlib/CodableTests.swift
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
// Copyright (c) 2014 - 2019 Apple Inc. and the Swift project authors
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2017 - 2021 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove the copyright header?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've restored the copyright header, with the correct years.
(However, the majority of stdlib tests don't have copyright headers.)

// RUN: %target-run-simple-swift
// REQUIRES: executable_test
// REQUIRES: objc_interop
// REQUIRES: rdar49026133

import Foundation
import CoreGraphics
Expand Down Expand Up @@ -544,14 +546,22 @@ class TestCodable : TestCodableSuper {
@available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *)
func test_Measurement_JSON() {
for (testLine, unit) in unitValues {
// FIXME: <rdar://problem/49026133>
// Terminating due to uncaught exception NSInvalidArgumentException:
// *** You must override baseUnit in your class NSDimension to define its base unit.
expectCrashLater()
expectRoundTripEqualityThroughJSON(for: Measurement(value: 42, unit: unit), lineNumber: testLine)
}
}

@available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *)
func test_Measurement_Plist() {
for (testLine, unit) in unitValues {
expectRoundTripEqualityThroughJSON(for: Measurement(value: 42, unit: unit), lineNumber: testLine)
// FIXME: <rdar://problem/49026133>
// Terminating due to uncaught exception NSInvalidArgumentException:
// *** You must override baseUnit in your class NSDimension to define its base unit.
expectCrashLater()
expectRoundTripEqualityThroughPlist(for: Measurement(value: 42, unit: unit), lineNumber: testLine)
}
}

Expand Down Expand Up @@ -915,10 +925,10 @@ if #available(macOS 10.11, iOS 9.0, watchOS 2.0, tvOS 9.0, *) {
}

if #available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *) {
// tests["test_DateInterval_JSON"] = TestCodable.test_DateInterval_JSON
tests["test_DateInterval_JSON"] = TestCodable.test_DateInterval_JSON
tests["test_DateInterval_Plist"] = TestCodable.test_DateInterval_Plist
// tests["test_Measurement_JSON"] = TestCodable.test_Measurement_JSON
// tests["test_Measurement_Plist"] = TestCodable.test_Measurement_Plist
tests["test_Measurement_JSON"] = TestCodable.test_Measurement_JSON
tests["test_Measurement_Plist"] = TestCodable.test_Measurement_Plist
}

if #available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *) {
Expand Down
22 changes: 9 additions & 13 deletions test/stdlib/FloatingPoint.swift.gyb
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
// RUN: %empty-directory(%t)
// RUN: %gyb %s -o %t/FloatingPoint.swift
// RUN: %line-directive %t/FloatingPoint.swift -- %target-build-swift -parse-stdlib %t/FloatingPoint.swift -o %t/a.out
// RUN: %target-codesign %t/a.out
// RUN: %line-directive %t/FloatingPoint.swift -- %target-run %t/a.out
// RUN: %target-run-simple-swiftgyb(-parse-stdlib)
// REQUIRES: executable_test
// REQUIRES: rdar49026133

import Swift
import StdlibUnittest
Expand Down Expand Up @@ -118,17 +113,17 @@ FloatingPoint.test("BinaryFloatingPoint/genericIntegerConversion") {
FloatingPoint.test("BinaryFloatingPoint/genericFloatingPointConversion") {
func convert<
T: BinaryFloatingPoint, U: BinaryFloatingPoint
>(exactly value: T, to: U.Type) -> U { U(exactly: value) }
>(exactly value: T, to: U.Type) -> U? { U(exactly: value) }

expectEqual(convert(exactly: 0 as Float, to: Double.self), 0.0)
expectEqual(convert(exactly: -0.0 as Float, to: Double.self), -0.0)
expectEqual(
convert(exactly: -0.0 as Float, to: Double.self).sign,
convert(exactly: -0.0 as Float, to: Double.self)?.sign,
FloatingPointSign.minus)
expectEqual(convert(exactly: 0 as Double, to: Float.self), 0.0 as Float)
expectEqual(convert(exactly: -0.0 as Double, to: Float.self), -0.0 as Float)
expectEqual(
convert(exactly: -0.0 as Double, to: Float.self).sign,
convert(exactly: -0.0 as Double, to: Float.self)?.sign,
FloatingPointSign.minus)
expectEqual(convert(exactly: 1 as Float, to: Double.self), 1.0)
expectEqual(convert(exactly: -1 as Float, to: Double.self), -1.0)
Expand Down Expand Up @@ -827,10 +822,11 @@ FloatingPoint.test("${FloatSelf}/{Comparable,Hashable,Equatable}") {
// If either lhs or rhs is signaling, or if both are quiet NaNs, the
// result is a quiet NaN.
if lhs.isSignalingNaN || rhs.isSignalingNaN || (lhs.isNaN && rhs.isNaN) {
expectTrue(min.isQuietNaN)
expectTrue(max.isQuietNaN)
expectTrue(minMag.isQuietNaN)
expectTrue(maxMag.isQuietNaN)
// FIXME: <rdar://problem/48917925>
// expectTrue(min.isQuietNaN)
// expectTrue(max.isQuietNaN)
// expectTrue(minMag.isQuietNaN)
// expectTrue(maxMag.isQuietNaN)
}
// If only one of lhs and rhs is NaN, the result of the min/max
// operations is always the other value. While contrary to all other
Expand Down
11 changes: 2 additions & 9 deletions test/stdlib/SetTrapsObjC.swift
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
// RUN: %empty-directory(%t)
// RUN: %target-build-swift %s -o %t/a.out_Debug -Onone
// RUN: %target-build-swift %s -o %t/a.out_Release -O
//
// RUN: %target-codesign %t/a.out_Debug
// RUN: %target-codesign %t/a.out_Release
// RUN: %target-run %t/a.out_Debug
// RUN: %target-run %t/a.out_Release
// RUN: %target-run-simple-swift(-Onone)
// RUN: %target-run-simple-swift(-O)
// REQUIRES: executable_test
// REQUIRES: objc_interop
// REQUIRES: rdar49026133

import StdlibUnittest
import Foundation
Expand Down
17 changes: 8 additions & 9 deletions validation-test/stdlib/DictionaryTrapsObjC.swift
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
// RUN: %empty-directory(%t)
// RUN: %target-build-swift %s -o %t/a.out_Debug -Onone
// RUN: %target-build-swift %s -o %t/a.out_Release -O
// RUN: %target-codesign %t/a.out_Debug
// RUN: %target-codesign %t/a.out_Release
//
// RUN: %target-run %t/a.out_Debug
// RUN: %target-run %t/a.out_Release
// RUN: %target-run-simple-swift(-Onone -DDEBUG)
// RUN: %target-run-simple-swift(-O)
// REQUIRES: executable_test
// REQUIRES: objc_interop
// REQUIRES: rdar49026133

import StdlibUnittest
import Foundation
Expand Down Expand Up @@ -205,6 +198,10 @@ DictionaryTraps.test("ForcedNonverbatimBridge.Value")
_ = d1 as! Dictionary<NSObject, String>
}

// FIXME: <https://bugs.swift.org/browse/SR-14282>
// Segmentation fault: 11 (when compiling with optimizations).
// While running pass #0 SILModuleTransform "SILGenCleanup".
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm frustratingly, this compiler crash is a new issue that is unrelated to the original problem (which was a runtime abort() call in the *_debug.sanity tests). Serves us right for leaving this test disabled for so long... 😞

If you still have a crash log handy, could you please file a bug for it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you still have a crash log handy, could you please file a bug for it?

I've filed SR-14282.

#if DEBUG

DictionaryTraps.test("ForcedVerbatimBridge.StringKey")
.skip(.custom(
Expand Down Expand Up @@ -284,6 +281,8 @@ DictionaryTraps.test("ForcedVerbatimBridge.Value")
}
}

#endif // DEBUG

DictionaryTraps.test("Downcast.Verbatim")
.skip(.custom(
{ _isFastAssertConfiguration() },
Expand Down