Closed
Bug 411893
Opened 17 years ago
Closed 17 years ago
num.toPrecision(undefined) !== num.toString()
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
VERIFIED
FIXED
People
(Reporter: Waldo, Assigned: Waldo)
References
Details
Attachments
(2 files)
869 bytes,
patch
|
crowderbt
:
review+
brendan
:
approval1.9+
|
Details | Diff | Splinter Review |
2.44 KB,
text/plain
|
bc
:
review+
|
Details |
As it turns out, looking at the spec sez it makes the most sense to special-case this before calling the num_to workhorse.
Attachment #296518 -
Flags: review?(crowder)
Updated•17 years ago
|
Attachment #296518 -
Flags: review?(crowder) → review+
Updated•17 years ago
|
Attachment #296518 -
Flags: approval1.9+
Assignee | ||
Comment 1•17 years ago
|
||
No idea where this goes in the test suite, and untested, but probably correct...
Attachment #296619 -
Flags: review?(bclary)
Assignee | ||
Comment 2•17 years ago
|
||
Fixed on trunk.
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
Updated•17 years ago
|
Attachment #296619 -
Attachment mime type: application/x-javascript → text/plain
Comment 3•17 years ago
|
||
Comment on attachment 296619 [details]
Untested testcase
Go ahead and add yourself as the contributor.
...
>var gTestfile = 'toPrecision-undefined-check.js';
use the section and a numeric suffix for the file name for tests that are
easily mapped to the ecma 262-3 spec. Normally I try to use a 2 digit suffix
but there is already an old test with a single digit, so keeping in tune with
that.
e.g. 15.7.4.7-2.js
the file should be ecma_3/Number/15.7.4.7-2.js
>//-----------------------------------------------------------------------------
>var BUGNUMBER = "(none)";
use 411893 as the bugnumber
>var summary = "num.toPrecision(undefined) should equal num.toString()";
>var actual, expect;
>
>printBugNumber(BUGNUMBER);
>printStatus(summary);
>
>/**************
> * BEGIN TEST *
> **************/
>
>var failed = false;
>
>try
>{
> var prec = 3.3.toPrecision(undefined);
> var str = 3.3.toString();
I'm a 'little' concerned that it might be possible someday for 3.3.toString
to fail in the same way as 3.3.toPrecision which this comparison wouldn't catch,
but that is probably just paranoia.
> if (prec !== str)
> {
> throw "not equal! " +
> "3.3.toPrecision(undefined) === '" + prec + "', " +
> "3.3.toString() === '" + str + "'";
> }
>}
>catch (e)
>{
> failed = e;
>}
>
>
>
only need one blank line here.
>expect = false;
>actual = failed;
>
>reportCompare(expect, actual, summary);
test passes current trunk as well as the branch.
r+ with those nits picked. Thanks Waldo!
Attachment #296619 -
Flags: review?(bclary) → review+
Assignee | ||
Comment 4•17 years ago
|
||
(In reply to comment #3)
> > var prec = 3.3.toPrecision(undefined);
> > var str = 3.3.toString();
>
> I'm a 'little' concerned that it might be possible someday for 3.3.toString
> to fail in the same way as 3.3.toPrecision which this comparison wouldn't
> catch, but that is probably just paranoia.
That's not a problem, because the spec says that toPrecision with a first argument with value undefined is equivalent to ToString(this primitive number), which is what Number.prototype.toString is defined as in the spec with an undefined first argument.
Comment 5•17 years ago
|
||
/cvsroot/mozilla/js/tests/ecma_3/Number/15.7.4.7-2.js
initial revision: 1.1
Flags: in-testsuite+
Flags: in-litmus-
You need to log in
before you can comment on or make changes to this bug.
Description
•