1
- // RUN: rm -rf %t &&mkdir %t
1
+ // RUN: rm -rf %t && mkdir %t
2
2
// RUN: cp %s %t/main.swift
3
3
4
4
// RUN: echo "typealias TestFloat = Float" > %t/float_type.swift
5
5
// RUN: %target-build-swift %t/main.swift %t/float_type.swift -o %t/float.out
6
- // RUN: %target-run %t/float.out | FileCheck %s
6
+ // RUN: %target-run %t/float.out
7
7
8
8
// RUN: echo "typealias TestFloat = Double" > %t/double_type.swift
9
9
// RUN: %target-build-swift %t/main.swift %t/double_type.swift -o %t/double.out
10
- // RUN: %target-run %t/double.out | FileCheck %s
10
+ // RUN: %target-run %t/double.out
11
11
// REQUIRES: executable_test
12
12
13
+ import StdlibUnittest
14
+
15
+ var FloatTests = TestSuite ( " Float " )
16
+
13
17
//===---
14
18
// Helpers
15
19
//===---
@@ -36,7 +40,7 @@ func checkNormal(_ normal: TestFloat) {
36
40
_precondition ( !normal. isSignalingNaN)
37
41
}
38
42
39
- func testNormal ( ) {
43
+ FloatTests . test ( " normal " ) {
40
44
let positiveNormal : TestFloat = 42.0
41
45
checkNormal ( positiveNormal)
42
46
_precondition ( positiveNormal. sign == . plus)
@@ -53,11 +57,7 @@ func testNormal() {
53
57
_precondition ( negativeNormal != positiveNormal)
54
58
_precondition ( positiveNormal == - negativeNormal)
55
59
_precondition ( negativeNormal == - positiveNormal)
56
-
57
- print ( " testNormal done " )
58
60
}
59
- testNormal ( )
60
- // CHECK: testNormal done
61
61
62
62
//===---
63
63
// Zeroes
@@ -73,7 +73,7 @@ func checkZero(_ zero: TestFloat) {
73
73
_precondition ( !zero. isSignalingNaN)
74
74
}
75
75
76
- func testZero ( ) {
76
+ FloatTests . test ( " zero " ) {
77
77
let plusZero = noinlinePlusZero ( )
78
78
checkZero ( plusZero)
79
79
_precondition ( plusZero. sign == . plus)
@@ -90,11 +90,7 @@ func testZero() {
90
90
_precondition ( minusZero == - 0.0 )
91
91
_precondition ( minusZero == plusZero)
92
92
_precondition ( minusZero == minusZero)
93
-
94
- print ( " testZero done " )
95
93
}
96
- testZero ( )
97
- // CHECK: testZero done
98
94
99
95
//===---
100
96
// Subnormals
@@ -118,7 +114,8 @@ func asUInt64(_ a: UInt32) -> UInt64 {
118
114
return UInt64 ( a)
119
115
}
120
116
121
- func testSubnormal( ) {
117
+ #if !arch(arm)
118
+ FloatTests . test ( " subnormal " ) {
122
119
var iterations : Int
123
120
switch asUInt64 ( TestFloat . RawSignificand. max) {
124
121
case UInt64 . max:
@@ -145,16 +142,8 @@ func testSubnormal() {
145
142
_precondition ( negativeSubnormal. sign == . minus)
146
143
_precondition ( negativeSubnormal. floatingPointClass == . negativeSubnormal)
147
144
_precondition ( negativeSubnormal != - 0.0 )
148
-
149
- print ( " testSubnormal done " )
150
145
}
151
-
152
- #if arch(arm)
153
- print ( " testSubnormal done " )
154
- #else
155
- testSubnormal ( )
156
146
#endif
157
- // CHECK: testSubnormal done
158
147
159
148
//===---
160
149
// Infinities
@@ -170,7 +159,7 @@ func checkInf(_ inf: TestFloat) {
170
159
_precondition ( !inf. isSignalingNaN)
171
160
}
172
161
173
- func testInf ( ) {
162
+ FloatTests . test ( " infinity " ) {
174
163
var stdlibPlusInf = TestFloat . infinity
175
164
checkInf ( stdlibPlusInf)
176
165
_precondition ( stdlibPlusInf. sign == . plus)
@@ -196,11 +185,7 @@ func testInf() {
196
185
197
186
_precondition ( stdlibPlusInf != computedMinusInf)
198
187
_precondition ( stdlibMinusInf != computedPlusInf)
199
-
200
- print ( " testInf done " )
201
188
}
202
- testInf ( )
203
- // CHECK: testInf done
204
189
205
190
//===---
206
191
// NaNs
@@ -231,7 +216,7 @@ func checkSNaN(_ snan: TestFloat) {
231
216
#endif
232
217
}
233
218
234
- func testNaN ( ) {
219
+ FloatTests . test ( " nan " ) {
235
220
var stdlibDefaultNaN = TestFloat . nan
236
221
checkQNaN ( stdlibDefaultNaN)
237
222
@@ -240,11 +225,7 @@ func testNaN() {
240
225
241
226
var stdlibSNaN = TestFloat . signalingNaN
242
227
checkSNaN ( stdlibSNaN)
243
- print ( " testNaN done " )
244
228
}
245
- testNaN ( )
246
- // CHECK: testNaN done
247
229
248
- print ( " all done. " )
249
- // CHECK: all done.
230
+ runAllTests ( )
250
231
0 commit comments