private void AssertRun(string source, Expectation[] expectations) { var result = new PlottyCompiler() .Compile(source) .GenerationResult; var machine = new PlottyMachine(); machine.Load(result.Lines); while (machine.CanExecute) { machine.Execute(); } //foreach (var expectation in expectations) //{ // var address = result.AddressMap[new Reference(expectation.Reference)]; // if (expectation.Operator == Operator.Equal) // { // machine.Memory[address].Should().Be(expectation.Value); // } // else // { // machine.Memory[address].Should().NotBe(expectation.Value); // } //} }
public void Run(string source) { var compiler = new PlottyCompiler(); var result = compiler.Compile(source); mainSymbolTable = result.SymbolTable.Children.Single(x => x.Owner is Function f && f.Name == "main"); IntermediateCode = result.IntermediateCode; Machine.Load(result.GenerationResult.Lines); while (Machine.CanExecute) { Machine.Execute(); } }
public void ReferencesHaveTheExpectedValues(string source, IEnumerable <Expectation> expectations) { var result = new PlottyCompiler().Compile(source); AssertRun(result.GenerationResult, expectations); }