Example #1
0
    public bool testHeteroTreeDup()
    {
        factory = new ASTFactory();
        factory.setMaxNodeType(49);
        // create a tree and try to dup:
        // ( [type 1] [type 2] ( [type 49] [type 3 #2] ) [type 3] )
        AST x   = factory.create(1, "[type 1]", "MyAST");     // will be root
        AST y   = factory.create(2, "[type 2]", "MyAST");
        AST z   = factory.create(3, "[type 3]", "MyAST");
        AST sub = factory.create(49, "[type 49]", "ASTType49");

        sub.addChild(factory.create(3, "[type 3 #2]", "MyAST"));
        AST t     = factory.make(new AST[] { x, y, sub, z });
        AST dup_t = factory.dupList(t);
        // check structure
        bool a = dup_t.EqualsList(t);
        // check types
        bool b = equalsNodeTypesList(t, dup_t);

        return(a && b);
    }