@@ -242,13 +242,16 @@ class TestNSNumberBridging : XCTestCase {
242
242
XCTAssertEqual ( Int ( exactly: interestingValue) , int)
243
243
let uint = UInt ( exactly: number!)
244
244
XCTAssertEqual ( UInt ( exactly: interestingValue) , uint)
245
+
245
246
let float = Float ( exactly: number!)
246
247
let expectedFloat = Float ( exactly: int32!)
247
- // these are disabled because of https://bugs.swift.org/browse/SR-4634
248
- if ( int32! != Int32 . min && int32! != Int32 . max &&
249
- int32! != Int32 . min + 1 && int32! != Int32 . max - 1 ) {
248
+ if int32! > Int32 . min + 1 && int32! < Int32 . max - 1 {
250
249
testFloat ( expectedFloat, float)
250
+ } else {
251
+ XCTAssertNil ( float)
252
+ XCTAssertNil ( expectedFloat)
251
253
}
254
+
252
255
let double = Double ( exactly: number!)
253
256
let expectedDouble = Double ( exactly: int32!)
254
257
testDouble ( expectedDouble, double)
@@ -284,12 +287,16 @@ class TestNSNumberBridging : XCTestCase {
284
287
XCTAssertEqual ( Int ( exactly: interestingValue) , int)
285
288
let uint = UInt ( exactly: number!)
286
289
XCTAssertEqual ( UInt ( exactly: interestingValue) , uint)
290
+
287
291
let float = Float ( exactly: number!)
288
292
let expectedFloat = Float ( exactly: uint32!)
289
- // these are disabled because of https://bugs.swift.org/browse/SR-4634
290
- if ( uint32! != UInt32 . max && uint32! != UInt32 . max - 1 ) {
293
+ if uint32! < UInt32 . max - 1 {
291
294
testFloat ( expectedFloat, float)
295
+ } else {
296
+ XCTAssertNil ( float)
297
+ XCTAssertNil ( expectedFloat)
292
298
}
299
+
293
300
let double = Double ( exactly: number!)
294
301
let expectedDouble = Double ( exactly: uint32!)
295
302
testDouble ( expectedDouble, double)
@@ -325,10 +332,16 @@ class TestNSNumberBridging : XCTestCase {
325
332
XCTAssertEqual ( Int ( exactly: interestingValue) , int)
326
333
let uint = UInt ( exactly: number!)
327
334
XCTAssertEqual ( UInt ( exactly: interestingValue) , uint)
335
+
328
336
let float = Float ( exactly: number!)
329
- XCTAssertEqual ( Float ( interestingValue) , float)
330
337
let double = Double ( exactly: number!)
331
- XCTAssertEqual ( Double ( interestingValue) , double)
338
+ if int64! > Int64 . min + 1 && int64! < Int64 . max - 1 {
339
+ XCTAssertEqual ( Float ( interestingValue) , float)
340
+ XCTAssertEqual ( Double ( interestingValue) , double)
341
+ } else {
342
+ XCTAssertNil ( float)
343
+ XCTAssertNil ( double)
344
+ }
332
345
}
333
346
let bridged = interestingValue. _bridgeToObjectiveC ( )
334
347
testNumber ( bridged)
@@ -361,10 +374,16 @@ class TestNSNumberBridging : XCTestCase {
361
374
XCTAssertEqual ( Int ( exactly: interestingValue) , int)
362
375
let uint = UInt ( exactly: number!)
363
376
XCTAssertEqual ( UInt ( exactly: interestingValue) , uint)
377
+
364
378
let float = Float ( exactly: number!)
365
- XCTAssertEqual ( Float ( interestingValue) , float)
366
379
let double = Double ( exactly: number!)
367
- XCTAssertEqual ( Double ( interestingValue) , double)
380
+ if uint64! < UInt64 . max - 1 {
381
+ XCTAssertEqual ( Float ( interestingValue) , float)
382
+ XCTAssertEqual ( Double ( interestingValue) , double)
383
+ } else {
384
+ XCTAssertNil ( float)
385
+ XCTAssertNil ( double)
386
+ }
368
387
}
369
388
let bridged = interestingValue. _bridgeToObjectiveC ( )
370
389
testNumber ( bridged)
@@ -397,10 +416,16 @@ class TestNSNumberBridging : XCTestCase {
397
416
XCTAssertEqual ( Int ( exactly: interestingValue) , int)
398
417
let uint = UInt ( exactly: number!)
399
418
XCTAssertEqual ( UInt ( exactly: interestingValue) , uint)
419
+
400
420
let float = Float ( exactly: number!)
401
- XCTAssertEqual ( Float ( interestingValue) , float)
402
421
let double = Double ( exactly: number!)
403
- XCTAssertEqual ( Double ( interestingValue) , double)
422
+ if int! > Int . min + 1 && int! < Int . max - 1 {
423
+ XCTAssertEqual ( Float ( interestingValue) , float)
424
+ XCTAssertEqual ( Double ( interestingValue) , double)
425
+ } else {
426
+ XCTAssertNil ( float)
427
+ XCTAssertNil ( double)
428
+ }
404
429
}
405
430
let bridged = interestingValue. _bridgeToObjectiveC ( )
406
431
testNumber ( bridged)
@@ -433,10 +458,16 @@ class TestNSNumberBridging : XCTestCase {
433
458
XCTAssertEqual ( Int ( exactly: interestingValue) , int)
434
459
let uint = UInt ( exactly: number!)
435
460
XCTAssertEqual ( UInt ( exactly: interestingValue) , uint)
461
+
436
462
let float = Float ( exactly: number!)
437
- XCTAssertEqual ( Float ( interestingValue) , float)
438
463
let double = Double ( exactly: number!)
439
- XCTAssertEqual ( Double ( interestingValue) , double)
464
+ if uint! < UInt . max - 1 {
465
+ XCTAssertEqual ( Float ( interestingValue) , float)
466
+ XCTAssertEqual ( Double ( interestingValue) , double)
467
+ } else {
468
+ XCTAssertNil ( float)
469
+ XCTAssertNil ( double)
470
+ }
440
471
}
441
472
let bridged = interestingValue. _bridgeToObjectiveC ( )
442
473
testNumber ( bridged)
0 commit comments