package test; import junit.framework.TestCase; import tool.Interp; import java.io.StringBufferInputStream; public class TestInterp extends TestCase { public void testAssign() throws Exception { String input = "a=34\n"; Interp interpreter = new Interp(new StringBufferInputStream(input)); interpreter.execute(); String expecting = "(trees.AssignTree a 34)\n"; String found = interpreter.out.toString(); assertEquals("testing single int", expecting, found); } public void testAssignPrint() throws Exception { String input = "a=34\n" + "print a\n"; Interp interpreter = new Interp(new StringBufferInputStream(input)); interpreter.execute(); String expecting = "(trees.AssignTree a 34)\n" + "(trees.PrintTree a)\n" + "34\n"; String found = interpreter.out.toString(); assertEquals("testing single int", expecting, found); } }