Skip to content

Commit

Permalink
Merge pull request #2973 from dhong44/maxMinTests
Browse files Browse the repository at this point in the history
Add tests for Math max and min
  • Loading branch information
fjeremic authored Sep 27, 2018
2 parents 75267aa + 9cd678b commit 2aedb8a
Show file tree
Hide file tree
Showing 27 changed files with 168 additions and 105 deletions.
26 changes: 26 additions & 0 deletions test/functional/Java8andUp/playlist.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1025,6 +1025,32 @@
</groups>
</test>

<test>
<testCaseName>JCL_TEST_MathMethods</testCaseName>
<variations>
<variation>'-Xjit:disableAsyncCompilation,{*Test_Math*}(count=1)'</variation>
</variations>
<command>$(JAVA_COMMAND) $(JVM_OPTIONS) \
-cp $(Q)$(RESOURCES_DIR)$(P)$(TESTNG)$(P)$(TEST_RESROOT)$(D)GeneralTest.jar$(Q) \
-Dcom.ibm.tools.attach.enable=yes \
org.testng.TestNG -d $(REPORTDIR) $(Q)$(TEST_RESROOT)$(D)testng.xml$(Q) -testnames JCL_TEST_MathMethods \
-groups $(TEST_GROUP) \
-excludegroups $(DEFAULT_EXCLUDE); \
$(TEST_STATUS)</command>
<levels>
<level>sanity</level>
</levels>
<groups>
<group>functional</group>
</groups>
<subsets>
<subset>8</subset>
<subset>9</subset>
<subset>10</subset>
<subset>11</subset>
</subsets>
</test>

<test>
<testCaseName>VmArgumentTests</testCaseName>
<command>$(JAVA_COMMAND) $(JVM_OPTIONS) \
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*******************************************************************************
* Copyright (c) 2001, 2018 IBM Corp. and others
*
Expand All @@ -20,7 +19,6 @@
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
*******************************************************************************/

package org.openj9.test.java.lang;

public @interface AnnotationType {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*******************************************************************************
* Copyright (c) 2001, 2018 IBM Corp. and others
*
Expand All @@ -20,7 +19,6 @@
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
*******************************************************************************/

package org.openj9.test.java.lang;

class DefaultClass {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*******************************************************************************
* Copyright (c) 2001, 2018 IBM Corp. and others
*
Expand All @@ -20,7 +19,6 @@
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
*******************************************************************************/

package org.openj9.test.java.lang;

class GenericClass<E> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*******************************************************************************
* Copyright (c) 2001, 2018 IBM Corp. and others
*
Expand All @@ -20,7 +19,6 @@
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
*******************************************************************************/

package org.openj9.test.java.lang;

class GenericsClass<first,second> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*******************************************************************************
* Copyright (c) 2001, 2018 IBM Corp. and others
*
Expand All @@ -20,7 +19,6 @@
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
*******************************************************************************/

package org.openj9.test.java.lang;

public class InnerClasses {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*******************************************************************************
* Copyright (c) 2001, 2018 IBM Corp. and others
*
Expand All @@ -20,7 +19,6 @@
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
*******************************************************************************/

package org.openj9.test.java.lang;

interface Interface {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*******************************************************************************
* Copyright (c) 2001, 2018 IBM Corp. and others
*
Expand All @@ -20,7 +19,6 @@
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
*******************************************************************************/

package org.openj9.test.java.lang;

public enum PublicEnum {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*******************************************************************************
* Copyright (c) 2001, 2018 IBM Corp. and others
*
Expand All @@ -20,7 +19,6 @@
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
*******************************************************************************/

package org.openj9.test.java.lang;

public final class PublicFinalClass {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*******************************************************************************
* Copyright (c) 2001, 2018 IBM Corp. and others
*
Expand All @@ -20,7 +19,6 @@
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
*******************************************************************************/

package org.openj9.test.java.lang;

public strictfp class PublicStrictFPClass {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
package org.openj9.test.java.lang;

import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeMethod;
import org.testng.AssertJUnit;

/*******************************************************************************
* Copyright (c) 1998, 2018 IBM Corp. and others
*
Expand All @@ -26,6 +19,13 @@
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
*******************************************************************************/
package org.openj9.test.java.lang;

import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeMethod;
import org.testng.AssertJUnit;

@Test(groups = { "level.sanity" })
public class Test_ClassCastException {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
package org.openj9.test.java.lang;

/*******************************************************************************
* Copyright (c) 1998, 2018 IBM Corp. and others
*
Expand All @@ -21,6 +19,7 @@
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
*******************************************************************************/
package org.openj9.test.java.lang;

import org.testng.annotations.Test;
import org.openj9.test.support.resource.Support_Resources;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@

package org.openj9.test.java.lang;

import org.testng.annotations.Test;
import org.testng.Assert;
import org.testng.AssertJUnit;

/*******************************************************************************
* Copyright (c) 1998, 2018 IBM Corp. and others
*
Expand All @@ -26,6 +19,12 @@
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
*******************************************************************************/
package org.openj9.test.java.lang;

import org.testng.annotations.Test;
import org.testng.Assert;
import org.testng.AssertJUnit;

@Test(groups = { "level.sanity" })
public class Test_Compiler {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
package org.openj9.test.java.lang;

import org.testng.annotations.Test;
import org.testng.AssertJUnit;

/*******************************************************************************
* Copyright (c) 1998, 2018 IBM Corp. and others
*
Expand All @@ -24,6 +19,11 @@
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
*******************************************************************************/
package org.openj9.test.java.lang;

import org.testng.annotations.Test;
import org.testng.AssertJUnit;

@Test(groups = { "level.sanity" })
public class Test_InstantiationError {
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@

package org.openj9.test.java.lang;

import org.testng.annotations.Test;
import org.testng.AssertJUnit;

/*******************************************************************************
* Copyright (c) 1998, 2018 IBM Corp. and others
*
Expand All @@ -25,6 +19,11 @@
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
*******************************************************************************/
package org.openj9.test.java.lang;

import org.testng.annotations.Test;
import org.testng.AssertJUnit;

@Test(groups = { "level.sanity" })
public class Test_InstantiationException {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
package org.openj9.test.java.lang;

import org.testng.annotations.Test;

/*******************************************************************************
* Copyright (c) 2013, 2018 IBM Corp. and others
*
Expand All @@ -23,6 +19,10 @@
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
*******************************************************************************/
package org.openj9.test.java.lang;

import org.testng.annotations.Test;

@Test(groups = { "level.sanity" })
public class Test_J9VMInternals {
/*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,3 @@

package org.openj9.test.java.lang;

import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
import java.security.AccessController;
import java.security.AllPermission;
import java.security.CodeSource;
import java.security.PermissionCollection;
import java.security.PrivilegedExceptionAction;

import org.testng.Assert;
import org.testng.annotations.Test;
import org.testng.log4testng.Logger;


/*******************************************************************************
* Copyright (c) 2013, 2018 IBM Corp. and others
*
Expand All @@ -36,6 +19,21 @@
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
*******************************************************************************/
package org.openj9.test.java.lang;

import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
import java.security.AccessController;
import java.security.AllPermission;
import java.security.CodeSource;
import java.security.PermissionCollection;
import java.security.PrivilegedExceptionAction;

import org.testng.Assert;
import org.testng.annotations.Test;
import org.testng.log4testng.Logger;

@Test(groups = { "level.sanity" })
public class Test_J9VMInternalsImpl {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*******************************************************************************
* Copyright (c) 2018, 2018 IBM Corp. and others
*
* 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] http://openjdk.java.net/legal/assembly-exception.html
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
*******************************************************************************/

package org.openj9.test.java.lang;

import org.testng.annotations.Test;
import org.testng.Assert;

@Test(groups = { "level.sanity" }, invocationCount = 2)
public class Test_Math {
long longValues[] = {0L, 1L, -1L, 42L, -42L, 88L, -88L, 0x80000000L, 0x7fffffffL, 0x8000000000000000L,
0x7fffffff00000000L, 0x80000000ffffffffL, 0x7fffffffffffffffL, 0x7fffffff7fffffffL, Long.MAX_VALUE, Long.MIN_VALUE};

int intValues[] = {0, 1, -1, 42, -42, 88, -88, 0x8000, 0x7fff, 0xffff8000, Integer.MAX_VALUE, Integer.MIN_VALUE};

/**
* @tests java.lang.Math#Max()
*/
public void test_Max() {
for (int i : intValues) {
for (int j : intValues) {
Assert.assertEquals(Math.max(i,j), i > j ? i : j, "Math.max failed on integers " + i + " and " + j);
}
}

for (long i : longValues) {
for (long j : longValues) {
Assert.assertEquals(Math.max(i,j), i > j ? i : j, "Math.max failed on long values " + i + " and " + j);
}
}
}

/**
* @tests java.lang.Math#Min()
*/
public void test_Min() {
for (int i : intValues) {
for (int j : intValues) {
Assert.assertEquals(Math.min(i,j), i < j ? i : j, "Math.min failed on integers " + i + " and " + j);
}
}

for (long i : longValues) {
for (long j : longValues) {
Assert.assertEquals(Math.min(i,j), i < j ? i : j, "Math.min failed on long values " + i + " and " + j);
}
}
}
}
Loading

0 comments on commit 2aedb8a

Please sign in to comment.