jdk/test/lib/testlibrary/AssertsTest.java
author sla
Mon, 07 Apr 2014 08:09:55 +0200
changeset 23723 46b29c0e9656
parent 23036 b711f9772be8
child 30902 cf3d869e9f79
permissions -rw-r--r--
8039256: Add sun/jvmstat/monitor/MonitoredVm/CR6672135.java to ProblemList.txt Reviewed-by: mgronlun, alanb
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
/*
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
     2
 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
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
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    24
import static jdk.testlibrary.Asserts.*;
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    25
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    26
/* @test
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    27
 * @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
    28
 */
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    29
public class AssertsTest {
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    30
    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
    31
        final int id;
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    32
        public Foo(int id) {
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    33
            this.id = id;
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    34
        }
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    35
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    36
        public int compareTo(Foo f) {
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    37
            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
    38
        }
23036
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
    39
        public String toString() {
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
    40
            return "Foo(" + Integer.toString(id) + ")";
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
    41
        }
21662
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    42
    }
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    43
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    44
    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
    45
        testLessThan();
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    46
        testLessThanOrEqual();
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    47
        testEquals();
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    48
        testGreaterThanOrEqual();
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    49
        testGreaterThan();
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    50
        testNotEquals();
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    51
        testNull();
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    52
        testNotNull();
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    53
        testTrue();
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    54
        testFalse();
23036
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
    55
        testFail();
21662
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    56
    }
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    57
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    58
    private static void testLessThan() throws Exception {
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    59
        expectPass(Assertion.LT, 1, 2);
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
        expectFail(Assertion.LT, 2, 2);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    62
        expectFail(Assertion.LT, 2, 1);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    63
        expectFail(Assertion.LT, null, 2);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    64
        expectFail(Assertion.LT, 2, null);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    65
    }
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    66
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    67
    private static void testLessThanOrEqual() throws Exception {
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    68
        expectPass(Assertion.LTE, 1, 2);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    69
        expectPass(Assertion.LTE, 2, 2);
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
        expectFail(Assertion.LTE, 3, 2);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    72
        expectFail(Assertion.LTE, null, 2);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    73
        expectFail(Assertion.LTE, 2, null);
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
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    76
    private static void testEquals() throws Exception {
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    77
        expectPass(Assertion.EQ, 1, 1);
23036
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
    78
        expectPass(Assertion.EQ, (Comparable)null, (Comparable)null);
21662
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
        Foo f1 = new Foo(1);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    81
        expectPass(Assertion.EQ, f1, f1);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    82
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    83
        Foo f2 = new Foo(1);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    84
        expectFail(Assertion.EQ, f1, f2);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    85
        expectFail(Assertion.LTE, null, 2);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    86
        expectFail(Assertion.LTE, 2, null);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    87
    }
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    88
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    89
    private static void testGreaterThanOrEqual() throws Exception {
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    90
        expectPass(Assertion.GTE, 1, 1);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    91
        expectPass(Assertion.GTE, 2, 1);
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
        expectFail(Assertion.GTE, 1, 2);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    94
        expectFail(Assertion.GTE, null, 2);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    95
        expectFail(Assertion.GTE, 2, null);
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
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    98
    private static void testGreaterThan() throws Exception {
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
    99
        expectPass(Assertion.GT, 2, 1);
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
        expectFail(Assertion.GT, 1, 1);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   102
        expectFail(Assertion.GT, 1, 2);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   103
        expectFail(Assertion.GT, null, 2);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   104
        expectFail(Assertion.GT, 2, null);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   105
    }
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   106
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   107
    private static void testNotEquals() throws Exception {
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   108
        expectPass(Assertion.NE, null, 1);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   109
        expectPass(Assertion.NE, 1, null);
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
        Foo f1 = new Foo(1);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   112
        Foo f2 = new Foo(1);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   113
        expectPass(Assertion.NE, f1, f2);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   114
23036
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   115
        expectFail(Assertion.NE, (Comparable)null, (Comparable)null);
21662
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   116
        expectFail(Assertion.NE, f1, f1);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   117
        expectFail(Assertion.NE, 1, 1);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   118
    }
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   119
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   120
    private static void testNull() throws Exception {
23036
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   121
        expectPass(Assertion.NULL, (Comparable)null);
21662
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
        expectFail(Assertion.NULL, 1);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   124
    }
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   125
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   126
    private static void testNotNull() throws Exception {
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   127
        expectPass(Assertion.NOTNULL, 1);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   128
23036
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   129
        expectFail(Assertion.NOTNULL, (Comparable)null);
21662
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   130
    }
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   131
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   132
    private static void testTrue() throws Exception {
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   133
        expectPass(Assertion.TRUE, true);
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
        expectFail(Assertion.TRUE, false);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   136
    }
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   137
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   138
    private static void testFalse() throws Exception {
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   139
        expectPass(Assertion.FALSE, 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
        expectFail(Assertion.FALSE, true);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   142
    }
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   143
23036
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   144
    private static void testFail() throws Exception {
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   145
        try {
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   146
            fail();
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   147
        } catch (RuntimeException re) {
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   148
            assertEquals("fail", re.getMessage());
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   149
        }
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   150
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   151
        try {
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   152
            fail("Failure");
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   153
        } catch (RuntimeException re) {
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   154
            assertEquals("Failure", re.getMessage());
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   155
        }
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   156
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   157
        Exception e = new Exception("the cause");
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   158
        try {
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   159
            fail("Fail w/ cause", e);
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   160
        } catch (RuntimeException re) {
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   161
            assertEquals("Fail w/ cause", re.getMessage());
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   162
            assertEquals(e, re.getCause(), "Cause mismatch");
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   163
        }
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   164
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   165
        try {
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   166
            fail(1, 2, "Different", "vs");
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   167
        } catch (RuntimeException re) {
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   168
            assertEquals("Different <1> vs <2>", re.getMessage());
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   169
        }
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   170
    }
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   171
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   172
b711f9772be8 8035889: jdk testlibrary - add printing of values of failed assertions
rriggs
parents: 21662
diff changeset
   173
21662
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   174
    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
   175
        throws Exception {
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   176
        Assertion.run(assertion, args);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   177
    }
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   178
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   179
    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
   180
        throws Exception {
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   181
        try {
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   182
            Assertion.run(assertion, args);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   183
        } catch (RuntimeException e) {
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   184
            return;
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   185
        }
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   186
        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
   187
                            " to throw a RuntimeException");
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   188
    }
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
}
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   191
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   192
enum Assertion {
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   193
    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
   194
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   195
    public static <T extends Comparable<T>> void run(Assertion assertion, T ... args) {
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   196
        String msg = "Expected " + format(assertion, args) + " to pass";
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   197
        switch (assertion) {
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   198
            case LT:
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   199
                assertLessThan(args[0], args[1], msg);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   200
                break;
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   201
            case LTE:
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   202
                assertLessThanOrEqual(args[0], args[1], msg);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   203
                break;
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   204
            case EQ:
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   205
                assertEquals(args[0], args[1], msg);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   206
                break;
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   207
            case GTE:
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   208
                assertGreaterThanOrEqual(args[0], args[1], msg);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   209
                break;
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   210
            case GT:
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   211
                assertGreaterThan(args[0], args[1], msg);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   212
                break;
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   213
            case NE:
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   214
                assertNotEquals(args[0], args[1], msg);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   215
                break;
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   216
            case NULL:
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   217
                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
   218
                break;
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   219
            case NOTNULL:
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   220
                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
   221
                break;
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   222
            case FALSE:
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   223
                assertFalse((Boolean) args[0], msg);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   224
                break;
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   225
            case TRUE:
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   226
                assertTrue((Boolean) args[0], msg);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   227
                break;
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   228
            default:
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   229
                // do nothing
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   230
        }
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   231
    }
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   232
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   233
    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
   234
        switch (assertion) {
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   235
            case LT:
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   236
                return asString("assertLessThan", args);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   237
            case LTE:
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   238
                return asString("assertLessThanOrEqual", args);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   239
            case EQ:
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   240
                return asString("assertEquals", args);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   241
            case GTE:
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   242
                return asString("assertGreaterThanOrEquals", args);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   243
            case GT:
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   244
                return asString("assertGreaterThan", args);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   245
            case NE:
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   246
                return asString("assertNotEquals", args);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   247
            case NULL:
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   248
                return asString("assertNull", args);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   249
            case NOTNULL:
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   250
                return asString("assertNotNull", args);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   251
            case FALSE:
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   252
                return asString("assertFalse", args);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   253
            case TRUE:
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   254
                return asString("assertTrue", args);
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   255
            default:
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   256
                return "";
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   257
        }
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   258
    }
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   259
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   260
    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
   261
        if (args == null) {
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   262
            return String.format("%s(null)", assertion);
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
        if (args.length == 1) {
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   265
            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
   266
        } else {
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   267
            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
   268
        }
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   269
    }
b37eb0c9db8d 8015497: Take new fixes from hotspot/test/testlibrary to jdk/test/lib/testlibrary
ykantser
parents:
diff changeset
   270
}