require 'test/unit' require 'forward_referencing' class LineLink attr_accessor :data, :link def initialize(chain,data,link) @data,@link = data,link end def to_s "#{data} #{link}" end end class LineChain < ForwardReferencer attr_accessor :chain def load(text) @chain = {} pattern = /(\w*) (\w*)/ text.each do |line| matches = pattern.match line line_link = LineLink.new self, matches[1], matches[2] @chain[line_link.data] = line_link forward_reference = create line_link.data if ((link = @chain[line_link.link]) != nil) || (line_link.link == 'end') line_link.link = link remove forward_reference end continue end end end class TC_Histogram < Test::Unit::TestCase def test_forward_referencing text = <