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