diff options
author | mikaelpeltier <mikaelpeltier@google.com> | 2015-04-08 13:11:31 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2015-04-08 13:11:32 +0000 |
commit | e8b47c365059d925517fc830828f5dcd9f4d2078 (patch) | |
tree | a7dd61b22f0cca2536dd2375293005f3b09b9fd9 /jack-tests/tests/com/android | |
parent | 1f97da0c733c6a525a8bd7b0f6a8325ce671586f (diff) | |
parent | 81861fd04ba4863b321de26c0852575fa7f173c3 (diff) | |
download | toolchain_jack-e8b47c365059d925517fc830828f5dcd9f4d2078.tar.gz toolchain_jack-e8b47c365059d925517fc830828f5dcd9f4d2078.tar.bz2 toolchain_jack-e8b47c365059d925517fc830828f5dcd9f4d2078.zip |
Merge "Fix bug into Java parser" into ub-jack
Diffstat (limited to 'jack-tests/tests/com/android')
6 files changed, 206 insertions, 0 deletions
diff --git a/jack-tests/tests/com/android/jack/AllTests.java b/jack-tests/tests/com/android/jack/AllTests.java index 76dc3973..47b7a087 100644 --- a/jack-tests/tests/com/android/jack/AllTests.java +++ b/jack-tests/tests/com/android/jack/AllTests.java @@ -28,6 +28,7 @@ import com.android.jack.fileconflict.FileConflictTests; import com.android.jack.flow.FlowTests; import com.android.jack.frontend.DuplicateSourceTest; import com.android.jack.frontend.FrontEndTests; +import com.android.jack.frontend.ParserTest; import com.android.jack.generic.basic.GenericTests; import com.android.jack.ifstatement.IfstatementTests; import com.android.jack.imports.ImportTests; @@ -118,6 +119,7 @@ import org.junit.runners.Suite.SuiteClasses; NoPackageTests.class, OrderTests.class, OpcodesTests.class, + ParserTest.class, PreProcessorTests.class, ReturnstatementTests.class, ResourceTests.class, diff --git a/jack-tests/tests/com/android/jack/frontend/ParserTest.java b/jack-tests/tests/com/android/jack/frontend/ParserTest.java new file mode 100644 index 00000000..692c261b --- /dev/null +++ b/jack-tests/tests/com/android/jack/frontend/ParserTest.java @@ -0,0 +1,73 @@ +/* + * 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; + +import com.android.jack.Options; +import com.android.jack.test.toolchain.AbstractTestTools; +import com.android.jack.test.toolchain.JackApiToolchainBase; + +import junit.framework.Assert; + +import org.junit.Test; + +import java.io.ByteArrayOutputStream; +import java.io.File; + +public class ParserTest { + + @Test + public void test001() throws Exception { + File outJackTmpTest = AbstractTestTools.createTempDir(); + ByteArrayOutputStream errOut = new ByteArrayOutputStream(); + + JackApiToolchainBase toolchain = + AbstractTestTools.getCandidateToolchain(JackApiToolchainBase.class); + toolchain.setErrorStream(errOut); + toolchain.addProperty(Options.INPUT_FILTER.getName(), "ordered-filter"); + + try { + toolchain.addToClasspath(toolchain.getDefaultBootClasspath()).srcToExe(outJackTmpTest, + false /* zipFile */ + , AbstractTestTools.getTestRootDir("com.android.jack.frontend.test005.jack")); + Assert.fail(); + } catch (FrontendCompilationException e) { + Assert.assertTrue( + errOut.toString().contains("Syntax error on token \"}\", delete this token")); + } + } + + @Test + public void test002() throws Exception { + File outJackTmpTest = AbstractTestTools.createTempDir(); + ByteArrayOutputStream errOut = new ByteArrayOutputStream(); + + JackApiToolchainBase toolchain = + AbstractTestTools.getCandidateToolchain(JackApiToolchainBase.class); + toolchain.setErrorStream(errOut); + toolchain.addProperty(Options.INPUT_FILTER.getName(), "ordered-filter"); + + try { + toolchain.addToClasspath(toolchain.getDefaultBootClasspath()).srcToExe(outJackTmpTest, + false /* zipFile */ + , AbstractTestTools.getTestRootDir("com.android.jack.frontend.test006.jack")); + Assert.fail(); + } catch (FrontendCompilationException e) { + Assert.assertTrue( + errOut.toString().contains("Syntax error on token \"b5\", delete this token")); + } + } +} diff --git a/jack-tests/tests/com/android/jack/frontend/test005/jack/A.java b/jack-tests/tests/com/android/jack/frontend/test005/jack/A.java new file mode 100644 index 00000000..945e6c3e --- /dev/null +++ b/jack-tests/tests/com/android/jack/frontend/test005/jack/A.java @@ -0,0 +1,31 @@ +/* + * 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.test005.jack; + + +public final class A { + public interface B { + void test(); + } + + private final B b = new B() { + + @Override + public void test() {} + } + }; +} diff --git a/jack-tests/tests/com/android/jack/frontend/test005/jack/B.java b/jack-tests/tests/com/android/jack/frontend/test005/jack/B.java new file mode 100644 index 00000000..d7f76eef --- /dev/null +++ b/jack-tests/tests/com/android/jack/frontend/test005/jack/B.java @@ -0,0 +1,34 @@ +/* + * 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.test005.jack; + +public class B { + + private static class X { + static final Object instance1; + static { + try { + instance1 = new Object(); + } catch (Throwable e) { + throw new AssertionError(e); + } + } + } + + X x = new X(); + Object o = X.instance1; +} diff --git a/jack-tests/tests/com/android/jack/frontend/test006/jack/A.java b/jack-tests/tests/com/android/jack/frontend/test006/jack/A.java new file mode 100644 index 00000000..b3064897 --- /dev/null +++ b/jack-tests/tests/com/android/jack/frontend/test006/jack/A.java @@ -0,0 +1,32 @@ +/* + * 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.test006.jack; + + +public final class A { + public static final int foo = 1234b5; + + public interface B { + void test(); + } + + private final B b = new B() { + + @Override + public void test() {} + }; +} diff --git a/jack-tests/tests/com/android/jack/frontend/test006/jack/B.java b/jack-tests/tests/com/android/jack/frontend/test006/jack/B.java new file mode 100644 index 00000000..545f0459 --- /dev/null +++ b/jack-tests/tests/com/android/jack/frontend/test006/jack/B.java @@ -0,0 +1,34 @@ +/* + * 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.test006.jack; + +public class B { + + private static class X { + static final Object instance1; + static { + try { + instance1 = new Object(); + } catch (Throwable e) { + throw new AssertionError(e); + } + } + } + + X x = new X(); + Object o = X.instance1; +} |