michael@0: /* michael@0: * Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommonn.org/licenses/publicdomain/ michael@0: */ michael@0: michael@0: var BUGNUMBER = 795745; michael@0: var summary = michael@0: "Number.prototype.to* should throw a RangeError when passed a bad precision"; michael@0: michael@0: print(BUGNUMBER + ": " + summary); michael@0: michael@0: /************** michael@0: * BEGIN TEST * michael@0: **************/ michael@0: michael@0: function test(method, prec) michael@0: { michael@0: try michael@0: { michael@0: Number.prototype[method].call(0, prec); michael@0: throw "should have thrown"; michael@0: } michael@0: catch (e) michael@0: { michael@0: assertEq(e instanceof RangeError, true, michael@0: "expected RangeError for " + method + " with precision " + prec + michael@0: ", got " + e); michael@0: } michael@0: } michael@0: michael@0: test("toExponential", -32); michael@0: test("toFixed", -32); michael@0: test("toPrecision", -32); michael@0: michael@0: test("toExponential", 9999999); michael@0: test("toFixed", 9999999); michael@0: test("toPrecision", 9999999); michael@0: michael@0: test("toPrecision", 0); michael@0: michael@0: /******************************************************************************/ michael@0: michael@0: if (typeof reportCompare === "function") michael@0: reportCompare(true, true); michael@0: michael@0: print("Tests complete");