If you think a bug might affect users in the 57 release, please set the correct tracking and status flags for Release Management.

NaN/Infinity.toExponential(...) should not check range

RESOLVED FIXED

Status

Rhino
Core
--
trivial
RESOLVED FIXED
9 years ago
9 years ago

People

(Reporter: mozilla, Assigned: Attila Szegedi)

Tracking

1.7R1
Other
Linux

Details

Attachments

(2 attachments)

(Reporter)

Description

9 years ago
according to 15.7.4.6 toExponential should verify the range only after it has verified that the number is neither NaN nor Infinity.
that is: Infinity.toExponential(-3) should not throw a RangeError.
(Assignee)

Comment 1

9 years ago
Created attachment 352565 [details] [diff] [review]
Patch that fixes the bug in both toExponential and toPrecision
Assignee: nobody → szegedia
Status: NEW → ASSIGNED
(Assignee)

Comment 2

9 years ago
Reviewing the specification, it seems that in addition to toExponential, toPrecision would also need to allow for both NaN and the two infinities to skip range check, and toPrecision also needs to handle undefined value for precision specially. 

Attached patch fixes all these problems.
(Assignee)

Comment 3

9 years ago
Created attachment 352573 [details] [diff] [review]
Extensions to ECMA testcases for toExponential and toPrecision

Added testcases
(Assignee)

Comment 4

9 years ago
Committed fixes to CVS:

***
cvs ci -m "Fix for #467276: NaN/Infinity.toExponential(...) should not check range" -l "/Rhino/src/org/mozilla/javascript/NativeNumber.java"
    Checking in src/org/mozilla/javascript/NativeNumber.java;
    /cvsroot/mozilla/js/rhino/src/org/mozilla/javascript/NativeNumber.java,v  <--  NativeNumber.java
    new revision: 1.42; previous revision: 1.41
    done
ok (took 0:01.410)
***

***
cvs ci -m "Adding testcases for NaN/Infinity.toExponential(...)/toPrecision() should not check range (see Bug #467276)" -l "/tests/ecma_3/Number/15.7.4.7-1.js" "/tests/ecma_3/Number/15.7.4.6-1.js"
    Checking in ecma_3/Number/15.7.4.6-1.js;
    /cvsroot/mozilla/js/tests/ecma_3/Number/15.7.4.6-1.js,v  <--  15.7.4.6-1.js
    new revision: 1.7; previous revision: 1.6
    done
    Checking in ecma_3/Number/15.7.4.7-1.js;
    /cvsroot/mozilla/js/tests/ecma_3/Number/15.7.4.7-1.js,v  <--  15.7.4.7-1.js
    new revision: 1.7; previous revision: 1.6
    done
ok (took 0:01.629)
***
Status: ASSIGNED → RESOLVED
Last Resolved: 9 years ago
Resolution: --- → FIXED

Comment 5

9 years ago
synced to mc: http://hg.mozilla.org/mozilla-central/rev/03d4e7eb5fcb

please get a review before checking in js tests or modifications. also, for the time being, please keep in sync with mozilla-central. thanks.

Updated

9 years ago
Blocks: 473575
You need to log in before you can comment on or make changes to this bug.