Bug 20049

Summary: testapi failure: MyObject - 0 should be NaN but instead is 1.
Product: WebKit Reporter: Alexey Proskuryakov <ap>
Component: JavaScriptCoreAssignee: Cameron Zwarich (cpst) <zwarich>
Status: RESOLVED FIXED    
Severity: Normal CC: sam, zwarich
Priority: P1 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: Mac   
OS: OS X 10.5   
Attachments:
Description Flags
Proposed patch oliver: review+

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.