Skip to content

Commit

Permalink
Issue ceylon#339: Fix and improve the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tombentley committed Feb 23, 2012
1 parent b0f765a commit f1a315d
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 22 deletions.
Expand Up @@ -19,6 +19,7 @@
*/
package com.redhat.ceylon.compiler.java.test.interop;

import org.junit.Ignore;
import org.junit.Test;

import com.redhat.ceylon.compiler.java.test.CompilerTest;
Expand Down Expand Up @@ -82,29 +83,29 @@ public void testIopCheckedExceptions(){
@Test
public void testIopRefinesProtectedAccessMethod(){
compile("access/JavaAccessModifiers.java");
assertErrors("access/RefinesProtectedAccessMethod",
new CompilerError(23, "non-actual member refines an inherited member"));
compareWithJavaSource("access/RefinesProtectedAccessMethod");
}

@Test
public void testIopRefinesProtectedAccessMethodWithActual(){
public void testIopCallsProtectedAccessMethod(){
compile("access/JavaAccessModifiers.java");
assertErrors("access/RefinesProtectedAccessMethodWithActual",
new CompilerError(23, "actual member is not shared"));
assertErrors("access/CallsProtectedAccessMethod",
new CompilerError(23, "member method or attribute is not visible: protectedAccessMethod of type JavaAccessModifiers"));
}

@Test
public void testIopCallsProtectedAccessMethod(){
@Ignore("#396")
public void testIopRefinesAndCallsProtectedAccessMethod(){
compile("access/JavaAccessModifiers.java");
assertErrors("access/CallsProtectedAccessMethod",
new CompilerError(23, "member method or attribute is not visible: protectedAccessMethod of type JavaAccessModifiers"));
compareWithJavaSource("access/RefinesAndCallsProtectedAccessMethod");
}

@Test
public void testIopRefinesDefaultAccessMethod(){
compile("access/JavaAccessModifiers.java");
// XXX This error comes from javac rather than the ceylon typechecker
assertErrors("access/RefinesDefaultAccessMethod",
new CompilerError(22, "non-actual member refines an inherited member"));
new CompilerError(22, "defaultAccessMethod() in com.redhat.ceylon.compiler.java.test.interop.access.RefinesDefaultAccessMethod cannot override defaultAccessMethod() in com.redhat.ceylon.compiler.java.test.interop.access.JavaAccessModifiers; attempting to assign weaker access privileges; was package"));
}

@Test
Expand All @@ -114,6 +115,13 @@ public void testIopRefinesDefaultAccessMethodWithActual(){
new CompilerError(22, "actual member is not shared"));
}

@Test
public void testIopRefinesDefaultAccessMethodWithSharedActual(){
compile("access/JavaAccessModifiers.java");
assertErrors("access/RefinesDefaultAccessMethodWithSharedActual",
new CompilerError(22, "actual member does not refine any inherited member"));
}

@Test
public void testIopCallsDefaultAccessMethod(){
compile("access/JavaAccessModifiers.java");
Expand Down
@@ -1,6 +1,6 @@
package com.redhat.ceylon.compiler.java.test.interop.access;

class ExtendsDefaultAccessClass extends com.redhat.ceylon.compiler.java.test.interop.access.JavaDefaultAccessClass {
class ExtendsDefaultAccessClass extends .com.redhat.ceylon.compiler.java.test.interop.access.JavaDefaultAccessClass {

ExtendsDefaultAccessClass() {
super();
Expand Down
@@ -0,0 +1,25 @@
/*
* Copyright Red Hat Inc. and/or its affiliates and other contributors
* as indicated by the authors tag. All rights reserved.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License version 2.
*
* This particular file is subject to the "Classpath" exception as provided in the
* LICENSE file that accompanied this code.
*
* This program is distributed in the hope that it will be useful, but WITHOUT A
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public License,
* along with this distribution; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
@nomodel
class RefinesAndCallProtectedAccessMethod() extends JavaAccessModifiers() {
void foo(JavaAccessModifiers bar) {
bar.protectedAccessMethod();
}
}
Expand Up @@ -18,6 +18,6 @@
* MA 02110-1301, USA.
*/
@nomodel
class RefinesDefaultAccessMethodWithActual() extends JavaAccessModifiers() {
class RefinesDefaultAccessMethod() extends JavaAccessModifiers() {
actual void defaultAccessMethod() {}
}
Expand Up @@ -18,10 +18,6 @@
* MA 02110-1301, USA.
*/
@nomodel
class RefinesProtectedActual() extends JavaAccessModifiers() {

actual void protectedAccessMethod() {
}


class RefinesDefaultAccessMethod() extends JavaAccessModifiers() {
shared actual void defaultAccessMethod() {}
}
Expand Up @@ -18,10 +18,8 @@
* MA 02110-1301, USA.
*/
@nomodel
class RefinesProtected() extends JavaAccessModifiers() {

void protectedAccessMethod() {
class RefinesProtectedAccessMethod() extends JavaAccessModifiers() {
shared actual void protectedAccessMethod() {
super.protectedAccessMethod();
}


}
@@ -0,0 +1,18 @@
package com.redhat.ceylon.compiler.java.test.interop.access;

class RefinesProtectedAccessMethod extends com.redhat.ceylon.compiler.java.test.interop.access.JavaAccessModifiers {

@.java.lang.Override
public final void protectedAccessMethod() {
super.protectedAccessMethod();
}

RefinesProtectedAccessMethod() {
super();
}

public static void main(.java.lang.String[] args) {
.ceylon.language.process.getProcess().setupArguments(args);
new .com.redhat.ceylon.compiler.java.test.interop.access.RefinesProtectedAccessMethod();
}
}

0 comments on commit f1a315d

Please sign in to comment.