Bug 12961 - shouldBe() should support NaN
Summary: shouldBe() should support NaN
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: 523.x (Safari 3)
Hardware: Mac OS X 10.4
: P2 Normal
Assignee: Alexey Proskuryakov
URL:
Keywords:
Depends on:
Blocks: 12953
  Show dependency treegraph
 
Reported: 2007-03-04 00:33 PST by Alexey Proskuryakov
Modified: 2007-03-04 22:31 PST (History)
1 user (show)

See Also:


Attachments
proposed patch (1.18 KB, patch)
2007-03-04 00:35 PST, Alexey Proskuryakov
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.