diff options
author | glass <glass@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-10-21 06:08:33 +0000 |
---|---|---|
committer | glass <glass@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-10-21 06:08:33 +0000 |
commit | 6c50bdda0b33f8031e54e3ea7857de43da821ead (patch) | |
tree | b9d944adb4640fdb92497cb65964e9b6fb46c6a9 /test/ruby/test_hash.rb | |
parent | d83f9745f5f4e3ed8cc0ce2b47c6dfbef498e42f (diff) | |
download | ruby-6c50bdda0b33f8031e54e3ea7857de43da821ead.tar.gz |
hash.c: Add Hash#slice
* hash.c (rb_hash_slice): add Hash#slice [Feature #8499]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60229 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_hash.rb')
-rw-r--r-- | test/ruby/test_hash.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb index ebc622a827..01b4f3a67d 100644 --- a/test/ruby/test_hash.rb +++ b/test/ruby/test_hash.rb @@ -1006,6 +1006,14 @@ class TestHash < Test::Unit::TestCase assert_equal(nil, h.select!{true}) end + def test_slice + h = @cls[1=>2,3=>4,5=>6] + assert_equal({1=>2, 3=>4}, h.slice(1, 3)) + assert_equal({}, h.slice(7)) + assert_equal({}, h.slice) + assert_equal({}, {}.slice) + end + def test_clear2 assert_equal({}, @cls[1=>2,3=>4,5=>6].clear) h = @cls[1=>2,3=>4,5=>6] |