langtools/test/tools/javac/literals/UnderscoreLiterals.java
author ohair
Tue, 25 May 2010 15:54:51 -0700
changeset 5520 86e4b9a9da40
parent 3895 3b3c2a1e5e8a
child 18649 8cfa05227758
permissions -rw-r--r--
6943119: Rebrand source copyright notices Reviewed-by: darcy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3895
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
     1
/*
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 3895
diff changeset
     2
 * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
3895
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
     4
 *
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
     7
 * published by the Free Software Foundation.
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
     8
 *
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    13
 * accompanied this code).
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    14
 *
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    18
 *
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 3895
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 3895
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 3895
diff changeset
    21
 * questions.
3895
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    22
 */
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    23
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    24
/*
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    25
 * @test
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    26
 * @bug 6860973
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    27
 * @summary Project Coin: Underscores in literals
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    28
 */
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    29
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    30
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    31
public class UnderscoreLiterals {
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    32
    public static void main(String... args) throws Exception {
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    33
        new UnderscoreLiterals().run();
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    34
    }
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    35
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    36
    public void run() throws Exception {
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    37
        // decimal
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    38
        test(1, 1);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    39
        test(10, 10);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    40
        test(1_0, 10);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    41
        test(1__0, 10);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    42
        test(1_0_0, 100);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    43
        test(1__0__0, 100);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    44
        test(123_456_789, 123456789);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    45
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    46
        // long
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    47
        test(1l, 1l);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    48
        test(10l, 10l);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    49
        test(1_0l, 10l);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    50
        test(1__0l, 10l);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    51
        test(1_0_0l, 100l);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    52
        test(1__0__0l, 100l);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    53
        test(123_456_789l, 123456789l);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    54
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    55
        // float
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    56
        test(.1f, .1f);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    57
        test(.10f, .10f);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    58
        test(.1_0f, .10f);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    59
        test(.1__0f, .10f);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    60
        test(.1_0_0f, .100f);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    61
        test(.1__0__0f, .100f);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    62
        test(1e1, 1e1);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    63
        test(1e10, 1e10);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    64
        test(1e1_0, 1e10);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    65
        test(1e1__0, 1e10);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    66
        test(1e1_0_0, 1e100);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    67
        test(1e1__0__0, 1e100);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    68
        test(.123_456_789f, .123456789f);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    69
        test(0.1f, 0.1f);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    70
        test(0.10f, 0.10f);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    71
        test(0.1_0f, 0.10f);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    72
        test(0.1__0f, 0.10f);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    73
        test(0.1_0_0f, 0.100f);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    74
        test(0.1__0__0f, 0.100f);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    75
        test(0.123_456_789f, 0.123456789f);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    76
        test(1_1.1f, 1_1.1f);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    77
        test(1_1.10f, 1_1.10f);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    78
        test(1_1.1_0f, 1_1.10f);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    79
        test(1_1.1__0f, 1_1.10f);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    80
        test(1_1.1_0_0f, 1_1.100f);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    81
        test(1_1.1__0__0f, 1_1.100f);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    82
        test(1_1.123_456_789f, 1_1.123456789f);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    83
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    84
        // double
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    85
        test(.1d, .1d);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    86
        test(.10d, .10d);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    87
        test(.1_0d, .10d);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    88
        test(.1__0d, .10d);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    89
        test(.1_0_0d, .100d);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    90
        test(.1__0__0d, .100d);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    91
        test(1e1, 1e1);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    92
        test(1e10, 1e10);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    93
        test(1e1_0, 1e10);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    94
        test(1e1__0, 1e10);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    95
        test(1e1_0_0, 1e100);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    96
        test(1e1__0__0, 1e100);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    97
        test(.123_456_789d, .123456789d);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    98
        test(0.1d, 0.1d);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
    99
        test(0.10d, 0.10d);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   100
        test(0.1_0d, 0.10d);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   101
        test(0.1__0d, 0.10d);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   102
        test(0.1_0_0d, 0.100d);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   103
        test(0.1__0__0d, 0.100d);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   104
        test(0.123_456_789d, 0.123456789d);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   105
        test(1_1.1d, 1_1.1d);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   106
        test(1_1.10d, 1_1.10d);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   107
        test(1_1.1_0d, 1_1.10d);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   108
        test(1_1.1__0d, 1_1.10d);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   109
        test(1_1.1_0_0d, 1_1.100d);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   110
        test(1_1.1__0__0d, 1_1.100d);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   111
        test(1_1.123_456_789d, 1_1.123456789d);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   112
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   113
        // binary
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   114
        test(0b1, 1);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   115
        test(0b10, 2);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   116
        test(0b1_0, 2);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   117
        test(0b1__0, 2);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   118
        test(0b1_0_0, 4);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   119
        test(0b1__0__0, 4);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   120
        test(0b0001_0010_0011, 0x123);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   121
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   122
        // octal
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   123
        test(01, 1);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   124
        test(010, 8);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   125
        test(01_0, 8);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   126
        test(01__0, 8);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   127
        test(01_0_0, 64);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   128
        test(01__0__0, 64);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   129
        test(0_1, 1);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   130
        test(0_10, 8);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   131
        test(0_1_0, 8);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   132
        test(0_1__0, 8);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   133
        test(0_1_0_0, 64);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   134
        test(0_1__0__0, 64);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   135
        test(0_001_002_003, 01002003);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   136
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   137
        // hexadecimal
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   138
        test(0x1, 1);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   139
        test(0x10, 16);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   140
        test(0x1_0, 16);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   141
        test(0x1__0, 16);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   142
        test(0x1_0_0, 256);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   143
        test(0x1__0__0, 256);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   144
        test(0x01_02_03_04, 0x1020304);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   145
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   146
        // misc
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   147
        long creditCardNumber = 1234_5678_9012_3456L;
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   148
        test(creditCardNumber, 1234567890123456L);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   149
        long socialSecurityNumbers = 999_99_9999L;
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   150
        test(socialSecurityNumbers, 999999999L);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   151
        double monetaryAmount = 12_345_132.12d;
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   152
        test(monetaryAmount, 12345132.12d);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   153
        long hexBytes = 0xFF_EC_DE_5E;
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   154
        test(hexBytes, 0xffecde5e);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   155
        long hexWords = 0xFFEC_DE5E;
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   156
        test(hexWords, 0xffecde5e);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   157
        long maxLong = 0x7fff_ffff_ffff_ffffL;
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   158
        test(maxLong, 0x7fffffffffffffffL);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   159
        long maxLongDecimal = 9223372036854775807L;
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   160
        long alsoMaxLong = 9_223_372_036_854_775_807L;
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   161
        test(alsoMaxLong, maxLongDecimal);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   162
        double whyWouldYouEverDoThis = 0x1.ffff_ffff_ffff_fp10_23;
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   163
        double whyWouldYouEverDoEvenThis = 0x1.fffffffffffffp1023;
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   164
        test(whyWouldYouEverDoThis, whyWouldYouEverDoEvenThis);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   165
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   166
        if (errors > 0)
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   167
             throw new Exception(errors + " errors found");
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   168
    }
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   169
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   170
    void test(int value, int expect) {
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   171
        count++;
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   172
        if (value != expect)
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   173
            error("test " + count + "\nexpected: 0x" + Integer.toHexString(expect) + "\n   found: 0x" + Integer.toHexString(value));
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   174
    }
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   175
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   176
    void test(double value, double expect) {
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   177
        count++;
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   178
        if (value != expect)
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   179
            error("test " + count + "\nexpected: 0x" + expect + "\n   found: 0x" + value);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   180
    }
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   181
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   182
    void test(long value, long expect) {
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   183
        count++;
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   184
        if (value != expect)
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   185
            error("test " + count + "\nexpected: 0x" + Long.toHexString(expect) + "\n   found: 0x" + Long.toHexString(value));
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   186
    }
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   187
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   188
    void error(String message) {
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   189
        System.out.println(message);
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   190
        errors++;
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   191
    }
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   192
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   193
    int count;
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   194
    int errors;
3b3c2a1e5e8a 6860965: Project Coin: binary literals
jjg
parents:
diff changeset
   195
}