Search in sources :

Example 51 with CompilerError

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

the class CMRHTTPTests method assertTimeout.

private void assertTimeout(String[] files, List<String> options) {
    ErrorCollector collector = compileErrorTest(files, options, null, false, true);
    Set<CompilerError> errors = collector.get(Diagnostic.Kind.ERROR);
    Assert.assertTrue("Expecting a single error, got " + errors.size(), errors.size() == 1);
    CompilerError err = errors.iterator().next();
    Assert.assertTrue("Expecting a java.net.SocketTimeoutException, got " + err, err.toString().contains("java.net.SocketTimeoutException"));
}
Also used : ErrorCollector(org.eclipse.ceylon.compiler.java.test.ErrorCollector) CompilerError(org.eclipse.ceylon.compiler.java.test.CompilerError)

Example 52 with CompilerError

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

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)"), CompilerError.warning(29, "literal so small it is indistinguishable from zero: '2.0E-324' (use 0.0)"), CompilerError.warning(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(org.eclipse.ceylon.compiler.java.test.CompilerError) Test(org.junit.Test)

Example 53 with CompilerError

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

the class RecoveryTests method testMissingImport.

@Test
public void testMissingImport() throws IOException {
    String subPath = "modules/missingImport";
    String srcPath = getPackagePath() + subPath;
    List<String> options = new LinkedList<String>();
    options.add("-src");
    options.add(srcPath);
    options.addAll(defaultOptions);
    options.add("-continue");
    ErrorCollector c = new ErrorCollector();
    CeyloncTaskImpl task = getCompilerTask(options, c, Arrays.asList("okmodule"), subPath + "/someok.ceylon");
    Boolean ret = task.call();
    assertFalse(ret);
    TreeSet<CompilerError> actualErrors = c.get(Diagnostic.Kind.ERROR);
    compareErrors(actualErrors, new CompilerError(21, "cannot find module artifact 'notfound-1(.car|.jar)'\n  \t- dependency tree: 'okmodule/1.0.0' -> 'notfound/1'"));
    File carFile = getModuleArchive("default", null);
    assertTrue(carFile.exists());
    JarFile car = new JarFile(carFile);
    ZipEntry moduleClass = car.getEntry("foobar_.class");
    assertNotNull(moduleClass);
    car.close();
    carFile = getModuleArchive("okmodule", "1.0.0");
    assertFalse(carFile.exists());
}
Also used : ZipEntry(java.util.zip.ZipEntry) ErrorCollector(org.eclipse.ceylon.compiler.java.test.ErrorCollector) CompilerError(org.eclipse.ceylon.compiler.java.test.CompilerError) CeyloncTaskImpl(org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl) JarFile(java.util.jar.JarFile) JarFile(java.util.jar.JarFile) File(java.io.File) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 54 with CompilerError

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

the class RecoveryTests method testSyntaxErrorInModule.

@Test
public void testSyntaxErrorInModule() throws IOException {
    String subPath = "modules/syntaxErrorInModule";
    String srcPath = getPackagePath() + subPath;
    List<String> options = new LinkedList<String>();
    options.add("-src");
    options.add(srcPath);
    options.addAll(defaultOptions);
    options.add("-continue");
    ErrorCollector c = new ErrorCollector();
    CeyloncTaskImpl task = getCompilerTask(options, c, Arrays.asList("okmodule"), subPath + "/someok.ceylon");
    Boolean ret = task.call();
    assertFalse(ret);
    TreeSet<CompilerError> actualErrors = c.get(Diagnostic.Kind.ERROR);
    compareErrors(actualErrors, new CompilerError(20, "incorrect syntax: missing ':' operator at '\"1.0.0\"'"));
    File carFile = getModuleArchive("default", null);
    assertTrue(carFile.exists());
    JarFile car = new JarFile(carFile);
    ZipEntry moduleClass = car.getEntry("foobar_.class");
    assertNotNull(moduleClass);
    car.close();
    carFile = getModuleArchive("okmodule", "1.0.0");
    assertFalse(carFile.exists());
}
Also used : ZipEntry(java.util.zip.ZipEntry) ErrorCollector(org.eclipse.ceylon.compiler.java.test.ErrorCollector) CompilerError(org.eclipse.ceylon.compiler.java.test.CompilerError) CeyloncTaskImpl(org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl) JarFile(java.util.jar.JarFile) JarFile(java.util.jar.JarFile) File(java.io.File) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 55 with CompilerError

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

the class ReportingTests method testAnnoAlreadySuppressed2.

@Test
public void testAnnoAlreadySuppressed2() {
    // 
    defaultOptions.add("-suppress-warnings");
    defaultOptions.add("unusedDeclaration");
    assertErrors(new String[] { "AlreadySuppressed.ceylon" }, defaultOptions, null, new CompilerError(Kind.WARNING, "", 3, "warnings already suppressed by annotation"));
}
Also used : CompilerError(org.eclipse.ceylon.compiler.java.test.CompilerError) 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