use of org.eclipse.ceylon.compiler.java.test.ErrorCollector in project ceylon by eclipse.
the class IssuesTests_1500_1999 method testBug1969.
@SuppressWarnings("deprecation")
@Test
public void testBug1969() {
java.util.List<File> sourceFiles = new ArrayList<File>(1);
sourceFiles.add(new File(getPackagePath(), "bug19xx/Bug1969.ceylon"));
CeyloncTool runCompiler = makeCompiler();
StringWriter writer = new StringWriter();
CeyloncFileManager runFileManager = (CeyloncFileManager) runCompiler.getStandardFileManager(writer, null, null, null);
// make sure the destination repo exists
new File(destDir).mkdirs();
List<String> options = new LinkedList<String>();
options.addAll(defaultOptions);
if (!options.contains("-src"))
options.addAll(Arrays.asList("-src", getSourcePath()));
if (!options.contains("-cacherep"))
options.addAll(Arrays.asList("-cacherep", getCachePath()));
if (!options.contains("-sysrep"))
options.addAll(Arrays.asList("-sysrep", getSysRepPath()));
if (!options.contains("-cp"))
options.addAll(Arrays.asList("-cp", getClassPathAsPath()));
options.add("-verbose");
Iterable<? extends JavaFileObject> compilationUnits1 = runFileManager.getJavaFileObjectsFromFiles(sourceFiles);
CeyloncTaskImpl task = runCompiler.getTask(writer, runFileManager, null, options, null, compilationUnits1);
ErrorCollector collector = new ErrorCollector();
assertCompilesOk(collector, task.call2());
Assert.assertTrue(writer.toString().length() > 0);
}
use of org.eclipse.ceylon.compiler.java.test.ErrorCollector 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"));
}
use of org.eclipse.ceylon.compiler.java.test.ErrorCollector in project ceylon by eclipse.
the class IssuesTests_6000_6499 method testBug6422.
@Ignore("Requires Android")
@Test
public void testBug6422() {
String project = "../../../AndroidStudioProjects/MyApplication2/app";
String src = project + "/src/main/ceylon";
List<String> options = Arrays.asList("-jdk-provider", "android/23", "-src", src, "-rep", project + "/build/intermediates/ceylon-android/repository");
ErrorCollector c = new ErrorCollector();
List<String> modules = Arrays.asList("com.example.android.myapplication");
assertCompilesOk(c, getCompilerTask(options, c, modules).call2());
}
use of org.eclipse.ceylon.compiler.java.test.ErrorCollector 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);
}
use of org.eclipse.ceylon.compiler.java.test.ErrorCollector 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()));
}
Aggregations