コード例 #1
0
        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));
            }
        }
コード例 #2
0
        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));
        }
コード例 #3
0
ファイル: CompilerTests.cs プロジェクト: andy-uq/TinyOS
        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));
            }
        }
コード例 #4
0
ファイル: CompilerTests.cs プロジェクト: andy-uq/TinyOS
        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));
        }