Once upon a Time, there could have been a literal nan... Yes, in Squeak 3.8 or 3.9 when formed thru ('0.' , (String new: 320 withAll: $0) , '1e321') - see http://bugs.squeak.org/view.php?id=6982 Let's consider this case rare and accidental... Now, even if literalEqualityOfNan is a bit like unreachable, let's consider this as a future proof test...
2014-10-27 21:53 GMT+01:00 commits@source.squeak.org:
Nicolas Cellier uploaded a new version of KernelTests to project The Trunk: http://source.squeak.org/trunk/KernelTests-nice.280.mcz
==================== Summary ====================
Name: KernelTests-nice.280 Author: nice Time: 27 October 2014, 9:53:44.861 pm UUID: fc50e9f5-10d8-45d8-8c9e-e80806596878 Ancestors: KernelTests-dtl.279
Two more expectations for float literal equality:
- zero and negativeZero are equal but not #literalEqual:
- nan are not equals but can be #literalEqual:
Thanks to Kris Gybels for reporting this case at https://pharo.fogbugz.com/f/cases/14316/
=============== Diff against KernelTests-dtl.279 ===============
Item was added:
- ----- Method: FloatTest>>testLiteralEqualityOfNan (in category 'testing
compare') -----
- testLiteralEqualityOfNan
| nan |
nan := Float nan.
self assert: (nan literalEqual: nan)
description: 'Float nan is not equal to itself, though it
is literally equal'.!
Item was added:
- ----- Method: FloatTest>>testLiteralEqualityOfZeroAndNegativeZero (in
category 'testing compare') -----
- testLiteralEqualityOfZeroAndNegativeZero
self assert: -1
equals: (Compiler evaluate: '1>2 ifTrue: [0.0] ifFalse:
[-0.0]') sign
description: 'Float zero and negativeZero are not
literally substituable'.!
squeak-dev@lists.squeakfoundation.org