ruby-changes:72864
From: Alexander <ko1@a...>
Date: Tue, 9 Aug 2022 01:31:39 +0900 (JST)
Subject: [ruby-changes:72864] c851bced39 (master): [ruby/psych] Clarify tests about parsing aliases
https://git.ruby-lang.org/ruby.git/commit/?id=c851bced39 From c851bced390204d6624e58c47941f34d0858b352 Mon Sep 17 00:00:00 2001 From: Alexander Momchilov <alexander.momchilov@s...> Date: Fri, 22 Jul 2022 15:49:05 -0400 Subject: [ruby/psych] Clarify tests about parsing aliases https://github.com/ruby/psych/commit/0bc30cb4cb --- test/psych/test_safe_load.rb | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/test/psych/test_safe_load.rb b/test/psych/test_safe_load.rb index b52d6048b3..e57dbcb2f5 100644 --- a/test/psych/test_safe_load.rb +++ b/test/psych/test_safe_load.rb @@ -19,18 +19,31 @@ module Psych https://github.com/ruby/ruby/blob/trunk/test/psych/test_safe_load.rb#L19 end end - def test_no_recursion - x = [] - x << x + def test_raises_when_alias_found_if_alias_parsing_not_enabled + yaml_with_aliases = <<~YAML + --- + a: &ABC + k1: v1 + k2: v2 + b: *ABC + YAML + assert_raise(Psych::BadAlias) do - Psych.safe_load Psych.dump(x) + Psych.safe_load(yaml_with_aliases) end end - def test_explicit_recursion - x = [] - x << x - assert_equal(x, Psych.safe_load(Psych.dump(x), permitted_classes: [], permitted_symbols: [], aliases: true)) + def test_aliases_are_parsed_when_alias_parsing_is_enabled + yaml_with_aliases = <<~YAML + --- + a: &ABC + k1: v1 + k2: v2 + b: *ABC + YAML + + result = Psych.safe_load(yaml_with_aliases, aliases: true) + assert_same result.fetch("a"), result.fetch("b") end def test_permitted_symbol -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/