Sha256: dddc4a38db5fb92856b4e0e349ec971b12707e5fcf48ee93f80661c10a1773a8
Contents?: true
Size: 1.3 KB
Versions: 4
Compression:
Stored size: 1.3 KB
Contents
# Copyright: Copyright (c) 2004 Nicolas Despres. All rights reserved. # Author: Nicolas Despres <polrop@lrde.epita.fr>. # License: Gnu General Public License. # $LastChangedBy: polrop $ # $Id: node.rb 171 2005-03-29 09:12:47Z polrop $ require 'abstract_node' class IndexedNode < AbstractNode include Concrete def initialize(data=nil, *sub_nodes) @sub_nodes = sub_nodes super end def <<(sub_node) check_sub_node_type(sub_node) @sub_nodes << sub_node end end # class IndexedNode if defined? TEST_MODE or __FILE__ == $0 require 'test/unit' class IndexedNodeTest < Test::Unit::TestCase def test_simple s11 = IndexedNode.new(11) s12 = IndexedNode.new(12) s = IndexedNode.new(1, s11, s12) assert_equal(1, s.data) assert_equal(s11, s.sub_nodes[0]) assert_equal(s12, s.sub_nodes[1]) end def test_crochet_equal s = IndexedNode.new(1) assert_nothing_raised { s[0] = IndexedNode.new(10) } assert_raises(TypeError) { s[1] = nil } end def test_merge s = IndexedNode.new(1) s11 = IndexedNode.new(11) s12 = IndexedNode.new(12) s.merge!({ 0 => s11, 1 => s12 }) end def test_chevron s = IndexedNode.new(1) assert_equal(0, s.size) s << IndexedNode.new(2) assert_equal(1, s.size) end end # class IndexedNodeTest end
Version data entries
4 entries across 4 versions & 2 rubygems
Version | Path |
---|---|
ttk-0.1.576 | ruby_ex/indexed_node.rb |
ttk-0.1.579 | ruby_ex/indexed_node.rb |
ttk-0.1.580 | ruby_ex/indexed_node.rb |
vcs-0.2.148 | ruby_ex/indexed_node.rb |