NASHORN-173.js revision 6:5a1b0714df0e
1/*
2 * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24/*
25 * NASHORN-173 : radix is ignored in Number.toString(radix).
26 * @test
27 * @run
28 */
29
30function printNumber(n) {
31    print(n);
32    print(n.toString(10));
33    print(n.toString(undefined));
34    print(n.toString(2));
35    print(n.toString(5));
36    print(n.toString(8));
37    print(n.toString(12));
38    print(n.toString(16));
39    print(n.toString(21));
40    print(n.toString(32));
41    print(n.toString(36));
42    try {
43      n.toString(0);
44    } catch (e) {
45      print(e.name);
46    }
47    try {
48      n.toString(37);
49    } catch (e) {
50      print(e.name);
51    }
52}
53
54printNumber(0);
55printNumber(1);
56printNumber(-10);
57printNumber(255);
58printNumber(255.5);
59printNumber(255.55);
60printNumber(4988883874234);
61printNumber(342234.2);
62printNumber(-32423423.2342);
63printNumber(837423.234765892);
64printNumber(2342344660903453345345);
65printNumber(-0.138789879520123);
66printNumber(10.5);
67printNumber(-10.22);
68printNumber(-32.44);
69printNumber(0.435235);
70printNumber(0.5);
71printNumber(5);
72printNumber(7.5);
73