Search in sources :

Example 6 with ExitState

use of org.eclipse.ceylon.compiler.java.launcher.Main.ExitState in project ceylon by eclipse.

the class IssuesTests_1500_1999 method testBug1836.

@Test
public void testBug1836() {
    ErrorCollector collector = new ErrorCollector();
    CeyloncTaskImpl task = getCompilerTask(defaultOptions, collector, "bug18xx/Bug1836.ceylon");
    ExitState call2 = task.call2();
    Assert.assertEquals(CeylonState.ERROR, call2.ceylonState);
    Assert.assertEquals(Main.EXIT_ERROR, call2.javacExitCode.exitCode);
}
Also used : ExitState(org.eclipse.ceylon.compiler.java.launcher.Main.ExitState) ErrorCollector(org.eclipse.ceylon.compiler.java.test.ErrorCollector) CeyloncTaskImpl(org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl) Test(org.junit.Test)

Example 7 with ExitState

use of org.eclipse.ceylon.compiler.java.launcher.Main.ExitState in project ceylon by eclipse.

the class IssuesTests_1500_1999 method testBug1773.

@Test
public void testBug1773() {
    ErrorCollector collector = new ErrorCollector();
    CeyloncTaskImpl task = getCompilerTask(defaultOptions, collector, "bug17xx/Bug1773.ceylon");
    // now compile it all the way
    ExitState exitState = task.call2();
    Assert.assertEquals(ExitState.CeylonState.ERROR, exitState.ceylonState);
    // make sure we only got one, do not trust actualErrors.size() for that since it's a Set so
    // two methods with same contents would count as one.
    Assert.assertEquals(1, exitState.errorCount);
    TreeSet<CompilerError> actualErrors = collector.get(Diagnostic.Kind.ERROR);
    compareErrors(actualErrors, new CompilerError(22, "dynamic is not supported on the JVM"));
}
Also used : ExitState(org.eclipse.ceylon.compiler.java.launcher.Main.ExitState) ErrorCollector(org.eclipse.ceylon.compiler.java.test.ErrorCollector) CompilerError(org.eclipse.ceylon.compiler.java.test.CompilerError) CeyloncTaskImpl(org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl) Test(org.junit.Test)

Example 8 with ExitState

use of org.eclipse.ceylon.compiler.java.launcher.Main.ExitState 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 9 with ExitState

use of org.eclipse.ceylon.compiler.java.launcher.Main.ExitState in project ceylon by eclipse.

the class CompilerTests method compilesWithoutWarnings.

protected void compilesWithoutWarnings(List<String> options, String... ceylon) {
    ErrorCollector dl = new ErrorCollector();
    ExitState exitState = getCompilerTask(options, dl, ceylon).call2();
    Assert.assertEquals(exitState.ceylonState, CeylonState.OK);
    Assert.assertEquals("The code compiled with javac warnings", 0, dl.get(Diagnostic.Kind.WARNING).size() + dl.get(Diagnostic.Kind.MANDATORY_WARNING).size());
}
Also used : ExitState(org.eclipse.ceylon.compiler.java.launcher.Main.ExitState)

Example 10 with ExitState

use of org.eclipse.ceylon.compiler.java.launcher.Main.ExitState in project ceylon by eclipse.

the class RecoveryTests method bug6290.

@Test
public void bug6290() {
    String[] src = new String[] { "bug6290/Bug6290.java", "bug6290/module.ceylon" };
    ExitState result = getCompilerTask(defaultOptions, null, src).call2();
    Assert.assertEquals(Main.Result.ABNORMAL, result.javacExitCode);
    Assert.assertEquals(CeylonState.ERROR, result.ceylonState);
}
Also used : ExitState(org.eclipse.ceylon.compiler.java.launcher.Main.ExitState) Test(org.junit.Test)

Aggregations

ExitState (org.eclipse.ceylon.compiler.java.launcher.Main.ExitState)11 CeyloncTaskImpl (org.eclipse.ceylon.compiler.java.tools.CeyloncTaskImpl)7 Test (org.junit.Test)5 ErrorCollector (org.eclipse.ceylon.compiler.java.test.ErrorCollector)4 File (java.io.File)2 ZipFile (java.util.zip.ZipFile)2 JavaPositionsRetriever (org.eclipse.ceylon.compiler.java.codegen.JavaPositionsRetriever)2 CompilerError (org.eclipse.ceylon.compiler.java.test.CompilerError)2 DiagnosticListener (org.eclipse.ceylon.javax.tools.DiagnosticListener)2 TaskEvent (org.eclipse.ceylon.langtools.source.util.TaskEvent)2 TaskListener (org.eclipse.ceylon.langtools.source.util.TaskListener)2 JCCompilationUnit (org.eclipse.ceylon.langtools.tools.javac.tree.JCTree.JCCompilationUnit)2 Writer (java.io.Writer)1 TreeSet (java.util.TreeSet)1 CeyloncTool (org.eclipse.ceylon.compiler.java.tools.CeyloncTool)1 JavacFileManager (org.eclipse.ceylon.langtools.tools.javac.file.JavacFileManager)1