diff options
author | nagachika <nagachika@ruby-lang.org> | 2020-07-23 16:59:03 +0900 |
---|---|---|
committer | nagachika <nagachika@ruby-lang.org> | 2020-07-23 16:59:03 +0900 |
commit | ae804b143455075687c8b4a401fba48fda72a217 (patch) | |
tree | a1a5009a9cb04686d308832030c71c00440a5aec /test | |
parent | f1563edca0af1a5ad5cc748eb855ff9265e69e7f (diff) | |
download | ruby-ae804b143455075687c8b4a401fba48fda72a217.tar.gz |
merge revision(s) b23fd59cbb3f097bcd559d0c85a86ff7a1eeeb7e: [Backport #16501]
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]
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_marshal.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/ruby/test_marshal.rb b/test/ruby/test_marshal.rb index f300710d2c..850f467c10 100644 --- a/test/ruby/test_marshal.rb +++ b/test/ruby/test_marshal.rb @@ -753,4 +753,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 |