public string TestLine(string line, CLLocalStore vars, CLContextProvider context, string expected) { // We'll parse the line as usual CalcObject obj1 = CLInterpreter.Interpret(line); string code2 = obj1.ToCode(); CalcObject obj3 = CLInterpreter.Interpret(code2); string code4 = obj3.ToCode(); // Make sure things look right Assert.AreEqual(code2, code4); // Now get the value out of it CalcValue val5 = obj3.GetValue(vars, context); string code6 = val5.ToCode(); CalcObject obj7 = CLInterpreter.Interpret(code6); string code8 = val5.ToCode(); CalcValue val9 = obj7.GetValue(vars, context); // Make sure things still look right Assert.AreEqual(code6, code8); Assert.AreEqual(val5, val9); // Now we should also make sure the values reported are as expected. Assert.AreEqual(code8, expected); // And we'll return the final value so it can be used later! return(code8); }
public void TestLine(string input, bool resolve = true) { // First, let's parse it CalcObject obj1 = CLInterpreter.Interpret(input); // And put it back to string and back string code2 = obj1.ToCode(); CalcObject obj3 = CLInterpreter.Interpret(code2); string code4 = obj3.ToCode(); // code2 and code4 need to match Assert.AreEqual(code2, code4, "code2 and code4 don't match on line: " + input); // We'll stop here if we're testing non-deterministic functions if (!resolve) { return; } // Then, let's get the value CalcValue val5 = obj1.GetValue(); string code6 = val5.ToCode(); CalcObject obj7 = CLInterpreter.Interpret(code6); string code8 = obj7.ToCode(); CalcValue val9 = obj7.GetValue(); // code6 and code8 need to match Assert.AreEqual(code6, code8, "code6 and code8 don't match on line: " + input); // val5 and val9 also need to match Assert.AreEqual(val5, val9, "val5 and val9 don't match on line: " + input); }