some more coverage

This commit is contained in:
Dmitry Jemerov
2011-11-03 19:03:29 +01:00
parent 2911ff95da
commit 8540d60ce1
2 changed files with 39 additions and 5 deletions
@@ -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;
}
}