1
1
// RUN: %target-run-simple-swift
2
2
// REQUIRES: executable_test
3
+ // UNSUPPORTED: use_os_stdlib
3
4
4
5
// rdar://77087867
5
6
// UNSUPPORTED: CPU=arm64_32 && OS=watchos
10
11
import StdlibUnittest
11
12
12
13
let PrintTests = TestSuite ( " FloatingPointPrinting " )
13
- //
14
- // // An earlier version of Swift's floating-point `.description` logic
15
- // // used potentially locale-sensitive C library functions, hence
16
- // // this logic to help verify that the output does not depend on
17
- // // the C locale.
18
- // PrintTests.setUp {
19
- // if let localeArgIndex = CommandLine.arguments.firstIndex(of: "--locale") {
20
- // let locale = CommandLine.arguments[localeArgIndex + 1]
21
- // expectEqual("ru_RU.UTF-8", locale)
22
- // setlocale(LC_ALL, locale)
23
- // } else {
24
- // setlocale(LC_ALL, "")
25
- // }
26
- // }
27
14
28
15
// Check that all floating point types
29
16
// are CustomStringConvertible
30
17
PrintTests . test ( " CustomStringConvertible " ) {
31
18
func hasDescription( _ any: Any ) {
32
19
expectTrue ( any is CustomStringConvertible )
33
20
}
34
- if #available( SwiftStdlib 6 . 0 , * ) {
21
+ #if !((os(macOS) || targetEnvironment(macCatalyst)) && arch(x86_64))
22
+ if #available( SwiftStdlib 5 . 3 , * ) {
35
23
hasDescription ( Float16 ( 1.0 ) )
36
24
hasDescription ( CFloat16 ( 1.0 ) )
37
25
}
26
+ #endif
38
27
hasDescription ( Float ( 1.0 ) )
39
28
hasDescription ( Double ( 1.0 ) )
40
29
#if !os(Windows) && (arch(i386) || arch(x86_64))
@@ -50,10 +39,12 @@ PrintTests.test("CustomDebugStringConvertible") {
50
39
func hasDebugDescription( _ any: Any ) {
51
40
expectTrue ( any is CustomDebugStringConvertible )
52
41
}
53
- if #available( SwiftStdlib 6 . 0 , * ) {
42
+ #if !((os(macOS) || targetEnvironment(macCatalyst)) && arch(x86_64))
43
+ if #available( SwiftStdlib 5 . 3 , * ) {
54
44
hasDebugDescription ( Float16 ( 1.0 ) )
55
45
hasDebugDescription ( CFloat16 ( 1.0 ) )
56
46
}
47
+ #endif
57
48
hasDebugDescription ( Float ( 1.0 ) )
58
49
hasDebugDescription ( Double ( 1.0 ) )
59
50
#if !os(Windows) && (arch(i386) || arch(x86_64))
@@ -63,11 +54,8 @@ PrintTests.test("CustomDebugStringConvertible") {
63
54
hasDebugDescription ( CDouble ( 1.0 ) )
64
55
}
65
56
66
- #if (os(macOS) || targetEnvironment(macCatalyst)) && arch(x86_64)
67
- @available ( SwiftStdlib 6 . 0 , * ) // Float16/intel
68
- #else
57
+ #if !((os(macOS) || targetEnvironment(macCatalyst)) && arch(x86_64))
69
58
@available ( SwiftStdlib 5 . 8 , * ) // Regex
70
- #endif
71
59
func testFinite( _ bitPattern: UInt16 ) {
72
60
let value = Float16 ( bitPattern: bitPattern)
73
61
let string = value. description
@@ -124,13 +112,11 @@ func testFinite(_ bitPattern: UInt16) {
124
112
)
125
113
}
126
114
}
115
+ #endif
127
116
128
117
PrintTests . test ( " Printable_Float16 " ) {
129
- #if (os(macOS) || targetEnvironment(macCatalyst)) && arch(x86_64)
130
- guard #available( SwiftStdlib 6 . 0 , * ) else { return } // Float16/intel
131
- #else
118
+ #if !((os(macOS) || targetEnvironment(macCatalyst)) && arch(x86_64))
132
119
guard #available( SwiftStdlib 5 . 8 , * ) else { return } // Regex
133
- #endif
134
120
for bitPattern in UInt16 . zero ..< 0x7c00 {
135
121
testFinite ( bitPattern)
136
122
testFinite ( 0x8000 | bitPattern)
@@ -158,6 +144,7 @@ PrintTests.test("Printable_Float16") {
158
144
expectEqual ( Float16 ( bitPattern: bitPattern) . debugDescription, expected)
159
145
expectEqual ( Float16 ( bitPattern: 0x8000 | bitPattern) . debugDescription, " - \( expected) " )
160
146
}
147
+ #endif
161
148
}
162
149
163
150
runAllTests ( )
0 commit comments