summaryrefslogtreecommitdiffstats
path: root/jack-tests
diff options
context:
space:
mode:
authorYohann Roussel <yroussel@google.com>2015-03-26 15:35:52 +0100
committerYohann Roussel <yroussel@google.com>2015-04-03 11:55:07 +0200
commitea1214cd80937e18fde9da30e0ee65a2749b9a58 (patch)
treef8ae67989764741948045afd758153b087d85e22 /jack-tests
parent52db3e6f7a198388e18745b3f6de642f2e040c0c (diff)
downloadtoolchain_jack-ea1214cd80937e18fde9da30e0ee65a2749b9a58.tar.gz
toolchain_jack-ea1214cd80937e18fde9da30e0ee65a2749b9a58.tar.bz2
toolchain_jack-ea1214cd80937e18fde9da30e0ee65a2749b9a58.zip
Add 3 frontend tests
Related to cases where ecj could create TypeDeclaration with a null binding. - testConflictingPackage001 and testConflictingPackage002 because CompilationUnitScope.buildTypeBinding is showing an evidence of TypeDeclaration with a null binding in case of package conflict. - testUninstanciableLocalClass001 because a comment in SafeASTVisitor (gwt) is saying that uninstanciable local classes may lead to TypeDeclaration with a null binding. Change-Id: I4aa5e9c00ff162d311b0dbd7bc16f64582a0e89c
Diffstat (limited to 'jack-tests')
-rw-r--r--jack-tests/.classpath2
-rw-r--r--jack-tests/tests/com/android/jack/AllTests.java4
-rw-r--r--jack-tests/tests/com/android/jack/frontend/FrontEndTests.java147
-rw-r--r--jack-tests/tests/com/android/jack/frontend/MissingClassTest.java61
-rw-r--r--jack-tests/tests/com/android/jack/frontend/test002/jack/PackageName.java21
-rw-r--r--jack-tests/tests/com/android/jack/frontend/test002/jack/PackageName/ClassInConflictingPackage.java21
-rw-r--r--jack-tests/tests/com/android/jack/frontend/test003/jack/PackageName.java21
-rw-r--r--jack-tests/tests/com/android/jack/frontend/test003/jack/PackageName/.gitkeep2
-rw-r--r--jack-tests/tests/com/android/jack/frontend/test004/jack/ClassWithNonInstanciableInner.java55
9 files changed, 270 insertions, 64 deletions
diff --git a/jack-tests/.classpath b/jack-tests/.classpath
index bc9b1d74..c6e7e07a 100644
--- a/jack-tests/.classpath
+++ b/jack-tests/.classpath
@@ -2,7 +2,7 @@
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
- <classpathentry excluding="com/android/jack/classpath/test002/lib1override/|com/android/jack/compiletime/test*/**|com/android/jack/enums/test003/link/Other.java|com/android/jack/enums/test003/link/Values.java|com/android/jack/error/test001/jack/A.java|com/android/jack/error/test002/jack/A.java|com/android/jack/jarjar/test003/dontcompile/|com/android/jack/java7/boxing/|com/android/jack/java7/exceptions/|com/android/jack/java7/parser/|com/android/jack/java7/switches/|com/android/jack/java7/trywithresources/|com/android/jack/lookup/test001/liboverride/|com/android/jack/nopackage/test*/**" kind="src" path="tests"/>
+ <classpathentry excluding="com/android/jack/classpath/test002/lib1override/|com/android/jack/compiletime/test*/**|com/android/jack/enums/test003/link/Other.java|com/android/jack/enums/test003/link/Values.java|com/android/jack/error/test001/jack/A.java|com/android/jack/error/test002/jack/A.java|com/android/jack/jarjar/test003/dontcompile/|com/android/jack/java7/boxing/|com/android/jack/java7/exceptions/|com/android/jack/java7/parser/|com/android/jack/java7/switches/|com/android/jack/java7/trywithresources/|com/android/jack/lookup/test001/liboverride/|com/android/jack/nopackage/test*/**|com/android/jack/frontend/test002/jack/PackageName/ClassInConflictingPackage.java" kind="src" path="tests"/>
<classpathentry kind="lib" path="libs/junit4.jar"/>
<classpathentry kind="lib" path="libs/antlr-runtime-lib.jar"/>
<classpathentry kind="lib" path="libs/dx-ref.jar"/>
diff --git a/jack-tests/tests/com/android/jack/AllTests.java b/jack-tests/tests/com/android/jack/AllTests.java
index 1ad2bd6e..01b54de1 100644
--- a/jack-tests/tests/com/android/jack/AllTests.java
+++ b/jack-tests/tests/com/android/jack/AllTests.java
@@ -26,7 +26,7 @@ import com.android.jack.fibonacci.FibonacciTests;
import com.android.jack.field.FieldTests;
import com.android.jack.fileconflict.FileConflictTests;
import com.android.jack.flow.FlowTests;
-import com.android.jack.frontend.MissingClassTest;
+import com.android.jack.frontend.FrontEndTests;
import com.android.jack.generic.basic.GenericTests;
import com.android.jack.ifstatement.IfstatementTests;
import com.android.jack.imports.ImportTests;
@@ -108,7 +108,7 @@ import org.junit.runners.Suite.SuiteClasses;
LibraryTests.class,
LookupTests.class,
MergerAllTests.class,
- MissingClassTest.class,
+ FrontEndTests.class,
MultiDexAllTests.class,
NewarrayTests.class,
ExprsimplifierTests.class,
diff --git a/jack-tests/tests/com/android/jack/frontend/FrontEndTests.java b/jack-tests/tests/com/android/jack/frontend/FrontEndTests.java
new file mode 100644
index 00000000..e70d950a
--- /dev/null
+++ b/jack-tests/tests/com/android/jack/frontend/FrontEndTests.java
@@ -0,0 +1,147 @@
+/*
+ * Copyright (C) 2014 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.frontend;
+
+import com.android.jack.category.ExtraTests;
+import com.android.jack.test.category.KnownBugs;
+import com.android.jack.test.toolchain.AbstractTestTools;
+import com.android.jack.test.toolchain.IToolchain;
+import com.android.jack.test.toolchain.JackApiToolchainBase;
+import com.android.jack.test.toolchain.JackBasedToolchain;
+
+import junit.framework.Assert;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+
+public class FrontEndTests {
+
+ @Test
+ @Category(KnownBugs.class)
+ public void testMissingClass001() throws Exception {
+ File outJackTmpMissing = AbstractTestTools.createTempDir();
+ File outJackTmpSuper = AbstractTestTools.createTempDir();
+ File outJackTmpTest = AbstractTestTools.createTempDir();
+
+ IToolchain toolchain =
+ AbstractTestTools.getCandidateToolchain();
+
+ toolchain.addToClasspath(toolchain.getDefaultBootClasspath())
+ .srcToLib(
+ outJackTmpMissing,
+ /* zipFiles= */ false,
+ AbstractTestTools.getTestRootDir("com.android.jack.frontend.test001.jack.missing"));
+
+ toolchain = AbstractTestTools.getCandidateToolchain();
+ toolchain.addToClasspath(toolchain.getDefaultBootClasspath())
+ .addToClasspath(outJackTmpMissing)
+ .srcToLib(outJackTmpSuper,
+ /* zipFiles= */ false,
+ AbstractTestTools.getTestRootDir("com.android.jack.frontend.test001.jack.sub2"));
+
+ toolchain = AbstractTestTools.getCandidateToolchain();
+ toolchain.addToClasspath(toolchain.getDefaultBootClasspath())
+ .addToClasspath(outJackTmpSuper)
+ .srcToLib(outJackTmpTest,
+ /* zipFiles= */ false,
+ AbstractTestTools.getTestRootDir("com.android.jack.frontend.test001.jack.test"));
+
+ }
+
+ /**
+ * Test that we do not crash and that we report the error.
+ */
+ @Test
+ @Category(KnownBugs.class)
+ public void testConflictingPackage001() throws Exception {
+ File outDir = AbstractTestTools.createTempDir();
+
+ JackApiToolchainBase toolchain =
+ AbstractTestTools.getCandidateToolchain(JackApiToolchainBase.class);
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ ByteArrayOutputStream err = new ByteArrayOutputStream();
+ toolchain.setOutputStream(out);
+ toolchain.setErrorStream(err);
+
+ try {
+ toolchain.addToClasspath(toolchain.getDefaultBootClasspath())
+ .srcToLib(
+ outDir,
+ /* zipFiles= */ false,
+ AbstractTestTools.getTestRootDir("com.android.jack.frontend.test002.jack"));
+ Assert.fail();
+ } catch (FrontendCompilationException e) {
+ Assert.assertEquals(0, out.size());
+ String errString = err.toString();
+ Assert.assertTrue(errString.contains("ERROR:"));
+ Assert.assertTrue(errString.contains(
+ "com.android.jack.frontend.test002.jack.PackageName"));
+ Assert.assertTrue(errString.contains("collides"));
+ }
+ }
+
+ /**
+ * Test that we do not crash.
+ */
+ @Test
+ @Category(ExtraTests.class)
+ public void testConflictingPackage002() throws Exception {
+ File outDir = AbstractTestTools.createTempDir();
+
+ IToolchain toolchain = AbstractTestTools.getCandidateToolchain();
+
+ toolchain.addToClasspath(toolchain.getDefaultBootClasspath())
+ .srcToLib(
+ outDir,
+ /* zipFiles= */ false,
+ AbstractTestTools.getTestRootDir("com.android.jack.frontend.test003.jack"));
+ }
+
+ /**
+ * Test that Jack is neither failing nor dropping warnings while ecj frontend is subject to skip
+ * the local classes.
+ */
+ @Test
+ @Category(ExtraTests.class)
+ public void testUninstanciableLocalClass001() throws Exception {
+ File outDir = AbstractTestTools.createTempDir();
+
+ IToolchain toolchain = AbstractTestTools.getCandidateToolchain(JackBasedToolchain.class);
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ ByteArrayOutputStream err = new ByteArrayOutputStream();
+ toolchain.setOutputStream(out);
+ toolchain.setErrorStream(err);
+
+ toolchain.addToClasspath(toolchain.getDefaultBootClasspath())
+ .srcToLib(
+ outDir,
+ /* zipFiles= */ false,
+ AbstractTestTools.getTestRootDir("com.android.jack.frontend.test004.jack"));
+ Assert.assertEquals(0, out.size());
+ String errString = err.toString();
+ int warnIndex = errString.indexOf("WARNING:");
+ Assert.assertTrue(warnIndex != -1);
+ warnIndex = errString.indexOf("WARNING:", warnIndex + 1);
+ Assert.assertTrue(warnIndex != -1);
+ Assert.assertTrue(errString.indexOf("WARNING:", warnIndex + 1) == -1);
+
+ }
+
+}
diff --git a/jack-tests/tests/com/android/jack/frontend/MissingClassTest.java b/jack-tests/tests/com/android/jack/frontend/MissingClassTest.java
deleted file mode 100644
index a3c5d45b..00000000
--- a/jack-tests/tests/com/android/jack/frontend/MissingClassTest.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) 2014 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.frontend;
-
-import com.android.jack.test.category.KnownBugs;
-import com.android.jack.test.toolchain.AbstractTestTools;
-import com.android.jack.test.toolchain.IToolchain;
-
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import java.io.File;
-
-public class MissingClassTest {
-
- @Test
- @Category(KnownBugs.class)
- public void test001() throws Exception {
- File outJackTmpMissing = AbstractTestTools.createTempDir();
- File outJackTmpSuper = AbstractTestTools.createTempDir();
- File outJackTmpTest = AbstractTestTools.createTempDir();
-
- IToolchain toolchain = AbstractTestTools.getCandidateToolchain();
-
- toolchain.addToClasspath(toolchain.getDefaultBootClasspath())
- .srcToLib(
- outJackTmpMissing,
- /* zipFiles= */ false,
- AbstractTestTools.getTestRootDir("com.android.jack.frontend.test001.jack.missing"));
-
- toolchain = AbstractTestTools.getCandidateToolchain();
- toolchain.addToClasspath(toolchain.getDefaultBootClasspath())
- .addToClasspath(outJackTmpMissing)
- .srcToLib(outJackTmpSuper,
- /* zipFiles= */ false,
- AbstractTestTools.getTestRootDir("com.android.jack.frontend.test001.jack.sub2"));
-
- toolchain = AbstractTestTools.getCandidateToolchain();
- toolchain.addToClasspath(toolchain.getDefaultBootClasspath())
- .addToClasspath(outJackTmpSuper)
- .srcToLib(outJackTmpTest,
- /* zipFiles= */ false,
- AbstractTestTools.getTestRootDir("com.android.jack.frontend.test001.jack.test"));
-
- }
-
-}
diff --git a/jack-tests/tests/com/android/jack/frontend/test002/jack/PackageName.java b/jack-tests/tests/com/android/jack/frontend/test002/jack/PackageName.java
new file mode 100644
index 00000000..4ccb52d3
--- /dev/null
+++ b/jack-tests/tests/com/android/jack/frontend/test002/jack/PackageName.java
@@ -0,0 +1,21 @@
+/*
+ * 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.frontend.test002.jack;
+
+public class PackageName {
+
+}
diff --git a/jack-tests/tests/com/android/jack/frontend/test002/jack/PackageName/ClassInConflictingPackage.java b/jack-tests/tests/com/android/jack/frontend/test002/jack/PackageName/ClassInConflictingPackage.java
new file mode 100644
index 00000000..5110d6e0
--- /dev/null
+++ b/jack-tests/tests/com/android/jack/frontend/test002/jack/PackageName/ClassInConflictingPackage.java
@@ -0,0 +1,21 @@
+/*
+ * 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.frontend.test002.jack.PackageName;
+
+public class ClassInConflictingPackage {
+
+}
diff --git a/jack-tests/tests/com/android/jack/frontend/test003/jack/PackageName.java b/jack-tests/tests/com/android/jack/frontend/test003/jack/PackageName.java
new file mode 100644
index 00000000..e3fc1922
--- /dev/null
+++ b/jack-tests/tests/com/android/jack/frontend/test003/jack/PackageName.java
@@ -0,0 +1,21 @@
+/*
+ * 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.frontend.test003.jack;
+
+public class PackageName {
+
+}
diff --git a/jack-tests/tests/com/android/jack/frontend/test003/jack/PackageName/.gitkeep b/jack-tests/tests/com/android/jack/frontend/test003/jack/PackageName/.gitkeep
new file mode 100644
index 00000000..4c500633
--- /dev/null
+++ b/jack-tests/tests/com/android/jack/frontend/test003/jack/PackageName/.gitkeep
@@ -0,0 +1,2 @@
+
+This is just to commit the folder in git. \ No newline at end of file
diff --git a/jack-tests/tests/com/android/jack/frontend/test004/jack/ClassWithNonInstanciableInner.java b/jack-tests/tests/com/android/jack/frontend/test004/jack/ClassWithNonInstanciableInner.java
new file mode 100644
index 00000000..bf7d7c5f
--- /dev/null
+++ b/jack-tests/tests/com/android/jack/frontend/test004/jack/ClassWithNonInstanciableInner.java
@@ -0,0 +1,55 @@
+/*
+ * 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.frontend.test004.jack;
+
+public class ClassWithNonInstanciableInner {
+
+ private static final boolean FALSE = false;
+
+ public static void test1() {
+ if (FALSE) {
+ new Runnable() {
+
+ @Override
+ public void run() {
+ int i = 1;
+ }
+ };
+ }
+ }
+
+ public static void test2() {
+ class Runner implements Runnable {
+
+ @Override
+ public void run() {
+ }
+ }
+ return;
+ }
+
+ public static void test3() {
+ abstract class Runner implements Runnable {
+
+ @Override
+ public void run() {
+ }
+ }
+ return;
+ }
+
+}