summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJean Boussier <jean.boussier@gmail.com>2019-07-24 16:01:20 -0400
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-06-05 11:49:56 +0900
commitf641d78a6fcf0b96c50077503a763478d0599fe5 (patch)
tree0a67ca59d70a6b3c195e1c395c1c812c0c422e23 /test
parent4085c51a5175aeff2aeb8b849214c2899a79eb19 (diff)
[ruby/psych] Implement `freeze` option for Pysch.load
https://github.com/ruby/psych/commit/7dae24894d
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3188
Diffstat (limited to 'test')
-rw-r--r--test/psych/test_psych.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/psych/test_psych.rb b/test/psych/test_psych.rb
index eeadc864ef4..8fd9d278b58 100644
--- a/test/psych/test_psych.rb
+++ b/test/psych/test_psych.rb
@@ -192,6 +192,22 @@ class TestPsych < Psych::TestCase
assert_equal({ 'hello' => 'world' }, got)
end
+ def test_load_freeze
+ data = Psych.load("--- {foo: ['a']}", freeze: true)
+ assert_predicate data, :frozen?
+ assert_predicate data['foo'], :frozen?
+ assert_predicate data['foo'].first, :frozen?
+ end
+
+ def test_load_freeze_deduplication
+ unless String.method_defined?(:-@) && (-("a" * 20)).equal?((-("a" * 20)))
+ skip "This Ruby implementation doesn't support string deduplication"
+ end
+
+ data = Psych.load("--- ['a']", freeze: true)
+ assert_same 'a', data.first
+ end
+
def test_load_default_fallback
assert_equal false, Psych.load("")
end