mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/psych/lib/psych/visitors/to_ruby.rb: correctly register
self-referential strings. Fixes tenderlove/psych #135 * test/psych/test_string.rb: appropriate test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40137 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
fbb29bc08c
commit
7a7bb64464
3 changed files with 49 additions and 7 deletions
|
@ -15,6 +15,31 @@ module Psych
|
|||
end
|
||||
end
|
||||
|
||||
def test_string_subclass_with_anchor
|
||||
y = Psych.load <<-eoyml
|
||||
---
|
||||
body:
|
||||
string: &70121654388580 !ruby/string
|
||||
str: ! 'foo'
|
||||
x:
|
||||
body: *70121654388580
|
||||
eoyml
|
||||
assert_equal({"body"=>{"string"=>"foo", "x"=>{"body"=>"foo"}}}, y)
|
||||
end
|
||||
|
||||
def test_self_referential_string
|
||||
y = Psych.load <<-eoyml
|
||||
---
|
||||
string: &70121654388580 !ruby/string
|
||||
str: ! 'foo'
|
||||
body: *70121654388580
|
||||
eoyml
|
||||
|
||||
assert_equal({"string"=>"foo"}, y)
|
||||
value = y['string']
|
||||
assert_equal value, value.instance_variable_get(:@body)
|
||||
end
|
||||
|
||||
def test_another_subclass_with_attributes
|
||||
y = Psych.load Psych.dump Y.new("foo").tap {|y| y.val = 1}
|
||||
assert_equal "foo", y
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue