Search in sources :

Example 36 with CompilerError

use of org.eclipse.ceylon.compiler.java.test.CompilerError in project ceylon by eclipse.

the class IssuesTests_6500_6999 method testBug6592.

@Test
public void testBug6592() {
    CompilationAssertion expectSysError = new CompilationAssertion() {

        public void onError(ErrorCollector collector, ExitState exitState) {
            TreeSet<CompilerError> treeSet = collector.get(Kind.ERROR);
            assertEquals(1, treeSet.size());
            CompilerError e = treeSet.iterator().next();
            assertTrue(e.message.contains("No such overrides file: "));
            assertTrue(e.message.contains("doesNotExist.xml"));
        }
    };
    assertCompiles(Arrays.asList("-overrides", "doesNotExist.xml"), new String[] { "bug65xx/bug6592/bug6592.ceylon" }, expectSysError);
    expectSysError = new CompilationAssertion() {

        public void onError(ErrorCollector collector, ExitState exitState) {
            TreeSet<CompilerError> treeSet = collector.get(Kind.ERROR);
            assertEquals(1, treeSet.size());
            CompilerError e = treeSet.iterator().next();
            assertTrue(e.message.contains("overrides.xml:2:12: Missing 'module' attribute in element [module: null]."));
        }
    };
    assertCompiles(Arrays.asList("-overrides", "test/src/org/eclipse/ceylon/compiler/java/test/issues/bug65xx/bug6592/overrides.xml"), new String[] { "bug65xx/bug6592/bug6592.ceylon" }, expectSysError);
}
Also used : ExitState(org.eclipse.ceylon.compiler.java.launcher.Main.ExitState) TreeSet(java.util.TreeSet) ErrorCollector(org.eclipse.ceylon.compiler.java.test.ErrorCollector) CompilerError(org.eclipse.ceylon.compiler.java.test.CompilerError) Test(org.junit.Test)

Example 37 with CompilerError

use of org.eclipse.ceylon.compiler.java.test.CompilerError in project ceylon by eclipse.

the class ModelLoaderTests method bogusModelAnnotationsTopLevelAttribute.

@Test
public void bogusModelAnnotationsTopLevelAttribute() {
    compile("bogusTopLevelAttributeNoGetter_.java", "bogusTopLevelAttributeMissingType_.java", "bogusTopLevelAttributeInvalidType_.java");
    assertErrors("bogusTopLevelAttributeUser", new CompilerError(2, "Error while loading the org.eclipse.ceylon.compiler.java.test.model/1 module:\n" + "   Error while resolving toplevel attribute org.eclipse.ceylon.compiler.java.test.model::bogusTopLevelAttributeNoGetter: getter method missing"), new CompilerError(-1, "Error while resolving type of toplevel attribute for org.eclipse.ceylon.compiler.java.test.model::bogusTopLevelAttributeMissingType: Could not find type 'org.eclipse.ceylon.compiler.java.test.model.MissingType'"), new CompilerError(-1, "Error while parsing type of toplevel attribute for org.eclipse.ceylon.compiler.java.test.model::bogusTopLevelAttributeInvalidType: Expecting word but got AND"), new CompilerError(3, "could not determine type of function or value reference: the type of 'bogusTopLevelAttributeNoGetter' is not known - Error while loading the org.eclipse.ceylon.compiler.java.test.model/1 module:\n" + "   Error while resolving toplevel attribute org.eclipse.ceylon.compiler.java.test.model::bogusTopLevelAttributeNoGetter: getter method missing"), new CompilerError(4, "could not determine type of function or value reference: the type of 'bogusTopLevelAttributeMissingType' is not known - Error while resolving type of toplevel attribute for org.eclipse.ceylon.compiler.java.test.model::bogusTopLevelAttributeMissingType: Could not find type 'org.eclipse.ceylon.compiler.java.test.model.MissingType'"), new CompilerError(5, "could not determine type of function or value reference: the type of 'bogusTopLevelAttributeInvalidType' is not known - Error while parsing type of toplevel attribute for org.eclipse.ceylon.compiler.java.test.model::bogusTopLevelAttributeInvalidType: Expecting word but got AND"));
}
Also used : CompilerError(org.eclipse.ceylon.compiler.java.test.CompilerError) Test(org.junit.Test)

Example 38 with CompilerError

use of org.eclipse.ceylon.compiler.java.test.CompilerError in project ceylon by eclipse.

the class InteropTests method testIopCallsDefaultAccessClassInAnotherPkg.

@Test
public void testIopCallsDefaultAccessClassInAnotherPkg() {
    compile("access/JavaAccessModifiers.java");
    compile("access/JavaDefaultAccessClass3.java");
    assertErrors("CallsDefaultAccessClassInAnotherPkg", new CompilerError(21, "imported declaration is not visible: 'JavaDefaultAccessClass' is not shared"), new CompilerError(22, "imported declaration is not visible: 'JavaDefaultAccessClass2' is not shared"), new CompilerError(28, "type is not visible: 'JavaDefaultAccessClass'"), new CompilerError(29, "type is not visible: 'JavaDefaultAccessClass2'"), new CompilerError(30, "type constructor is not visible: 'JavaDefaultAccessClass3'"));
}
Also used : CompilerError(org.eclipse.ceylon.compiler.java.test.CompilerError) Test(org.junit.Test)

Example 39 with CompilerError

use of org.eclipse.ceylon.compiler.java.test.CompilerError in project ceylon by eclipse.

the class InteropTests method testIopAmbiguousOverloading.

@Test
public void testIopAmbiguousOverloading() {
    compile("TypesJava.java", "JavaWithOverloadedMembers.java");
    assertErrors("AmbiguousOverloading", new CompilerError(25, "illegal argument types in invocation of overloaded method or class: there must be exactly one overloaded declaration of 'ambiguousOverload' which accepts the given argument types 'String, String'"), new CompilerError(26, "illegal argument types in invocation of overloaded method or class: there must be exactly one overloaded declaration of 'ambiguousOverload2' which accepts the given argument types 'Integer, Integer'"));
}
Also used : CompilerError(org.eclipse.ceylon.compiler.java.test.CompilerError) Test(org.junit.Test)

Example 40 with CompilerError

use of org.eclipse.ceylon.compiler.java.test.CompilerError in project ceylon by eclipse.

the class InteropTests method testJava9Module.

/**
 * Warning: this test requires a build with "ant -Djigsaw=true clean dist" and to run on Java 9+Jigsaw
 */
@Test
public void testJava9Module() throws Throwable {
    Assume.assumeTrue("Runs on JDK9", JDKUtils.jdk == JDKUtils.JDK.JDK9);
    assertErrors(new String[] { "java9/user/runError.ceylon", "java9/user/package.ceylon" }, Arrays.asList("-out", destDir, "-rep", "test/java9/modules"), null, new CompilerError(1, "imported package is not shared: 'com.ceylon.java9.internal'"));
    ErrorCollector c = new ErrorCollector();
    assertCompilesOk(c, getCompilerTask(Arrays.asList("-out", destDir, "-rep", "test/java9/modules"), c, "java9/user/run.ceylon", "java9/user/package.ceylon").call2());
    // check that we do not have a module-info.class
    File archive = getModuleArchive("org.eclipse.ceylon.compiler.java.test.interop.java9.user", "1");
    try (ZipFile zf = new ZipFile(archive)) {
        ZipEntry entry = zf.getEntry("module-info.class");
        assertNull(entry);
    }
    c = new ErrorCollector();
    assertCompilesOk(c, getCompilerTask(Arrays.asList("-out", destDir, "-rep", "test/java9/modules", "-module-info"), c, "java9/user/run.ceylon", "java9/user/package.ceylon").call2());
    // check that we do have a module-info.class
    try (ZipFile zf = new ZipFile(archive)) {
        ZipEntry entry = zf.getEntry("module-info.class");
        assertNotNull(entry);
    }
    run("org.eclipse.ceylon.compiler.java.test.interop.java9.user.run", new ModuleWithArtifact("org.eclipse.ceylon.compiler.java.test.interop.java9.user", "1"), new ModuleWithArtifact("com.ceylon.java9", "123", "test/java9/modules", "jar"));
    assertEquals(0, runInJava9(new String[] { destDir, "test/java9/modules", "../dist/dist/repo" }, new ModuleSpec(null, "org.eclipse.ceylon.compiler.java.test.interop.java9.user", "1"), Collections.<String>emptyList()));
}
Also used : ZipFile(java.util.zip.ZipFile) ModuleSpec(org.eclipse.ceylon.common.ModuleSpec) ZipEntry(java.util.zip.ZipEntry) CompilerError(org.eclipse.ceylon.compiler.java.test.CompilerError) ErrorCollector(org.eclipse.ceylon.compiler.java.test.ErrorCollector) ZipFile(java.util.zip.ZipFile) File(java.io.File) Test(org.junit.Test)

Aggregations

CompilerError (org.eclipse.ceylon.compiler.java.test.CompilerError)55 Test (org.junit.Test)54 ErrorCollector (org.eclipse.ceylon.compiler.java.test.ErrorCollector)19 File (java.io.File)15 CeyloncTaskImpl (org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl)12 JarFile (java.util.jar.JarFile)11 ZipEntry (java.util.zip.ZipEntry)8 LinkedList (java.util.LinkedList)7 ZipFile (java.util.zip.ZipFile)5 FileInputStream (java.io.FileInputStream)2 FileOutputStream (java.io.FileOutputStream)2 JarOutputStream (java.util.jar.JarOutputStream)2 ExitState (org.eclipse.ceylon.compiler.java.launcher.Main.ExitState)2 CompilationTask (org.eclipse.ceylon.javax.tools.JavaCompiler.CompilationTask)2 Ignore (org.junit.Ignore)2 HttpServer (com.sun.net.httpserver.HttpServer)1 FileWriter (java.io.FileWriter)1 Writer (java.io.Writer)1 TreeSet (java.util.TreeSet)1 JarEntry (java.util.jar.JarEntry)1