Sha256: e3bf9f33bb24b138331e81d42862ec8d926cffab2917a21cfd03364331e3884f

Contents?: true

Size: 729 Bytes

Versions: 1

Compression:

Stored size: 729 Bytes

Contents

# -*- coding: utf-8 -*-
require File.join(File.dirname(__FILE__), "..", "..", "spec_helper")

require 'treevisitor/visitors/depth_tree_node_visitor'
require 'treevisitor/visitors/clone_tree_node_visitor'

describe "Tree Node Visitors" do

  before do
    ta = TreeNode.new( "a", nil )
    LeafNode.new("1", ta )
    LeafNode.new("2", ta )
    
    tb = TreeNode.new( "b", ta )
    LeafNode.new( "3", tb ) 
    
    @tree = ta
  end

  it DepthTreeNodeVisitor do
    visitor = DepthTreeNodeVisitor.new
    @tree.accept( visitor )
    visitor.depth.should == 0

    visitor = CloneTreeNodeVisitor.new
    @tree.accept( visitor )
    visitor.cloned_root.nr_nodes.should ==  @tree.nr_nodes
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
treevisitor-0.1.6 spec/treevisitor/visitors/depth_tree_node_visitor_spec.rb