test/jdk/lib/testlibrary/AssertsTest.java
author sangheki
Mon, 08 Apr 2019 12:15:40 -0700
changeset 54467 0c5d713cf43f
parent 51840 dc15e45122b2
permissions -rw-r--r--
8218049: Survivor MemoryMXBean used() size granularity is region based Reviewed-by: tschatzl, kbarrett
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
21662
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
     1
/*
51840
dc15e45122b2 8210894: remove jdk/testlibrary/Asserts
iignatyev
parents: 47216
diff changeset
     2
 * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
21662
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
     4
 *
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
     7
 * published by the Free Software Foundation.
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
     8
 *
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    13
 * accompanied this code).
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    14
 *
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    18
 *
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    21
 * questions.
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    22
 */
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    23
30902
cf3d869e9f79 8081565: javac lint warnings in jdk testlibrary
rriggs
parents: 23036
diff changeset
    24
import java.lang.SuppressWarnings;
cf3d869e9f79 8081565: javac lint warnings in jdk testlibrary
rriggs
parents: 23036
diff changeset
    25
51840
dc15e45122b2 8210894: remove jdk/testlibrary/Asserts
iignatyev
parents: 47216
diff changeset
    26
import static jdk.test.lib.Asserts.*;
21662
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    27
51840
dc15e45122b2 8210894: remove jdk/testlibrary/Asserts
iignatyev
parents: 47216
diff changeset
    28
/*
dc15e45122b2 8210894: remove jdk/testlibrary/Asserts
iignatyev
parents: 47216
diff changeset
    29
 * @test
dc15e45122b2 8210894: remove jdk/testlibrary/Asserts
iignatyev
parents: 47216
diff changeset
    30
 * @library /test/lib
21662
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    31
 * @summary Tests the different assertions in the Assert class
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    32
 */
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    33
public class AssertsTest {
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    34
    private static class Foo implements Comparable<Foo> {
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    35
        final int id;
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    36
        public Foo(int id) {
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    37
            this.id = id;
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    38
        }
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    39
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    40
        public int compareTo(Foo f) {
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    41
            return new Integer(id).compareTo(new Integer(f.id));
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    42
        }
23036
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
    43
        public String toString() {
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
    44
            return "Foo(" + Integer.toString(id) + ")";
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
    45
        }
21662
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    46
    }
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    47
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    48
    public static void main(String[] args) throws Exception {
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    49
        testLessThan();
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    50
        testLessThanOrEqual();
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    51
        testEquals();
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    52
        testGreaterThanOrEqual();
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    53
        testGreaterThan();
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    54
        testNotEquals();
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    55
        testNull();
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    56
        testNotNull();
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    57
        testTrue();
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    58
        testFalse();
23036
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
    59
        testFail();
21662
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    60
    }
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    61
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    62
    private static void testLessThan() throws Exception {
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    63
        expectPass(Assertion.LT, 1, 2);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    64
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    65
        expectFail(Assertion.LT, 2, 2);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    66
        expectFail(Assertion.LT, 2, 1);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    67
        expectFail(Assertion.LT, null, 2);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    68
        expectFail(Assertion.LT, 2, null);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    69
    }
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    70
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    71
    private static void testLessThanOrEqual() throws Exception {
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    72
        expectPass(Assertion.LTE, 1, 2);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    73
        expectPass(Assertion.LTE, 2, 2);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    74
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    75
        expectFail(Assertion.LTE, 3, 2);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    76
        expectFail(Assertion.LTE, null, 2);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    77
        expectFail(Assertion.LTE, 2, null);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    78
    }
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    79
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    80
    private static void testEquals() throws Exception {
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    81
        expectPass(Assertion.EQ, 1, 1);
30902
cf3d869e9f79 8081565: javac lint warnings in jdk testlibrary
rriggs
parents: 23036
diff changeset
    82
        expectPass(Assertion.EQ, (Integer)null, (Integer)null);
21662
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    83
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    84
        Foo f1 = new Foo(1);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    85
        expectPass(Assertion.EQ, f1, f1);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    86
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    87
        Foo f2 = new Foo(1);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    88
        expectFail(Assertion.EQ, f1, f2);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    89
        expectFail(Assertion.LTE, null, 2);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    90
        expectFail(Assertion.LTE, 2, null);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    91
    }
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    92
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    93
    private static void testGreaterThanOrEqual() throws Exception {
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    94
        expectPass(Assertion.GTE, 1, 1);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    95
        expectPass(Assertion.GTE, 2, 1);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    96
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    97
        expectFail(Assertion.GTE, 1, 2);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    98
        expectFail(Assertion.GTE, null, 2);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    99
        expectFail(Assertion.GTE, 2, null);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   100
    }
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   101
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   102
    private static void testGreaterThan() throws Exception {
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   103
        expectPass(Assertion.GT, 2, 1);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   104
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   105
        expectFail(Assertion.GT, 1, 1);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   106
        expectFail(Assertion.GT, 1, 2);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   107
        expectFail(Assertion.GT, null, 2);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   108
        expectFail(Assertion.GT, 2, null);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   109
    }
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   110
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   111
    private static void testNotEquals() throws Exception {
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   112
        expectPass(Assertion.NE, null, 1);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   113
        expectPass(Assertion.NE, 1, null);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   114
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   115
        Foo f1 = new Foo(1);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   116
        Foo f2 = new Foo(1);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   117
        expectPass(Assertion.NE, f1, f2);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   118
30902
cf3d869e9f79 8081565: javac lint warnings in jdk testlibrary
rriggs
parents: 23036
diff changeset
   119
        expectFail(Assertion.NE, (Integer)null, (Integer)null);
21662
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   120
        expectFail(Assertion.NE, f1, f1);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   121
        expectFail(Assertion.NE, 1, 1);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   122
    }
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   123
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   124
    private static void testNull() throws Exception {
30902
cf3d869e9f79 8081565: javac lint warnings in jdk testlibrary
rriggs
parents: 23036
diff changeset
   125
        expectPass(Assertion.NULL, (Integer)null);
21662
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   126
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   127
        expectFail(Assertion.NULL, 1);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   128
    }
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   129
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   130
    private static void testNotNull() throws Exception {
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   131
        expectPass(Assertion.NOTNULL, 1);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   132
30902
cf3d869e9f79 8081565: javac lint warnings in jdk testlibrary
rriggs
parents: 23036
diff changeset
   133
        expectFail(Assertion.NOTNULL, (Integer)null);
21662
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   134
    }
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   135
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   136
    private static void testTrue() throws Exception {
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   137
        expectPass(Assertion.TRUE, true);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   138
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   139
        expectFail(Assertion.TRUE, false);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   140
    }
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   141
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   142
    private static void testFalse() throws Exception {
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   143
        expectPass(Assertion.FALSE, false);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   144
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   145
        expectFail(Assertion.FALSE, true);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   146
    }
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   147
23036
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   148
    private static void testFail() throws Exception {
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   149
        try {
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   150
            fail();
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   151
        } catch (RuntimeException re) {
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   152
            assertEquals("fail", re.getMessage());
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   153
        }
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   154
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   155
        try {
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   156
            fail("Failure");
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   157
        } catch (RuntimeException re) {
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   158
            assertEquals("Failure", re.getMessage());
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   159
        }
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   160
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   161
        Exception e = new Exception("the cause");
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   162
        try {
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   163
            fail("Fail w/ cause", e);
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   164
        } catch (RuntimeException re) {
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   165
            assertEquals("Fail w/ cause", re.getMessage());
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   166
            assertEquals(e, re.getCause(), "Cause mismatch");
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   167
        }
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   168
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   169
        try {
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   170
            fail(1, 2, "Different", "vs");
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   171
        } catch (RuntimeException re) {
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   172
            assertEquals("Different <1> vs <2>", re.getMessage());
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   173
        }
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   174
    }
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   175
30902
cf3d869e9f79 8081565: javac lint warnings in jdk testlibrary
rriggs
parents: 23036
diff changeset
   176
    @SuppressWarnings("unchecked")
21662
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   177
    private static <T extends Comparable<T>> void expectPass(Assertion assertion, T ... args)
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   178
        throws Exception {
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   179
        Assertion.run(assertion, args);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   180
    }
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   181
30902
cf3d869e9f79 8081565: javac lint warnings in jdk testlibrary
rriggs
parents: 23036
diff changeset
   182
    @SuppressWarnings("unchecked")
21662
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   183
    private static <T extends Comparable<T>> void expectFail(Assertion assertion, T ... args)
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   184
        throws Exception {
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   185
        try {
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   186
            Assertion.run(assertion, args);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   187
        } catch (RuntimeException e) {
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   188
            return;
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   189
        }
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   190
        throw new Exception("Expected " + Assertion.format(assertion, (Object[]) args) +
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   191
                            " to throw a RuntimeException");
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   192
    }
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   193
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   194
}
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   195
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   196
enum Assertion {
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   197
    LT, LTE, EQ, GTE, GT, NE, NULL, NOTNULL, FALSE, TRUE;
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   198
30902
cf3d869e9f79 8081565: javac lint warnings in jdk testlibrary
rriggs
parents: 23036
diff changeset
   199
    @SuppressWarnings("unchecked")
21662
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   200
    public static <T extends Comparable<T>> void run(Assertion assertion, T ... args) {
30902
cf3d869e9f79 8081565: javac lint warnings in jdk testlibrary
rriggs
parents: 23036
diff changeset
   201
        String msg = "Expected " + format(assertion, (Object[])args) + " to pass";
21662
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   202
        switch (assertion) {
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   203
            case LT:
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   204
                assertLessThan(args[0], args[1], msg);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   205
                break;
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   206
            case LTE:
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   207
                assertLessThanOrEqual(args[0], args[1], msg);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   208
                break;
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   209
            case EQ:
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   210
                assertEquals(args[0], args[1], msg);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   211
                break;
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   212
            case GTE:
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   213
                assertGreaterThanOrEqual(args[0], args[1], msg);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   214
                break;
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   215
            case GT:
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   216
                assertGreaterThan(args[0], args[1], msg);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   217
                break;
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   218
            case NE:
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   219
                assertNotEquals(args[0], args[1], msg);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   220
                break;
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   221
            case NULL:
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   222
                assertNull(args == null ? args : args[0], msg);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   223
                break;
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   224
            case NOTNULL:
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   225
                assertNotNull(args == null ? args : args[0], msg);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   226
                break;
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   227
            case FALSE:
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   228
                assertFalse((Boolean) args[0], msg);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   229
                break;
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   230
            case TRUE:
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   231
                assertTrue((Boolean) args[0], msg);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   232
                break;
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   233
            default:
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   234
                // do nothing
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   235
        }
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   236
    }
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   237
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   238
    public static String format(Assertion assertion, Object ... args) {
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   239
        switch (assertion) {
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   240
            case LT:
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   241
                return asString("assertLessThan", args);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   242
            case LTE:
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   243
                return asString("assertLessThanOrEqual", args);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   244
            case EQ:
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   245
                return asString("assertEquals", args);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   246
            case GTE:
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   247
                return asString("assertGreaterThanOrEquals", args);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   248
            case GT:
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   249
                return asString("assertGreaterThan", args);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   250
            case NE:
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   251
                return asString("assertNotEquals", args);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   252
            case NULL:
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   253
                return asString("assertNull", args);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   254
            case NOTNULL:
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   255
                return asString("assertNotNull", args);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   256
            case FALSE:
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   257
                return asString("assertFalse", args);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   258
            case TRUE:
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   259
                return asString("assertTrue", args);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   260
            default:
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   261
                return "";
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   262
        }
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   263
    }
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   264
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   265
    private static String asString(String assertion, Object ... args) {
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   266
        if (args == null) {
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   267
            return String.format("%s(null)", assertion);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   268
        }
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   269
        if (args.length == 1) {
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   270
            return String.format("%s(%s)", assertion, args[0]);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   271
        } else {
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   272
            return String.format("%s(%s, %s)", assertion, args[0], args[1]);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   273
        }
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   274
    }
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   275
}