jdk/test/java/util/Formatter/Basic-X.java.template
author lana
Thu, 26 Dec 2013 12:04:16 -0800
changeset 23010 6dadb192ad81
parent 19196 5368bd038f19
child 27725 433b57a5a5c1
permissions -rw-r--r--
8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013 Summary: updated files with 2011, 2012 and 2013 years according to the file's last updated date Reviewed-by: tbell, lancea, chegar
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
23010
6dadb192ad81 8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents: 19196
diff changeset
     2
 * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4341
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4341
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4341
diff changeset
    21
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
/* Type-specific source code for unit test
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
 * Regenerate the BasicX classes via genBasic.sh whenever this file changes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 * We check in the generated source files so that the test tree can be used
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 * independently of the rest of the source tree.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
#warn This file is preprocessed before being compiled
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.io.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.math.BigDecimal;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.math.BigInteger;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.text.DateFormatSymbols;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import java.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
#if[double]
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import sun.misc.DoubleConsts;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
#end[double]
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
import static java.util.Calendar.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
#if[datetime]
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
import static java.util.SimpleTimeZone.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
import java.util.regex.Pattern;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
#end[datetime]
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
public class Basic$Type$ extends Basic {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    private static void test(String fs, String exp, Object ... args) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
        Formatter f = new Formatter(new StringBuilder(), Locale.US);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
        f.format(fs, args);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
        ck(fs, exp, f.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    private static void test(Locale l, String fs, String exp, Object ... args)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
        Formatter f = new Formatter(new StringBuilder(), l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
        f.format(fs, args);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
        ck(fs, exp, f.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    private static void test(String fs, Object ... args) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        Formatter f = new Formatter(new StringBuilder(), Locale.US);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        f.format(fs, args);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        ck(fs, "fail", f.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    private static void test(String fs) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        Formatter f = new Formatter(new StringBuilder(), Locale.US);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        f.format(fs, "fail");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        ck(fs, "fail", f.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    private static void testSysOut(String fs, String exp, Object ... args) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        FileOutputStream fos = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        FileInputStream fis = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
            PrintStream saveOut = System.out;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
            fos = new FileOutputStream("testSysOut");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
            System.setOut(new PrintStream(fos));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
            System.out.format(Locale.US, fs, args);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
            fos.close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
            fis = new FileInputStream("testSysOut");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
            byte [] ba = new byte[exp.length()];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
            int len = fis.read(ba);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
            String got = new String(ba);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
            if (len != ba.length)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
                fail(fs, exp, got);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
            ck(fs, exp, got);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
            System.setOut(saveOut);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        } catch (FileNotFoundException ex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
            fail(fs, ex.getClass());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        } catch (IOException ex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
            fail(fs, ex.getClass());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
                if (fos != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
                    fos.close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
                if (fis != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
                    fis.close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
            } catch (IOException ex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
                fail(fs, ex.getClass());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    private static void tryCatch(String fs, Class<?> ex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        boolean caught = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
            test(fs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        } catch (Throwable x) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
            if (ex.isAssignableFrom(x.getClass()))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
                caught = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        if (!caught)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
            fail(fs, ex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
            pass();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    private static void tryCatch(String fs, Class<?> ex, Object ... args) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        boolean caught = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
            test(fs, args);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        } catch (Throwable x) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
            if (ex.isAssignableFrom(x.getClass()))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
                caught = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        if (!caught)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
            fail(fs, ex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
            pass();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
#if[datetime]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    private static void testDateTime(String fs, String exp, Calendar c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        testDateTime(fs, exp, c, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    private static void testDateTime(String fs, String exp, Calendar c, boolean upper) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        // Date/Time conversions applicable to Calendar, Date, and long.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        // Calendar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        test(fs, exp, c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        test((Locale)null, fs, exp, c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        test(Locale.US, fs, exp, c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        // Date/long do not have timezone information so they will always use
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        // the default timezone.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        String nexp = (fs.equals("%tZ") || fs.equals("%TZ")
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
                       || fs.equals("%tc") || fs.equals("%Tc")
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
                       ? exp.replace("PST", "GMT-08:00")
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
                       : exp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        // Date (implemented via conversion to Calendar)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        Date d = c.getTime();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        test(fs, nexp, d);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        test((Locale)null, fs, nexp, d);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        test(Locale.US, fs, nexp, d);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        // long (implemented via conversion to Calendar)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        long l = c.getTimeInMillis();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        test(fs, nexp, l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        test((Locale)null, fs, nexp, l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        test(Locale.US, fs, nexp, l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        if (upper)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
            // repeat all tests for upper case variant (%T)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
            testDateTime(Pattern.compile("t").matcher(fs).replaceFirst("T"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
                         exp.toUpperCase(), c, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    private static void testHours() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        for (int i = 0; i < 24; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
            // GregorianCalendar(int year, int month, int dayOfMonth,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
            //    int hourOfDay, int minute, int second);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
            Calendar c = new GregorianCalendar(1995, MAY, 23, i, 48, 34);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
            //-----------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
            // DateTime.HOUR_OF_DAY - 'k' (0 - 23) -- like H
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
            //-----------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
            String exp = Integer.toString(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
            testDateTime("%tk", exp, c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
            //-----------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
            // DateTime.HOUR - 'l' (1 - 12) -- like I
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
            //-----------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
            int v = i % 12;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
            v = (v == 0 ? 12 : v);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
            String exp2 = Integer.toString(v);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
            testDateTime("%tl", exp2, c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
            //-----------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
            // DateTime.HOUR_OF_DAY_0 - 'H' (00 - 23) [zero padded]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
            //-----------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
            if (exp.length() < 2) exp = "0" + exp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
            testDateTime("%tH", exp, c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
            //-----------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
            // DateTime.HOUR_0 - 'I' (01 - 12)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
            //-----------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
            if (exp2.length() < 2) exp2 = "0" + exp2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
            testDateTime("%tI", exp2, c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
            //-----------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
            // DateTime.AM_PM - (am or pm)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
            //-----------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
            testDateTime("%tp", (i <12 ? "am" : "pm"), c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
#end[datetime]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
#if[dec]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
#if[prim]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    private static $type$ negate($type$ v) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        return ($type$) -v;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
#end[prim]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
#end[dec]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
#if[Byte]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    private static $type$ negate($type$ v) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        return new $type$((byte) -v.byteValue());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
#end[Byte]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
#if[Short]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    private static $type$ negate($type$ v) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        return new $type$((short) -v.shortValue());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
#end[Short]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
#if[Integer]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    private static $type$ negate($type$ v) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        return new $type$(-v.intValue());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
#end[Integer]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
#if[Long]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    private static $type$ negate($type$ v) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        return new $type$(-v.longValue());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
#end[Long]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
#if[BigDecimal]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    private static $type$ create(double v) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        return new $type$(v);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    private static $type$ negate($type$ v) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        return v.negate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    private static $type$ mult($type$ v, double mul) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        return v.multiply(new $type$(mul));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
    private static $type$ recip($type$ v) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
        return BigDecimal.ONE.divide(v);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
#end[BigDecimal]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
#if[float]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
    private static $type$ create(double v) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        return ($type$) v;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    private static $type$ negate(double v) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
        return ($type$) -v;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
    private static $type$ mult($type$ v, double mul) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        return v * ($type$) mul;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
    private static $type$ recip($type$ v) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        return 1.0f / v;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
#end[float]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
#if[Float]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    private static $type$ create(double v) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        return new $type$(v);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    private static $type$ negate($type$ v) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
        return new $type$(-v.floatValue());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
    private static $type$ mult($type$ v, double mul) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
        return new $type$(v.floatValue() * (float) mul);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
    private static $type$ recip($type$ v) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
        return new $type$(1.0f / v.floatValue());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
#end[Float]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
#if[double]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
    private static $type$ create(double v) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
        return ($type$) v;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
    private static $type$ negate(double v) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
        return -v;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
    private static $type$ mult($type$ v, double mul) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
        return v * mul;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
    private static $type$ recip($type$ v) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
        return 1.0 / v;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
#end[double]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
#if[Double]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
    private static $type$ create(double v) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
        return new $type$(v);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
    private static $type$ negate($type$ v) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
        return new $type$(-v.doubleValue());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
    private static $type$ mult($type$ v, double mul) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
        return new $type$(v.doubleValue() * mul);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
    private static $type$ recip($type$ v) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
        return new $type$(1.0 / v.doubleValue());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
#end[Double]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
    public static void test() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
        TimeZone.setDefault(TimeZone.getTimeZone("GMT-0800"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
        // Any characters not explicitly defined as conversions, date/time
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
        // conversion suffixes, or flags are illegal and are reserved for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
        // future extensions.  Use of such a character in a format string will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
        // cause an UnknownFormatConversionException or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
        // UnknownFormatFlagsException to be thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
        tryCatch("%q", UnknownFormatConversionException.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
        tryCatch("%t&", UnknownFormatConversionException.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
        tryCatch("%&d", UnknownFormatConversionException.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
        tryCatch("%^b", UnknownFormatConversionException.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
        // Formatter.java class javadoc examples
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
        test(Locale.FRANCE, "e = %+10.4f", "e =    +2,7183", Math.E);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
        test("%4$2s %3$2s %2$2s %1$2s", " d  c  b  a", "a", "b", "c", "d");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
        test("Amount gained or lost since last statement: $ %,(.2f",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
             "Amount gained or lost since last statement: $ (6,217.58)",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
             (new BigDecimal("-6217.58")));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
        Calendar c = new GregorianCalendar(1969, JULY, 20, 16, 17, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
        testSysOut("Local time: %tT", "Local time: 16:17:00", c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
        test("Unable to open file '%1$s': %2$s",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
             "Unable to open file 'food': No such file or directory",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
             "food", "No such file or directory");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
        Calendar duke = new GregorianCalendar(1995, MAY, 23, 19, 48, 34);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
        duke.set(Calendar.MILLISECOND, 584);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
        test("Duke's Birthday: %1$tB %1$te, %1$tY",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
             "Duke's Birthday: May 23, 1995",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
             duke);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
        test("Duke's Birthday: %1$tB %1$te, %1$tY",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
             "Duke's Birthday: May 23, 1995",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
             duke.getTime());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
        test("Duke's Birthday: %1$tB %1$te, %1$tY",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
             "Duke's Birthday: May 23, 1995",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
             duke.getTimeInMillis());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
        test("%4$s %3$s %2$s %1$s %4$s %3$s %2$s %1$s",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
             "d c b a d c b a", "a", "b", "c", "d");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
        test("%s %s %<s %<s", "a b b b", "a", "b", "c", "d");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
        test("%s %s %s %s", "a b c d", "a", "b", "c", "d");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
        test("%2$s %s %<s %s", "b a a b", "a", "b", "c", "d");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
        // %b
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
        // General conversion applicable to any argument.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
        test("%b", "true", true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
        test("%b", "false", false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
        test("%B", "TRUE", true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
        test("%B", "FALSE", false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
        test("%b", "true", Boolean.TRUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
        test("%b", "false", Boolean.FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
        test("%B", "TRUE", Boolean.TRUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
        test("%B", "FALSE", Boolean.FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
        test("%14b", "          true", true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
        test("%-14b", "true          ", true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
        test("%5.1b", "    f", false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
        test("%-5.1b", "f    ", false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
        test("%b", "true", "foo");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
        test("%b", "false", (Object)null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
        // Boolean.java hardcodes the Strings for "true" and "false", so no
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
        // localization is possible.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
        test(Locale.FRANCE, "%b", "true", true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
        test(Locale.FRANCE, "%b", "false", false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
        // If you pass in a single array to a varargs method, the compiler
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
        // uses it as the array of arguments rather than treating it as a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
        // single array-type argument.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
        test("%b", "false", (Object[])new String[2]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
        test("%b", "true", new String[2], new String[2]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
        int [] ia = { 1, 2, 3 };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
        test("%b", "true", ia);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
        // %b - errors
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
        tryCatch("%#b", FormatFlagsConversionMismatchException.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
        tryCatch("%-b", MissingFormatWidthException.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
        // correct or side-effect of implementation?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
        tryCatch("%.b", UnknownFormatConversionException.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
        tryCatch("%,b", FormatFlagsConversionMismatchException.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
        // %c
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
        // General conversion applicable to any argument.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
        test("%c", "i", 'i');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
        test("%C", "I", 'i');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
        test("%4c",  "   i", 'i');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
        test("%-4c", "i   ", 'i');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
        test("%4C",  "   I", 'i');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
        test("%-4C", "I   ", 'i');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
        test("%c", "i", new Character('i'));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
        test("%c", "H", (byte) 72);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
        test("%c", "i", (short) 105);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
        test("%c", "!", (int) 33);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
        test("%c", "\u007F", Byte.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
        test("%c", new String(Character.toChars(Short.MAX_VALUE)),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
             Short.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
        test("%c", "null", (Object) null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
        // %c - errors
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
        tryCatch("%c", IllegalFormatConversionException.class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
                 Boolean.TRUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
        tryCatch("%c", IllegalFormatConversionException.class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
                 (float) 0.1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
        tryCatch("%c", IllegalFormatConversionException.class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
                 new Object());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
        tryCatch("%c", IllegalFormatCodePointException.class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
                 Byte.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
        tryCatch("%c", IllegalFormatCodePointException.class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
                 Short.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
        tryCatch("%c", IllegalFormatCodePointException.class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
                 Integer.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
        tryCatch("%c", IllegalFormatCodePointException.class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
                 Integer.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
        tryCatch("%#c", FormatFlagsConversionMismatchException.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
        tryCatch("%,c", FormatFlagsConversionMismatchException.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
        tryCatch("%(c", FormatFlagsConversionMismatchException.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
        tryCatch("%$c", UnknownFormatConversionException.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
        tryCatch("%.2c", IllegalFormatPrecisionException.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
        // %s
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
        // General conversion applicable to any argument.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
        test("%s", "Hello, Duke", "Hello, Duke");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
        test("%S", "HELLO, DUKE", "Hello, Duke");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
        test("%20S", "         HELLO, DUKE", "Hello, Duke");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
        test("%20s", "         Hello, Duke", "Hello, Duke");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
        test("%-20s", "Hello, Duke         ", "Hello, Duke");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
        test("%-20.5s", "Hello               ", "Hello, Duke");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
        test("%s", "null", (Object)null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
        StringBuffer sb = new StringBuffer("foo bar");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
        test("%s", sb.toString(), sb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
        test("%S", sb.toString().toUpperCase(), sb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
        // %s - errors
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
        tryCatch("%-s", MissingFormatWidthException.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
        tryCatch("%--s", DuplicateFormatFlagsException.class);
3416
0dd4f82becda 5063507: (fmt) missing exception for "%#s" format specifier
sherman
parents: 1823
diff changeset
   488
        tryCatch("%#s", FormatFlagsConversionMismatchException.class, 0);
0dd4f82becda 5063507: (fmt) missing exception for "%#s" format specifier
sherman
parents: 1823
diff changeset
   489
        tryCatch("%#s", FormatFlagsConversionMismatchException.class, 0.5f);
0dd4f82becda 5063507: (fmt) missing exception for "%#s" format specifier
sherman
parents: 1823
diff changeset
   490
        tryCatch("%#s", FormatFlagsConversionMismatchException.class, "hello");
0dd4f82becda 5063507: (fmt) missing exception for "%#s" format specifier
sherman
parents: 1823
diff changeset
   491
        tryCatch("%#s", FormatFlagsConversionMismatchException.class, null);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
        // %h
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
        // General conversion applicable to any argument.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
        test("%h", Integer.toHexString("Hello, Duke".hashCode()),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
             "Hello, Duke");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
        test("%10h", "  ddf63471", "Hello, Duke");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
        test("%-10h", "ddf63471  ", "Hello, Duke");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
        test("%-10H", "DDF63471  ", "Hello, Duke");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
        test("%10h", "  402e0000", 15.0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
        test("%10H", "  402E0000", 15.0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
        // %h - errors
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
        tryCatch("%#h", FormatFlagsConversionMismatchException.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
        // flag/conversion errors
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
        tryCatch("%F", UnknownFormatConversionException.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
        tryCatch("%#g", FormatFlagsConversionMismatchException.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
#if[dec]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
#if[prim]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
        $type$ minByte = Byte.MIN_VALUE;   // -128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
#else[prim]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
        $type$ minByte = new $type$(Byte.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
#end[prim]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
        // %d
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
        // Numeric conversion applicable to byte, short, int, long, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
        // BigInteger.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
        test("%d", "null", (Object)null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
#if[byte]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
#if[prim]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
        // %d - byte
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
        $type$ seventeen = ($type$) 17;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
        test("%d", "17", seventeen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
        test("%,d", "17", seventeen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
        test("%,d", "-17", negate(seventeen));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
        test("%(d", "17", seventeen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
        test("%(d", "(17)", negate(seventeen));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
        test("% d", " 17", seventeen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
        test("% d", "-17", negate(seventeen));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
        test("%+d", "+17", seventeen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
        test("%+d", "-17", negate(seventeen));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
        test("%010d", "0000000017", seventeen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
        test("%010d", "-000000017", negate(seventeen));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
        test("%(10d", "      (17)", negate(seventeen));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
        test("%-10d", "17        ", seventeen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
        test("%-10d", "-17       ", negate(seventeen));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
#end[prim]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
#else[byte]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
#if[short]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
        // %d - short
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
        $type$ oneToFive = ($type$) 12345;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
        test("%d", "12345", oneToFive);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
        test("%,d", "12,345", oneToFive);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
        test("%,d", "-12,345", negate(oneToFive));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
        test("%(d", "12345", oneToFive);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
        test("%(d", "(12345)", negate(oneToFive));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
        test("% d", " 12345", oneToFive);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
        test("% d", "-12345", negate(oneToFive));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
        test("%+d", "+12345", oneToFive);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
        test("%+d", "-12345", negate(oneToFive));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
        test("%010d", "0000012345", oneToFive);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
        test("%010d", "-000012345", negate(oneToFive));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
        test("%(10d", "   (12345)", negate(oneToFive));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
        test("%-10d", "12345     ", oneToFive);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
        test("%-10d", "-12345    ", negate(oneToFive));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
#else[short]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
#if[prim]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
        // %d - int and long
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
        $type$ oneToSeven = ($type$) 1234567;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
        test("%d", "1234567", oneToSeven);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
        test("%,d", "1,234,567", oneToSeven);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
        test(Locale.FRANCE, "%,d", "1\u00a0234\u00a0567", oneToSeven);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
        test("%,d", "-1,234,567", negate(oneToSeven));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
        test("%(d", "1234567", oneToSeven);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
        test("%(d", "(1234567)", negate(oneToSeven));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
        test("% d", " 1234567", oneToSeven);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
        test("% d", "-1234567", negate(oneToSeven));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
        test("%+d", "+1234567", oneToSeven);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
        test("%+d", "-1234567", negate(oneToSeven));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
        test("%010d", "0001234567", oneToSeven);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
        test("%010d", "-001234567", negate(oneToSeven));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
        test("%(10d", " (1234567)", negate(oneToSeven));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
        test("%-10d", "1234567   ", oneToSeven);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
        test("%-10d", "-1234567  ", negate(oneToSeven));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
#end[prim]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
#end[short]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
#end[byte]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
        // %d - errors
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
        tryCatch("%#d", FormatFlagsConversionMismatchException.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
        tryCatch("%D", UnknownFormatConversionException.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
        tryCatch("%0d", MissingFormatWidthException.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
        tryCatch("%-d", MissingFormatWidthException.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
        tryCatch("%7.3d", IllegalFormatPrecisionException.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
        // %o
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
        // Numeric conversion applicable to byte, short, int, long, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
        // BigInteger.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
        test("%o", "null", (Object)null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
#if[byte]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
        // %o - byte
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
        test("%010o", "0000000200", minByte);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
        test("%-10o", "200       ", minByte);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
        test("%#10o", "      0200", minByte);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
#end[byte]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
#if[short]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
        // %o - short
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
        test("%010o", "0000177600", minByte);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
        test("%-10o", "177600    ", minByte);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
        test("%#10o", "   0177600", minByte);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
#end[short]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
#if[int]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
        // %o - int
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
        test("%014o", "00037777777600", minByte);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
        test("%-14o", "37777777600   ", minByte);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
        test("%#14o", "  037777777600", minByte);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
        $type$ oneToSevenOct = ($type$) 1234567;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
        test("%o", "4553207", oneToSevenOct);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
        test("%010o", "0004553207", oneToSevenOct);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
        test("%-10o", "4553207   ", oneToSevenOct);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
        test("%#10o", "  04553207", oneToSevenOct);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
#end[int]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
#if[long]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
        // %o - long
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
        test("%024o", "001777777777777777777600", minByte);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
        test("%-24o", "1777777777777777777600  ", minByte);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
        test("%#24o", " 01777777777777777777600", minByte);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
        $type$ oneToSevenOct = ($type$) 1234567;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
        test("%o", "4553207", oneToSevenOct);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
        test("%010o", "0004553207", oneToSevenOct);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
        test("%-10o", "4553207   ", oneToSevenOct);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
        test("%#10o", "  04553207", oneToSevenOct);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
#end[long]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
        // %o - errors
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
        tryCatch("%(o", FormatFlagsConversionMismatchException.class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
                 minByte);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
        tryCatch("%+o", FormatFlagsConversionMismatchException.class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
                 minByte);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
        tryCatch("% o", FormatFlagsConversionMismatchException.class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
                 minByte);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
        tryCatch("%0o", MissingFormatWidthException.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
        tryCatch("%-o", MissingFormatWidthException.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
        tryCatch("%,o", FormatFlagsConversionMismatchException.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
        tryCatch("%O", UnknownFormatConversionException.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
        // %x
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
        // Numeric conversion applicable to byte, short, int, long, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
        // BigInteger.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
        test("%x", "null", (Object)null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
#if[byte]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
        // %x - byte
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
        test("%010x", "0000000080", minByte);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
        test("%-10x", "80        ", minByte);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
        test("%#10x", "      0x80", minByte);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
        test("%0#10x","0x00000080", minByte);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
        test("%#10X", "      0X80", minByte);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
        test("%X", "80", minByte);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
#end[byte]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
#if[short]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
        // %x - short
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
        test("%010x", "000000ff80", minByte);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
        test("%-10x", "ff80      ", minByte);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
        test("%#10x", "    0xff80", minByte);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
        test("%0#10x","0x0000ff80", minByte);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
        test("%#10X", "    0XFF80", minByte);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
        test("%X", "FF80", minByte);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
#end[short]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
#if[int]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
        // %x - int
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
        $type$ oneToSevenHex = ($type$)1234567;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
        test("%x", "null", (Object)null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
        test("%x", "12d687", oneToSevenHex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
        test("%010x", "000012d687", oneToSevenHex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
        test("%-10x", "12d687    ", oneToSevenHex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
        test("%#10x", "  0x12d687", oneToSevenHex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
        test("%#10X", "  0X12D687",oneToSevenHex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
        test("%X", "12D687", oneToSevenHex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
        test("%010x", "00ffffff80", minByte);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
        test("%-10x", "ffffff80  ", minByte);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
        test("%#10x", "0xffffff80", minByte);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
        test("%0#12x","0x00ffffff80", minByte);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
        test("%#12X", "  0XFFFFFF80", minByte);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
        test("%X", "FFFFFF80", minByte);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
#end[int]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
#if[long]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
        // %x - long
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
        $type$ oneToSevenHex = ($type$)1234567;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
        test("%x", "null", (Object)null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
        test("%x", "12d687", oneToSevenHex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
        test("%010x", "000012d687", oneToSevenHex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
        test("%-10x", "12d687    ", oneToSevenHex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
        test("%#10x", "  0x12d687", oneToSevenHex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
        test("%#10X", "  0X12D687",oneToSevenHex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
        test("%X", "12D687", oneToSevenHex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
        test("%018x",    "00ffffffffffffff80", minByte);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
        test("%-18x",      "ffffffffffffff80  ", minByte);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
        test("%#20x",  "  0xffffffffffffff80", minByte);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
        test("%0#20x", "0x00ffffffffffffff80", minByte);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
        test("%#20X", "  0XFFFFFFFFFFFFFF80", minByte);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
        test("%X",        "FFFFFFFFFFFFFF80", minByte);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
#end[long]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
        // %x - errors
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
        tryCatch("%,x", FormatFlagsConversionMismatchException.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
        tryCatch("%0x", MissingFormatWidthException.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
        tryCatch("%-x", MissingFormatWidthException.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
#end[dec]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
#if[BigInteger]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
        // BigInteger - errors
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
        tryCatch("%f", IllegalFormatConversionException.class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
                 new BigInteger("1"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
        // %d - BigInteger
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
        test("%d", "null", (Object)null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
        test("%d", "1234567", new BigInteger("1234567", 10));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
        test("%,d", "1,234,567", new BigInteger("1234567", 10));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
        test(Locale.FRANCE, "%,d", "1\u00a0234\u00a0567", new BigInteger("1234567", 10));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
        test("%,d", "-1,234,567", new BigInteger("-1234567", 10));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
        test("%(d", "1234567", new BigInteger("1234567", 10));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
        test("%(d", "(1234567)", new BigInteger("-1234567", 10));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
        test("% d", " 1234567", new BigInteger("1234567", 10));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
        test("% d", "-1234567", new BigInteger("-1234567", 10));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
        test("%+d", "+1234567", new BigInteger("1234567", 10));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
        test("%+d", "-1234567", new BigInteger("-1234567", 10));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
        test("%010d", "0001234567", new BigInteger("1234567", 10));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
        test("%010d", "-001234567", new BigInteger("-1234567", 10));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
        test("%(10d", " (1234567)", new BigInteger("-1234567", 10));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
        test("%+d", "+1234567", new BigInteger("1234567", 10));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
        test("%+d", "-1234567", new BigInteger("-1234567", 10));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
        test("%-10d", "1234567   ", new BigInteger("1234567", 10));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
        test("%-10d", "-1234567  ", new BigInteger("-1234567", 10));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
        // %o - BigInteger
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
        test("%o", "null", (Object)null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
        test("%o", "1234567", new BigInteger("1234567", 8));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
        test("%(o", "1234567", new BigInteger("1234567", 8));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
        test("%(o", "(1234567)", new BigInteger("-1234567", 8));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
        test("% o", " 1234567", new BigInteger("1234567", 8));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
        test("% o", "-1234567", new BigInteger("-1234567", 8));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
        test("%+o", "+1234567", new BigInteger("1234567", 8));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
        test("%+o", "-1234567", new BigInteger("-1234567", 8));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
        test("%010o", "0001234567", new BigInteger("1234567", 8));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
        test("%010o", "-001234567", new BigInteger("-1234567", 8));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
        test("%(10o", " (1234567)", new BigInteger("-1234567", 8));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
        test("%+o", "+1234567", new BigInteger("1234567", 8));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
        test("%+o", "-1234567", new BigInteger("-1234567", 8));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
        test("%-10o", "1234567   ", new BigInteger("1234567", 8));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
        test("%-10o", "-1234567  ", new BigInteger("-1234567", 8));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
        test("%#10o", "  01234567", new BigInteger("1234567", 8));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
        test("%#10o", " -01234567", new BigInteger("-1234567", 8));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
        // %x - BigInteger
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
        test("%x", "null", (Object)null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
        test("%x", "1234567", new BigInteger("1234567", 16));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
        test("%(x", "1234567", new BigInteger("1234567", 16));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
        test("%(x", "(1234567)", new BigInteger("-1234567", 16));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
        test("% x", " 1234567", new BigInteger("1234567", 16));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
        test("% x", "-1234567", new BigInteger("-1234567", 16));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
        test("%+x", "+1234567", new BigInteger("1234567", 16));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
        test("%+x", "-1234567", new BigInteger("-1234567", 16));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
        test("%010x", "0001234567", new BigInteger("1234567", 16));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
        test("%010x", "-001234567", new BigInteger("-1234567", 16));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
        test("%(10x", " (1234567)", new BigInteger("-1234567", 16));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
        test("%+x", "+1234567", new BigInteger("1234567", 16));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
        test("%+x", "-1234567", new BigInteger("-1234567", 16));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
        test("%-10x", "1234567   ", new BigInteger("1234567", 16));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
        test("%-10x", "-1234567  ", new BigInteger("-1234567", 16));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
        test("%#10x", " 0x1234567", new BigInteger("1234567", 16));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
        test("%#10x", "-0x1234567", new BigInteger("-1234567", 16));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
        test("%#10X", " 0X1234567", new BigInteger("1234567", 16));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
        test("%#10X", "-0X1234567", new BigInteger("-1234567", 16));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
        test("%X", "1234567A", new BigInteger("1234567a", 16));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
        test("%X", "-1234567A", new BigInteger("-1234567a", 16));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
#end[BigInteger]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
#if[fp]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
#if[BigDecimal]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
        // %s - BigDecimal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
        $type$ one = BigDecimal.ONE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
        $type$ ten = BigDecimal.TEN;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
        $type$ pi  = new $type$(Math.PI);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
        $type$ piToThe300 = pi.pow(300);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
        test("%s", "3.141592653589793115997963468544185161590576171875", pi);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
#end[BigDecimal]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
#if[float]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
        // %s - float
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
        $type$ one = 1.0f;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
        $type$ ten = 10.0f;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
        $type$ pi  = (float) Math.PI;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
        test("%s", "3.1415927", pi);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
#end[float]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
#if[Float]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
        // %s - Float
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
        $type$ one = new $type$(1.0f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
        $type$ ten = new $type$(10.0f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
        $type$ pi  = new $type$(Math.PI);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
        test("%s", "3.1415927", pi);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
#end[Float]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
#if[double]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
        // %s - double
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
        $type$ one = 1.0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
        $type$ ten = 10.0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
        $type$ pi  = Math.PI;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
        test("%s", "3.141592653589793", pi);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
#end[double]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
#if[Double]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
        // %s - Double
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
        $type$ one = new $type$(1.0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
        $type$ ten = new $type$(10.0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
        $type$ pi  = new $type$(Math.PI);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
        test("%s", "3.141592653589793", pi);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
#end[Double]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
        // flag/conversion errors
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
        tryCatch("%d", IllegalFormatConversionException.class, one);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
        tryCatch("%,.4e", FormatFlagsConversionMismatchException.class, one);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
        // %e
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
        // Floating-point conversions applicable to float, double, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
        // BigDecimal.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
        test("%e", "null", (Object)null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
        // %e - float and double
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
        // double PI = 3.141 592 653 589 793 238 46;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
        test("%e", "3.141593e+00", pi);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
        test("%.0e", "1e+01", ten);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
        test("%#.0e", "1.e+01", ten);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
        test("%E", "3.141593E+00", pi);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
        test("%10.3e", " 3.142e+00", pi);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
        test("%10.3e", "-3.142e+00", negate(pi));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
        test("%010.3e", "03.142e+00", pi);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
        test("%010.3e", "-3.142e+00", negate(pi));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
        test("%-12.3e", "3.142e+00   ", pi);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
        test("%-12.3e", "-3.142e+00  ", negate(pi));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
        test("%.3e", "3.142e+00", pi);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
        test("%.3e", "-3.142e+00", negate(pi));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
        test("%.3e", "3.142e+06", mult(pi, 1000000.0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
        test("%.3e", "-3.142e+06", mult(pi, -1000000.0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
        test(Locale.FRANCE, "%e", "3,141593e+00", pi);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
        // double PI^300
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
        //    = 13962455701329742638131355433930076081862072808 ... e+149
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
#if[BigDecimal]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
        // %e - BigDecimal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
        test("%.3e", "1.396e+149", piToThe300);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
        test("%.3e", "-1.396e+149", piToThe300.negate());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
        test("%.3e", "1.000e-100", recip(ten.pow(100)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
        test("%.3e", "-1.000e-100", negate(recip(ten.pow(100))));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
        test("%3.0e", "1e-06", new BigDecimal("0.000001"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
        test("%3.0e", "1e-05", new BigDecimal("0.00001"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
        test("%3.0e", "1e-04", new BigDecimal("0.0001"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
        test("%3.0e", "1e-03", new BigDecimal("0.001"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
        test("%3.0e", "1e-02", new BigDecimal("0.01"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
        test("%3.0e", "1e-01", new BigDecimal("0.1"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
        test("%3.0e", "9e-01", new BigDecimal("0.9"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
        test("%3.1e", "9.0e-01", new BigDecimal("0.9"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
        test("%3.0e", "1e+00", new BigDecimal("1.00"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
        test("%3.0e", "1e+01", new BigDecimal("10.00"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
        test("%3.0e", "1e+02", new BigDecimal("99.19"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
        test("%3.1e", "9.9e+01", new BigDecimal("99.19"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
        test("%3.0e", "1e+02", new BigDecimal("99.99"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
        test("%3.0e", "1e+02", new BigDecimal("100.00"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
        test("%#3.0e", "1.e+03",    new BigDecimal("1000.00"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
        test("%3.0e", "1e+04",     new BigDecimal("10000.00"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
        test("%3.0e", "1e+05",    new BigDecimal("100000.00"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
        test("%3.0e", "1e+06",   new BigDecimal("1000000.00"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
        test("%3.0e", "1e+07",  new BigDecimal("10000000.00"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
        test("%3.0e", "1e+08", new BigDecimal("100000000.00"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
#end[BigDecimal]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
        test("%10.3e", " 1.000e+00", one);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
        test("%+.3e", "+3.142e+00", pi);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
        test("%+.3e", "-3.142e+00", negate(pi));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
        test("% .3e", " 3.142e+00", pi);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
        test("% .3e", "-3.142e+00", negate(pi));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
        test("%#.0e", "3.e+00", create(3.0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
        test("%#.0e", "-3.e+00", create(-3.0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
        test("%.0e", "3e+00", create(3.0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
        test("%.0e", "-3e+00", create(-3.0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
        test("%(.4e", "3.1416e+06", mult(pi, 1000000.0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
        test("%(.4e", "(3.1416e+06)", mult(pi, -1000000.0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
        // %e - boundary problems
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
        test("%3.0e", "1e-06", 0.000001);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
        test("%3.0e", "1e-05", 0.00001);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
        test("%3.0e", "1e-04", 0.0001);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
        test("%3.0e", "1e-03", 0.001);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
        test("%3.0e", "1e-02", 0.01);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
        test("%3.0e", "1e-01", 0.1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
        test("%3.0e", "9e-01", 0.9);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
        test("%3.1e", "9.0e-01", 0.9);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
        test("%3.0e", "1e+00", 1.00);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
        test("%3.0e", "1e+01", 10.00);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
        test("%3.0e", "1e+02", 99.19);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
        test("%3.1e", "9.9e+01", 99.19);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
        test("%3.0e", "1e+02", 99.99);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
        test("%3.0e", "1e+02", 100.00);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
        test("%#3.0e", "1.e+03",     1000.00);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
        test("%3.0e", "1e+04",     10000.00);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
        test("%3.0e", "1e+05",    100000.00);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
        test("%3.0e", "1e+06",   1000000.00);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
        test("%3.0e", "1e+07",  10000000.00);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
        test("%3.0e", "1e+08", 100000000.00);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
        // %f
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
        // Floating-point conversions applicable to float, double, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
        // BigDecimal.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
        test("%f", "null", (Object)null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
        test("%f", "3.141593", pi);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
        test(Locale.FRANCE, "%f", "3,141593", pi);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
        test("%10.3f", "     3.142", pi);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
        test("%10.3f", "    -3.142", negate(pi));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
        test("%010.3f", "000003.142", pi);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
        test("%010.3f", "-00003.142", negate(pi));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
        test("%-10.3f", "3.142     ", pi);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
        test("%-10.3f", "-3.142    ", negate(pi));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
        test("%.3f", "3.142", pi);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
        test("%.3f", "-3.142", negate(pi));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
        test("%+.3f", "+3.142", pi);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
        test("%+.3f", "-3.142", negate(pi));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
        test("% .3f", " 3.142", pi);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
        test("% .3f", "-3.142", negate(pi));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
        test("%#.0f", "3.", create(3.0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
        test("%#.0f", "-3.", create(-3.0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
        test("%.0f", "3", create(3.0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
        test("%.0f", "-3", create(-3.0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
        test("%.3f", "10.000", ten);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
        test("%.3f", "1.000", one);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
        test("%10.3f", "     1.000", one);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
        // %f - boundary problems
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
        test("%3.0f", "  0", 0.000001);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
        test("%3.0f", "  0", 0.00001);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
        test("%3.0f", "  0", 0.0001);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
        test("%3.0f", "  0", 0.001);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
        test("%3.0f", "  0", 0.01);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
        test("%3.0f", "  0", 0.1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
        test("%3.0f", "  1", 0.9);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
        test("%3.1f", "0.9", 0.9);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
        test("%3.0f", "  1", 1.00);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
        test("%3.0f", " 10", 10.00);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1032
        test("%3.0f", " 99", 99.19);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
        test("%3.1f", "99.2", 99.19);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1034
        test("%3.0f", "100", 99.99);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1035
        test("%3.0f", "100", 100.00);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
        test("%#3.0f", "1000.",     1000.00);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
        test("%3.0f", "10000",     10000.00);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
        test("%3.0f", "100000",    100000.00);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1039
        test("%3.0f", "1000000",   1000000.00);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
        test("%3.0f", "10000000",  10000000.00);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
        test("%3.0f", "100000000", 100000000.00);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
#if[BigDecimal]
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1043
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
        // %f - BigDecimal
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
        test("%4.0f", "  99", new BigDecimal("99.19"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
        test("%4.1f", "99.2", new BigDecimal("99.19"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
        BigDecimal val = new BigDecimal("99.95");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
        test("%4.0f", " 100", val);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
        test("%#4.0f", "100.", val);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
        test("%4.1f", "100.0", val);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
        test("%4.2f", "99.95", val);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
        test("%4.3f", "99.950", val);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
        val = new BigDecimal(".99");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1057
        test("%4.1f", " 1.0", val);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
        test("%4.2f", "0.99", val);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
        test("%4.3f", "0.990", val);
1823
23d42a96635e 6476425: (fmt)java.util.Formatter.print() throws IllegalArgumentException on large BigDecima
sherman
parents: 2
diff changeset
  1060
23d42a96635e 6476425: (fmt)java.util.Formatter.print() throws IllegalArgumentException on large BigDecima
sherman
parents: 2
diff changeset
  1061
        // #6476425
23d42a96635e 6476425: (fmt)java.util.Formatter.print() throws IllegalArgumentException on large BigDecima
sherman
parents: 2
diff changeset
  1062
        val = new BigDecimal("0.00001");
23d42a96635e 6476425: (fmt)java.util.Formatter.print() throws IllegalArgumentException on large BigDecima
sherman
parents: 2
diff changeset
  1063
        test("%.0f", "0", val);
23d42a96635e 6476425: (fmt)java.util.Formatter.print() throws IllegalArgumentException on large BigDecima
sherman
parents: 2
diff changeset
  1064
        test("%.1f", "0.0", val);
23d42a96635e 6476425: (fmt)java.util.Formatter.print() throws IllegalArgumentException on large BigDecima
sherman
parents: 2
diff changeset
  1065
        test("%.2f", "0.00", val);
23d42a96635e 6476425: (fmt)java.util.Formatter.print() throws IllegalArgumentException on large BigDecima
sherman
parents: 2
diff changeset
  1066
        test("%.3f", "0.000", val);
23d42a96635e 6476425: (fmt)java.util.Formatter.print() throws IllegalArgumentException on large BigDecima
sherman
parents: 2
diff changeset
  1067
        test("%.4f", "0.0000", val);
23d42a96635e 6476425: (fmt)java.util.Formatter.print() throws IllegalArgumentException on large BigDecima
sherman
parents: 2
diff changeset
  1068
        test("%.5f", "0.00001", val);
23d42a96635e 6476425: (fmt)java.util.Formatter.print() throws IllegalArgumentException on large BigDecima
sherman
parents: 2
diff changeset
  1069
23d42a96635e 6476425: (fmt)java.util.Formatter.print() throws IllegalArgumentException on large BigDecima
sherman
parents: 2
diff changeset
  1070
        val = new BigDecimal("1.00001");
23d42a96635e 6476425: (fmt)java.util.Formatter.print() throws IllegalArgumentException on large BigDecima
sherman
parents: 2
diff changeset
  1071
        test("%.0f", "1", val);
23d42a96635e 6476425: (fmt)java.util.Formatter.print() throws IllegalArgumentException on large BigDecima
sherman
parents: 2
diff changeset
  1072
        test("%.1f", "1.0", val);
23d42a96635e 6476425: (fmt)java.util.Formatter.print() throws IllegalArgumentException on large BigDecima
sherman
parents: 2
diff changeset
  1073
        test("%.2f", "1.00", val);
23d42a96635e 6476425: (fmt)java.util.Formatter.print() throws IllegalArgumentException on large BigDecima
sherman
parents: 2
diff changeset
  1074
        test("%.3f", "1.000", val);
23d42a96635e 6476425: (fmt)java.util.Formatter.print() throws IllegalArgumentException on large BigDecima
sherman
parents: 2
diff changeset
  1075
        test("%.4f", "1.0000", val);
23d42a96635e 6476425: (fmt)java.util.Formatter.print() throws IllegalArgumentException on large BigDecima
sherman
parents: 2
diff changeset
  1076
        test("%.5f", "1.00001", val);
23d42a96635e 6476425: (fmt)java.util.Formatter.print() throws IllegalArgumentException on large BigDecima
sherman
parents: 2
diff changeset
  1077
23d42a96635e 6476425: (fmt)java.util.Formatter.print() throws IllegalArgumentException on large BigDecima
sherman
parents: 2
diff changeset
  1078
        val = new BigDecimal("1.23456");
23d42a96635e 6476425: (fmt)java.util.Formatter.print() throws IllegalArgumentException on large BigDecima
sherman
parents: 2
diff changeset
  1079
        test("%.0f", "1", val);
23d42a96635e 6476425: (fmt)java.util.Formatter.print() throws IllegalArgumentException on large BigDecima
sherman
parents: 2
diff changeset
  1080
        test("%.1f", "1.2", val);
23d42a96635e 6476425: (fmt)java.util.Formatter.print() throws IllegalArgumentException on large BigDecima
sherman
parents: 2
diff changeset
  1081
        test("%.2f", "1.23", val);
23d42a96635e 6476425: (fmt)java.util.Formatter.print() throws IllegalArgumentException on large BigDecima
sherman
parents: 2
diff changeset
  1082
        test("%.3f", "1.235", val);
23d42a96635e 6476425: (fmt)java.util.Formatter.print() throws IllegalArgumentException on large BigDecima
sherman
parents: 2
diff changeset
  1083
        test("%.4f", "1.2346", val);
23d42a96635e 6476425: (fmt)java.util.Formatter.print() throws IllegalArgumentException on large BigDecima
sherman
parents: 2
diff changeset
  1084
        test("%.5f", "1.23456", val);
23d42a96635e 6476425: (fmt)java.util.Formatter.print() throws IllegalArgumentException on large BigDecima
sherman
parents: 2
diff changeset
  1085
        test("%.6f", "1.234560", val);
23d42a96635e 6476425: (fmt)java.util.Formatter.print() throws IllegalArgumentException on large BigDecima
sherman
parents: 2
diff changeset
  1086
23d42a96635e 6476425: (fmt)java.util.Formatter.print() throws IllegalArgumentException on large BigDecima
sherman
parents: 2
diff changeset
  1087
        val = new BigDecimal("9.99999");
23d42a96635e 6476425: (fmt)java.util.Formatter.print() throws IllegalArgumentException on large BigDecima
sherman
parents: 2
diff changeset
  1088
        test("%.0f", "10", val);
23d42a96635e 6476425: (fmt)java.util.Formatter.print() throws IllegalArgumentException on large BigDecima
sherman
parents: 2
diff changeset
  1089
        test("%.1f", "10.0", val);
23d42a96635e 6476425: (fmt)java.util.Formatter.print() throws IllegalArgumentException on large BigDecima
sherman
parents: 2
diff changeset
  1090
        test("%.2f", "10.00", val);
23d42a96635e 6476425: (fmt)java.util.Formatter.print() throws IllegalArgumentException on large BigDecima
sherman
parents: 2
diff changeset
  1091
        test("%.3f", "10.000", val);
23d42a96635e 6476425: (fmt)java.util.Formatter.print() throws IllegalArgumentException on large BigDecima
sherman
parents: 2
diff changeset
  1092
        test("%.4f", "10.0000", val);
23d42a96635e 6476425: (fmt)java.util.Formatter.print() throws IllegalArgumentException on large BigDecima
sherman
parents: 2
diff changeset
  1093
        test("%.5f", "9.99999", val);
23d42a96635e 6476425: (fmt)java.util.Formatter.print() throws IllegalArgumentException on large BigDecima
sherman
parents: 2
diff changeset
  1094
        test("%.6f", "9.999990", val);
23d42a96635e 6476425: (fmt)java.util.Formatter.print() throws IllegalArgumentException on large BigDecima
sherman
parents: 2
diff changeset
  1095
23d42a96635e 6476425: (fmt)java.util.Formatter.print() throws IllegalArgumentException on large BigDecima
sherman
parents: 2
diff changeset
  1096
23d42a96635e 6476425: (fmt)java.util.Formatter.print() throws IllegalArgumentException on large BigDecima
sherman
parents: 2
diff changeset
  1097
        val = new BigDecimal("1.99999");
23d42a96635e 6476425: (fmt)java.util.Formatter.print() throws IllegalArgumentException on large BigDecima
sherman
parents: 2
diff changeset
  1098
        test("%.0f", "2", val);
23d42a96635e 6476425: (fmt)java.util.Formatter.print() throws IllegalArgumentException on large BigDecima
sherman
parents: 2
diff changeset
  1099
        test("%.1f", "2.0", val);
23d42a96635e 6476425: (fmt)java.util.Formatter.print() throws IllegalArgumentException on large BigDecima
sherman
parents: 2
diff changeset
  1100
        test("%.2f", "2.00", val);
23d42a96635e 6476425: (fmt)java.util.Formatter.print() throws IllegalArgumentException on large BigDecima
sherman
parents: 2
diff changeset
  1101
        test("%.3f", "2.000", val);
23d42a96635e 6476425: (fmt)java.util.Formatter.print() throws IllegalArgumentException on large BigDecima
sherman
parents: 2
diff changeset
  1102
        test("%.4f", "2.0000", val);
23d42a96635e 6476425: (fmt)java.util.Formatter.print() throws IllegalArgumentException on large BigDecima
sherman
parents: 2
diff changeset
  1103
        test("%.5f", "1.99999", val);
23d42a96635e 6476425: (fmt)java.util.Formatter.print() throws IllegalArgumentException on large BigDecima
sherman
parents: 2
diff changeset
  1104
        test("%.6f", "1.999990", val);
23d42a96635e 6476425: (fmt)java.util.Formatter.print() throws IllegalArgumentException on large BigDecima
sherman
parents: 2
diff changeset
  1105
15520
b5c4972b71cd 6355704: (fmt) %f formatting of BigDecimals is incorrect
mchung
parents: 10608
diff changeset
  1106
        val = new BigDecimal(0.9996);
b5c4972b71cd 6355704: (fmt) %f formatting of BigDecimals is incorrect
mchung
parents: 10608
diff changeset
  1107
        test("%.0f", "1", val);
b5c4972b71cd 6355704: (fmt) %f formatting of BigDecimals is incorrect
mchung
parents: 10608
diff changeset
  1108
        test("%.1f", "1.0", val);
b5c4972b71cd 6355704: (fmt) %f formatting of BigDecimals is incorrect
mchung
parents: 10608
diff changeset
  1109
        test("%.2f", "1.00", val);
b5c4972b71cd 6355704: (fmt) %f formatting of BigDecimals is incorrect
mchung
parents: 10608
diff changeset
  1110
        test("%.3f", "1.000", val);
b5c4972b71cd 6355704: (fmt) %f formatting of BigDecimals is incorrect
mchung
parents: 10608
diff changeset
  1111
        test("%.4f", "0.9996", val);
b5c4972b71cd 6355704: (fmt) %f formatting of BigDecimals is incorrect
mchung
parents: 10608
diff changeset
  1112
        test("%.5f", "0.99960", val);
b5c4972b71cd 6355704: (fmt) %f formatting of BigDecimals is incorrect
mchung
parents: 10608
diff changeset
  1113
        test("%.6f", "0.999600", val);
b5c4972b71cd 6355704: (fmt) %f formatting of BigDecimals is incorrect
mchung
parents: 10608
diff changeset
  1114
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1115
#end[BigDecimal]
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1116
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1117
#if[float]
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1118
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1119
        // %f - float
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1120
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1121
        // Float can not accurately store 1e6 * PI.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1122
        test("%.3f", "3141.593", mult(pi, 1000.0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1123
        test("%.3f", "-3141.593", mult(pi, -1000.0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1124
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1125
        test("%,.2f", "3,141.59", mult(pi, 1000.0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1126
        test(Locale.FRANCE, "%,.2f", "3\u00a0141,59", mult(pi, 1000.0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1127
        test("%,.2f", "-3,141.59", mult(pi, -1000.0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1128
        test("%(.2f", "3141.59", mult(pi, 1000.0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1129
        test("%(.2f", "(3141.59)", mult(pi, -1000.0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1130
        test("%(,.2f", "3,141.59", mult(pi, 1000.0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1131
        test("%(,.2f", "(3,141.59)", mult(pi, -1000.0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1132
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1133
#else[float]
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1134
#if[!Float]
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1135
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1136
        // %f - float, double, Double, BigDecimal
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1137
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1138
        test("%.3f", "3141592.654", mult(pi, 1000000.0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1139
        test("%.3f", "-3141592.654", mult(pi, -1000000.0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1140
        test("%,.4f", "3,141,592.6536", mult(pi, 1000000.0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1141
        test(Locale.FRANCE, "%,.4f", "3\u00a0141\u00a0592,6536", mult(pi, 1000000.0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1142
        test("%,.4f", "-3,141,592.6536", mult(pi, -1000000.0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1143
        test("%(.4f", "3141592.6536", mult(pi, 1000000.0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1144
        test("%(.4f", "(3141592.6536)", mult(pi, -1000000.0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1145
        test("%(,.4f", "3,141,592.6536", mult(pi, 1000000.0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1146
        test("%(,.4f", "(3,141,592.6536)", mult(pi, -1000000.0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1147
#end[!Float]
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1148
#end[float]
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1149
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1150
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1151
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1152
        // %g
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1153
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1154
        // Floating-point conversions applicable to float, double, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1155
        // BigDecimal.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1156
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1157
        test("%g", "null", (Object)null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1158
        test("%g", "3.14159", pi);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1159
        test(Locale.FRANCE, "%g", "3,14159", pi);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1160
        test("%.0g", "1e+01", ten);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1161
        test("%G", "3.14159", pi);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1162
        test("%10.3g", "      3.14", pi);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1163
        test("%10.3g", "     -3.14", negate(pi));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1164
        test("%010.3g", "0000003.14", pi);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1165
        test("%010.3g", "-000003.14", negate(pi));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1166
        test("%-12.3g", "3.14        ", pi);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1167
        test("%-12.3g", "-3.14       ", negate(pi));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1168
        test("%.3g", "3.14", pi);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1169
        test("%.3g", "-3.14", negate(pi));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1170
        test("%.3g", "3.14e+08", mult(pi, 100000000.0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1171
        test("%.3g", "-3.14e+08", mult(pi, -100000000.0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1172
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1173
        test("%.3g", "1.00e-05", recip(create(100000.0)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1174
        test("%.3g", "-1.00e-05", recip(create(-100000.0)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1175
        test("%.0g", "-1e-05", recip(create(-100000.0)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1176
        test("%.0g", "1e+05", create(100000.0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1177
        test("%.3G", "1.00E-05", recip(create(100000.0)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1178
        test("%.3G", "-1.00E-05", recip(create(-100000.0)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1179
18545
5f4e734fad1b 6469160: (fmt) general (%g) formatting of zero (0.0) with precision 0 or 1 throws ArrayOutOfBoundsException
bpb
parents: 15520
diff changeset
  1180
        test("%.1g", "-0", -0.0);
5f4e734fad1b 6469160: (fmt) general (%g) formatting of zero (0.0) with precision 0 or 1 throws ArrayOutOfBoundsException
bpb
parents: 15520
diff changeset
  1181
        test("%3.0g", " -0", -0.0);
5f4e734fad1b 6469160: (fmt) general (%g) formatting of zero (0.0) with precision 0 or 1 throws ArrayOutOfBoundsException
bpb
parents: 15520
diff changeset
  1182
        test("%.1g", "0", 0.0);
5f4e734fad1b 6469160: (fmt) general (%g) formatting of zero (0.0) with precision 0 or 1 throws ArrayOutOfBoundsException
bpb
parents: 15520
diff changeset
  1183
        test("%3.0g", "  0", 0.0);
5f4e734fad1b 6469160: (fmt) general (%g) formatting of zero (0.0) with precision 0 or 1 throws ArrayOutOfBoundsException
bpb
parents: 15520
diff changeset
  1184
        test("%.1g", "0", +0.0);
5f4e734fad1b 6469160: (fmt) general (%g) formatting of zero (0.0) with precision 0 or 1 throws ArrayOutOfBoundsException
bpb
parents: 15520
diff changeset
  1185
        test("%3.0g", "  0", +0.0);
5f4e734fad1b 6469160: (fmt) general (%g) formatting of zero (0.0) with precision 0 or 1 throws ArrayOutOfBoundsException
bpb
parents: 15520
diff changeset
  1186
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1187
        test("%3.0g", "1e-06", 0.000001);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1188
        test("%3.0g", "1e-05", 0.00001);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1189
        test("%3.0g", "1e-05", 0.0000099);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1190
        test("%3.1g", "1e-05", 0.0000099);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1191
        test("%3.2g", "9.9e-06", 0.0000099);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1192
        test("%3.0g", "0.0001", 0.0001);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1193
        test("%3.0g", "9e-05",  0.00009);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1194
        test("%3.0g", "0.0001", 0.000099);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1195
        test("%3.1g", "0.0001", 0.000099);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1196
        test("%3.2g", "9.9e-05", 0.000099);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1197
        test("%3.0g", "0.001", 0.001);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1198
        test("%3.0g", "0.001", 0.00099);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1199
        test("%3.1g", "0.001", 0.00099);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1200
        test("%3.2g", "0.00099", 0.00099);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1201
        test("%3.3g", "0.00100", 0.001);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1202
        test("%3.4g", "0.001000", 0.001);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1203
        test("%3.0g", "0.01", 0.01);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1204
        test("%3.0g", "0.1", 0.1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1205
        test("%3.0g", "0.9", 0.9);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1206
        test("%3.1g", "0.9", 0.9);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1207
        test("%3.0g", "  1", 1.00);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1208
        test("%3.2g", " 10", 10.00);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1209
        test("%3.0g", "1e+01", 10.00);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1210
        test("%3.0g", "1e+02", 99.19);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1211
        test("%3.1g", "1e+02", 99.19);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1212
        test("%3.2g", " 99", 99.19);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1213
        test("%3.0g", "1e+02", 99.9);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1214
        test("%3.1g", "1e+02", 99.9);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1215
        test("%3.2g", "1.0e+02", 99.9);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1216
        test("%3.0g", "1e+02", 99.99);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1217
        test("%3.0g", "1e+02", 100.00);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1218
        test("%3.0g", "1e+03", 999.9);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1219
        test("%3.1g", "1e+03", 999.9);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1220
        test("%3.2g", "1.0e+03", 999.9);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1221
        test("%3.3g", "1.00e+03", 999.9);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1222
        test("%3.4g", "999.9", 999.9);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1223
        test("%3.4g", "1000", 999.99);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1224
        test("%3.0g", "1e+03", 1000.00);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1225
        test("%3.0g", "1e+04",     10000.00);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1226
        test("%3.0g", "1e+05",    100000.00);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1227
        test("%3.0g", "1e+06",   1000000.00);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1228
        test("%3.0g", "1e+07",  10000000.00);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1229
        test("%3.9g", "100000000",  100000000.00);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1230
        test("%3.10g", "100000000.0", 100000000.00);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1231
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1232
        tryCatch("%#3.0g", FormatFlagsConversionMismatchException.class, 1000.00);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1233
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1234
        // double PI^300
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1235
        //    = 13962455701329742638131355433930076081862072808 ... e+149
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1236
#if[BigDecimal]
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1237
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1238
        // %g - BigDecimal
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1239
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1240
        test("%.3g", "1.40e+149", piToThe300);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1241
        test("%.3g", "-1.40e+149", piToThe300.negate());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1242
        test(Locale.FRANCE, "%.3g", "-1,40e+149", piToThe300.negate());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1243
        test("%.3g", "1.00e-100", recip(ten.pow(100)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1244
        test("%.3g", "-1.00e-100", negate(recip(ten.pow(100))));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1245
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1246
        test("%3.0g", "1e-06", new BigDecimal("0.000001"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1247
        test("%3.0g", "1e-05", new BigDecimal("0.00001"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1248
        test("%3.0g", "0.0001", new BigDecimal("0.0001"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1249
        test("%3.0g", "0.001", new BigDecimal("0.001"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1250
        test("%3.3g", "0.00100", new BigDecimal("0.001"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1251
        test("%3.4g", "0.001000", new BigDecimal("0.001"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1252
        test("%3.0g", "0.01", new BigDecimal("0.01"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1253
        test("%3.0g", "0.1", new BigDecimal("0.1"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1254
        test("%3.0g", "0.9", new BigDecimal("0.9"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1255
        test("%3.1g", "0.9", new BigDecimal("0.9"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1256
        test("%3.0g", "  1", new BigDecimal("1.00"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1257
        test("%3.2g", " 10", new BigDecimal("10.00"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1258
        test("%3.0g", "1e+01", new BigDecimal("10.00"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1259
        test("%3.0g", "1e+02", new BigDecimal("99.19"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1260
        test("%3.1g", "1e+02", new BigDecimal("99.19"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1261
        test("%3.2g", " 99", new BigDecimal("99.19"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1262
        test("%3.0g", "1e+02", new BigDecimal("99.99"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1263
        test("%3.0g", "1e+02", new BigDecimal("100.00"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1264
        test("%3.0g", "1e+03", new BigDecimal("1000.00"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1265
        test("%3.0g", "1e+04",      new BigDecimal("10000.00"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1266
        test("%3.0g", "1e+05",      new BigDecimal("100000.00"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1267
        test("%3.0g", "1e+06",      new BigDecimal("1000000.00"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1268
        test("%3.0g", "1e+07",      new BigDecimal("10000000.00"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1269
        test("%3.9g", "100000000",  new BigDecimal("100000000.00"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1270
        test("%3.10g", "100000000.0", new BigDecimal("100000000.00"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1271
#end[BigDecimal]
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1272
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1273
        test("%.3g", "10.0", ten);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1274
        test("%.3g", "1.00", one);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1275
        test("%10.3g", "      1.00", one);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1276
        test("%+10.3g", "     +3.14", pi);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1277
        test("%+10.3g", "     -3.14", negate(pi));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1278
        test("% .3g", " 3.14", pi);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1279
        test("% .3g", "-3.14", negate(pi));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1280
        test("%.0g", "3", create(3.0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1281
        test("%.0g", "-3", create(-3.0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1282
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1283
        test("%(.4g", "3.142e+08", mult(pi, 100000000.0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1284
        test("%(.4g", "(3.142e+08)", mult(pi, -100000000.0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1285
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1286
#if[float]
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1287
        // Float can not accurately store 1e6 * PI.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1288
        test("%,.6g", "3,141.59", mult(pi, 1000.0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1289
        test("%(,.6g", "(3,141.59)", mult(pi, -1000.0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1290
#else[float]
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1291
#if[!Float]
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1292
        test("%,.11g", "3,141,592.6536", mult(pi, 1000000.0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1293
        test("%(,.11g", "(3,141,592.6536)", mult(pi, -1000000.0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1294
#end[!Float]
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1295
#end[float]
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1296
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1297
#if[double]
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1298
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1299
        // %a
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1300
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1301
        // Floating-point conversions applicable to float, double, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1302
        // BigDecimal.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1303
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1304
        test("%a", "null", (Object)null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1305
        test("%.11a", "0x0.00000000000p0", 0.0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1306
        test(Locale.FRANCE, "%.11a", "0x0.00000000000p0", 0.0); // no localization
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1307
        test("%.1a", "0x0.0p0", 0.0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1308
        test("%.11a", "-0x0.00000000000p0", -0.0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1309
        test("%.1a", "-0x0.0p0", -0.0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1310
        test("%.11a", "0x1.00000000000p0", 1.0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1311
        test("%.1a", "0x1.0p0", 1.0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1312
        test("%.11a", "-0x1.00000000000p0", -1.0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1313
        test("%.1a", "-0x1.0p0", -1.0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1314
        test("%.11a", "0x1.80000000000p1", 3.0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1315
        test("%.1a", "0x1.8p1", 3.0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1316
        test("%.11a", "0x1.00000000000p-1022", DoubleConsts.MIN_NORMAL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1317
        test("%.1a", "0x1.0p-1022", DoubleConsts.MIN_NORMAL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1318
        test("%.11a", "0x1.00000000000p-1022",
10608
7cfca36fc79b 7092404: Add Math.nextDown and Double.isFinite
darcy
parents: 5506
diff changeset
  1319
             Math.nextDown(DoubleConsts.MIN_NORMAL));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1320
        test("%.1a", "0x1.0p-1022",
10608
7cfca36fc79b 7092404: Add Math.nextDown and Double.isFinite
darcy
parents: 5506
diff changeset
  1321
             Math.nextDown(DoubleConsts.MIN_NORMAL));
19196
5368bd038f19 6476168: (fmt) Inconsistency formatting subnormal doubles with hexadecimal conversion
bpb
parents: 18545
diff changeset
  1322
        test("%.11a", "0x1.ffffffffffep-1023", 0x0.fffffffffffp-1022);
5368bd038f19 6476168: (fmt) Inconsistency formatting subnormal doubles with hexadecimal conversion
bpb
parents: 18545
diff changeset
  1323
        test("%.1a", "0x1.0p-1022", 0x0.fffffffffffp-1022);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1324
        test("%.30a", "0x0.000000000000100000000000000000p-1022", Double.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1325
        test("%.13a", "0x0.0000000000001p-1022", Double.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1326
        test("%.11a", "0x1.00000000000p-1074", Double.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1327
        test("%.1a", "0x1.0p-1074", Double.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1328
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1329
        test("%.11a", "0x1.08000000000p-1069",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1330
             Double.MIN_VALUE + Double.MIN_VALUE*32);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1331
        test("%.1a", "0x1.0p-1069",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1332
             Double.MIN_VALUE + Double.MIN_VALUE*32);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1333
        test("%.30a", "0x1.fffffffffffff00000000000000000p1023", Double.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1334
        test("%.13a", "0x1.fffffffffffffp1023", Double.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1335
        test("%.11a", "0x1.00000000000p1024", Double.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1336
        test("%.1a", "0x1.0p1024", Double.MAX_VALUE);
19196
5368bd038f19 6476168: (fmt) Inconsistency formatting subnormal doubles with hexadecimal conversion
bpb
parents: 18545
diff changeset
  1337
        test("%.11a", "0x1.18000000000p0", 0x1.18p0);
5368bd038f19 6476168: (fmt) Inconsistency formatting subnormal doubles with hexadecimal conversion
bpb
parents: 18545
diff changeset
  1338
        test("%.1a", "0x1.2p0", 0x1.18p0);
5368bd038f19 6476168: (fmt) Inconsistency formatting subnormal doubles with hexadecimal conversion
bpb
parents: 18545
diff changeset
  1339
5368bd038f19 6476168: (fmt) Inconsistency formatting subnormal doubles with hexadecimal conversion
bpb
parents: 18545
diff changeset
  1340
        test("%.11a", "0x1.18000000000p0", 0x1.180000000001p0);
5368bd038f19 6476168: (fmt) Inconsistency formatting subnormal doubles with hexadecimal conversion
bpb
parents: 18545
diff changeset
  1341
        test("%.1a", "0x1.2p0", 0x1.180000000001p0);
5368bd038f19 6476168: (fmt) Inconsistency formatting subnormal doubles with hexadecimal conversion
bpb
parents: 18545
diff changeset
  1342
        test("%.11a", "0x1.28000000000p0", 0x1.28p0);
5368bd038f19 6476168: (fmt) Inconsistency formatting subnormal doubles with hexadecimal conversion
bpb
parents: 18545
diff changeset
  1343
        test("%.1a", "0x1.2p0", 0x1.28p0);
5368bd038f19 6476168: (fmt) Inconsistency formatting subnormal doubles with hexadecimal conversion
bpb
parents: 18545
diff changeset
  1344
5368bd038f19 6476168: (fmt) Inconsistency formatting subnormal doubles with hexadecimal conversion
bpb
parents: 18545
diff changeset
  1345
        test("%.11a", "0x1.28000000000p0", 0x1.280000000001p0);
5368bd038f19 6476168: (fmt) Inconsistency formatting subnormal doubles with hexadecimal conversion
bpb
parents: 18545
diff changeset
  1346
        test("%.1a", "0x1.3p0", 0x1.280000000001p0);
5368bd038f19 6476168: (fmt) Inconsistency formatting subnormal doubles with hexadecimal conversion
bpb
parents: 18545
diff changeset
  1347
5368bd038f19 6476168: (fmt) Inconsistency formatting subnormal doubles with hexadecimal conversion
bpb
parents: 18545
diff changeset
  1348
        test("%a", "0x0.123p-1022", 0x0.123p-1022);
5368bd038f19 6476168: (fmt) Inconsistency formatting subnormal doubles with hexadecimal conversion
bpb
parents: 18545
diff changeset
  1349
        test("%1.3a", "0x1.230p-1026", 0x0.123p-1022);
5368bd038f19 6476168: (fmt) Inconsistency formatting subnormal doubles with hexadecimal conversion
bpb
parents: 18545
diff changeset
  1350
        test("%1.12a", "0x1.230000000000p-1026", 0x0.123p-1022);
5368bd038f19 6476168: (fmt) Inconsistency formatting subnormal doubles with hexadecimal conversion
bpb
parents: 18545
diff changeset
  1351
        test("%1.15a", "0x0.123000000000000p-1022", 0x0.123p-1022);
5368bd038f19 6476168: (fmt) Inconsistency formatting subnormal doubles with hexadecimal conversion
bpb
parents: 18545
diff changeset
  1352
        test("%1.5a", "0x1.00000p-1074", 0x0.0000000000001p-1022);
5368bd038f19 6476168: (fmt) Inconsistency formatting subnormal doubles with hexadecimal conversion
bpb
parents: 18545
diff changeset
  1353
        test("%1.7a", "0x1.0000000p-1022", 0x0.fffffffffffffp-1022);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1354
19196
5368bd038f19 6476168: (fmt) Inconsistency formatting subnormal doubles with hexadecimal conversion
bpb
parents: 18545
diff changeset
  1355
        test("%1.6a", "0x1.230000p-1026", 0x0.123000057p-1022);
5368bd038f19 6476168: (fmt) Inconsistency formatting subnormal doubles with hexadecimal conversion
bpb
parents: 18545
diff changeset
  1356
        test("%1.7a", "0x1.2300005p-1026", 0x0.123000057p-1022);
5368bd038f19 6476168: (fmt) Inconsistency formatting subnormal doubles with hexadecimal conversion
bpb
parents: 18545
diff changeset
  1357
        test("%1.8a", "0x1.23000057p-1026", 0x0.123000057p-1022);
5368bd038f19 6476168: (fmt) Inconsistency formatting subnormal doubles with hexadecimal conversion
bpb
parents: 18545
diff changeset
  1358
        test("%1.9a", "0x1.230000570p-1026", 0x0.123000057p-1022);
5368bd038f19 6476168: (fmt) Inconsistency formatting subnormal doubles with hexadecimal conversion
bpb
parents: 18545
diff changeset
  1359
5368bd038f19 6476168: (fmt) Inconsistency formatting subnormal doubles with hexadecimal conversion
bpb
parents: 18545
diff changeset
  1360
        test("%1.6a", "0x1.230000p-1026", 0x0.123000058p-1022);
5368bd038f19 6476168: (fmt) Inconsistency formatting subnormal doubles with hexadecimal conversion
bpb
parents: 18545
diff changeset
  1361
        test("%1.7a", "0x1.2300006p-1026", 0x0.123000058p-1022);
5368bd038f19 6476168: (fmt) Inconsistency formatting subnormal doubles with hexadecimal conversion
bpb
parents: 18545
diff changeset
  1362
        test("%1.8a", "0x1.23000058p-1026", 0x0.123000058p-1022);
5368bd038f19 6476168: (fmt) Inconsistency formatting subnormal doubles with hexadecimal conversion
bpb
parents: 18545
diff changeset
  1363
        test("%1.9a", "0x1.230000580p-1026", 0x0.123000058p-1022);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1364
19196
5368bd038f19 6476168: (fmt) Inconsistency formatting subnormal doubles with hexadecimal conversion
bpb
parents: 18545
diff changeset
  1365
        test("%1.6a", "0x1.230000p-1026", 0x0.123000059p-1022);
5368bd038f19 6476168: (fmt) Inconsistency formatting subnormal doubles with hexadecimal conversion
bpb
parents: 18545
diff changeset
  1366
        test("%1.7a", "0x1.2300006p-1026", 0x0.123000059p-1022);
5368bd038f19 6476168: (fmt) Inconsistency formatting subnormal doubles with hexadecimal conversion
bpb
parents: 18545
diff changeset
  1367
        test("%1.8a", "0x1.23000059p-1026", 0x0.123000059p-1022);
5368bd038f19 6476168: (fmt) Inconsistency formatting subnormal doubles with hexadecimal conversion
bpb
parents: 18545
diff changeset
  1368
        test("%1.9a", "0x1.230000590p-1026", 0x0.123000059p-1022);
5368bd038f19 6476168: (fmt) Inconsistency formatting subnormal doubles with hexadecimal conversion
bpb
parents: 18545
diff changeset
  1369
5368bd038f19 6476168: (fmt) Inconsistency formatting subnormal doubles with hexadecimal conversion
bpb
parents: 18545
diff changeset
  1370
        test("%1.4a", "0x1.0000p-1022", Math.nextDown(Double.MIN_NORMAL));
5368bd038f19 6476168: (fmt) Inconsistency formatting subnormal doubles with hexadecimal conversion
bpb
parents: 18545
diff changeset
  1371
5368bd038f19 6476168: (fmt) Inconsistency formatting subnormal doubles with hexadecimal conversion
bpb
parents: 18545
diff changeset
  1372
        test("%a", "0x1.fffffffffffffp1023", Double.MAX_VALUE);
5368bd038f19 6476168: (fmt) Inconsistency formatting subnormal doubles with hexadecimal conversion
bpb
parents: 18545
diff changeset
  1373
        test("%1.1a", "0x1.0p1024", Double.MAX_VALUE);
5368bd038f19 6476168: (fmt) Inconsistency formatting subnormal doubles with hexadecimal conversion
bpb
parents: 18545
diff changeset
  1374
        test("%1.2a", "0x1.00p1024", Double.MAX_VALUE);
5368bd038f19 6476168: (fmt) Inconsistency formatting subnormal doubles with hexadecimal conversion
bpb
parents: 18545
diff changeset
  1375
        test("%1.6a", "0x1.000000p1024", Double.MAX_VALUE);
5368bd038f19 6476168: (fmt) Inconsistency formatting subnormal doubles with hexadecimal conversion
bpb
parents: 18545
diff changeset
  1376
        test("%1.9a", "0x1.000000000p1024", Double.MAX_VALUE);
5368bd038f19 6476168: (fmt) Inconsistency formatting subnormal doubles with hexadecimal conversion
bpb
parents: 18545
diff changeset
  1377
        test("%1.11a", "0x1.00000000000p1024", Double.MAX_VALUE);
5368bd038f19 6476168: (fmt) Inconsistency formatting subnormal doubles with hexadecimal conversion
bpb
parents: 18545
diff changeset
  1378
        test("%1.12a", "0x1.000000000000p1024", Double.MAX_VALUE);
5368bd038f19 6476168: (fmt) Inconsistency formatting subnormal doubles with hexadecimal conversion
bpb
parents: 18545
diff changeset
  1379
        test("%1.13a", "0x1.fffffffffffffp1023", Double.MAX_VALUE);
5368bd038f19 6476168: (fmt) Inconsistency formatting subnormal doubles with hexadecimal conversion
bpb
parents: 18545
diff changeset
  1380
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1381
#end[double]
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1382
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1383
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1384
        // %f, %e, %g, %a - Boundaries
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1385
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1386
#if[float]
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1387
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1388
        // %f, %e, %g, %a - NaN
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1389
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1390
        test("%f", "NaN", Float.NaN);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1391
        // s
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1392
        test("%+f", "NaN", Float.NaN);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1393
//      test("%F", "NAN", Float.NaN);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1394
        test("%e", "NaN", Float.NaN);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1395
        test("%+e", "NaN", Float.NaN);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1396
        test("%E", "NAN", Float.NaN);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1397
        test("%g", "NaN", Float.NaN);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1398
        test("%+g", "NaN", Float.NaN);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1399
        test("%G", "NAN", Float.NaN);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1400
        test("%a", "NaN", Float.NaN);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1401
        test("%+a", "NaN", Float.NaN);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1402
        test("%A", "NAN", Float.NaN);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1403
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1404
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1405
        // %f, %e, %g, %a - +0.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1406
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1407
        test("%f", "0.000000", +0.0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1408
        test("%+f", "+0.000000", +0.0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1409
        test("% f", " 0.000000", +0.0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1410
//      test("%F", "0.000000", +0.0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1411
        test("%e", "0.000000e+00", 0e0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1412
        test("%e", "0.000000e+00", +0.0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1413
        test("%+e", "+0.000000e+00", +0.0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1414
        test("% e", " 0.000000e+00", +0.0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1415
        test("%E", "0.000000E+00", 0e0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1416
        test("%E", "0.000000E+00", +0.0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1417
        test("%+E", "+0.000000E+00", +0.0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1418
        test("% E", " 0.000000E+00", +0.0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1419
        test("%g", "0.00000", +0.0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1420
        test("%+g", "+0.00000", +0.0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1421
        test("% g", " 0.00000", +0.0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1422
        test("%G", "0.00000", +0.0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1423
        test("% G", " 0.00000", +0.0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1424
        test("%a", "0x0.0p0", +0.0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1425
        test("%+a", "+0x0.0p0", +0.0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1426
        test("% a", " 0x0.0p0", +0.0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1427
        test("%A", "0X0.0P0", +0.0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1428
        test("% A", " 0X0.0P0", +0.0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1429
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1430
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1431
        // %f, %e, %g, %a - -0.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1432
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1433
        test("%f", "-0.000000", -0.0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1434
        test("%+f", "-0.000000", -0.0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1435
//      test("%F", "-0.000000", -0.0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1436
        test("%e", "-0.000000e+00", -0.0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1437
        test("%+e", "-0.000000e+00", -0.0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1438
        test("%E", "-0.000000E+00", -0.0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1439
        test("%+E", "-0.000000E+00", -0.0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1440
        test("%g", "-0.00000", -0.0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1441
        test("%+g", "-0.00000", -0.0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1442
        test("%G", "-0.00000", -0.0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1443
        test("%a", "-0x0.0p0", -0.0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1444
        test("%+a", "-0x0.0p0", -0.0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1445
        test("%+A", "-0X0.0P0", -0.0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1446
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1447
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1448
        // %f, %e, %g, %a - +Infinity
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1449
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1450
        test("%f", "Infinity", Float.POSITIVE_INFINITY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1451
        test("%+f", "+Infinity", Float.POSITIVE_INFINITY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1452
        test("% f", " Infinity", Float.POSITIVE_INFINITY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1453
//      test("%F", "INFINITY", Float.POSITIVE_INFINITY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1454
        test("%e", "Infinity", Float.POSITIVE_INFINITY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1455
        test("%+e", "+Infinity", Float.POSITIVE_INFINITY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1456
        test("% e", " Infinity", Float.POSITIVE_INFINITY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1457
        test("%E", "INFINITY", Float.POSITIVE_INFINITY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1458
        test("%+E", "+INFINITY", Float.POSITIVE_INFINITY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1459
        test("% E", " INFINITY", Float.POSITIVE_INFINITY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1460
        test("%g", "Infinity", Float.POSITIVE_INFINITY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1461
        test("%+g", "+Infinity", Float.POSITIVE_INFINITY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1462
        test("%G", "INFINITY", Float.POSITIVE_INFINITY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1463
        test("% G", " INFINITY", Float.POSITIVE_INFINITY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1464
        test("%+G", "+INFINITY", Float.POSITIVE_INFINITY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1465
        test("%a", "Infinity", Float.POSITIVE_INFINITY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1466
        test("%+a", "+Infinity", Float.POSITIVE_INFINITY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1467
        test("% a", " Infinity", Float.POSITIVE_INFINITY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1468
        test("%A", "INFINITY", Float.POSITIVE_INFINITY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1469
        test("%+A", "+INFINITY", Float.POSITIVE_INFINITY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1470
        test("% A", " INFINITY", Float.POSITIVE_INFINITY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1471
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1472
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1473
        // %f, %e, %g, %a - -Infinity
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1474
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1475
        test("%f", "-Infinity", Float.NEGATIVE_INFINITY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1476
        test("%+f", "-Infinity", Float.NEGATIVE_INFINITY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1477
        test("%(f", "(Infinity)", Float.NEGATIVE_INFINITY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1478
//      test("%F", "-INFINITY", Float.NEGATIVE_INFINITY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1479
        test("%e", "-Infinity", Float.NEGATIVE_INFINITY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1480
        test("%+e", "-Infinity", Float.NEGATIVE_INFINITY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1481
        test("%E", "-INFINITY", Float.NEGATIVE_INFINITY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1482
        test("%+E", "-INFINITY", Float.NEGATIVE_INFINITY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1483
        test("%g", "-Infinity", Float.NEGATIVE_INFINITY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1484
        test("%+g", "-Infinity", Float.NEGATIVE_INFINITY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1485
        test("%G", "-INFINITY", Float.NEGATIVE_INFINITY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1486
        test("%+G", "-INFINITY", Float.NEGATIVE_INFINITY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1487
        test("%a", "-Infinity", Float.NEGATIVE_INFINITY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1488
        test("%+a", "-Infinity", Float.NEGATIVE_INFINITY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1489
        test("%A", "-INFINITY", Float.NEGATIVE_INFINITY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1490
        test("%+A", "-INFINITY", Float.NEGATIVE_INFINITY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1491
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1492
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1493
        // %f, %e, %g, %a - Float.MIN_VALUE
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1494
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1495
        test("%f", "0.000000", Float.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1496
        test("%,f", "0.000000", Float.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1497
        test("%(f", "(0.000000)", -Float.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1498
        test("%30.0f",  "                             0", Float.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1499
        test("%30.5f",  "                       0.00000", Float.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1500
        test("%30.13f", "               0.0000000000000", Float.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1501
        test("%30.20f", "        0.00000000000000000000", Float.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1502
        test("%e", "1.401298e-45", Float.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1503
        test("%E", "1.401298E-45", Float.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1504
        test("%(.1e", "1.4e-45", Float.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1505
        test("%(E", "(1.401298E-45)", -Float.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1506
        test("%30.5e",  "                   1.40130e-45", Float.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1507
        test("%30.13e", "           1.4012984643248e-45", Float.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1508
        test("%30.20e", "    1.40129846432481700000e-45", Float.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1509
        test("%g", "1.40130e-45", Float.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1510
        test("%G", "1.40130E-45", Float.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1511
        test("%(g", "1.40130e-45", Float.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1512
        test("%,g", "1.40130e-45", Float.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1513
        test("%(G", "(1.40130E-45)", -Float.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1514
        test("%30.5g",  "                    1.4013e-45", Float.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1515
        test("%30.13g", "            1.401298464325e-45", Float.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1516
        test("%30.20g", "     1.4012984643248170000e-45", Float.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1517
        test("%a", "0x1.0p-149", Float.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1518
        test("%A", "0X1.0P-149", Float.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1519
        test("%20a", "          0x1.0p-149", Float.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1520
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1521
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1522
        // %f, %e, %g, %a - Float.MAX_VALUE
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1523
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1524
        test("%f", "340282346638528860000000000000000000000.000000", Float.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1525
        test("%,f","340,282,346,638,528,860,000,000,000,000,000,000,000.000000",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1526
             Float.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1527
        test("%(f", "(340282346638528860000000000000000000000.000000)", -Float.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1528
        test("%60.5f",  "               340282346638528860000000000000000000000.00000",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1529
             Float.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1530
        test("%60.13f", "       340282346638528860000000000000000000000.0000000000000",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1531
             Float.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1532
        test("%61.20f", " 340282346638528860000000000000000000000.00000000000000000000",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1533
             Float.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1534
        test("%e", "3.402823e+38", Float.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1535
        test("%E", "3.402823E+38", Float.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1536
        test("%(e", "3.402823e+38", Float.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1537
        test("%(e", "(3.402823e+38)", -Float.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1538
        test("%30.5e",  "                   3.40282e+38", Float.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1539
        test("%30.13e", "           3.4028234663853e+38", Float.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1540
        test("%30.20e", "    3.40282346638528860000e+38", Float.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1541
        test("%g", "3.40282e+38", Float.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1542
        test("%G", "3.40282E+38", Float.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1543
        test("%,g", "3.40282e+38", Float.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1544
        test("%(g", "(3.40282e+38)", -Float.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1545
        test("%30.5g",  "                    3.4028e+38", Float.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1546
        test("%30.13g", "            3.402823466385e+38", Float.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1547
        test("%30.20G", "     3.4028234663852886000E+38", Float.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1548
        test("%a", "0x1.fffffep127", Float.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1549
        test("%A", "0X1.FFFFFEP127", Float.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1550
        test("%20a","      0x1.fffffep127", Float.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1551
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1552
#end[float]
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1553
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1554
#if[double]
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1555
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1556
        // %f, %e, %g, %a - Double.MIN_VALUE
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1557
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1558
        test("%f", "0.000000", Double.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1559
        test("%,f", "0.000000", Double.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1560
        test("%(f", "(0.000000)", -Double.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1561
        test("%30.0f",  "                             0", Double.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1562
        test("%30.5f",  "                       0.00000", Double.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1563
        test("%30.13f", "               0.0000000000000", Double.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1564
        test("%30.20f", "        0.00000000000000000000", Double.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1565
        test("%30.350f","0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000490000000000000000000000000",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1566
             Double.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1567
        test("%e", "4.900000e-324", Double.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1568
        test("%E", "4.900000E-324", Double.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1569
        test("%(.1e", "4.9e-324", Double.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1570
        test("%(E", "(4.900000E-324)", -Double.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1571
        test("%30.5e",  "                  4.90000e-324", Double.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1572
        test("%30.13e", "          4.9000000000000e-324", Double.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1573
        test("%30.20e", "   4.90000000000000000000e-324", Double.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1574
        test("%g", "4.90000e-324", Double.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1575
        test("%G", "4.90000E-324", Double.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1576
        test("%(g", "4.90000e-324", Double.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1577
        test("%,g", "4.90000e-324", Double.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1578
        test("%30.5g",  "                   4.9000e-324", Double.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1579
        test("%30.13g", "           4.900000000000e-324", Double.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1580
        test("%30.20g", "    4.9000000000000000000e-324", Double.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1581
        test("%a", "0x0.0000000000001p-1022", Double.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1582
        test("%A", "0X0.0000000000001P-1022", Double.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1583
        test("%30a",    "       0x0.0000000000001p-1022", Double.MIN_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1584
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1585
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1586
        // %f, %e, %g, %a - Double.MAX_VALUE
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1587
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1588
        test("%f", "179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.000000",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1589
             Double.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1590
        test("%,f", "179,769,313,486,231,570,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000.000000",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1591
             Double.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1592
        test("%,(f", "(179,769,313,486,231,570,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000.000000)",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1593
             -Double.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1594
        test("%,30.5f", "179,769,313,486,231,570,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000.00000",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1595
             Double.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1596
        test("%30.13f", "179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.0000000000000",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1597
             Double.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1598
        test("%30.20f", "179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.00000000000000000000",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1599
             Double.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1600
        test("%e", "1.797693e+308", Double.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1601
        test("%E", "1.797693E+308", Double.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1602
        test("%(e", "1.797693e+308", Double.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1603
        test("%(e", "(1.797693e+308)", -Double.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1604
        test("%30.5e",  "                  1.79769e+308", Double.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1605
        test("%30.13e", "          1.7976931348623e+308", Double.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1606
        test("%30.20e", "   1.79769313486231570000e+308", Double.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1607
        test("%g", "1.79769e+308", Double.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1608
        test("%G", "1.79769E+308", Double.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1609
        test("%,g", "1.79769e+308", Double.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1610
        test("%(g", "(1.79769e+308)", -Double.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1611
        test("%30.5g",  "                   1.7977e+308", Double.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1612
        test("%30.13g", "           1.797693134862e+308", Double.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1613
        test("%30.20g", "    1.7976931348623157000e+308", Double.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1614
        test("%a", "0x1.fffffffffffffp1023", Double.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1615
        test("%A", "0X1.FFFFFFFFFFFFFP1023", Double.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1616
        test("%30a",    "        0x1.fffffffffffffp1023", Double.MAX_VALUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1617
#end[double]
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1618
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1619
#end[fp]
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1620
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1621
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1622
        // %t
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1623
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1624
        // Date/Time conversions applicable to Calendar, Date, and long.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1625
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1626
        test("%tA", "null", (Object)null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1627
        test("%TA", "NULL", (Object)null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1628
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1629
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1630
        // %t - errors
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1631
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1632
        tryCatch("%t", UnknownFormatConversionException.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1633
        tryCatch("%T", UnknownFormatConversionException.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1634
        tryCatch("%tP", UnknownFormatConversionException.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1635
        tryCatch("%TP", UnknownFormatConversionException.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1636
        tryCatch("%.5tB", IllegalFormatPrecisionException.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1637
        tryCatch("%#tB", FormatFlagsConversionMismatchException.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1638
        tryCatch("%-tB", MissingFormatWidthException.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1639
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1640
#if[datetime]
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1641
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1642
        // %t - create test Calendar
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1643
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1644
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1645
        // Get the supported ids for GMT-08:00 (Pacific Standard Time)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1646
        String[] ids = TimeZone.getAvailableIDs(-8 * 60 * 60 * 1000);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1647
        // Create a Pacific Standard Time time zone
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1648
        SimpleTimeZone tz = new SimpleTimeZone(-8 * 60 * 60 * 1000, ids[0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1649
        // public GregorianCalendar(TimeZone zone, Locale aLocale);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1650
        Calendar c0 = new GregorianCalendar(tz, Locale.US);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1651
        // public final void set(int year, int month, int date,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1652
        //     int hourOfDay, int minute, int second);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1653
        c0.set(1995, MAY, 23, 19, 48, 34);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1654
        c0.set(Calendar.MILLISECOND, 584);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1655
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1656
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1657
        // %t - Minutes, {nano,milli}*seconds
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1658
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1659
        // testDateTime() verifies the expected output for all applicable types
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1660
        // (Calendar, Date, and long).  It also verifies output for "%t" and
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1661
        // "%T". Thus it is sufficient to invoke that method once per
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1662
        // conversion/expected output.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1663
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1664
        testDateTime("%tM", "48", c0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1665
        testDateTime("%tN", "584000000", c0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1666
        testDateTime("%tL", "584", c0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1667
//      testDateTime("%tQ", "801283714584", c0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1668
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1669
        testDateTime("%ts", String.valueOf(c0.getTimeInMillis() / 1000), c0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1670
        testDateTime("%tS", "34", c0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1671
        testDateTime("%tT", "19:48:34", c0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1672
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1673
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1674
        // %t - Hours, morning/afternoon markers
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1675
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1676
        // testHours() iterates through all twenty-four hours to verify
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1677
        // numeric return value and morning/afternoon markers.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1678
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1679
        testHours();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1680
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1681
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1682
        // %t - Portions of date [ day, month, dates, weeks ]
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1683
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1684
        testDateTime("%ta", "Tue", c0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1685
        testDateTime("%tA", "Tuesday", c0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1686
        testDateTime("%tb", "May", c0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1687
        testDateTime("%tB", "May", c0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1688
        testDateTime("%tC", "19", c0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1689
        testDateTime("%td", "23", c0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1690
        testDateTime("%te", "23", c0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1691
        testDateTime("%th", "May", c0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1692
        testDateTime("%tj", "143", c0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1693
        testDateTime("%tm", "05", c0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1694
        testDateTime("%ty", "95", c0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1695
        testDateTime("%tY", "1995", c0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1696
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1697
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1698
        // %t - TimeZone
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1699
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1700
        testDateTime("%tz", "-0800", c0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1701
        testDateTime("%tZ", "PST", c0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1702
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1703
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1704
        // %tz should always adjust for DST
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1705
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1706
        TimeZone dtz = TimeZone.getDefault();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1707
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1708
        // Artificial TimeZone based on PST with 3:15 DST always in effect
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1709
        TimeZone atz = new SimpleTimeZone(-8 * 60 * 60 * 1000, "AlwaysDST",
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1710
            JANUARY, 1, 0, 0, STANDARD_TIME,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1711
            // 24hrs - 1m = 60 * 60 * 1000 * 24 - 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1712
            DECEMBER, 31, 0, 60 * 60 * 1000 * 24 - 1, STANDARD_TIME,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1713
            (int)(60 * 60 * 1000 * 3.25));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1714
        TimeZone.setDefault(atz);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1715
        testDateTime("%tz", "-0445", Calendar.getInstance(atz));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1716
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1717
        // Restore the TimeZone and verify
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1718
        TimeZone.setDefault(dtz);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1719
        if (atz.hasSameRules(TimeZone.getDefault()))
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1720
            throw new RuntimeException("Default TimeZone not restored");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1721
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1722
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1723
        // %t - Composites
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1724
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1725
        testDateTime("%tr", "07:48:34 PM", c0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1726
        testDateTime("%tR", "19:48", c0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1727
        testDateTime("%tc", "Tue May 23 19:48:34 PST 1995", c0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1728
        testDateTime("%tD", "05/23/95", c0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1729
        testDateTime("%tF", "1995-05-23", c0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1730
        testDateTime("%-12tF", "1995-05-23  ", c0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1731
        testDateTime("%12tF", "  1995-05-23", c0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1732
#end[datetime]
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1733
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1734
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1735
        // %n
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1736
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1737
        test("%n", System.getProperty("line.separator"), (Object)null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1738
        test("%n", System.getProperty("line.separator"), "");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1739
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1740
        tryCatch("%,n", IllegalFormatFlagsException.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1741
        tryCatch("%.n", UnknownFormatConversionException.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1742
        tryCatch("%5.n", UnknownFormatConversionException.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1743
        tryCatch("%5n", IllegalFormatWidthException.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1744
        tryCatch("%.7n", IllegalFormatPrecisionException.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1745
        tryCatch("%<n", IllegalFormatFlagsException.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1746
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1747
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1748
        // %%
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1749
        //---------------------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1750
        test("%%", "%", (Object)null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1751
        test("%%", "%", "");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1752
        tryCatch("%%%", UnknownFormatConversionException.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1753
        // perhaps an IllegalFormatArgumentIndexException should be defined?
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1754
        tryCatch("%<%", IllegalFormatFlagsException.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1755
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1756
}