test/tools/javac/literals/BadUnderscoreLiterals.java

Wed, 13 Aug 2014 14:50:00 -0700

author
katleman
date
Wed, 13 Aug 2014 14:50:00 -0700
changeset 2549
0b6cc4ea670f
parent 757
c44234f680da
child 2525
2eb010b6cb22
permissions
-rw-r--r--

Added tag jdk8u40-b01 for changeset bf89a471779d

     1 /*
     2  * @test /nodynamiccopyright/
     3  * @bug 6860973
     4  * @summary Project Coin: underscores in literals
     5  *
     6  * @compile/fail BadUnderscoreLiterals.java
     7  * @compile/fail/ref=BadUnderscoreLiterals.7.out -XDrawDiagnostics BadUnderscoreLiterals.java
     8  *
     9  * @compile/fail -source 6 BadUnderscoreLiterals.java
    10  * @compile/fail/ref=BadUnderscoreLiterals.6.out -XDrawDiagnostics -source 6 -Xlint:-options BadUnderscoreLiterals.java
    11  */
    13 public class BadUnderscoreLiterals {
    14     int valid = 1_1;            // valid literal; illegal in -source 6
    16     // test zero
    17     int z1 = _0;                // valid (but undefined) variable
    18     int z2 = 0_;                // trailing underscore
    20     // test simple (decimal) integers
    21     int i1 = _1_2_3;            // valid (but undefined) variable
    22     int i2 = 1_2_3_;            // trailing underscore
    24     // test binary integers
    25     int b1 = 0b_0;              // leading underscore after radix
    26     int b2 = 0b0_;              // trailing underscore
    28     // test hexadecimal integers
    29     int x1 = 0x_0;              // leading underscore after radix
    30     int x2 = 0x0_;              // trailing underscore
    32     // test floating point numbers
    33     float f1 = 0_.1;            // trailing underscore before decimal point
    34     float f2 = 0._1;            // leading underscore after decimal point
    35     float f3 = 0.1_;            // trailing underscore
    36     float f4 = 0.1_e0;          // trailing underscore before exponent
    37     float f5 = 0e_1;            // leading underscore in exponent
    38     float f6 = 0e1_;            // trailing underscore in exponent
    40     // hexadecimal floating point
    41     float xf1 = 0x_0.1p0;       // leading underscore after radix
    42     float xf2 = 0x0_.1p0;       // trailing underscore before decimal point
    43     float xf3 = 0x0._1p0;       // leading underscore after decimal point
    44     float xf4 = 0x0.1_p0;       // trailing underscore before exponent
    45     float xf5 = 0x0p_1;         // leading underscore after exponent
    46     float xf6 = 0x0p1_;         // trailing underscore
    47 }

mercurial