Skip to content

Commit 52bb458

Browse files
committed
stdlib: floating point test: add a bitwise comparison assertion
1 parent fe5e1dc commit 52bb458

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

test/1_stdlib/FloatingPoint.swift.gyb

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33
// RUN: %S/../../utils/line-directive %t/FloatingPoint.swift -- %target-run %t/a.out
44
// REQUIRES: executable_test
55

6+
%{
7+
from gyb_stdlib_unittest_support import TRACE, stackTrace, trace
8+
}%
9+
610
import Swift
711
import StdlibUnittest
812

9-
1013
#if arch(i386) || arch(x86_64)
1114

1215
struct Float80Bits : Equatable, CustomStringConvertible {
@@ -51,6 +54,29 @@ extension Float80 {
5154

5255
#endif
5356

57+
% for (FloatTy, BitPatternTy) in [
58+
% ('Float', 'UInt32'),
59+
% ('Double', 'UInt64'),
60+
% ('Float80', 'Float80Bits')
61+
% ]:
62+
% if FloatTy == 'Float80':
63+
#if arch(i386) || arch(x86_64)
64+
% end
65+
func expectBitwiseEqual(
66+
_ expected: ${FloatTy}, _ actual: ${FloatTy}, ${TRACE}
67+
) {
68+
expectEqual(expected.bitPattern, actual.bitPattern, ${trace})
69+
}
70+
func expectBitwiseEqual(
71+
bitPattern expected: ${BitPatternTy}, _ actual: ${FloatTy}, ${TRACE}
72+
) {
73+
expectBitwiseEqual(${FloatTy}(bitPattern: expected), actual, ${trace})
74+
}
75+
% if FloatTy == 'Float80':
76+
#endif
77+
% end
78+
% end
79+
5480
var FloatingPoint = TestSuite("FloatingPoint")
5581

5682
func positiveOne<T: IntegerLiteralConvertible>() -> T {

0 commit comments

Comments
 (0)