Example #1
0
 void TestLeafType() {
     var cw=new CmpWalker(0,null);
     Ok(IsLeafType(cw,new object()));
     Ok(IsLeafType(cw,1));
     Ok(IsLeafType(cw,"a"));
     Ok(IsLeafType(cw,1.23));
     Ok(IsLeafType(cw,'a'));
     Ok(IsLeafType(cw,new Leaf()));
     Ok(!IsLeafType(cw,new Node()));
     Ok(IsLeafType(cw,new Node().A));
     Ok(IsLeafType(cw,new LeafS()));
     Ok(!IsLeafType(cw,new NodeS()));
     Ok(!IsLeafType(cw,new []{1,2}));
     Ok(!IsLeafType(cw,new Dictionary<int,int>{{1,2},{2,3}}));
 }
Example #2
0
    void TestWalk() {
        var cw=new CmpWalker(0,null);
        var path=new List<PathEntry>();
        TestWalkHelper(cw.Walk(null,1,path).ToArray(),new GWalker.Node[]{new GWalker.Node(null,1,-1,0,true)});
        IsDeeply(path,new[]{new PathEntry(0,new[]{0,0})});

        cw=new CmpWalker(0,null);
        var ass=new int[]{1,2};
        path=new List<PathEntry>();
        TestWalkHelper(cw.Walk(null,ass,path).ToArray(),new GWalker.Node[]{
                new GWalker.Node(null,ass,-1,2,false),new GWalker.Node(null,1,-1,0,true),
                new GWalker.Node(null,2,-1,0,true)});
        IsDeeply(path,new[]{new PathEntry(0,new[]{2,0}),new PathEntry(2)});
    }
Example #3
0
 bool IsLeafType(CmpWalker cw,object o) {
     return cw.IsLeafType(o,o.GetType());
 }
Example #4
0
 public Result Compare(object l,object r,out List<PathEntry> path) {
     path=new List<PathEntry>();;
     var lw=new CmpWalker(0,BBD);
     var rw=new CmpWalker(1,BBD);
     var result=CmpLists(lw.Walk(null,l,path),rw.Walk(null,r,path));
     if(result==Result.Eq) path=null;
     return result;
 }