Skip to content

[test] Reinstate CoreGraphics↔︎NSValue bridging tests on iOS/watchOS/tvOS #32515

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 2 commits into from
Jun 30, 2020
Merged
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
17 changes: 17 additions & 0 deletions test/stdlib/NSValueBridging.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,18 @@
//
// REQUIRES: objc_interop

// The UIKit overlay isn't present on iOS 10.3.
// UNSUPPORTED: CPU=i386
Copy link
Contributor

Choose a reason for hiding this comment

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

What about other tests that don't depend on UIKit? Could we put these tests into a separate file that does not run on the i386 iOS simulator, while the rest of the test does?

You could also use StdlibUnittest facilities to skip a test on the simulator. See these tests: https://github.com/apple/swift/blob/30ccb529485dac910a8f2a11504205fb5ea16873/validation-test/StdlibUnittest/Common.swift#L153

Copy link
Member Author

Choose a reason for hiding this comment

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

That makes sense -- I'll submit a followup PR soon.


import StdlibUnittest
import StdlibUnittestFoundationExtras
import Foundation
import CoreGraphics

#if os(iOS) || os(tvOS) || os(watchOS)
import UIKit
#endif

var nsValueBridging = TestSuite("NSValueBridging")

func rangesEqual(_ x: NSRange, _ y: NSRange) -> Bool {
Expand Down Expand Up @@ -66,6 +73,16 @@ ${ testCase("CGAffineTransform", "CGAffineTransform(rotationAngle: .pi)", N

#endif

#if os(iOS) || os(tvOS) || os(watchOS)

${ testCase("CGRect", "CGRect(x: 17, y: 38, width: 6, height: 79)", "cgRect", "(==)") }
${ testCase("CGPoint", "CGPoint(x: 17, y: 38)", "cgPoint", "(==)") }
${ testCase("CGSize", "CGSize(width: 6, height: 79)", "cgSize", "(==)") }
${ testCase("CGVector", "CGVector(dx: 6, dy: 79)", "cgVector", "(==)") }
${ testCase("CGAffineTransform", "CGAffineTransform(rotationAngle: .pi)", "cgAffineTransform", "(==)") }

#endif

nsValueBridging.test("NSValue can only be cast back to its original type") {
let range = NSRange(location: 17, length: 38)
let rangeObject: Any = NSValue(range: range)
Expand Down