Bug 12961

Summary: shouldBe() should support NaN
Product: WebKit Reporter: Alexey Proskuryakov <ap>
Component: Tools / TestsAssignee: Alexey Proskuryakov <ap>
Status: RESOLVED FIXED    
Severity: Normal CC: zimmermann
Priority: P2    
Version: 523.x (Safari 3)   
Hardware: Mac   
OS: OS X 10.4   
Bug Depends on:    
Bug Blocks: 12953    
Attachments:
Description Flags
proposed patch darin: review+

Description Alexey Proskuryakov 2007-03-04 00:33:36 PST
Currently, JS shouldBe() tests don't work with NaN results, because NaN != NaN. Patch forthcoming.
Comment 1 Alexey Proskuryakov 2007-03-04 00:35:51 PST
Created attachment 13468 [details]
proposed patch
Comment 2 Nikolas Zimmermann 2007-03-04 03:53:54 PST
Looks fine, though what is the "===" operator? (you didn't add it - just wondering though...)

-  else if (_av === _bv)
+  else if (_av === _bv || (typeof(_av) == "number" && typeof(_bv) == "number" && isNaN(_av) && isNaN(_bv)))

Niko

Comment 3 David Kilzer (:ddkilzer) 2007-03-04 07:05:44 PST
(In reply to comment #2)
> Looks fine, though what is the "===" operator? (you didn't add it - just
> wondering though...)

It's the identity (strict equality) operator.  There is also a "not identity" operator: !==

http://www.webreference.com/js/tips/991205.html

Comment 4 Darin Adler 2007-03-04 21:56:00 PST
Comment on attachment 13468 [details]
proposed patch

r=me
Comment 5 Alexey Proskuryakov 2007-03-04 22:31:54 PST
Committed revision 19959.