Ejemplo n.º 1
0
        public void CompilationTest()
        {
            var elfCode = ResourceHelper.ReadFromResource("Elf.Playground.Staple.Universal.elf");
            var elfAst = new ElfAstBuilder(elfCode).BuildAst();

            var evis = new DefaultElfCompiler().Compile((FuncDef)elfAst.Children.ElementAt(0).Children.ElementAt(1));

            var pewpew = evis.Select(evi => evi.ToString()).StringJoin(Environment.NewLine);
            AssertHelper.AreEqualFromResource("Elf.Playground.Staple.VirtualMachineTests.Compilation", pewpew, @"d:\elf-vmcompile");
        }
Ejemplo n.º 2
0
        public void TestEviBindings()
        {
            var elfCode = ResourceHelper.ReadFromResource("Elf.Playground.Staple.Universal.elf");
            var elfAst = new ElfAstBuilder(elfCode).BuildAst();

            var evis = new DefaultElfCompiler().Compile((FuncDef)elfAst.Children.ElementAt(0).Children.ElementAt(1));
            evis.ForEach((evi, i) => Assert.IsNotNull(evi.AstNode, i + ": " + evi));

            var pewpew = evis.Select(evi => String.Format("{0} -> {1}", evi, evi.AstNode.FullTPath));
            var pepew = pewpew.StringJoin(Environment.NewLine);
            AssertHelper.AreEqualFromResource("Elf.Playground.Staple.DebugInfoTests.EviBindings", pepew, @"d:\elf-elfastbind");
        }
Ejemplo n.º 3
0
        public void TestAntlrNodeBindings()
        {
            var elfCode = ResourceHelper.ReadFromResource("Elf.Playground.Staple.Universal.elf");
            var elfAst = new ElfAstBuilder(elfCode).BuildAst();

            var elfNodes = elfAst.Flatten(node => node.Children);
            elfNodes.ForEach(elfNode => Assert.IsNotNull(elfNode.AntlrNode, elfNode.ShortTPath));

            var pewpew = elfNodes.Select(node => String.Format(
                "{0} -> {1}", node.FullTPath, node.AntlrNode.ToStringTree()));

            var pepew = pewpew.StringJoin(Environment.NewLine);
            AssertHelper.AreEqualFromResource("Elf.Playground.Staple.DebugInfoTests.AntlrNodeBindings", pepew, @"d:\elf-antlrbind");
        }
Ejemplo n.º 4
0
 public void ContentTest()
 {
     var elfCode = ResourceHelper.ReadFromResource("Elf.Playground.Staple.Universal.elf");
     var ast = new ElfAstBuilder(elfCode).BuildAst();
     AssertHelper.AreEqualFromResource("Elf.Playground.Staple.AstTests.Content", ast.Content, @"d:\elf-astcontent");
 }