< prev index next >

test/jdk/java/util/Formatter/Basic-X.java.template

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. --- 1,7 ---- /* ! * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation.
*** 50,59 **** --- 50,62 ---- ck(fs, exp, f.toString()); f = new Formatter(new StringBuilder(), Locale.US); f.format("foo " + fs + " bar", args); ck(fs, "foo " + exp + " bar", f.toString()); + + JavacIntrinsicsSupport.formatAndCheck(fs, exp, Locale.US, args); + JavacIntrinsicsSupport.formatAndCheck("foo " + fs + " bar", "foo " + exp + " bar", Locale.US, args); } private static void test(Locale l, String fs, String exp, Object ... args) { Formatter f = new Formatter(new StringBuilder(), l);
*** 61,70 **** --- 64,76 ---- ck(fs, exp, f.toString()); f = new Formatter(new StringBuilder(), l); f.format("foo " + fs + " bar", args); ck(fs, "foo " + exp + " bar", f.toString()); + + JavacIntrinsicsSupport.formatAndCheck(fs, exp, l, args); + JavacIntrinsicsSupport.formatAndCheck("foo " + fs + " bar", "foo " + exp + " bar", l, args); } private static void test(String fs, Object ... args) { Formatter f = new Formatter(new StringBuilder(), Locale.US); f.format(fs, args);
*** 122,131 **** --- 128,139 ---- } if (!caught) fail(fs, ex); else pass(); + + tryCatchIntrinsic(fs, ex); } private static void tryCatch(String fs, Class<?> ex, Object ... args) { boolean caught = false; try {
*** 136,145 **** --- 144,183 ---- } if (!caught) fail(fs, ex); else pass(); + + tryCatchIntrinsic(fs, ex, args); + } + + private static void tryCatchIntrinsic(String fs, Class<?> ex) { + boolean caught = false; + try { + JavacIntrinsicsSupport.formatAndCheck(fs, "fail", Locale.US, "fail"); + } catch (Throwable x) { + if (ex.isAssignableFrom(x.getClass())) + caught = true; + } + if (!caught) + fail(fs, ex); + else + pass(); + } + + private static void tryCatchIntrinsic(String fs, Class<?> ex, Object ... args) { + boolean caught = false; + try { + JavacIntrinsicsSupport.formatAndCheck(fs, "fail", Locale.US, args); + } catch (Throwable x) { + if (ex.isAssignableFrom(x.getClass())) + caught = true; + } + if (!caught) + fail(fs, ex); + else + pass(); } #if[datetime] private static void testDateTime(String fs, String exp, Calendar c) { testDateTime(fs, exp, c, true);
*** 592,602 **** // %d - int and long //--------------------------------------------------------------------- $type$ oneToSeven = ($type$) 1234567; test("%d", "1234567", oneToSeven); test("%,d", "1,234,567", oneToSeven); ! test(Locale.FRANCE, "%,d", "1\u202f234\u202f567", oneToSeven); test("%,d", "-1,234,567", negate(oneToSeven)); test("%(d", "1234567", oneToSeven); test("%(d", "(1234567)", negate(oneToSeven)); test("% d", " 1234567", oneToSeven); test("% d", "-1234567", negate(oneToSeven)); --- 630,640 ---- // %d - int and long //--------------------------------------------------------------------- $type$ oneToSeven = ($type$) 1234567; test("%d", "1234567", oneToSeven); test("%,d", "1,234,567", oneToSeven); ! test(Locale.FRANCE, "%,d", "1\u00a0234\u00a0567", oneToSeven); test("%,d", "-1,234,567", negate(oneToSeven)); test("%(d", "1234567", oneToSeven); test("%(d", "(1234567)", negate(oneToSeven)); test("% d", " 1234567", oneToSeven); test("% d", "-1234567", negate(oneToSeven));
*** 787,797 **** // %d - BigInteger //--------------------------------------------------------------------- test("%d", "null", (Object)null); test("%d", "1234567", new BigInteger("1234567", 10)); test("%,d", "1,234,567", new BigInteger("1234567", 10)); ! test(Locale.FRANCE, "%,d", "1\u202f234\u202f567", new BigInteger("1234567", 10)); test("%,d", "-1,234,567", new BigInteger("-1234567", 10)); test("%(d", "1234567", new BigInteger("1234567", 10)); test("%(d", "(1234567)", new BigInteger("-1234567", 10)); test("% d", " 1234567", new BigInteger("1234567", 10)); test("% d", "-1234567", new BigInteger("-1234567", 10)); --- 825,835 ---- // %d - BigInteger //--------------------------------------------------------------------- test("%d", "null", (Object)null); test("%d", "1234567", new BigInteger("1234567", 10)); test("%,d", "1,234,567", new BigInteger("1234567", 10)); ! test(Locale.FRANCE, "%,d", "1\u00a0234\u00a0567", new BigInteger("1234567", 10)); test("%,d", "-1,234,567", new BigInteger("-1234567", 10)); test("%(d", "1234567", new BigInteger("1234567", 10)); test("%(d", "(1234567)", new BigInteger("-1234567", 10)); test("% d", " 1234567", new BigInteger("1234567", 10)); test("% d", "-1234567", new BigInteger("-1234567", 10));
*** 1164,1174 **** // Float can not accurately store 1e6 * PI. test("%.3f", "3141.593", mult(pi, 1000.0)); test("%.3f", "-3141.593", mult(pi, -1000.0)); test("%,.2f", "3,141.59", mult(pi, 1000.0)); ! test(Locale.FRANCE, "%,.2f", "3\u202f141,59", mult(pi, 1000.0)); test("%,.2f", "-3,141.59", mult(pi, -1000.0)); test("%(.2f", "3141.59", mult(pi, 1000.0)); test("%(.2f", "(3141.59)", mult(pi, -1000.0)); test("%(,.2f", "3,141.59", mult(pi, 1000.0)); test("%(,.2f", "(3,141.59)", mult(pi, -1000.0)); --- 1202,1212 ---- // Float can not accurately store 1e6 * PI. test("%.3f", "3141.593", mult(pi, 1000.0)); test("%.3f", "-3141.593", mult(pi, -1000.0)); test("%,.2f", "3,141.59", mult(pi, 1000.0)); ! test(Locale.FRANCE, "%,.2f", "3\u00a0141,59", mult(pi, 1000.0)); test("%,.2f", "-3,141.59", mult(pi, -1000.0)); test("%(.2f", "3141.59", mult(pi, 1000.0)); test("%(.2f", "(3141.59)", mult(pi, -1000.0)); test("%(,.2f", "3,141.59", mult(pi, 1000.0)); test("%(,.2f", "(3,141.59)", mult(pi, -1000.0));
*** 1179,1189 **** // %f - float, double, Double, BigDecimal //--------------------------------------------------------------------- test("%.3f", "3141592.654", mult(pi, 1000000.0)); test("%.3f", "-3141592.654", mult(pi, -1000000.0)); test("%,.4f", "3,141,592.6536", mult(pi, 1000000.0)); ! test(Locale.FRANCE, "%,.4f", "3\u202f141\u202f592,6536", mult(pi, 1000000.0)); test("%,.4f", "-3,141,592.6536", mult(pi, -1000000.0)); test("%(.4f", "3141592.6536", mult(pi, 1000000.0)); test("%(.4f", "(3141592.6536)", mult(pi, -1000000.0)); test("%(,.4f", "3,141,592.6536", mult(pi, 1000000.0)); test("%(,.4f", "(3,141,592.6536)", mult(pi, -1000000.0)); --- 1217,1227 ---- // %f - float, double, Double, BigDecimal //--------------------------------------------------------------------- test("%.3f", "3141592.654", mult(pi, 1000000.0)); test("%.3f", "-3141592.654", mult(pi, -1000000.0)); test("%,.4f", "3,141,592.6536", mult(pi, 1000000.0)); ! test(Locale.FRANCE, "%,.4f", "3\u00a0141\u00a0592,6536", mult(pi, 1000000.0)); test("%,.4f", "-3,141,592.6536", mult(pi, -1000000.0)); test("%(.4f", "3141592.6536", mult(pi, 1000000.0)); test("%(.4f", "(3141592.6536)", mult(pi, -1000000.0)); test("%(,.4f", "3,141,592.6536", mult(pi, 1000000.0)); test("%(,.4f", "(3,141,592.6536)", mult(pi, -1000000.0));
< prev index next >