diff options
author | Yusuke Endoh <mame@ruby-lang.org> | 2020-01-11 15:04:44 +0900 |
---|---|---|
committer | Yusuke Endoh <mame@ruby-lang.org> | 2020-01-17 17:20:19 +0900 |
commit | b23fd59cbb3f097bcd559d0c85a86ff7a1eeeb7e (patch) | |
tree | 6335497f7d67ee338cf61750d8d4244967c4a1d1 /test | |
parent | c98c492578d898dc07a04b8240d8d5b1508ffafa (diff) |
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]
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/2830
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 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 |