/* * private static void error(string code) * { * * Exception e = null; * try * { * test(code, null); * } * catch (Exception ex) * { * e = ex; * } * if (e == null) * throw Error.Fail(); * * } */ // ReSharper disable ParameterOnlyUsedForPreconditionCheck.Local private static void test( string code, string expectedResult, string expectedOutput = "", bool checkTypes = true) // ReSharper restore ParameterOnlyUsedForPreconditionCheck.Local { var outputWriter = new StringWriter(); var errorWriter = new StringWriter(); var prog = Prog.Init(outputWriter, errorWriter, "unittest.ef", code, checkTypes); var res = prog.Interpreter.Eval(prog); var val = res.ToCodeString(); if (val != expectedResult) { throw new Exception(); } var actualOutput = outputWriter.GetAndReset(); if (actualOutput != expectedOutput) { throw new Exception(); } }