Skip to content

Commit ace5d76

Browse files
author
Nathan Hawes
authored
Merge pull request swiftlang#27793 from phausler/back_port_foundation_tests
Back port foundation tests
2 parents a060fc7 + 4315f40 commit ace5d76

File tree

2 files changed

+37
-26
lines changed

2 files changed

+37
-26
lines changed

test/stdlib/TestData.swift

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3806,30 +3806,34 @@ class TestData : TestDataSuper {
38063806
}
38073807

38083808
func test_nsdataSequence() {
3809-
let bytes: [UInt8] = Array(0x00...0xFF)
3810-
let data = bytes.withUnsafeBytes { NSData(bytes: $0.baseAddress, length: $0.count) }
3809+
if #available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) {
3810+
let bytes: [UInt8] = Array(0x00...0xFF)
3811+
let data = bytes.withUnsafeBytes { NSData(bytes: $0.baseAddress, length: $0.count) }
38113812

3812-
for byte in bytes {
3813-
expectEqual(data[Int(byte)], byte)
3813+
for byte in bytes {
3814+
expectEqual(data[Int(byte)], byte)
3815+
}
38143816
}
38153817
}
38163818

38173819
func test_dispatchSequence() {
3818-
let bytes1: [UInt8] = Array(0x00..<0xF0)
3819-
let bytes2: [UInt8] = Array(0xF0..<0xFF)
3820-
var data = DispatchData.empty
3821-
bytes1.withUnsafeBytes {
3822-
data.append($0)
3823-
}
3824-
bytes2.withUnsafeBytes {
3825-
data.append($0)
3826-
}
3820+
if #available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) {
3821+
let bytes1: [UInt8] = Array(0x00..<0xF0)
3822+
let bytes2: [UInt8] = Array(0xF0..<0xFF)
3823+
var data = DispatchData.empty
3824+
bytes1.withUnsafeBytes {
3825+
data.append($0)
3826+
}
3827+
bytes2.withUnsafeBytes {
3828+
data.append($0)
3829+
}
38273830

3828-
for byte in bytes1 {
3829-
expectEqual(data[Int(byte)], byte)
3830-
}
3831-
for byte in bytes2 {
3832-
expectEqual(data[Int(byte)], byte)
3831+
for byte in bytes1 {
3832+
expectEqual(data[Int(byte)], byte)
3833+
}
3834+
for byte in bytes2 {
3835+
expectEqual(data[Int(byte)], byte)
3836+
}
38333837
}
38343838
}
38353839
}
@@ -4151,9 +4155,10 @@ DataTests.test("test_validateMutation_slice_customBacking_withUnsafeMutableBytes
41514155
DataTests.test("test_validateMutation_slice_customMutableBacking_withUnsafeMutableBytes_lengthLessThanLowerBound") { TestData().test_validateMutation_slice_customMutableBacking_withUnsafeMutableBytes_lengthLessThanLowerBound() }
41524156
DataTests.test("test_byte_access_of_discontiguousData") { TestData().test_byte_access_of_discontiguousData() }
41534157
DataTests.test("test_rangeOfSlice") { TestData().test_rangeOfSlice() }
4154-
DataTests.test("test_nsdataSequence") { TestData().test_nsdataSequence() }
4155-
DataTests.test("test_dispatchSequence") { TestData().test_dispatchSequence() }
4156-
4158+
if #available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) {
4159+
DataTests.test("test_nsdataSequence") { TestData().test_nsdataSequence() }
4160+
DataTests.test("test_dispatchSequence") { TestData().test_dispatchSequence() }
4161+
}
41574162

41584163
// XCTest does not have a crash detection, whereas lit does
41594164
DataTests.test("bounding failure subdata") {

test/stdlib/TestDecimal.swift

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,11 @@ class TestDecimal : TestDecimalSuper {
120120
expectFalse(zero.isNaN)
121121
expectFalse(zero.isSignaling)
122122

123-
let d1 = Decimal(1234567890123456789 as UInt64)
124-
expectEqual(d1._exponent, 0)
125-
expectEqual(d1._length, 4)
123+
if #available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) {
124+
let d1 = Decimal(1234567890123456789 as UInt64)
125+
expectEqual(d1._exponent, 0)
126+
expectEqual(d1._length, 4)
127+
}
126128
}
127129
func test_Constants() {
128130
expectEqual(8, NSDecimalMaxSize)
@@ -303,7 +305,9 @@ class TestDecimal : TestDecimalSuper {
303305
expectEqual(Decimal(68040), Decimal(386).advanced(by: Decimal(67654)))
304306
expectEqual(Decimal(1.234), abs(Decimal(1.234)))
305307
expectEqual(Decimal(1.234), abs(Decimal(-1.234)))
306-
expectTrue(Decimal.nan.magnitude.isNaN)
308+
if #available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) {
309+
expectTrue(Decimal.nan.magnitude.isNaN)
310+
}
307311
var a = Decimal(1234)
308312
var r = a
309313
expectEqual(.noError, NSDecimalMultiplyByPowerOf10(&r, &a, 1, .plain))
@@ -335,7 +339,9 @@ class TestDecimal : TestDecimalSuper {
335339
expectEqual(.noError, NSDecimalPower(&result, &actual, j, .plain))
336340
let expected = Decimal(pow(Double(i), Double(j)))
337341
expectEqual(expected, result, "\(result) == \(i)^\(j)")
338-
expectEqual(expected, pow(actual, j))
342+
if #available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) {
343+
expectEqual(expected, pow(actual, j))
344+
}
339345
}
340346
}
341347
}

0 commit comments

Comments
 (0)