Mercurial > hg > graal-compiler
annotate graal/com.oracle.graal.test/src/com/oracle/graal/test/GraalTest.java @ 16390:ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Contributed-by: Tom Deneau <tom.deneau@amd.com>
Contributed-by: Gustav Trede <gustav.trede@gmail.com>
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 02 Jul 2014 23:40:19 +0200 |
parents | 3b6f898a2384 |
children | 86ec7f6f71b3 |
rev | line source |
---|---|
7717
cf94bd18eb47
lift GraalCompilerTest.getMethod to a common base class
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
1 /* |
cf94bd18eb47
lift GraalCompilerTest.getMethod to a common base class
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
cf94bd18eb47
lift GraalCompilerTest.getMethod to a common base class
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
cf94bd18eb47
lift GraalCompilerTest.getMethod to a common base class
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
4 * |
cf94bd18eb47
lift GraalCompilerTest.getMethod to a common base class
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
cf94bd18eb47
lift GraalCompilerTest.getMethod to a common base class
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
cf94bd18eb47
lift GraalCompilerTest.getMethod to a common base class
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
cf94bd18eb47
lift GraalCompilerTest.getMethod to a common base class
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
8 * |
cf94bd18eb47
lift GraalCompilerTest.getMethod to a common base class
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
cf94bd18eb47
lift GraalCompilerTest.getMethod to a common base class
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
cf94bd18eb47
lift GraalCompilerTest.getMethod to a common base class
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
cf94bd18eb47
lift GraalCompilerTest.getMethod to a common base class
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
cf94bd18eb47
lift GraalCompilerTest.getMethod to a common base class
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
cf94bd18eb47
lift GraalCompilerTest.getMethod to a common base class
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
14 * |
cf94bd18eb47
lift GraalCompilerTest.getMethod to a common base class
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
cf94bd18eb47
lift GraalCompilerTest.getMethod to a common base class
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
cf94bd18eb47
lift GraalCompilerTest.getMethod to a common base class
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
cf94bd18eb47
lift GraalCompilerTest.getMethod to a common base class
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
18 * |
cf94bd18eb47
lift GraalCompilerTest.getMethod to a common base class
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
cf94bd18eb47
lift GraalCompilerTest.getMethod to a common base class
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
cf94bd18eb47
lift GraalCompilerTest.getMethod to a common base class
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
21 * questions. |
cf94bd18eb47
lift GraalCompilerTest.getMethod to a common base class
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
22 */ |
cf94bd18eb47
lift GraalCompilerTest.getMethod to a common base class
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
23 package com.oracle.graal.test; |
cf94bd18eb47
lift GraalCompilerTest.getMethod to a common base class
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
24 |
15612
cf430b3e838b
moved assertEquals and MultiCauseAssertionError from GraalCompilerTest to GraalTest
Doug Simon <doug.simon@oracle.com>
parents:
15321
diff
changeset
|
25 import java.io.*; |
7717
cf94bd18eb47
lift GraalCompilerTest.getMethod to a common base class
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
26 import java.lang.reflect.*; |
13973 | 27 import java.util.*; |
7717
cf94bd18eb47
lift GraalCompilerTest.getMethod to a common base class
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
28 |
cf94bd18eb47
lift GraalCompilerTest.getMethod to a common base class
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
29 import org.junit.*; |
15612
cf430b3e838b
moved assertEquals and MultiCauseAssertionError from GraalCompilerTest to GraalTest
Doug Simon <doug.simon@oracle.com>
parents:
15321
diff
changeset
|
30 import org.junit.internal.*; |
16390
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
31 import static org.junit.Assert.*; |
7717
cf94bd18eb47
lift GraalCompilerTest.getMethod to a common base class
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
32 |
cf94bd18eb47
lift GraalCompilerTest.getMethod to a common base class
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
33 /** |
cf94bd18eb47
lift GraalCompilerTest.getMethod to a common base class
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
34 * Base class for Graal tests. |
cf94bd18eb47
lift GraalCompilerTest.getMethod to a common base class
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
35 * <p> |
15612
cf430b3e838b
moved assertEquals and MultiCauseAssertionError from GraalCompilerTest to GraalTest
Doug Simon <doug.simon@oracle.com>
parents:
15321
diff
changeset
|
36 * This contains common utility methods and classes that are used in tests. |
7717
cf94bd18eb47
lift GraalCompilerTest.getMethod to a common base class
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
37 */ |
cf94bd18eb47
lift GraalCompilerTest.getMethod to a common base class
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
38 public class GraalTest { |
cf94bd18eb47
lift GraalCompilerTest.getMethod to a common base class
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
39 |
cf94bd18eb47
lift GraalCompilerTest.getMethod to a common base class
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
40 protected Method getMethod(String methodName) { |
13814
b42977294f02
respect useCountLeadingZerosInstruction. improve substitution test
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
8340
diff
changeset
|
41 return getMethod(getClass(), methodName); |
b42977294f02
respect useCountLeadingZerosInstruction. improve substitution test
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
8340
diff
changeset
|
42 } |
b42977294f02
respect useCountLeadingZerosInstruction. improve substitution test
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
8340
diff
changeset
|
43 |
b42977294f02
respect useCountLeadingZerosInstruction. improve substitution test
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
8340
diff
changeset
|
44 protected Method getMethod(Class<?> clazz, String methodName) { |
7717
cf94bd18eb47
lift GraalCompilerTest.getMethod to a common base class
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
45 Method found = null; |
13814
b42977294f02
respect useCountLeadingZerosInstruction. improve substitution test
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
8340
diff
changeset
|
46 for (Method m : clazz.getMethods()) { |
7717
cf94bd18eb47
lift GraalCompilerTest.getMethod to a common base class
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
47 if (m.getName().equals(methodName)) { |
cf94bd18eb47
lift GraalCompilerTest.getMethod to a common base class
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
48 Assert.assertNull(found); |
cf94bd18eb47
lift GraalCompilerTest.getMethod to a common base class
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
49 found = m; |
cf94bd18eb47
lift GraalCompilerTest.getMethod to a common base class
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
50 } |
cf94bd18eb47
lift GraalCompilerTest.getMethod to a common base class
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
51 } |
14645
4f5a97ba0883
Also look for private test methods
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13973
diff
changeset
|
52 if (found == null) { |
4f5a97ba0883
Also look for private test methods
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13973
diff
changeset
|
53 /* Now look for non-public methods (but this does not look in superclasses). */ |
4f5a97ba0883
Also look for private test methods
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13973
diff
changeset
|
54 for (Method m : clazz.getDeclaredMethods()) { |
4f5a97ba0883
Also look for private test methods
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13973
diff
changeset
|
55 if (m.getName().equals(methodName)) { |
4f5a97ba0883
Also look for private test methods
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13973
diff
changeset
|
56 Assert.assertNull(found); |
4f5a97ba0883
Also look for private test methods
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13973
diff
changeset
|
57 found = m; |
4f5a97ba0883
Also look for private test methods
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13973
diff
changeset
|
58 } |
4f5a97ba0883
Also look for private test methods
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13973
diff
changeset
|
59 } |
4f5a97ba0883
Also look for private test methods
Christian Wimmer <christian.wimmer@oracle.com>
parents:
13973
diff
changeset
|
60 } |
7717
cf94bd18eb47
lift GraalCompilerTest.getMethod to a common base class
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
61 if (found != null) { |
cf94bd18eb47
lift GraalCompilerTest.getMethod to a common base class
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
62 return found; |
cf94bd18eb47
lift GraalCompilerTest.getMethod to a common base class
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
63 } else { |
cf94bd18eb47
lift GraalCompilerTest.getMethod to a common base class
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
64 throw new RuntimeException("method not found: " + methodName); |
cf94bd18eb47
lift GraalCompilerTest.getMethod to a common base class
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
65 } |
cf94bd18eb47
lift GraalCompilerTest.getMethod to a common base class
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
66 } |
13973 | 67 |
68 protected Method getMethod(Class<?> clazz, String methodName, Class<?>[] parameterTypes) { | |
69 try { | |
70 return clazz.getMethod(methodName, parameterTypes); | |
71 } catch (NoSuchMethodException | SecurityException e) { | |
72 throw new RuntimeException("method not found: " + methodName + "" + Arrays.toString(parameterTypes)); | |
73 } | |
74 } | |
15612
cf430b3e838b
moved assertEquals and MultiCauseAssertionError from GraalCompilerTest to GraalTest
Doug Simon <doug.simon@oracle.com>
parents:
15321
diff
changeset
|
75 |
cf430b3e838b
moved assertEquals and MultiCauseAssertionError from GraalCompilerTest to GraalTest
Doug Simon <doug.simon@oracle.com>
parents:
15321
diff
changeset
|
76 /** |
cf430b3e838b
moved assertEquals and MultiCauseAssertionError from GraalCompilerTest to GraalTest
Doug Simon <doug.simon@oracle.com>
parents:
15321
diff
changeset
|
77 * Compares two given objects for {@linkplain Assert#assertEquals(Object, Object) equality}. |
cf430b3e838b
moved assertEquals and MultiCauseAssertionError from GraalCompilerTest to GraalTest
Doug Simon <doug.simon@oracle.com>
parents:
15321
diff
changeset
|
78 * Does a deep copy equality comparison if {@code expected} is an array. |
cf430b3e838b
moved assertEquals and MultiCauseAssertionError from GraalCompilerTest to GraalTest
Doug Simon <doug.simon@oracle.com>
parents:
15321
diff
changeset
|
79 */ |
15622
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
80 protected void assertDeepEquals(Object expected, Object actual) { |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
81 assertDeepEquals(null, expected, actual); |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
82 } |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
83 |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
84 /** |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
85 * Compares two given objects for {@linkplain Assert#assertEquals(Object, Object) equality}. |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
86 * Does a deep copy equality comparison if {@code expected} is an array. |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
87 * |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
88 * @param message the identifying message for the {@link AssertionError} |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
89 */ |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
90 protected void assertDeepEquals(String message, Object expected, Object actual) { |
16390
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
91 if (ulpsDelta() > 0) { |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
92 assertDeepEquals(message, expected, actual, ulpsDelta()); |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
93 } else { |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
94 assertDeepEquals(message, expected, actual, equalFloatsOrDoublesDelta()); |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
95 } |
15622
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
96 } |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
97 |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
98 /** |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
99 * Compares two given values for equality, doing a recursive test if both values are arrays of |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
100 * the same type. |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
101 * |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
102 * @param message the identifying message for the {@link AssertionError} |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
103 * @param delta the maximum delta between two doubles or floats for which both numbers are still |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
104 * considered equal. |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
105 */ |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
106 protected void assertDeepEquals(String message, Object expected, Object actual, double delta) { |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
107 if (expected != null && actual != null) { |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
108 Class<?> expectedClass = expected.getClass(); |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
109 Class<?> actualClass = actual.getClass(); |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
110 if (expectedClass.isArray()) { |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
111 Assert.assertTrue(message, expected != null); |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
112 Assert.assertTrue(message, actual != null); |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
113 Assert.assertEquals(message, expectedClass, actual.getClass()); |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
114 if (expected instanceof int[]) { |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
115 Assert.assertArrayEquals(message, (int[]) expected, (int[]) actual); |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
116 } else if (expected instanceof byte[]) { |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
117 Assert.assertArrayEquals(message, (byte[]) expected, (byte[]) actual); |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
118 } else if (expected instanceof char[]) { |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
119 Assert.assertArrayEquals(message, (char[]) expected, (char[]) actual); |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
120 } else if (expected instanceof short[]) { |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
121 Assert.assertArrayEquals(message, (short[]) expected, (short[]) actual); |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
122 } else if (expected instanceof float[]) { |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
123 Assert.assertArrayEquals(message, (float[]) expected, (float[]) actual, (float) delta); |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
124 } else if (expected instanceof long[]) { |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
125 Assert.assertArrayEquals(message, (long[]) expected, (long[]) actual); |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
126 } else if (expected instanceof double[]) { |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
127 Assert.assertArrayEquals(message, (double[]) expected, (double[]) actual, delta); |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
128 } else if (expected instanceof boolean[]) { |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
129 new ExactComparisonCriteria().arrayEquals(message, expected, actual); |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
130 } else if (expected instanceof Object[]) { |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
131 new ComparisonCriteria() { |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
132 @Override |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
133 protected void assertElementsEqual(Object e, Object a) { |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
134 assertDeepEquals(message, e, a, delta); |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
135 } |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
136 }.arrayEquals(message, expected, actual); |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
137 } else { |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
138 Assert.fail((message == null ? "" : message) + "non-array value encountered: " + expected); |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
139 } |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
140 } else if (expectedClass.equals(double.class) && actualClass.equals(double.class)) { |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
141 Assert.assertEquals((double) expected, (double) actual, delta); |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
142 } else if (expectedClass.equals(float.class) && actualClass.equals(float.class)) { |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
143 Assert.assertEquals((float) expected, (float) actual, delta); |
15635
3b6f898a2384
add missing case in assertDeepEquals
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15622
diff
changeset
|
144 } else { |
3b6f898a2384
add missing case in assertDeepEquals
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15622
diff
changeset
|
145 Assert.assertEquals(message, expected, actual); |
15612
cf430b3e838b
moved assertEquals and MultiCauseAssertionError from GraalCompilerTest to GraalTest
Doug Simon <doug.simon@oracle.com>
parents:
15321
diff
changeset
|
146 } |
cf430b3e838b
moved assertEquals and MultiCauseAssertionError from GraalCompilerTest to GraalTest
Doug Simon <doug.simon@oracle.com>
parents:
15321
diff
changeset
|
147 } else { |
15622
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
148 Assert.assertEquals(message, expected, actual); |
15612
cf430b3e838b
moved assertEquals and MultiCauseAssertionError from GraalCompilerTest to GraalTest
Doug Simon <doug.simon@oracle.com>
parents:
15321
diff
changeset
|
149 } |
cf430b3e838b
moved assertEquals and MultiCauseAssertionError from GraalCompilerTest to GraalTest
Doug Simon <doug.simon@oracle.com>
parents:
15321
diff
changeset
|
150 } |
cf430b3e838b
moved assertEquals and MultiCauseAssertionError from GraalCompilerTest to GraalTest
Doug Simon <doug.simon@oracle.com>
parents:
15321
diff
changeset
|
151 |
15622
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
152 /** |
16390
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
153 * Compares two given values for equality, doing a recursive test if both values are arrays of |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
154 * the same type. Uses {@linkplain StrictMath#ulp(float) ULP}s for comparison of floats. |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
155 * |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
156 * @param message the identifying message for the {@link AssertionError} |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
157 * @param ulpsDelta the maximum allowed ulps difference between two doubles or floats for which |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
158 * both numbers are still considered equal. |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
159 */ |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
160 protected void assertDeepEquals(String message, Object expected, Object actual, int ulpsDelta) { |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
161 ComparisonCriteria doubleUlpsDeltaCriteria = new ComparisonCriteria() { |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
162 @Override |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
163 protected void assertElementsEqual(Object e, Object a) { |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
164 assertTrue(message, e instanceof Double && a instanceof Double); |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
165 // determine acceptable error based on whether it is a normal number or a NaN/Inf |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
166 double de = (Double) e; |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
167 double epsilon = (!Double.isNaN(de) && Double.isFinite(de) ? ulpsDelta * Math.ulp(de) : 0); |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
168 Assert.assertEquals(message, (Double) e, (Double) a, epsilon); |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
169 } |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
170 }; |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
171 |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
172 ComparisonCriteria floatUlpsDeltaCriteria = new ComparisonCriteria() { |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
173 @Override |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
174 protected void assertElementsEqual(Object e, Object a) { |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
175 assertTrue(message, e instanceof Float && a instanceof Float); |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
176 // determine acceptable error based on whether it is a normal number or a NaN/Inf |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
177 float fe = (Float) e; |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
178 float epsilon = (!Float.isNaN(fe) && Float.isFinite(fe) ? ulpsDelta * Math.ulp(fe) : 0); |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
179 Assert.assertEquals(message, (Float) e, (Float) a, epsilon); |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
180 } |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
181 }; |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
182 |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
183 if (expected != null && actual != null) { |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
184 Class<?> expectedClass = expected.getClass(); |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
185 Class<?> actualClass = actual.getClass(); |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
186 if (expectedClass.isArray()) { |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
187 Assert.assertEquals(message, expectedClass, actualClass); |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
188 if (expected instanceof double[] || expected instanceof Object[]) { |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
189 doubleUlpsDeltaCriteria.arrayEquals(message, expected, actual); |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
190 return; |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
191 } else if (expected instanceof float[] || expected instanceof Object[]) { |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
192 floatUlpsDeltaCriteria.arrayEquals(message, expected, actual); |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
193 return; |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
194 } |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
195 } else if (expectedClass.equals(double.class) && actualClass.equals(double.class)) { |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
196 doubleUlpsDeltaCriteria.arrayEquals(message, expected, actual); |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
197 return; |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
198 } else if (expectedClass.equals(float.class) && actualClass.equals(float.class)) { |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
199 floatUlpsDeltaCriteria.arrayEquals(message, expected, actual); |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
200 return; |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
201 } |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
202 } |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
203 // anything else just use the non-ulps version |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
204 assertDeepEquals(message, expected, actual, equalFloatsOrDoublesDelta()); |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
205 } |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
206 |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
207 /** |
15622
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
208 * Gets the value used by {@link #assertDeepEquals(Object, Object)} and |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
209 * {@link #assertDeepEquals(String, Object, Object)} for the maximum delta between two doubles |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
210 * or floats for which both numbers are still considered equal. |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
211 */ |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
212 protected double equalFloatsOrDoublesDelta() { |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
213 return 0.0D; |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
214 } |
7b09605b29c5
renamed GraalTest.assertEquals* to assertDeepEquals to avoid confusion with JUnit API methods
Doug Simon <doug.simon@oracle.com>
parents:
15612
diff
changeset
|
215 |
16390
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
216 // unless overridden ulpsDelta is not used |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
217 protected int ulpsDelta() { |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
218 return 0; |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
219 } |
ae8f4016792a
HSAIL: added support for several missing java.lang.Math routines
Doug Simon <doug.simon@oracle.com>
parents:
15635
diff
changeset
|
220 |
15612
cf430b3e838b
moved assertEquals and MultiCauseAssertionError from GraalCompilerTest to GraalTest
Doug Simon <doug.simon@oracle.com>
parents:
15321
diff
changeset
|
221 @SuppressWarnings("serial") |
cf430b3e838b
moved assertEquals and MultiCauseAssertionError from GraalCompilerTest to GraalTest
Doug Simon <doug.simon@oracle.com>
parents:
15321
diff
changeset
|
222 public static class MultiCauseAssertionError extends AssertionError { |
cf430b3e838b
moved assertEquals and MultiCauseAssertionError from GraalCompilerTest to GraalTest
Doug Simon <doug.simon@oracle.com>
parents:
15321
diff
changeset
|
223 |
cf430b3e838b
moved assertEquals and MultiCauseAssertionError from GraalCompilerTest to GraalTest
Doug Simon <doug.simon@oracle.com>
parents:
15321
diff
changeset
|
224 private Throwable[] causes; |
cf430b3e838b
moved assertEquals and MultiCauseAssertionError from GraalCompilerTest to GraalTest
Doug Simon <doug.simon@oracle.com>
parents:
15321
diff
changeset
|
225 |
cf430b3e838b
moved assertEquals and MultiCauseAssertionError from GraalCompilerTest to GraalTest
Doug Simon <doug.simon@oracle.com>
parents:
15321
diff
changeset
|
226 public MultiCauseAssertionError(String message, Throwable... causes) { |
cf430b3e838b
moved assertEquals and MultiCauseAssertionError from GraalCompilerTest to GraalTest
Doug Simon <doug.simon@oracle.com>
parents:
15321
diff
changeset
|
227 super(message); |
cf430b3e838b
moved assertEquals and MultiCauseAssertionError from GraalCompilerTest to GraalTest
Doug Simon <doug.simon@oracle.com>
parents:
15321
diff
changeset
|
228 this.causes = causes; |
cf430b3e838b
moved assertEquals and MultiCauseAssertionError from GraalCompilerTest to GraalTest
Doug Simon <doug.simon@oracle.com>
parents:
15321
diff
changeset
|
229 } |
cf430b3e838b
moved assertEquals and MultiCauseAssertionError from GraalCompilerTest to GraalTest
Doug Simon <doug.simon@oracle.com>
parents:
15321
diff
changeset
|
230 |
cf430b3e838b
moved assertEquals and MultiCauseAssertionError from GraalCompilerTest to GraalTest
Doug Simon <doug.simon@oracle.com>
parents:
15321
diff
changeset
|
231 @Override |
cf430b3e838b
moved assertEquals and MultiCauseAssertionError from GraalCompilerTest to GraalTest
Doug Simon <doug.simon@oracle.com>
parents:
15321
diff
changeset
|
232 public void printStackTrace(PrintStream out) { |
cf430b3e838b
moved assertEquals and MultiCauseAssertionError from GraalCompilerTest to GraalTest
Doug Simon <doug.simon@oracle.com>
parents:
15321
diff
changeset
|
233 super.printStackTrace(out); |
cf430b3e838b
moved assertEquals and MultiCauseAssertionError from GraalCompilerTest to GraalTest
Doug Simon <doug.simon@oracle.com>
parents:
15321
diff
changeset
|
234 int num = 0; |
cf430b3e838b
moved assertEquals and MultiCauseAssertionError from GraalCompilerTest to GraalTest
Doug Simon <doug.simon@oracle.com>
parents:
15321
diff
changeset
|
235 for (Throwable cause : causes) { |
cf430b3e838b
moved assertEquals and MultiCauseAssertionError from GraalCompilerTest to GraalTest
Doug Simon <doug.simon@oracle.com>
parents:
15321
diff
changeset
|
236 if (cause != null) { |
cf430b3e838b
moved assertEquals and MultiCauseAssertionError from GraalCompilerTest to GraalTest
Doug Simon <doug.simon@oracle.com>
parents:
15321
diff
changeset
|
237 out.print("cause " + (num++)); |
cf430b3e838b
moved assertEquals and MultiCauseAssertionError from GraalCompilerTest to GraalTest
Doug Simon <doug.simon@oracle.com>
parents:
15321
diff
changeset
|
238 cause.printStackTrace(out); |
cf430b3e838b
moved assertEquals and MultiCauseAssertionError from GraalCompilerTest to GraalTest
Doug Simon <doug.simon@oracle.com>
parents:
15321
diff
changeset
|
239 } |
cf430b3e838b
moved assertEquals and MultiCauseAssertionError from GraalCompilerTest to GraalTest
Doug Simon <doug.simon@oracle.com>
parents:
15321
diff
changeset
|
240 } |
cf430b3e838b
moved assertEquals and MultiCauseAssertionError from GraalCompilerTest to GraalTest
Doug Simon <doug.simon@oracle.com>
parents:
15321
diff
changeset
|
241 } |
cf430b3e838b
moved assertEquals and MultiCauseAssertionError from GraalCompilerTest to GraalTest
Doug Simon <doug.simon@oracle.com>
parents:
15321
diff
changeset
|
242 |
cf430b3e838b
moved assertEquals and MultiCauseAssertionError from GraalCompilerTest to GraalTest
Doug Simon <doug.simon@oracle.com>
parents:
15321
diff
changeset
|
243 @Override |
cf430b3e838b
moved assertEquals and MultiCauseAssertionError from GraalCompilerTest to GraalTest
Doug Simon <doug.simon@oracle.com>
parents:
15321
diff
changeset
|
244 public void printStackTrace(PrintWriter out) { |
cf430b3e838b
moved assertEquals and MultiCauseAssertionError from GraalCompilerTest to GraalTest
Doug Simon <doug.simon@oracle.com>
parents:
15321
diff
changeset
|
245 super.printStackTrace(out); |
cf430b3e838b
moved assertEquals and MultiCauseAssertionError from GraalCompilerTest to GraalTest
Doug Simon <doug.simon@oracle.com>
parents:
15321
diff
changeset
|
246 int num = 0; |
cf430b3e838b
moved assertEquals and MultiCauseAssertionError from GraalCompilerTest to GraalTest
Doug Simon <doug.simon@oracle.com>
parents:
15321
diff
changeset
|
247 for (Throwable cause : causes) { |
cf430b3e838b
moved assertEquals and MultiCauseAssertionError from GraalCompilerTest to GraalTest
Doug Simon <doug.simon@oracle.com>
parents:
15321
diff
changeset
|
248 if (cause != null) { |
cf430b3e838b
moved assertEquals and MultiCauseAssertionError from GraalCompilerTest to GraalTest
Doug Simon <doug.simon@oracle.com>
parents:
15321
diff
changeset
|
249 out.print("cause " + (num++) + ": "); |
cf430b3e838b
moved assertEquals and MultiCauseAssertionError from GraalCompilerTest to GraalTest
Doug Simon <doug.simon@oracle.com>
parents:
15321
diff
changeset
|
250 cause.printStackTrace(out); |
cf430b3e838b
moved assertEquals and MultiCauseAssertionError from GraalCompilerTest to GraalTest
Doug Simon <doug.simon@oracle.com>
parents:
15321
diff
changeset
|
251 } |
cf430b3e838b
moved assertEquals and MultiCauseAssertionError from GraalCompilerTest to GraalTest
Doug Simon <doug.simon@oracle.com>
parents:
15321
diff
changeset
|
252 } |
cf430b3e838b
moved assertEquals and MultiCauseAssertionError from GraalCompilerTest to GraalTest
Doug Simon <doug.simon@oracle.com>
parents:
15321
diff
changeset
|
253 } |
cf430b3e838b
moved assertEquals and MultiCauseAssertionError from GraalCompilerTest to GraalTest
Doug Simon <doug.simon@oracle.com>
parents:
15321
diff
changeset
|
254 } |
7717
cf94bd18eb47
lift GraalCompilerTest.getMethod to a common base class
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
255 } |