some more coverage
This commit is contained in:
@@ -6,7 +6,14 @@ import junit.framework.TestCase;
|
||||
import org.jetbrains.jet.codegen.ClassFileFactory;
|
||||
import org.jetbrains.jet.parsing.JetParsingTest;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarInputStream;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
@@ -25,7 +32,7 @@ public class CompileEnvironmentTest extends TestCase {
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
public void testSmoke() {
|
||||
public void testSmoke() throws IOException {
|
||||
final File activeRtJar = CompileEnvironment.findRtJar(true);
|
||||
environment.setJavaRuntime(activeRtJar);
|
||||
environment.initializeKotlinRuntime();
|
||||
@@ -36,5 +43,23 @@ public class CompileEnvironmentTest extends TestCase {
|
||||
final ClassFileFactory factory = environment.compileModule(moduleBuilder, testDataDir);
|
||||
assertNotNull(factory);
|
||||
assertNotNull(factory.asBytes("Smoke/namespace.class"));
|
||||
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
CompileEnvironment.writeToJar(factory, baos, null, false);
|
||||
JarInputStream is = new JarInputStream(new ByteArrayInputStream(baos.toByteArray()));
|
||||
final List<String> entries = listEntries(is);
|
||||
assertTrue(entries.contains("Smoke/namespace.class"));
|
||||
}
|
||||
|
||||
private List<String> listEntries(JarInputStream is) throws IOException {
|
||||
List<String> entries = new ArrayList<String>();
|
||||
while (true) {
|
||||
final JarEntry jarEntry = is.getNextJarEntry();
|
||||
if (jarEntry == null) {
|
||||
break;
|
||||
}
|
||||
entries.add(jarEntry.getName());
|
||||
}
|
||||
return entries;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user