diff --git a/compiler/testData/codegen/visibility/package/packageClass.java b/compiler/testData/codegen/visibility/package/packageClass.java new file mode 100644 index 00000000000..3879960423f --- /dev/null +++ b/compiler/testData/codegen/visibility/package/packageClass.java @@ -0,0 +1,9 @@ +package protectedPack; + +import java.lang.String; + +class packageClass { + public String test() { + return "OK"; + } +} diff --git a/compiler/testData/codegen/visibility/package/packageClass.kt b/compiler/testData/codegen/visibility/package/packageClass.kt new file mode 100644 index 00000000000..13b9e6dc782 --- /dev/null +++ b/compiler/testData/codegen/visibility/package/packageClass.kt @@ -0,0 +1,5 @@ +package protectedPack + +fun box(): String { + return packageClass().test()!! +} diff --git a/compiler/testData/codegen/visibility/package/packageFun.java b/compiler/testData/codegen/visibility/package/packageFun.java new file mode 100644 index 00000000000..e1f04d5cd51 --- /dev/null +++ b/compiler/testData/codegen/visibility/package/packageFun.java @@ -0,0 +1,9 @@ +package protectedPack; + +import java.lang.String; + +public class packageFun { + String test() { + return "OK"; + } +} diff --git a/compiler/testData/codegen/visibility/package/packageFun.kt b/compiler/testData/codegen/visibility/package/packageFun.kt new file mode 100644 index 00000000000..43d1f058b2a --- /dev/null +++ b/compiler/testData/codegen/visibility/package/packageFun.kt @@ -0,0 +1,5 @@ +package protectedPack + +fun box(): String { + return packageFun().test()!! +} diff --git a/compiler/testData/codegen/visibility/package/packageProperty.java b/compiler/testData/codegen/visibility/package/packageProperty.java new file mode 100644 index 00000000000..03e5285c389 --- /dev/null +++ b/compiler/testData/codegen/visibility/package/packageProperty.java @@ -0,0 +1,7 @@ +package protectedPack; + +import java.lang.String; + +public class packageProperty { + String test = "OK"; +} diff --git a/compiler/testData/codegen/visibility/package/packageProperty.kt b/compiler/testData/codegen/visibility/package/packageProperty.kt new file mode 100644 index 00000000000..bc20f5ffff7 --- /dev/null +++ b/compiler/testData/codegen/visibility/package/packageProperty.kt @@ -0,0 +1,5 @@ +package protectedPack + +fun box(): String { + return packageProperty().test!! +} diff --git a/compiler/tests/org/jetbrains/jet/codegen/AbstractJavaVisibilityTest.java b/compiler/tests/org/jetbrains/jet/codegen/AbstractJavaVisibilityTest.java new file mode 100644 index 00000000000..8aced67e6e5 --- /dev/null +++ b/compiler/tests/org/jetbrains/jet/codegen/AbstractJavaVisibilityTest.java @@ -0,0 +1,28 @@ +/* + * Copyright 2010-2013 JetBrains s.r.o. + * + * 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 org.jetbrains.jet.codegen; + +import org.jetbrains.annotations.NotNull; + +public abstract class AbstractJavaVisibilityTest extends CodegenTestCase { + @NotNull + @Override + protected GeneratedClassLoader createClassLoader(@NotNull ClassFileFactory factory) { + initializedClassLoader = new GeneratedClassLoader(factory, CodegenTestCase.class.getClassLoader(), getClassPathURLs()); + return initializedClassLoader; + } +} diff --git a/compiler/tests/org/jetbrains/jet/codegen/JavaVisibilityTestGenerated.java b/compiler/tests/org/jetbrains/jet/codegen/JavaVisibilityTestGenerated.java new file mode 100644 index 00000000000..a724845e585 --- /dev/null +++ b/compiler/tests/org/jetbrains/jet/codegen/JavaVisibilityTestGenerated.java @@ -0,0 +1,68 @@ +/* + * Copyright 2010-2013 JetBrains s.r.o. + * + * 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 org.jetbrains.jet.codegen; + +import junit.framework.Assert; +import junit.framework.Test; +import junit.framework.TestSuite; + +import java.io.File; +import org.jetbrains.jet.JetTestUtils; +import org.jetbrains.jet.test.InnerTestClasses; +import org.jetbrains.jet.test.TestMetadata; + +import org.jetbrains.jet.codegen.AbstractJavaVisibilityTest; + +/** This class is generated by {@link org.jetbrains.jet.generators.tests.GenerateTests}. DO NOT MODIFY MANUALLY */ +@SuppressWarnings("all") +@TestMetadata("compiler/testData/codegen/visibility") +@InnerTestClasses({JavaVisibilityTestGenerated.Package.class}) +public class JavaVisibilityTestGenerated extends AbstractJavaVisibilityTest { + public void testAllFilesPresentInVisibility() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/codegen/visibility"), "kt", true); + } + + @TestMetadata("compiler/testData/codegen/visibility/package") + public static class Package extends AbstractJavaVisibilityTest { + public void testAllFilesPresentInPackage() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/codegen/visibility/package"), "kt", true); + } + + @TestMetadata("packageClass.kt") + public void testPackageClass() throws Exception { + blackBoxFileWithJavaByFullPath("compiler/testData/codegen/visibility/package/packageClass.kt"); + } + + @TestMetadata("packageFun.kt") + public void testPackageFun() throws Exception { + blackBoxFileWithJavaByFullPath("compiler/testData/codegen/visibility/package/packageFun.kt"); + } + + @TestMetadata("packageProperty.kt") + public void testPackageProperty() throws Exception { + blackBoxFileWithJavaByFullPath("compiler/testData/codegen/visibility/package/packageProperty.kt"); + } + + } + + public static Test suite() { + TestSuite suite = new TestSuite("JavaVisibilityTestGenerated"); + suite.addTestSuite(JavaVisibilityTestGenerated.class); + suite.addTestSuite(Package.class); + return suite; + } +} diff --git a/generators/org/jetbrains/jet/generators/tests/GenerateTests.java b/generators/org/jetbrains/jet/generators/tests/GenerateTests.java index 3a21acaa6d0..996f0563132 100644 --- a/generators/org/jetbrains/jet/generators/tests/GenerateTests.java +++ b/generators/org/jetbrains/jet/generators/tests/GenerateTests.java @@ -22,6 +22,7 @@ import org.jetbrains.jet.checkers.AbstractDiagnosticsTestWithEagerResolve; import org.jetbrains.jet.checkers.AbstractJetPsiCheckerTest; import org.jetbrains.jet.codegen.AbstractCheckLocalVariablesTableTest; import org.jetbrains.jet.codegen.AbstractDataClassCodegenTest; +import org.jetbrains.jet.codegen.AbstractJavaVisibilityTest; import org.jetbrains.jet.codegen.defaultConstructor.AbstractDefaultConstructorCodegenTest; import org.jetbrains.jet.codegen.flags.AbstractWriteFlagsTest; import org.jetbrains.jet.codegen.generated.AbstractBlackBoxCodegenTest; @@ -95,6 +96,13 @@ public class GenerateTests { testModel("compiler/testData/codegen/dataClasses", "blackBoxFileByFullPath") ); + generateTest( + "compiler/tests/", + "JavaVisibilityTestGenerated", + AbstractJavaVisibilityTest.class, + testModel("compiler/testData/codegen/visibility", "blackBoxFileWithJavaByFullPath") + ); + generateTest( "compiler/tests/", "CheckLocalVariablesTableTestGenerated",