⚲
Project
General
Profile
Sign in
Register
Home
Projects
Help
Search
:
Backport187
All Projects
Ruby
»
Backport187
Overview
Activity
Issues
Like
Download (992 Bytes)
Backport #1331
ยป yaml_test.rb
yaml_test.rb -
bahuvrihi (Simon Chiang)
, 03/30/2009 12:53 PM
require
'yaml'
require
'test/unit'
class
A
;
end
class
YAMLTest
<
Test
::
Unit
::
TestCase
# Enable the gsub to make the tests pass
def
fix
(
dump
)
#dump.gsub!(/((?:&id\d+\s+)?!ruby\/object:.*?)\s*\?/) { "? #{$1} " }
end
# Currently this is the dump:
#
# ---
# !ruby/object:A ? {}
# : :a
#
# The dump should be:
#
# ---
# ? !ruby/object:A {}
# : :a
#
def
test_dump_and_reload_hash_with_ruby_object_as_key
hash
=
{
A
.
new
=>
:a
}
dump
=
YAML
.
dump
(
hash
)
fix
(
dump
)
assert_nothing_raised
{
YAML
.
load
(
dump
)
}
end
# Currently this is the dump:
#
# ---
# &id001 !ruby/object:A ? {}
# : *id001
#
# The dump should be:
#
# ---
# ? &id001 !ruby/object:A {}
# : *id001
#
def
test_dump_and_reload_self_referential_hash_with_ruby_object_as_key
a
=
A
.
new
hash
=
{
a
=>
a
}
dump
=
YAML
.
dump
(
hash
)
fix
(
dump
)
assert_nothing_raised
{
YAML
.
load
(
dump
)
}
end
end
(1-1/1)
Loading...