author | akulyakh |
Thu, 21 May 2015 11:41:04 -0700 | |
changeset 30730 | d3ce7619db2c |
parent 9721 | da048be191c2 |
child 39363 | ebaee646b121 |
permissions | -rw-r--r-- |
7640
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
1 |
/* |
30730
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
9721
diff
changeset
|
2 |
* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. |
7640
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
4 |
* |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
8 |
* |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
13 |
* accompanied this code). |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
14 |
* |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
18 |
* |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
21 |
* questions. |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
22 |
*/ |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
23 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
24 |
/* |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
25 |
* @test |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
26 |
* @bug 7006109 |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
27 |
* @summary Add test library to simplify the task of writing automated type-system tests |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
28 |
* @author mcimadamore |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
29 |
* @library . |
30730
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
9721
diff
changeset
|
30 |
* @modules jdk.compiler/com.sun.tools.javac.code |
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
9721
diff
changeset
|
31 |
* jdk.compiler/com.sun.tools.javac.comp |
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
9721
diff
changeset
|
32 |
* jdk.compiler/com.sun.tools.javac.file |
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
9721
diff
changeset
|
33 |
* jdk.compiler/com.sun.tools.javac.util |
7640
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
34 |
* @run main BoxingConversionTest |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
35 |
*/ |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
36 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
37 |
import com.sun.tools.javac.code.Type; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
38 |
import com.sun.tools.javac.code.Type.*; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
39 |
import com.sun.tools.javac.code.Symbol.*; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
40 |
import java.lang.reflect.Array; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
41 |
import java.util.EnumSet; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
42 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
43 |
/** |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
44 |
* Check invariants in assignment/method conversion involving boxing conversions |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
45 |
*/ |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
46 |
public class BoxingConversionTest extends TypeHarness { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
47 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
48 |
Type[] types1; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
49 |
Type[] types2; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
50 |
Type[] types3; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
51 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
52 |
enum Result { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
53 |
OK_BOTH(true), |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
54 |
FAIL_BOTH(false), |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
55 |
OK_ASSIGN_ONLY(true); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
56 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
57 |
boolean value; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
58 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
59 |
Result(boolean value) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
60 |
this.value = value; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
61 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
62 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
63 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
64 |
enum ConversionKind { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
65 |
ASSIGNMENT_CONVERSION(EnumSet.of(Result.OK_BOTH, Result.OK_ASSIGN_ONLY)) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
66 |
@Override |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
67 |
void check(TypeHarness harness, Type from, Type to, Result expected) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
68 |
harness.assertAssignable(from, to, resSet.contains(expected)); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
69 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
70 |
}, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
71 |
METHOD_CONVERSION(EnumSet.of(Result.OK_BOTH)) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
72 |
@Override |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
73 |
void check(TypeHarness harness, Type from, Type to, Result expected) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
74 |
harness.assertConvertible(from, to, resSet.contains(expected)); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
75 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
76 |
}; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
77 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
78 |
EnumSet<Result> resSet; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
79 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
80 |
private ConversionKind(EnumSet<Result> resSet) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
81 |
this.resSet = resSet; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
82 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
83 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
84 |
abstract void check(TypeHarness harness, Type from, Type to, Result expected); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
85 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
86 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
87 |
enum TestKind { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
88 |
SIMPLE { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
89 |
@Override |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
90 |
Type[] getFromTypes(BoxingConversionTest harness) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
91 |
return harness.types1; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
92 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
93 |
@Override |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
94 |
Type[] getToTypes(BoxingConversionTest harness) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
95 |
return harness.types1; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
96 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
97 |
@Override |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
98 |
Result[][] getResults(BoxingConversionTest harness) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
99 |
return harness.results1; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
100 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
101 |
}, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
102 |
CONSTANT_TYPES { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
103 |
@Override |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
104 |
Type[] getFromTypes(BoxingConversionTest harness) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
105 |
return harness.types2; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
106 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
107 |
@Override |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
108 |
Type[] getToTypes(BoxingConversionTest harness) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
109 |
return harness.types3; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
110 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
111 |
@Override |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
112 |
Result[][] getResults(BoxingConversionTest harness) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
113 |
return harness.results2; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
114 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
115 |
}; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
116 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
117 |
abstract Type[] getFromTypes(BoxingConversionTest harness); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
118 |
abstract Type[] getToTypes(BoxingConversionTest harness); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
119 |
abstract Result[][] getResults(BoxingConversionTest harness); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
120 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
121 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
122 |
static final Result T = Result.OK_BOTH; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
123 |
static final Result F = Result.FAIL_BOTH; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
124 |
static final Result A = Result.OK_ASSIGN_ONLY; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
125 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
126 |
Result[][] results1 = { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
127 |
//byte, short, int, long, float, double, char, bool, Byte, Short, Integer, Long, Float, Double, Character, Boolean |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
128 |
/*byte*/ { T , T , T , T , T , T , F , F , T , F , F , F , F , F , F , F }, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
129 |
/*short*/ { F , T , T , T , T , T , F , F , F , T , F , F , F , F , F , F }, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
130 |
/*int*/ { F , F , T , T , T , T , F , F , F , F , T , F , F , F , F , F }, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
131 |
/*long*/ { F , F , F , T , T , T , F , F , F , F , F , T , F , F , F , F }, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
132 |
/*float*/ { F , F , F , F , T , T , F , F , F , F , F , F , T , F , F , F }, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
133 |
/*double*/ { F , F , F , F , F , T , F , F , F , F , F , F , F , T , F , F }, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
134 |
/*char*/ { F , F , T , T , T , T , T , F , F , F , F , F , F , F , T , F }, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
135 |
/*bool*/ { F , F , F , F , F , F , F , T , F , F , F , F , F , F , F , T }, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
136 |
/*Byte*/ { T , T , T , T , T , T , F , F , T , F , F , F , F , F , F , F }, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
137 |
/*Short*/ { F , T , T , T , T , T , F , F , F , T , F , F , F , F , F , F }, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
138 |
/*Integer*/ { F , F , T , T , T , T , F , F , F , F , T , F , F , F , F , F }, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
139 |
/*Long*/ { F , F , F , T , T , T , F , F , F , F , F , T , F , F , F , F }, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
140 |
/*Float*/ { F , F , F , F , T , T , F , F , F , F , F , F , T , F , F , F }, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
141 |
/*Double*/ { F , F , F , F , F , T , F , F , F , F , F , F , F , T , F , F }, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
142 |
/*Character*/ { F , F , T , T , T , T , T , F , F , F , F , F , F , F , T , F }, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
143 |
/*Boolean*/ { F , F , F , F , F , F , F , T , F , F , F , F , F , F , F , T }}; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
144 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
145 |
Result[][] results2 = { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
146 |
//Byte, Short, Integer, Long, Float, Double, Chararacter, Boolean |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
147 |
/*byte*/ { T , F , F , F , F , F , F , F }, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
148 |
/*short*/ { F , T , F , F , F , F , F , F }, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
149 |
/*short1*/ { A , T , F , F , F , F , A , F }, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
150 |
/*short2*/ { F , T , F , F , F , F , A , F }, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
151 |
/*int*/ { F , F , T , F , F , F , F , F }, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
152 |
/*int1*/ { A , A , T , F , F , F , A , F }, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
153 |
/*int2*/ { F , A , T , F , F , F , A , F }, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
154 |
/*int4*/ { F , F , T , F , F , F , F , F }, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
155 |
/*long*/ { F , F , F , T , F , F , F , F }, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
156 |
/*long1*/ { F , F , F , T , F , F , F , F }, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
157 |
/*long2*/ { F , F , F , T , F , F , F , F }, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
158 |
/*long4*/ { F , F , F , T , F , F , F , F }, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
159 |
/*long8*/ { F , F , F , T , F , F , F , F }, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
160 |
/*float*/ { F , F , F , F , T , F , F , F }, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
161 |
/*float1*/ { F , F , F , F , T , F , F , F }, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
162 |
/*float2*/ { F , F , F , F , T , F , F , F }, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
163 |
/*float4*/ { F , F , F , F , T , F , F , F }, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
164 |
/*double*/ { F , F , F , F , F , T , F , F }, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
165 |
/*double1*/ { F , F , F , F , F , T , F , F }, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
166 |
/*double2*/ { F , F , F , F , F , T , F , F }, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
167 |
/*double4*/ { F , F , F , F , F , T , F , F }, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
168 |
/*double8*/ { F , F , F , F , F , T , F , F }, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
169 |
/*char*/ { F , F , F , F , F , F , T , F }, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
170 |
/*char1*/ { A , A , F , F , F , F , T , F }, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
171 |
/*char2*/ { F , A , F , F , F , F , T , F }, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
172 |
/*bool*/ { F , F , F , F , F , F , F , T }}; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
173 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
174 |
BoxingConversionTest() { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
175 |
Type[] primitiveTypes = new Type[] { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
176 |
predef.byteType, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
177 |
predef.shortType, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
178 |
predef.intType, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
179 |
predef.longType, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
180 |
predef.floatType, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
181 |
predef.doubleType, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
182 |
predef.charType, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
183 |
predef.booleanType }; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
184 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
185 |
Type[] boxedTypes = new Type[primitiveTypes.length]; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
186 |
for (int i = 0 ; i < primitiveTypes.length ; i++) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
187 |
boxedTypes[i] = box(primitiveTypes[i]); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
188 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
189 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
190 |
types1 = join(Type.class, primitiveTypes, boxedTypes); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
191 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
192 |
types2 = new Type[] { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
193 |
predef.byteType, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
194 |
predef.shortType, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
195 |
fac.Constant((short)0x0001), |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
196 |
fac.Constant((short)0x0100), |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
197 |
predef.intType, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
198 |
fac.Constant((int)0x0000_0001), |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
199 |
fac.Constant((int)0x0000_0100), |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
200 |
fac.Constant((int)0x0001_0000), |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
201 |
predef.longType, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
202 |
fac.Constant((long)0x0000_0000_0000_0001L), |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
203 |
fac.Constant((long)0x0000_0000_0000_0100L), |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
204 |
fac.Constant((long)0x0000_0000_0001_0000L), |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
205 |
fac.Constant((long)0x0001_0000_0000_0000L), |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
206 |
predef.floatType, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
207 |
fac.Constant((float)0x0000_0001), |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
208 |
fac.Constant((float)0x0000_0100), |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
209 |
fac.Constant((float)0x0001_0000), |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
210 |
predef.doubleType, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
211 |
fac.Constant((double)0x0000_0000_0000_0001L), |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
212 |
fac.Constant((double)0x0000_0000_0000_0100L), |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
213 |
fac.Constant((double)0x0000_0000_0001_0000L), |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
214 |
fac.Constant((double)0x0001_0000_0000_0000L), |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
215 |
predef.charType, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
216 |
fac.Constant((char)0x0001), |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
217 |
fac.Constant((char)0x0100), |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
218 |
predef.booleanType |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
219 |
}; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
220 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
221 |
types3 = boxedTypes; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
222 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
223 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
224 |
void testConversion(ConversionKind convKind, TestKind testKind) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
225 |
Type[] rows = testKind.getFromTypes(this); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
226 |
Type[] cols = testKind.getToTypes(this); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
227 |
for (int i = 0; i < rows.length ; i++) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
228 |
for (int j = 0; j < cols.length ; j++) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
229 |
convKind.check(this, rows[i], cols[j], testKind.getResults(this)[i][j]); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
230 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
231 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
232 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
233 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
234 |
@SuppressWarnings("unchecked") |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
235 |
<T> T[] join(Class<T> type, T[]... args) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
236 |
int totalLength = 0; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
237 |
for (T[] arr : args) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
238 |
totalLength += arr.length; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
239 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
240 |
T[] new_arr = (T[])Array.newInstance(type, totalLength); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
241 |
int idx = 0; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
242 |
for (T[] arr : args) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
243 |
System.arraycopy(arr, 0, new_arr, idx, arr.length); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
244 |
idx += arr.length; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
245 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
246 |
return new_arr; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
247 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
248 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
249 |
public static void main(String[] args) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
250 |
BoxingConversionTest harness = new BoxingConversionTest(); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
251 |
for (ConversionKind convKind : ConversionKind.values()) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
252 |
for (TestKind testKind : TestKind.values()) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
253 |
harness.testConversion(convKind, testKind); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
254 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
255 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
256 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
257 |
} |