summaryrefslogtreecommitdiff
path: root/test/psych/test_object.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/psych/test_object.rb')
-rw-r--r--test/psych/test_object.rb15
1 files changed, 12 insertions, 3 deletions
diff --git a/test/psych/test_object.rb b/test/psych/test_object.rb
index f1c61451d0..21c27794ea 100644
--- a/test/psych/test_object.rb
+++ b/test/psych/test_object.rb
@@ -28,7 +28,7 @@ module Psych
def test_tag_round_trip
tag = Tagged.new
- tag2 = Psych.load(Psych.dump(tag))
+ tag2 = Psych.unsafe_load(Psych.dump(tag))
assert_equal tag.baz, tag2.baz
assert_instance_of(Tagged, tag2)
end
@@ -36,10 +36,19 @@ module Psych
def test_cyclic_references
foo = Foo.new(nil)
foo.parent = foo
- loaded = Psych.load Psych.dump foo
+ loaded = Psych.load(Psych.dump(foo), permitted_classes: [Foo], aliases: true)
assert_instance_of(Foo, loaded)
- assert_equal loaded, loaded.parent
+ assert_same loaded, loaded.parent
+ end
+
+ def test_cyclic_reference_uses_alias
+ foo = Foo.new(nil)
+ foo.parent = foo
+
+ assert_raise(AliasesNotEnabled) do
+ Psych.load(Psych.dump(foo), permitted_classes: [Foo], aliases: false)
+ end
end
end
end