test/nashorn/script/basic/NASHORN-173.js
changeset 47216 71c04702a3d5
parent 24778 2ff5d7041566
equal deleted inserted replaced
47215:4ebc2e2fb97c 47216:71c04702a3d5
       
     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 
       
    30 function 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 
       
    54 printNumber(0);
       
    55 printNumber(1);
       
    56 printNumber(-10);
       
    57 printNumber(255);
       
    58 printNumber(255.5);
       
    59 printNumber(255.55);
       
    60 printNumber(4988883874234);
       
    61 printNumber(342234.2);
       
    62 printNumber(-32423423.2342);
       
    63 printNumber(837423.234765892);
       
    64 printNumber(2342344660903453345345);
       
    65 printNumber(-0.138789879520123);
       
    66 printNumber(10.5);
       
    67 printNumber(-10.22);
       
    68 printNumber(-32.44);
       
    69 printNumber(0.435235);
       
    70 printNumber(0.5);
       
    71 printNumber(5);
       
    72 printNumber(7.5);