1 /* 2 * Copyright (c) 2003, 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 /* @test 25 * @summary Unit test for formatter 26 * @bug 4906370 4962433 4973103 4989961 5005818 5031150 4970931 4989491 5002937 27 * 5005104 5007745 5061412 5055180 5066788 5088703 6317248 6318369 6320122 28 * 6344623 6369500 6534606 6282094 6286592 6476425 5063507 6469160 6476168 29 * 8059175 30 * 31 * @run shell/timeout=240 Basic.sh 32 */ 33 34 import static java.lang.System.out; 35 36 public class Basic { 37 38 private static int fail = 0; 39 private static int pass = 0; 40 41 private static Throwable first; 42 43 static void pass() { 44 pass++; 45 } 46 47 static void fail(String fs, Class ex) { 48 String s = "'" + fs + "': " + ex.getName() + " not thrown"; 49 if (first == null) 50 setFirst(s); 51 System.err.println("FAILED: " + s); 52 fail++; 53 } 54 55 static void fail(String fs, String exp, String got) { 56 String s = "'" + fs + "': Expected '" + exp + "', got '" + got + "'"; 57 if (first == null) 58 setFirst(s); 59 System.err.println("FAILED: " + s); 60 fail++; 61 } 62 63 private static void setFirst(String s) { 64 try { 65 throw new RuntimeException(s); 66 } catch (RuntimeException x) { 67 first = x; 68 } 69 } 70 71 static void ck(String fs, String exp, String got) { 72 if (!exp.equals(got)) 73 fail(fs, exp, got); 74 else 75 pass(); 76 } 77 78 public static void main(String[] args) { 79 BasicBoolean.test(); 80 BasicBooleanObject.test(); 81 BasicByte.test(); 82 BasicByteObject.test(); 83 BasicChar.test(); 84 BasicCharObject.test(); 85 BasicShort.test(); 86 BasicShortObject.test(); 87 BasicInt.test(); 88 BasicIntObject.test(); 89 BasicLong.test(); 90 BasicLongObject.test(); 91 BasicBigInteger.test(); 92 BasicFloat.test(); 93 BasicFloatObject.test(); 94 BasicDouble.test(); 95 BasicDoubleObject.test(); 96 BasicBigDecimal.test(); 97 98 BasicDateTime.test(); 99 100 if (fail != 0) 101 throw new RuntimeException((fail + pass) + " tests: " 102 + fail + " failure(s), first", first); 103 else 104 out.println("all " + (fail + pass) + " tests passed"); 105 } 106 }