11
11
import StdlibUnittest
12
12
13
13
%{
14
-
15
- floatNameToSignificandBits = { 'Float32':24, 'Float64':53, 'Float80':64 }
16
-
14
+ from SwiftFloatingPointTypes import all_floating_point_types
17
15
}%
18
16
19
17
var FloatingPointConversionTruncations = TestSuite("FloatingPointToFloatingPointConversionTruncations")
20
18
var FloatingPointConversionFailures = TestSuite("FloatingPointToFloatingPointConversionFailures")
21
19
22
- % for Self, selfSignificandBits in floatNameToSignificandBits.iteritems():
20
+ % for self_type in all_floating_point_types():
21
+ % SelfSignificandBits = self_type.bits
22
+ % Self = self_type.stdlib_name
23
23
24
24
% if Self == 'Float80':
25
- #if arch(i386) || arch(x86_64)
25
+ #if !os(Windows) && ( arch(i386) || arch(x86_64) )
26
26
% end
27
27
28
- % for OtherFloat, otherSignificandBits in floatNameToSignificandBits.iteritems():
28
+ % for other_type in all_floating_point_types():
29
+ % OtherSignificandBits = other_type.bits
30
+ % OtherFloat = other_type.stdlib_name
29
31
30
32
% if OtherFloat == 'Float80':
31
- #if arch(i386) || arch(x86_64)
33
+ #if !os(Windows) && ( arch(i386) || arch(x86_64) )
32
34
% end
33
35
34
- % if otherSignificandBits <= selfSignificandBits :
36
+ % if OtherSignificandBits <= SelfSignificandBits :
35
37
36
38
FloatingPointConversionTruncations.test("${OtherFloat}To${Self}Conversion")
37
39
.forEach(in: [
@@ -85,7 +87,7 @@ FloatingPointConversionFailures.test("${OtherFloat}To${Self}FailableConversion")
85
87
]) {
86
88
input in
87
89
let result = ${Self}(exactly: input)
88
- % if otherSignificandBits <= selfSignificandBits :
90
+ % if OtherSignificandBits <= SelfSignificandBits :
89
91
if let result = expectNotEmpty(result) {
90
92
// FIXME: we should have a stronger postcondition here.
91
93
expectEqual(input, ${OtherFloat}(result))
@@ -107,12 +109,12 @@ FloatingPointConversionFailures.test("${OtherFloat}To${Self}Conversion/AlwaysSuc
107
109
#endif
108
110
% end
109
111
110
- % end # for in floatNameToSignificandBits (Other)
112
+ % end # for in all_floating_point_types (Other)
111
113
112
114
% if Self == 'Float80':
113
115
#endif
114
116
% end
115
117
116
- % end # for in floatNameToSignificandBits (Self)
118
+ % end # for in all_floating_point_types (Self)
117
119
118
120
runAllTests()
0 commit comments