package test; import junit.framework.TestCase; import tool.CodeGen; import java.io.StringBufferInputStream; public class TestCodeGen extends TestCase { public void testAssign() throws Exception { String input = "a=34\n"; CodeGen generator = new CodeGen(new StringBufferInputStream(input)); generator.compile(); String found = generator.out.toString(); String expecting = " ldc 34\n" + " istore 1\n"; assertEquals("testing single int", expecting, found); } public void testPrint() throws Exception { String input = "print 34\n"; CodeGen generator = new CodeGen(new StringBufferInputStream(input)); generator.compile(); String found = generator.out.toString(); String expecting = " getstatic java/lang/System/out Ljava/io/PrintStream;\n" + " ldc 34\n" + " invokevirtual java/io/PrintStream/println(I)V\n"; assertEquals("testing single int", expecting, found); } }