Bug 20049 - testapi failure: MyObject - 0 should be NaN but instead is 1.
Summary: testapi failure: MyObject - 0 should be NaN but instead is 1.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac OS X 10.5
: P1 Normal
Assignee: Cameron Zwarich (cpst)
URL:
Keywords: InRadar
: 18037 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-07-16 01:26 PDT by Alexey Proskuryakov
Modified: 2009-03-21 20:04 PDT (History)
2 users (show)

See Also:


Attachments
Proposed patch (1.30 KB, patch)
2009-02-25 23:56 PST, Cameron Zwarich (cpst)
oliver: 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 2008-07-16 01:26:38 PDT
Testapi is reporting a failure with r35197:

__FAIL__: MyObject - 0 should be NaN but instead is 1.
Comment 1 Alexey Proskuryakov 2008-07-16 01:27:41 PDT
<rdar://problem/6079127>
Comment 2 Cameron Zwarich (cpst) 2008-11-10 12:16:04 PST
*** Bug 18037 has been marked as a duplicate of this bug. ***
Comment 3 Cameron Zwarich (cpst) 2009-02-25 23:48:42 PST
I think the test result here is correct. In the ECMA spec, subtraction uses ToNumber, not ToPrimitive, but the test file says this, where the second test is the failing test:

shouldBe("+MyObject", 1); // toNumber
...
shouldBe("MyObject - 0", NaN); // toPrimitive

Addition uses ToPrimitive, and the result of the equivalent addition test may be wrong, but that's a different question.
Comment 4 Cameron Zwarich (cpst) 2009-02-25 23:56:03 PST
Created attachment 28007 [details]
Proposed patch
Comment 5 Oliver Hunt 2009-03-21 19:24:05 PDT
Comment on attachment 28007 [details]
Proposed patch

r=me, but i'd really like it if we could come up with something that would attempt a toPrimitive conversion -- possibly another custom object?
Comment 6 Cameron Zwarich (cpst) 2009-03-21 20:04:38 PDT
Fixed in r41896. I agree with your comment, Oliver.