コード例 #1
0
        public void VariableDeclarationTest()
        {
            // GIVEN
            var source = @"
                function max(a: number, b: number): number do
                    function temp: number do skip; end; 
                    return temp();
                end;
                var a: number = 10 + 10;
                do  
                    var b: number = max(a + a, false);
                end;
            ";

            var compilerService = new CompilerService();
            var analyzer = new SemanticParser(compilerService);

            // WHEN
            var node = ParseWithAbstractTreeVisitor(Compiler, source);
            analyzer.Visit(node as CompilationUnit);

            // THEN
            Assert.NotNull(compilerService.FindVariable("a"));
            Assert.AreEqual(0, compilerService.Errors.Count);
            Assert.AreEqual(0, compilerService.Warnings.Count);
        }