test/unit/bio/db/test_newick.rb in bio-1.4.1 vs test/unit/bio/db/test_newick.rb in bio-1.4.2
- old
+ new
@@ -37,23 +37,38 @@
):0.04692,
HexLEZ73:0.00268
)[0.1250];
END_OF_TREE_STRING
+ def setup
+ @newick = Bio::Newick.new(TREE_STRING)
+ end
+
def test_string_tree
- newick = Bio::Newick.new(TREE_STRING)
- tree = newick.tree
+ tree = @newick.tree
assert_equal(3, tree.children(tree.root).size)
assert_equal(9, tree.descendents(tree.root).size)
assert_equal(6, tree.leaves.size)
leaf = tree.get_node_by_name('HexFLZ83')
assert_equal(3, tree.ancestors(leaf).size)
assert_equal(tree.path(tree.root, leaf)[1], tree.ancestors(leaf)[1])
assert_equal(0.00217, tree.get_edge(leaf, tree.parent(leaf)).distance)
assert_equal("HexFLZ83", leaf.name)
end
+ def test_reparse
+ tree = @newick.tree
+ assert_equal(@newick, @newick.reparse)
+ end
+
+ def test_reparse_before_lazy_parsing
+ # not to use @newick to guarantee that the Newick object
+ # is before lazy parsing.
+ newick = Bio::Newick.new(TREE_STRING)
+ assert_equal(newick, newick.reparse)
+ end
+
end #class TestNewick
class TestNewick2 < Test::Unit::TestCase
TREE_STRING = <<-END_OF_TREE_STRING
@@ -70,12 +85,15 @@
) ABC : 0.25 [99]
) test3 :0.5
)root;
END_OF_TREE_STRING
+ def setup
+ @newick = Bio::Newick.new(TREE_STRING)
+ end
+
def test_string_tree
- newick = Bio::Newick.new(TREE_STRING)
- tree = newick.tree
+ tree = @newick.tree
assert_equal('root', tree.root.name)
assert_equal([
"this is test",
"test2 (abc, def)",
"internal node\'s name",