diff options
Diffstat (limited to 'jack-tests/tests')
4 files changed, 142 insertions, 1 deletions
diff --git a/jack-tests/tests/com/android/jack/comparison/ComparisonTests.java b/jack-tests/tests/com/android/jack/comparison/ComparisonTests.java index 6a85530e..978e8049 100644 --- a/jack-tests/tests/com/android/jack/comparison/ComparisonTests.java +++ b/jack-tests/tests/com/android/jack/comparison/ComparisonTests.java @@ -23,7 +23,6 @@ import com.android.jack.test.runtime.RuntimeTestInfo; import com.android.jack.test.toolchain.AbstractTestTools; import org.junit.BeforeClass; -import org.junit.Ignore; import org.junit.Test; import org.junit.experimental.categories.Category; diff --git a/jack-tests/tests/com/android/jack/optimizations/notsimplifier/NotsimplifierTests.java b/jack-tests/tests/com/android/jack/optimizations/notsimplifier/NotsimplifierTests.java index 0962ae2f..9c55e5e9 100644 --- a/jack-tests/tests/com/android/jack/optimizations/notsimplifier/NotsimplifierTests.java +++ b/jack-tests/tests/com/android/jack/optimizations/notsimplifier/NotsimplifierTests.java @@ -32,18 +32,30 @@ public class NotsimplifierTests extends RuntimeTest { AbstractTestTools.getTestRootDir("com.android.jack.optimizations.notsimplifier.test001"), "com.android.jack.optimizations.notsimplifier.test001.dx.Tests"); + private RuntimeTestInfo TEST002 = new RuntimeTestInfo( + AbstractTestTools.getTestRootDir("com.android.jack.optimizations.notsimplifier.test002"), + "com.android.jack.optimizations.notsimplifier.test002.dx.Tests"); + @BeforeClass public static void setUpClass() { NotsimplifierTests.class.getClassLoader().setDefaultAssertionStatus(true); } + @Test @Category(RuntimeRegressionTest.class) public void test001() throws Exception { new RuntimeTestHelper(TEST001).compileAndRunTest(); } + @Test + @Category(RuntimeRegressionTest.class) + public void test002() throws Exception { + new RuntimeTestHelper(TEST002).compileAndRunTest(); + } + @Override protected void fillRtTestInfos() { rtTestInfos.add(TEST001); + rtTestInfos.add(TEST002); } } diff --git a/jack-tests/tests/com/android/jack/optimizations/notsimplifier/test002/dx/Tests.java b/jack-tests/tests/com/android/jack/optimizations/notsimplifier/test002/dx/Tests.java new file mode 100644 index 00000000..f63b42f1 --- /dev/null +++ b/jack-tests/tests/com/android/jack/optimizations/notsimplifier/test002/dx/Tests.java @@ -0,0 +1,86 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.jack.optimizations.notsimplifier.test002.dx; + +import com.android.jack.optimizations.notsimplifier.test002.jack.NotSimplifier; + +import junit.framework.Assert; + +import org.junit.Test; + +/** + * Tests about '!' simplifier optimization using comparison with bounds values or not of types. + */ +public class Tests { + + @Test + public void test1() { + Assert.assertTrue(NotSimplifier.smallerOrEqualTo0(Double.NaN)); + Assert.assertTrue(NotSimplifier.smallerOrEqualTo0(0.0d)); + Assert.assertTrue(NotSimplifier.smallerOrEqualTo0(-5.0d)); + Assert.assertTrue(NotSimplifier.smallerOrEqualTo0(-Double.MIN_VALUE)); + Assert.assertTrue(NotSimplifier.smallerOrEqualTo0(Double.NEGATIVE_INFINITY)); + Assert.assertFalse(NotSimplifier.smallerOrEqualTo0(Double.POSITIVE_INFINITY)); + Assert.assertFalse(NotSimplifier.smallerOrEqualTo0(Double.MAX_VALUE)); + Assert.assertFalse(NotSimplifier.smallerOrEqualTo0(5.0d)); + } + + @Test + public void test2() { + Assert.assertTrue(NotSimplifier.smallerOrEqualTo0(Float.NaN)); + Assert.assertTrue(NotSimplifier.smallerOrEqualTo0(0.0f)); + Assert.assertTrue(NotSimplifier.smallerOrEqualTo0(-5.0f)); + Assert.assertTrue(NotSimplifier.smallerOrEqualTo0(-Float.MIN_VALUE)); + Assert.assertTrue(NotSimplifier.smallerOrEqualTo0(Float.NEGATIVE_INFINITY)); + Assert.assertFalse(NotSimplifier.smallerOrEqualTo0(Float.POSITIVE_INFINITY)); + Assert.assertFalse(NotSimplifier.smallerOrEqualTo0(Float.MAX_VALUE)); + Assert.assertFalse(NotSimplifier.smallerOrEqualTo0(5.0f)); + } + + @Test + public void test3() { + Assert.assertTrue(NotSimplifier.smallerOrEqualTo0(0l)); + Assert.assertTrue(NotSimplifier.smallerOrEqualTo0(-5l)); + Assert.assertTrue(NotSimplifier.smallerOrEqualTo0(-Long.MIN_VALUE)); + Assert.assertFalse(NotSimplifier.smallerOrEqualTo0(Long.MAX_VALUE)); + Assert.assertFalse(NotSimplifier.smallerOrEqualTo0(1l)); + } + + @Test + public void test4() { + Assert.assertTrue(NotSimplifier.smallerOrEqualTo0(0)); + Assert.assertTrue(NotSimplifier.smallerOrEqualTo0(-5)); + Assert.assertTrue(NotSimplifier.smallerOrEqualTo0(-Integer.MIN_VALUE)); + Assert.assertFalse(NotSimplifier.smallerOrEqualTo0(Integer.MAX_VALUE)); + Assert.assertFalse(NotSimplifier.smallerOrEqualTo0(1)); + } + + @Test + public void test5() { + Assert.assertTrue(NotSimplifier.smallerOrEqualTo0((byte) 0)); + Assert.assertTrue(NotSimplifier.smallerOrEqualTo0((byte) -5)); + Assert.assertTrue(NotSimplifier.smallerOrEqualTo0(Byte.MIN_VALUE)); + Assert.assertFalse(NotSimplifier.smallerOrEqualTo0(Byte.MAX_VALUE)); + Assert.assertFalse(NotSimplifier.smallerOrEqualTo0((byte) 1)); + } + + @Test + public void test6() { + Assert.assertTrue(NotSimplifier.smallerOrEqualTo0(Character.MIN_VALUE)); + Assert.assertFalse(NotSimplifier.smallerOrEqualTo0(Character.MAX_VALUE)); + } +} diff --git a/jack-tests/tests/com/android/jack/optimizations/notsimplifier/test002/jack/NotSimplifier.java b/jack-tests/tests/com/android/jack/optimizations/notsimplifier/test002/jack/NotSimplifier.java new file mode 100644 index 00000000..bdd78444 --- /dev/null +++ b/jack-tests/tests/com/android/jack/optimizations/notsimplifier/test002/jack/NotSimplifier.java @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.jack.optimizations.notsimplifier.test002.jack; + +public class NotSimplifier { + + public static boolean smallerOrEqualTo0(double n) { + return !(n > 0); + } + + public static boolean smallerOrEqualTo0(float n) { + return !(n > 0); + } + + public static boolean smallerOrEqualTo0(long n) { + return !(n > 0); + } + + public static boolean smallerOrEqualTo0(int n) { + return !(n > 0); + } + + public static boolean smallerOrEqualTo0(byte n) { + return !(n > 0); + } + + public static boolean smallerOrEqualTo0(char n) { + return !(n > 0); + } +} |