[stdlib] Fix FloatingPoint.init(exactly:) (#11311)

* [stdlib] Fix FloatingPoint.init(exactly:)

This initializer wasn't actually checking the exact conversion. Corrects
the tests as well.
This commit is contained in:
Nate Cook
2017-10-17 13:52:11 -05:00
committed by GitHub
parent b571dd8e8e
commit c9f4df84f6
4 changed files with 47 additions and 79 deletions

View File

@@ -652,16 +652,12 @@ func testNSNumberBridgeFromUInt() {
let uint = (number!) as? UInt
expectEqual(UInt(exactly: interestingValue), uint)
// these are disabled because of https://bugs.swift.org/browse/SR-4634
if uint! != UInt(UInt32.max) && uint! != UInt(UInt32.max - 1) {
let float = (number!) as? Float
let expectedFloat = Float(uint!)
testFloat(expectedFloat, float)
}
let float = (number!) as? Float
let expectedFloat = Float(exactly: uint!)
testFloat(expectedFloat, float)
let double = (number!) as? Double
let expectedDouble = Double(uint!)
let expectedDouble = Double(exactly: uint!)
testDouble(expectedDouble, double)
}
let bridged = interestingValue as NSNumber