Skip to content

Commit 480361b

Browse files
committed
[test] move test to a file requiring the full stdlib
- SIMD types are not available in the minimal stdlib
1 parent 4967854 commit 480361b

File tree

2 files changed

+42
-29
lines changed

2 files changed

+42
-29
lines changed

test/stdlib/UnsafeRawPointer.swift

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -114,35 +114,6 @@ UnsafeMutableRawPointerExtraTestSuite.test("load.unaligned")
114114
expectEqual(result, 0xffff_0000)
115115
}
116116

117-
UnsafeMutableRawPointerExtraTestSuite.test("load.unaligned.SIMD")
118-
.skip(.custom({
119-
if #available(SwiftStdlib 5.7, *) { return false }
120-
return true
121-
}, reason: "Requires Swift 5.7's stdlib"))
122-
.code {
123-
guard #available(SwiftStdlib 5.7, *) else { return }
124-
var bytes: [UInt8] = Array(0..<64)
125-
var offset = 3
126-
let vector16 = bytes.withUnsafeBytes { buffer -> SIMD16<UInt8> in
127-
let aligned = buffer.baseAddress!.alignedUp(for: SIMD16<UInt8>.self)
128-
offset += buffer.baseAddress!.distance(to: aligned)
129-
return buffer.loadUnaligned(fromByteOffset: offset, as: SIMD16<UInt8>.self)
130-
}
131-
expectEqual(Int(vector16[0]), offset)
132-
var lastIndex = vector16.indices.last!
133-
expectEqual(Int(vector16[lastIndex]), offset+lastIndex)
134-
135-
offset = 11
136-
let vector32 = bytes.withUnsafeMutableBytes { buffer -> SIMD32<UInt8> in
137-
let aligned = buffer.baseAddress!.alignedUp(for: SIMD32<UInt8>.self)
138-
offset += buffer.baseAddress!.distance(to: aligned)
139-
return buffer.loadUnaligned(fromByteOffset: offset, as: SIMD32<UInt8>.self)
140-
}
141-
expectEqual(Int(vector32[0]), offset)
142-
lastIndex = vector32.indices.last!
143-
expectEqual(Int(vector32[lastIndex]), offset+lastIndex)
144-
}
145-
146117
UnsafeMutableRawPointerExtraTestSuite.test("load.invalid")
147118
.skip(.custom({ !_isDebugAssertConfiguration() },
148119
reason: "This tests a debug precondition.."))
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// RUN: %target-build-swift %s -parse-stdlib -Xfrontend -disable-access-control -o %t.out
2+
// RUN: %target-codesign %t.out
3+
// RUN: %target-run %t.out
4+
// REQUIRES: executable_test
5+
// UNSUPPORTED: freestanding
6+
7+
import Swift
8+
import StdlibUnittest
9+
10+
var UnsafeRawPointerTestSuite =
11+
TestSuite("UnsafeRawPointerTestSuite")
12+
13+
UnsafeRawPointerTestSuite.test("load.unaligned.SIMD")
14+
.skip(.custom({
15+
if #available(SwiftStdlib 5.7, *) { return false }
16+
return true
17+
}, reason: "Requires Swift 5.7's stdlib"))
18+
.code {
19+
guard #available(SwiftStdlib 5.7, *) else { return }
20+
var bytes: [UInt8] = Array(0..<64)
21+
var offset = 3
22+
let vector16 = bytes.withUnsafeBytes { buffer -> SIMD16<UInt8> in
23+
let aligned = buffer.baseAddress!.alignedUp(for: SIMD16<UInt8>.self)
24+
offset += buffer.baseAddress!.distance(to: aligned)
25+
return buffer.loadUnaligned(fromByteOffset: offset, as: SIMD16<UInt8>.self)
26+
}
27+
expectEqual(Int(vector16[0]), offset)
28+
var lastIndex = vector16.indices.last!
29+
expectEqual(Int(vector16[lastIndex]), offset+lastIndex)
30+
31+
offset = 11
32+
let vector32 = bytes.withUnsafeMutableBytes { buffer -> SIMD32<UInt8> in
33+
let aligned = buffer.baseAddress!.alignedUp(for: SIMD32<UInt8>.self)
34+
offset += buffer.baseAddress!.distance(to: aligned)
35+
return buffer.loadUnaligned(fromByteOffset: offset, as: SIMD32<UInt8>.self)
36+
}
37+
expectEqual(Int(vector32[0]), offset)
38+
lastIndex = vector32.indices.last!
39+
expectEqual(Int(vector32[lastIndex]), offset+lastIndex)
40+
}
41+
42+
runAllTests()

0 commit comments

Comments
 (0)