diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-04-19 05:55:42 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-04-19 05:55:42 +0000 |
commit | 9760a7f905367e96d6c22bbace1680d694fa16bd (patch) | |
tree | 39abec463772c7f6f1b67278fe409888d4b091fa /test/ruby/test_env.rb | |
parent | 55d3ed4b9d43beff4b905c9c3d853770203dd0b7 (diff) |
Add slice method to ENV like Hash#slice
[Feature #14559]
From: Benoit Tigeot <benoit@hopsandfork.com>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63188 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_env.rb')
-rw-r--r-- | test/ruby/test_env.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/ruby/test_env.rb b/test/ruby/test_env.rb index 699f7db084..2f4923fbd9 100644 --- a/test/ruby/test_env.rb +++ b/test/ruby/test_env.rb @@ -281,6 +281,17 @@ class TestEnv < Test::Unit::TestCase end end + def test_slice + ENV.clear + ENV["foo"] = "bar" + ENV["baz"] = "qux" + ENV["bar"] = "rab" + assert_equal({}, ENV.slice()) + assert_equal({}, ENV.slice("")) + assert_equal({}, ENV.slice("unknown")) + assert_equal({"foo"=>"bar", "baz"=>"qux"}, ENV.slice("foo", "baz")) + end + def test_clear ENV.clear assert_equal(0, ENV.size) |