Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* |
michael@0 | 2 | * Any copyright is dedicated to the Public Domain. |
michael@0 | 3 | * http://creativecommonn.org/licenses/publicdomain/ |
michael@0 | 4 | */ |
michael@0 | 5 | |
michael@0 | 6 | var BUGNUMBER = 795745; |
michael@0 | 7 | var summary = |
michael@0 | 8 | "Number.prototype.to* should throw a RangeError when passed a bad precision"; |
michael@0 | 9 | |
michael@0 | 10 | print(BUGNUMBER + ": " + summary); |
michael@0 | 11 | |
michael@0 | 12 | /************** |
michael@0 | 13 | * BEGIN TEST * |
michael@0 | 14 | **************/ |
michael@0 | 15 | |
michael@0 | 16 | function test(method, prec) |
michael@0 | 17 | { |
michael@0 | 18 | try |
michael@0 | 19 | { |
michael@0 | 20 | Number.prototype[method].call(0, prec); |
michael@0 | 21 | throw "should have thrown"; |
michael@0 | 22 | } |
michael@0 | 23 | catch (e) |
michael@0 | 24 | { |
michael@0 | 25 | assertEq(e instanceof RangeError, true, |
michael@0 | 26 | "expected RangeError for " + method + " with precision " + prec + |
michael@0 | 27 | ", got " + e); |
michael@0 | 28 | } |
michael@0 | 29 | } |
michael@0 | 30 | |
michael@0 | 31 | test("toExponential", -32); |
michael@0 | 32 | test("toFixed", -32); |
michael@0 | 33 | test("toPrecision", -32); |
michael@0 | 34 | |
michael@0 | 35 | test("toExponential", 9999999); |
michael@0 | 36 | test("toFixed", 9999999); |
michael@0 | 37 | test("toPrecision", 9999999); |
michael@0 | 38 | |
michael@0 | 39 | test("toPrecision", 0); |
michael@0 | 40 | |
michael@0 | 41 | /******************************************************************************/ |
michael@0 | 42 | |
michael@0 | 43 | if (typeof reportCompare === "function") |
michael@0 | 44 | reportCompare(true, true); |
michael@0 | 45 | |
michael@0 | 46 | print("Tests complete"); |