From b23fd59cbb3f097bcd559d0c85a86ff7a1eeeb7e Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Sat, 11 Jan 2020 15:04:44 +0900 Subject: marshal.c: Support dump and load of a Hash with the ruby2_keywords flag It is useful for a program that dumps and load arguments (like drb). In future, they should deal with both positional arguments and keyword ones explicitly, but until ruby2_keywords is deprecated, it is good to support the flag in marshal. The implementation is similar to String's encoding; it is dumped as a hidden instance variable. [Feature #16501] --- test/ruby/test_marshal.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_marshal.rb b/test/ruby/test_marshal.rb index 74ea75ee42..dbeee825da 100644 --- a/test/ruby/test_marshal.rb +++ b/test/ruby/test_marshal.rb @@ -754,4 +754,18 @@ class TestMarshal < Test::Unit::TestCase Marshal.dump(obj) end end + + ruby2_keywords def ruby2_keywords_hash(*a) + a.last + end + + def ruby2_keywords_test(key: 1) + key + end + + def test_marshal_with_ruby2_keywords_hash + flagged_hash = ruby2_keywords_hash(key: 42) + hash = Marshal.load(Marshal.dump(flagged_hash)) + assert_equal(42, ruby2_keywords_test(*[hash])) + end end -- cgit v1.2.3