Skip to content

Commit 4caf64a

Browse files
ultramiraculousChris Williams
authored andcommitted
Have FloatingPointConversion use float helper methods
1 parent 71f6b8a commit 4caf64a

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

validation-test/stdlib/FloatingPointConversion.swift.gyb

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,29 @@
1111
import StdlibUnittest
1212

1313
%{
14-
15-
floatNameToSignificandBits = { 'Float32':24, 'Float64':53, 'Float80':64 }
16-
14+
from SwiftFloatingPointTypes import all_floating_point_types
1715
}%
1816

1917
var FloatingPointConversionTruncations = TestSuite("FloatingPointToFloatingPointConversionTruncations")
2018
var FloatingPointConversionFailures = TestSuite("FloatingPointToFloatingPointConversionFailures")
2119

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
2323

2424
% if Self == 'Float80':
25-
#if arch(i386) || arch(x86_64)
25+
#if !os(Windows) && (arch(i386) || arch(x86_64))
2626
% end
2727

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
2931

3032
% if OtherFloat == 'Float80':
31-
#if arch(i386) || arch(x86_64)
33+
#if !os(Windows) && (arch(i386) || arch(x86_64))
3234
% end
3335

34-
% if otherSignificandBits <= selfSignificandBits:
36+
% if OtherSignificandBits <= SelfSignificandBits:
3537

3638
FloatingPointConversionTruncations.test("${OtherFloat}To${Self}Conversion")
3739
.forEach(in: [
@@ -85,7 +87,7 @@ FloatingPointConversionFailures.test("${OtherFloat}To${Self}FailableConversion")
8587
]) {
8688
input in
8789
let result = ${Self}(exactly: input)
88-
% if otherSignificandBits <= selfSignificandBits:
90+
% if OtherSignificandBits <= SelfSignificandBits:
8991
if let result = expectNotEmpty(result) {
9092
// FIXME: we should have a stronger postcondition here.
9193
expectEqual(input, ${OtherFloat}(result))
@@ -107,12 +109,12 @@ FloatingPointConversionFailures.test("${OtherFloat}To${Self}Conversion/AlwaysSuc
107109
#endif
108110
% end
109111

110-
% end # for in floatNameToSignificandBits (Other)
112+
% end # for in all_floating_point_types (Other)
111113

112114
% if Self == 'Float80':
113115
#endif
114116
% end
115117

116-
% end # for in floatNameToSignificandBits (Self)
118+
% end # for in all_floating_point_types (Self)
117119

118120
runAllTests()

0 commit comments

Comments
 (0)