From f8d34b2a751207fa9d31482e7f587f8bf59b892c Mon Sep 17 00:00:00 2001 From: tenderlove Date: Sun, 28 Oct 2012 01:13:09 +0000 Subject: [PATCH] * ext/psych/lib/psych/visitors/yaml_tree.rb: `tree` should return the same thing on every call. * test/psych/visitors/test_yaml_tree.rb: related test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37350 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ ext/psych/lib/psych/visitors/yaml_tree.rb | 1 + test/psych/visitors/test_yaml_tree.rb | 7 +++++++ 3 files changed, 15 insertions(+) diff --git a/ChangeLog b/ChangeLog index 235c4ef47a..d86047537f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Sun Oct 28 10:12:15 2012 Aaron Patterson + + * ext/psych/lib/psych/visitors/yaml_tree.rb: `tree` should return the + same thing on every call. + + * test/psych/visitors/test_yaml_tree.rb: related test. + Sun Oct 28 10:05:03 2012 Aaron Patterson * ext/psych/lib/psych/visitors/yaml_tree.rb: YAML Tree object should diff --git a/ext/psych/lib/psych/visitors/yaml_tree.rb b/ext/psych/lib/psych/visitors/yaml_tree.rb index a9b2ebff37..9cbc05df4a 100644 --- a/ext/psych/lib/psych/visitors/yaml_tree.rb +++ b/ext/psych/lib/psych/visitors/yaml_tree.rb @@ -47,6 +47,7 @@ module Psych def tree finish unless finished? + @emitter.root end def push object diff --git a/test/psych/visitors/test_yaml_tree.rb b/test/psych/visitors/test_yaml_tree.rb index 3f2954c71e..496cdd05cc 100644 --- a/test/psych/visitors/test_yaml_tree.rb +++ b/test/psych/visitors/test_yaml_tree.rb @@ -8,6 +8,13 @@ module Psych @v = Visitors::YAMLTree.new end + def test_tree_can_be_called_twice + @v.start + @v << Object.new + t = @v.tree + assert_equal t, @v.tree + end + def test_yaml_tree_can_take_an_emitter io = StringIO.new e = Psych::Emitter.new io