Closed Bug 467276 Opened 16 years ago Closed 16 years ago

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

Categories

(Rhino Graveyard :: Core, defect)

1.7R1
Other
Linux
defect
Not set
trivial

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: mozilla, Assigned: szegedia)

References

Details

Attachments

(2 files)

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: nobody → szegedia
Status: NEW → ASSIGNED
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.
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
Closed: 16 years ago
Resolution: --- → FIXED
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.
Blocks: 473575
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: