Sha256: 9532ba99b0e0706fda815ed09ede1bfbd7e1e51a1d36187c069220f30fbe552d

Contents?: true

Size: 683 Bytes

Versions: 16

Compression:

Stored size: 683 Bytes

Contents

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

describe TreeNodeVisitor 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 TreeNodeVisitor do
    accumulator = []
    visitor = TreeNodeVisitor.new
    visitor.on_enter_node{ |tree_node| accumulator << tree_node.content }
    visitor.on_leaf{ |leaf_node| accumulator << leaf_node.content }
    @tree.accept( visitor )
    accumulator.length.should == 5
    accumulator.should == %w{ a 1 2 b 3 }
  end
  
end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
tree.rb-0.3.12 spec/tree_rb/visitors/tree_node_visitors_spec.rb
tree.rb-0.3.11 spec/tree_rb/visitors/tree_node_visitors_spec.rb
tree.rb-0.3.10 spec/tree_rb/visitors/tree_node_visitors_spec.rb
tree.rb-0.3.9 spec/tree_rb/visitors/tree_node_visitors_spec.rb
tree.rb-0.3.8 spec/tree_rb/visitors/tree_node_visitors_spec.rb
tree.rb-0.3.7 spec/tree_rb/visitors/tree_node_visitors_spec.rb
tree.rb-0.3.6 spec/tree_rb/visitors/tree_node_visitors_spec.rb
tree.rb-0.3.5 spec/tree_rb/visitors/tree_node_visitors_spec.rb
tree.rb-0.3.4 spec/tree_rb/visitors/tree_node_visitors_spec.rb
tree.rb-0.3.3 spec/tree_rb/visitors/tree_node_visitors_spec.rb
tree.rb-0.3.2 spec/tree_rb/visitors/tree_node_visitors_spec.rb
tree.rb-0.3.1 spec/tree_rb/visitors/tree_node_visitors_spec.rb
tree.rb-0.3.0 spec/treevisitor/visitors/tree_node_visitors_spec.rb
treevisitor-0.2.3 spec/treevisitor/visitors/tree_node_visitors_spec.rb
treevisitor-0.2.2 spec/treevisitor/visitors/tree_node_visitors_spec.rb
treevisitor-0.2.1 spec/treevisitor/visitors/tree_node_visitors_spec.rb