public void ExecuteAsyncSimple() { List <double> expect = new List <double>(); for (int i = 0; i < 1000; i++) { expect.Add(i); } List <double>[] stories = new List <double> [1000]; (ReportParser report, List <Token> tokens, List <string> commands) = Compile(Resources.AsyncSimple); for (int i = 0; i < stories.Length; i++) { StackMachinePrint stackMachine = new StackMachinePrint(); stackMachine.Execute(commands); stories[i] = stackMachine.PrintHistory; } for (int i = 0; i < stories.Length; i++) { Console.WriteLine(string.Join(" ", stories[i])); CollectionAssert.AreEquivalent(expect, stories[i]); } for (int i = 1; i < stories.Length; i++) { if (!stories[0].SequenceEqual(stories[i])) { return; } } Assert.Fail(); }
public void ExecuteFunction() { StackMachinePrint stackMachine = ExecuteResource(Resources.function); Console.WriteLine(string.Join(" ", stackMachine.PrintHistory)); CollectionAssert.AreEqual(new double[] { 2 }, stackMachine.PrintHistory); }
private static StackMachinePrint ExecuteResource(string resource, bool needOptimize = true) { StackMachinePrint stackMachine = new StackMachinePrint(); List <string> compiled = needOptimize ? CompileAndOptimizing(resource) : Compile(resource).Item3; stackMachine.Execute(compiled); return(stackMachine); }
private static StackMachinePrint ExecuteResource(string resource) { StackMachinePrint stackMachine = new StackMachinePrint(); List <string> compiled = Compile(resource).Item3; stackMachine.Execute(compiled); return(stackMachine); }
public void TestOp() { StackMachinePrint stackMachine = ExecuteResource(Resources.Op); CollectionAssert.AreEqual(new double[] { 4 }, stackMachine.PrintHistory); }
public void TestFunctionCalculateNotOptimize() { StackMachinePrint stackMachine = ExecuteResource(Resources.FunctionCalculate, false); CollectionAssert.AreEqual(new double[] { 100 }, stackMachine.PrintHistory); }