Sha256: c4a353bc5e27daad0c8077af28a5e800c011237f78ec69d848c8d3b6d9b28279
Contents?: true
Size: 781 Bytes
Versions: 1
Compression:
Stored size: 781 Bytes
Contents
# -*- coding: utf-8 -*- require File.join(File.dirname(__FILE__), "..", "..", "spec_helper") require 'treevisitor/visitors/callback_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 CallbackTreeNodeVisitor do accumulator = [] visitor = CallbackTreeNodeVisitor.new visitor.on_enter_tree_node{ |tree_node| accumulator << tree_node.content } visitor.on_visit_leaf_node{ |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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
treevisitor-0.1.6 | spec/treevisitor/visitors/callback_tree_node_visitors_spec.rb |