-
Notifications
You must be signed in to change notification settings - Fork 729
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18317 from theresa-m/valuetypetests_1
Split ValueTypeTests for lw5 and enable basic value type tests
- Loading branch information
Showing
4 changed files
with
211 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
206 changes: 206 additions & 0 deletions
206
test/functional/Valhalla/src_lw5/org/openj9/test/lworld/ValueTypeTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,206 @@ | ||
/******************************************************************************* | ||
* Copyright IBM Corp. and others 2023 | ||
* | ||
* This program and the accompanying materials are made available under | ||
* the terms of the Eclipse Public License 2.0 which accompanies this | ||
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* or the Apache License, Version 2.0 which accompanies this distribution and | ||
* is available at https://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* This Source Code may also be made available under the following | ||
* Secondary Licenses when the conditions for such availability set | ||
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU | ||
* General Public License, version 2 with the GNU Classpath | ||
* Exception [1] and GNU General Public License, version 2 with the | ||
* OpenJDK Assembly Exception [2]. | ||
* | ||
* [1] https://www.gnu.org/software/classpath/license.html | ||
* [2] https://openjdk.org/legal/assembly-exception.html | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 OR GPL-2.0-only WITH OpenJDK-assembly-exception-1.0 | ||
*******************************************************************************/ | ||
package org.openj9.test.lworld; | ||
|
||
import static org.testng.Assert.*; | ||
import org.testng.annotations.Test; | ||
|
||
/* | ||
* Instructions to run this test: | ||
* | ||
* 1) Build the JDK with the '--enable-inline-types' configure flag | ||
* 2) cd [openj9-openjdk-dir]/openj9/test | ||
* 3) git clone https://github.com/adoptium/TKG.git | ||
* 4) cd TKG | ||
* 5) export TEST_JDK_HOME=[openj9-openjdk-dir]/build/linux-x86_64-server-release/images/jdk | ||
* 6) export JDK_VERSION=Valhalla | ||
* 7) export SPEC=linux_x86-64_cmprssptrs | ||
* 8) export BUILD_LIST=functional/Valhalla | ||
* 9) export AUTO_DETECT=false | ||
* 10) export JDK_IMPL=openj9 | ||
* 11) make -f run_configure.mk && make compile && make _sanity | ||
*/ | ||
|
||
@Test(groups = { "level.sanity" }) | ||
public class ValueTypeTests { | ||
/* default values */ | ||
static int[] defaultPointPositions1 = {0xFFEEFFEE, 0xAABBAABB}; | ||
static int[] defaultPointPositions2 = {0xCCDDCCDD, 0x33443344}; | ||
static int[] defaultPointPositions3 = {0x43211234, 0xABCDDCBA}; | ||
static int[][] defaultLinePositions1 = {defaultPointPositions1, defaultPointPositions2}; | ||
static int[][] defaultLinePositions2 = {defaultPointPositions2, defaultPointPositions3}; | ||
static int[][] defaultLinePositions3 = {defaultPointPositions1, defaultPointPositions3}; | ||
static int[][][] defaultTrianglePositions = {defaultLinePositions1, defaultLinePositions2, defaultLinePositions3}; | ||
|
||
static value class Point2D { | ||
int x; | ||
int y; | ||
|
||
public implicit Point2D(); | ||
|
||
Point2D(int x, int y) { | ||
this.x = x; | ||
this.y = y; | ||
} | ||
} | ||
|
||
static value class Point2DComplex { | ||
double d; | ||
long l; | ||
|
||
Point2DComplex(double d, long l) { | ||
this.d = d; | ||
this.l = l; | ||
} | ||
} | ||
|
||
static value class Line2D { | ||
Point2D st; | ||
Point2D en; | ||
|
||
Line2D(Point2D st, Point2D en) { | ||
this.st = st; | ||
this.en = en; | ||
} | ||
} | ||
|
||
static value class FlattenedLine2D { | ||
Point2D! st; | ||
Point2D! en; | ||
|
||
public implicit FlattenedLine2D(); | ||
|
||
FlattenedLine2D(Point2D! st, Point2D! en) { | ||
this.st = st; | ||
this.en = en; | ||
} | ||
} | ||
|
||
static value class Triangle2D { | ||
FlattenedLine2D! v1; | ||
FlattenedLine2D! v2; | ||
FlattenedLine2D! v3; | ||
|
||
public implicit Triangle2D(); | ||
|
||
Triangle2D(FlattenedLine2D! v1, FlattenedLine2D! v2, FlattenedLine2D! v3) { | ||
this.v1 = v1; | ||
this.v2 = v2; | ||
this.v3 = v3; | ||
} | ||
|
||
Triangle2D(int[][][] positions) { | ||
this(new FlattenedLine2D(new Point2D(positions[0][0][0], positions[0][0][1]), | ||
new Point2D(positions[0][1][0], positions[0][1][1])), | ||
new FlattenedLine2D(new Point2D(positions[1][0][0], positions[1][0][1]), | ||
new Point2D(positions[1][1][0], positions[1][1][1])), | ||
new FlattenedLine2D(new Point2D(positions[2][0][0], positions[2][0][1]), | ||
new Point2D(positions[2][1][0], positions[2][1][1]))); | ||
} | ||
} | ||
|
||
@Test(priority=1) | ||
static public void testCreatePoint2D() throws Throwable { | ||
int x = 0xFFEEFFEE; | ||
int y = 0xAABBAABB; | ||
|
||
Point2D point2D = new Point2D(x, y); | ||
|
||
assertEquals(point2D.x, x); | ||
assertEquals(point2D.y, y); | ||
|
||
// TODO add putfield tests once withfield is replaced | ||
} | ||
|
||
@Test(priority=1) | ||
static public void testCreatePoint2DComplex() throws Throwable { | ||
double d = Double.MAX_VALUE; | ||
long l = Long.MAX_VALUE; | ||
|
||
Point2DComplex p = new Point2DComplex(d, l); | ||
|
||
assertEquals(p.d, d); | ||
assertEquals(p.l, l); | ||
|
||
// TODO add putfield tests once withfield is replaced | ||
} | ||
|
||
@Test(priority=2) | ||
static public void testCreateLine2D() throws Throwable { | ||
int x = 0xFFEEFFEE; | ||
int y = 0xAABBAABB; | ||
int x2 = 0xCCDDCCDD; | ||
int y2 = 0xAAFFAAFF; | ||
|
||
Point2D st = new Point2D(x, y); | ||
Point2D en = new Point2D(x2, y2); | ||
Line2D line2D = new Line2D(st, en); | ||
|
||
assertEquals(line2D.st.x, x); | ||
assertEquals(line2D.st.y, y); | ||
assertEquals(line2D.en.x, x2); | ||
assertEquals(line2D.en.y, y2); | ||
|
||
// TODO add putfield tests once withfield is replaced | ||
} | ||
|
||
@Test(priority=2) | ||
static public void testCreateFlattenedLine2D() throws Throwable { | ||
int x = 0xFFEEFFEE; | ||
int y = 0xAABBAABB; | ||
int x2 = 0xCCDDCCDD; | ||
int y2 = 0xAAFFAAFF; | ||
|
||
Point2D! st = new Point2D(x, y); | ||
Point2D! en = new Point2D(x2, y2); | ||
FlattenedLine2D line2D = new FlattenedLine2D(st, en); | ||
|
||
assertEquals(line2D.st.x, x); | ||
assertEquals(line2D.st.y, y); | ||
assertEquals(line2D.en.x, x2); | ||
assertEquals(line2D.en.y, y2); | ||
|
||
// TODO add putfield tests once withfield is replaced | ||
} | ||
|
||
@Test(priority=3) | ||
static public void testCreateTriangle2D() throws Throwable { | ||
Triangle2D triangle2D = new Triangle2D(defaultTrianglePositions); | ||
checkEqualTriangle2D(triangle2D, defaultTrianglePositions); | ||
} | ||
|
||
static void checkEqualPoint2D(Point2D point, int[] positions) throws Throwable { | ||
assertEquals(point.x, positions[0]); | ||
assertEquals(point.y, positions[1]); | ||
} | ||
|
||
static void checkEqualFlattenedLine2D(FlattenedLine2D line, int[][] positions) throws Throwable { | ||
checkEqualPoint2D(line.st, positions[0]); | ||
checkEqualPoint2D(line.en, positions[1]); | ||
} | ||
|
||
static void checkEqualTriangle2D(Triangle2D triangle, int[][][] positions) throws Throwable { | ||
checkEqualFlattenedLine2D(triangle.v1, positions[0]); | ||
checkEqualFlattenedLine2D(triangle.v2, positions[1]); | ||
checkEqualFlattenedLine2D(triangle.v3, positions[2]); | ||
} | ||
} |
File renamed without changes.