Thu, 03 Feb 2011 09:36:28 +0000
5017953: spurious cascaded diagnostics when name not found
Summary: when an operator is applied to one or more erroneous operands, spurious diagnostics are generated
Reviewed-by: jjg
jjg@409 | 1 | /* |
ohair@554 | 2 | * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. |
jjg@409 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
jjg@409 | 4 | * |
jjg@409 | 5 | * This code is free software; you can redistribute it and/or modify it |
jjg@409 | 6 | * under the terms of the GNU General Public License version 2 only, as |
jjg@409 | 7 | * published by the Free Software Foundation. |
jjg@409 | 8 | * |
jjg@409 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
jjg@409 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
jjg@409 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
jjg@409 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
jjg@409 | 13 | * accompanied this code). |
jjg@409 | 14 | * |
jjg@409 | 15 | * You should have received a copy of the GNU General Public License version |
jjg@409 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
jjg@409 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
jjg@409 | 18 | * |
ohair@554 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ohair@554 | 20 | * or visit www.oracle.com if you need additional information or have any |
ohair@554 | 21 | * questions. |
jjg@409 | 22 | */ |
jjg@409 | 23 | |
jjg@409 | 24 | /* |
jjg@409 | 25 | * @test |
jjg@409 | 26 | * @bug 6860965 |
jjg@409 | 27 | * @summary Project Coin: binary literals |
jjg@409 | 28 | */ |
jjg@409 | 29 | |
jjg@409 | 30 | public class BinaryLiterals { |
jjg@409 | 31 | public static void main(String... args) throws Exception { |
jjg@409 | 32 | new BinaryLiterals().run(); |
jjg@409 | 33 | } |
jjg@409 | 34 | |
jjg@409 | 35 | public void run() throws Exception { |
jjg@409 | 36 | test(0, 0B0); |
jjg@409 | 37 | test(1, 0B1); |
jjg@409 | 38 | test(2, 0B10); |
jjg@409 | 39 | test(3, 0B11); |
jjg@409 | 40 | |
jjg@409 | 41 | test(0, 0b0); |
jjg@409 | 42 | test(1, 0b1); |
jjg@409 | 43 | test(2, 0b10); |
jjg@409 | 44 | test(3, 0b11); |
jjg@409 | 45 | |
jjg@409 | 46 | test(-0, -0b0); |
jjg@409 | 47 | test(-1, -0b1); |
jjg@409 | 48 | test(-2, -0b10); |
jjg@409 | 49 | test(-3, -0b11); |
jjg@409 | 50 | |
jjg@409 | 51 | test(-1, 0b11111111111111111111111111111111); |
jjg@409 | 52 | test(-2, 0b11111111111111111111111111111110); |
jjg@409 | 53 | test(-3, 0b11111111111111111111111111111101); |
jjg@409 | 54 | |
jjg@409 | 55 | test( 1, -0b11111111111111111111111111111111); |
jjg@409 | 56 | test( 2, -0b11111111111111111111111111111110); |
jjg@409 | 57 | test( 3, -0b11111111111111111111111111111101); |
jjg@409 | 58 | |
jjg@409 | 59 | test(0, 0b00); |
jjg@409 | 60 | test(1, 0b001); |
jjg@409 | 61 | test(2, 0b00010); |
jjg@409 | 62 | test(3, 0b000011); |
jjg@409 | 63 | |
jjg@409 | 64 | // aaaabbbbccccddddeeeeffffgggghhhh |
jjg@409 | 65 | test( 0x10, 0b10000); |
jjg@409 | 66 | test( 0x100, 0b100000000); |
jjg@409 | 67 | test( 0x10000, 0b10000000000000000); |
jjg@409 | 68 | test(0x80000000, 0b10000000000000000000000000000000); |
jjg@409 | 69 | test(0xffffffff, 0b11111111111111111111111111111111); |
jjg@409 | 70 | |
jjg@409 | 71 | test(0L, 0b0L); |
jjg@409 | 72 | test(1L, 0b1L); |
jjg@409 | 73 | test(2L, 0b10L); |
jjg@409 | 74 | test(3L, 0b11L); |
jjg@409 | 75 | |
jjg@409 | 76 | test(0, 0b00L); |
jjg@409 | 77 | test(1, 0b001L); |
jjg@409 | 78 | test(2, 0b00010L); |
jjg@409 | 79 | test(3, 0b000011L); |
jjg@409 | 80 | |
jjg@409 | 81 | // aaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnoooopppp |
jjg@409 | 82 | test( 0x10L, 0b10000L); |
jjg@409 | 83 | test( 0x100L, 0b100000000L); |
jjg@409 | 84 | test( 0x10000L, 0b10000000000000000L); |
jjg@409 | 85 | test( 0x80000000L, 0b10000000000000000000000000000000L); |
jjg@409 | 86 | test( 0xffffffffL, 0b11111111111111111111111111111111L); |
jjg@409 | 87 | test(0x8000000000000000L, 0b1000000000000000000000000000000000000000000000000000000000000000L); |
jjg@409 | 88 | test(0xffffffffffffffffL, 0b1111111111111111111111111111111111111111111111111111111111111111L); |
jjg@409 | 89 | |
jjg@409 | 90 | test(0l, 0b0l); |
jjg@409 | 91 | test(1l, 0b1l); |
jjg@409 | 92 | test(2l, 0b10l); |
jjg@409 | 93 | test(3l, 0b11l); |
jjg@409 | 94 | |
jjg@409 | 95 | test(0, 0b00l); |
jjg@409 | 96 | test(1, 0b001l); |
jjg@409 | 97 | test(2, 0b00010l); |
jjg@409 | 98 | test(3, 0b000011l); |
jjg@409 | 99 | |
jjg@409 | 100 | // aaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnoooopppp |
jjg@409 | 101 | test( 0x10l, 0b10000l); |
jjg@409 | 102 | test( 0x100l, 0b100000000l); |
jjg@409 | 103 | test( 0x10000l, 0b10000000000000000l); |
jjg@409 | 104 | test( 0x80000000l, 0b10000000000000000000000000000000l); |
jjg@409 | 105 | test( 0xffffffffl, 0b11111111111111111111111111111111l); |
jjg@409 | 106 | test(0x8000000000000000l, 0b1000000000000000000000000000000000000000000000000000000000000000l); |
jjg@409 | 107 | test(0xffffffffffffffffl, 0b1111111111111111111111111111111111111111111111111111111111111111l); |
jjg@409 | 108 | |
jjg@409 | 109 | if (errors > 0) |
jjg@409 | 110 | throw new Exception(errors + " errors found"); |
jjg@409 | 111 | } |
jjg@409 | 112 | |
jjg@409 | 113 | void test(int expect, int found) { |
jjg@409 | 114 | count++; |
jjg@409 | 115 | if (found != expect) |
jjg@409 | 116 | error("test " + count + "\nexpected: 0x" + Integer.toHexString(expect) + "\n found: 0x" + Integer.toHexString(found)); |
jjg@409 | 117 | } |
jjg@409 | 118 | |
jjg@409 | 119 | void test(long expect, long found) { |
jjg@409 | 120 | count++; |
jjg@409 | 121 | if (found != expect) |
jjg@409 | 122 | error("test " + count + "\nexpected: 0x" + Long.toHexString(expect) + "\n found: 0x" + Long.toHexString(found)); |
jjg@409 | 123 | } |
jjg@409 | 124 | |
jjg@409 | 125 | void error(String message) { |
jjg@409 | 126 | System.out.println(message); |
jjg@409 | 127 | errors++; |
jjg@409 | 128 | } |
jjg@409 | 129 | |
jjg@409 | 130 | int count; |
jjg@409 | 131 | int errors; |
jjg@409 | 132 | } |