private List <string> GetProgramOutput(string[] lines, string[] inputs) { FileReader.ClearInput(); IOHandler io = new TestIO(inputs); foreach (string line in lines) { FileReader.AddInputLine(line); } string input = ConcatLines(lines); BlockNode ast = p.Parse(input); Visitor v = new InterpreterVisitor(io); v.VisitProgram(ast); FileReader.ClearInput(); return(io.GetOutput()); }
public void ReportsError1() { FileReader.ClearInput(); string input = "var a : int;;"; FileReader.AddInputLine(input); try { p.Parse(input); Assert.IsTrue(false); } catch (Error e) { Assert.AreEqual( $"ERROR (line 1, column 12): Unexpected character: {SymbolType.SemiColon}\n\n\t{input}\n\t ^", e.ToString() ); } FileReader.ClearInput(); }