Search in sources :

Example 16 with CompilerError

use of com.redhat.ceylon.compiler.java.test.CompilerError in project ceylon-compiler by ceylon.

the class BcTests method testBinaryVersionIncompatible.

@Test
public void testBinaryVersionIncompatible() {
    compile("JavaOldVersion.java");
    assertErrors("CeylonNewVersion", new CompilerError(-1, "Ceylon class com.redhat.ceylon.compiler.java.test.bc.JavaOldVersion was compiled by an incompatible version of the Ceylon compiler\n  The class was compiled using 0.0.\n  This compiler supports " + Versions.JVM_BINARY_MAJOR_VERSION + "." + Versions.JVM_BINARY_MINOR_VERSION + ".\n  Please try to recompile your module using a compatible compiler.\n  Binary compatibility will only be supported after Ceylon 1.2."));
}
Also used : CompilerError(com.redhat.ceylon.compiler.java.test.CompilerError) Test(org.junit.Test)

Example 17 with CompilerError

use of com.redhat.ceylon.compiler.java.test.CompilerError in project ceylon-compiler by ceylon.

the class BcTests method testBinaryVersionIncompatibleModule2.

// tests after we renamed module_.class to $module_.class
@Test
public void testBinaryVersionIncompatibleModule2() throws IOException {
    CompilationTask compiler = compileJava("binaryVersionOld2/$module_.java");
    Assert.assertTrue(compiler.call());
    // so now make a jar containing the java module
    File jarFolder = new File(destDir, "com/redhat/ceylon/compiler/java/test/bc/binaryVersionOld2/1/");
    jarFolder.mkdirs();
    File jarFile = new File(jarFolder, "com.redhat.ceylon.compiler.java.test.bc.binaryVersionOld2-1.jar");
    // now jar it up
    JarOutputStream outputStream = new JarOutputStream(new FileOutputStream(jarFile));
    ZipEntry entry = new ZipEntry("com/redhat/ceylon/compiler/java/test/bc/binaryVersionOld2/$module_.class");
    outputStream.putNextEntry(entry);
    File javaClass = new File(destDir, "com/redhat/ceylon/compiler/java/test/bc/binaryVersionOld2/$module_.class");
    FileInputStream inputStream = new FileInputStream(javaClass);
    Util.copy(inputStream, outputStream);
    inputStream.close();
    outputStream.close();
    assertErrors("binaryVersion2/module", new CompilerError(21, "version '1' of module 'com.redhat.ceylon.compiler.java.test.bc.binaryVersionOld2' was compiled by" + " an incompatible version of the compiler" + " (binary version 0.0 of module is not compatible with binary version " + Versions.JVM_BINARY_MAJOR_VERSION + "." + Versions.JVM_BINARY_MINOR_VERSION + " of this compiler)"));
}
Also used : FileOutputStream(java.io.FileOutputStream) ZipEntry(java.util.zip.ZipEntry) JarOutputStream(java.util.jar.JarOutputStream) CompilerError(com.redhat.ceylon.compiler.java.test.CompilerError) File(java.io.File) CompilationTask(javax.tools.JavaCompiler.CompilationTask) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 18 with CompilerError

use of com.redhat.ceylon.compiler.java.test.CompilerError in project ceylon-compiler by ceylon.

the class ExpressionTests method testLitNumericLiteral.

@Test
public void testLitNumericLiteral() {
    compareWithJavaSource("literal/NumericLiteral");
    assertErrors("literal/NumericLiteralErrors", new CompilerError(24, "literal outside representable range: '9223372036854775808' is too large to be represented as an 'Integer'"), new CompilerError(25, "literal outside representable range: '-9223372036854775809' is too large to be represented as an 'Integer'"), new CompilerError(27, "literal so large it is indistinguishable from infinity: '1.7976931348623159E308' (use infinity)"), new CompilerError(28, "literal so large it is indistinguishable from infinity: '1.7976931348623159E308' (use infinity)"), new CompilerError(29, "literal so small it is indistinguishable from zero: '2.0E-324' (use 0.0)"), new CompilerError(30, "literal so small it is indistinguishable from zero: '2.0E-324' (use 0.0)"), new CompilerError(34, "invalid hexadecimal literal: '#CAFEBABECAFEBABE1' has more than 64 bits"), new CompilerError(36, "invalid binary literal: '$11011101110111011101110111011101110111011101110111011101110111011' has more than 64 bits"));
    assertErrors("literal/NumericLiteralParserErrors", new CompilerError(23, "incorrect syntax: no viable alternative at character '-'"), new CompilerError(24, "incorrect syntax: no viable alternative at character '+'"), new CompilerError(25, "incorrect syntax: no viable alternative at character '-'"), new CompilerError(26, "incorrect syntax: no viable alternative at character 's'"), new CompilerError(28, "incorrect syntax: mismatched character '-' expecting set null"), new CompilerError(29, "incorrect syntax: mismatched character '+' expecting set null"), new CompilerError(30, "incorrect syntax: extraneous token '23' expecting statement-ending ';'"), new CompilerError(31, "incorrect syntax: mismatched character 's' expecting set null"));
}
Also used : CompilerError(com.redhat.ceylon.compiler.java.test.CompilerError) Test(org.junit.Test)

Example 19 with CompilerError

use of com.redhat.ceylon.compiler.java.test.CompilerError in project ceylon-compiler by ceylon.

the class CMRTests method testMdlAetherMissingDependencies.

@Test
public void testMdlAetherMissingDependencies() throws IOException {
    CompilerError[] expectedErrors = new CompilerError[] { new CompilerError(6, "Error while loading the org.apache.camel:camel-jetty/2.9.4 module:\n" + "   Declaration 'org.apache.camel.component.http.HttpComponent' could not be found in module 'org.apache.camel:camel-jetty' or its imported modules"), new CompilerError(10, "argument must be assignable to parameter 'arg1' of 'addComponent' in 'DefaultCamelContext': 'JettyHttpComponent' is not assignable to 'Component?': Error while loading the org.apache.camel:camel-jetty/2.9.4 module:\n" + "   Declaration 'org.apache.camel.component.http.HttpComponent' could not be found in module 'org.apache.camel:camel-jetty' or its imported modules") };
    ErrorCollector collector = new ErrorCollector();
    // Try to compile the ceylon module
    CeyloncTaskImpl ceylonTask = getCompilerTask(Arrays.asList("-out", destDir, "-rep", "aether"), collector, "modules/bug1100/module.ceylon", "modules/bug1100/test.ceylon");
    assertEquals("Compilation failed", Boolean.FALSE, ceylonTask.call());
    TreeSet<CompilerError> actualErrors = collector.get(Diagnostic.Kind.ERROR);
    compareErrors(actualErrors, expectedErrors);
}
Also used : CompilerError(com.redhat.ceylon.compiler.java.test.CompilerError) ErrorCollector(com.redhat.ceylon.compiler.java.test.ErrorCollector) CeyloncTaskImpl(com.redhat.ceylon.compiler.java.tools.CeyloncTaskImpl) Test(org.junit.Test)

Example 20 with CompilerError

use of com.redhat.ceylon.compiler.java.test.CompilerError in project ceylon-compiler by ceylon.

the class CMRTests method testMdlBug1062IncompatibleMissingImport.

@Test
public void testMdlBug1062IncompatibleMissingImport() throws IOException {
    // compile our java class
    File classesOutputFolder = new File(destDir + "-jar-classes");
    cleanCars(classesOutputFolder.getPath());
    classesOutputFolder.mkdirs();
    File jarOutputFolder = new File(destDir + "-jar");
    cleanCars(jarOutputFolder.getPath());
    jarOutputFolder.mkdirs();
    compileJavaModule(jarOutputFolder, classesOutputFolder, "bug1062.javaA", "1", new File(getPackagePath(), "modules/bug1062/javaA1-src"), new File[0], "bug1062/javaA/JavaA.java");
    compileJavaModule(jarOutputFolder, classesOutputFolder, "bug1062.javaA", "2", new File(getPackagePath(), "modules/bug1062/javaA2-src"), new File[0], "bug1062/javaA/JavaA.java");
    compileJavaModule(jarOutputFolder, classesOutputFolder, "bug1062.javaB", "1", new File(getPackagePath(), "modules/bug1062/javaB-nomodule-src"), new File[] { new File(jarOutputFolder, "bug1062/javaA/1/bug1062.javaA-1.jar") }, "bug1062/javaB/JavaB.java");
    assertErrors("modules/bug1062/ceylon/test", Arrays.asList("-rep", jarOutputFolder.getPath()), null, new CompilerError(5, "could not determine type of method or attribute reference: 'method' of 'JavaB': Error while loading the bug1062.javaB/1 module:\n" + "   Declaration 'bug1062.javaA.JavaA' could not be found in module 'bug1062.javaB' or its imported modules but was found in the non-imported module 'bug1062.javaA'"), new CompilerError(5, "parameter type could not be determined: 'arg0' of 'method' in 'JavaB': Error while loading the bug1062.javaB/1 module:\n" + "   Declaration 'bug1062.javaA.JavaA' could not be found in module 'bug1062.javaB' or its imported modules but was found in the non-imported module 'bug1062.javaA'"));
}
Also used : CompilerError(com.redhat.ceylon.compiler.java.test.CompilerError) JarFile(java.util.jar.JarFile) ZipFile(java.util.zip.ZipFile) File(java.io.File) Test(org.junit.Test)

Aggregations

CompilerError (com.redhat.ceylon.compiler.java.test.CompilerError)47 Test (org.junit.Test)47 ErrorCollector (com.redhat.ceylon.compiler.java.test.ErrorCollector)15 File (java.io.File)13 CeyloncTaskImpl (com.redhat.ceylon.compiler.java.tools.CeyloncTaskImpl)11 JarFile (java.util.jar.JarFile)11 ZipEntry (java.util.zip.ZipEntry)7 LinkedList (java.util.LinkedList)6 ZipFile (java.util.zip.ZipFile)4 HttpServer (com.sun.net.httpserver.HttpServer)2 FileInputStream (java.io.FileInputStream)2 FileOutputStream (java.io.FileOutputStream)2 JarOutputStream (java.util.jar.JarOutputStream)2 CompilationTask (javax.tools.JavaCompiler.CompilationTask)2 ExitState (com.redhat.ceylon.compiler.java.launcher.Main.ExitState)1 Module (com.redhat.ceylon.model.typechecker.model.Module)1 FileWriter (java.io.FileWriter)1 Writer (java.io.Writer)1 Ignore (org.junit.Ignore)1