public void ControlFlow(string source, uint result) { var grammar = new AndyStructuralGrammar(); var parserState = new ParserState(source); var parseResult = grammar.block.Match(parserState); Assert.That(parseResult, Is.True); var compiler = new Andy.TinyOS.Compiler.Compiler(grammar, parserState); var program = compiler.Compile(); var cpu = new Cpu(); var r = Run(program, cpu); Assert.That(r.ExitCode, Is.EqualTo(result)); var variable = cpu.Ram.GetStream(r.GlobalData.Pages.First()); using (var reader = new BinaryReader(variable)) { var value = reader.ReadUInt32(); Assert.That(value, Is.EqualTo(result)); } }
public void SingleExpression(string source, uint result) { var grammar = new AndyStructuralGrammar(); var parserState = new ParserState(source); var parseResult = grammar.expression.Match(parserState); Assert.That(parseResult, Is.True); var compiler = new Andy.TinyOS.Compiler.Compiler(grammar, parserState); var program = compiler.Compile(); var r = Run(program, new Cpu()); Assert.That(r.ExitCode, Is.EqualTo(result)); }