summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_env.rb11
-rw-r--r--test/ruby/test_hash.rb8
2 files changed, 19 insertions, 0 deletions
diff --git a/test/ruby/test_env.rb b/test/ruby/test_env.rb
index 6a44cf17dd..c1109cb2ef 100644
--- a/test/ruby/test_env.rb
+++ b/test/ruby/test_env.rb
@@ -287,6 +287,17 @@ class TestEnv < Test::Unit::TestCase
assert_equal({"foo"=>"bar", "baz"=>"qux"}, ENV.slice("foo", "baz"))
end
+ def test_except
+ ENV.clear
+ ENV["foo"] = "bar"
+ ENV["baz"] = "qux"
+ ENV["bar"] = "rab"
+ assert_equal({"bar"=>"rab", "baz"=>"qux", "foo"=>"bar"}, ENV.except())
+ assert_equal({"bar"=>"rab", "baz"=>"qux", "foo"=>"bar"}, ENV.except(""))
+ assert_equal({"bar"=>"rab", "baz"=>"qux", "foo"=>"bar"}, ENV.except("unknown"))
+ assert_equal({"bar"=>"rab"}, ENV.except("foo", "baz"))
+ end
+
def test_clear
ENV.clear
assert_equal(0, ENV.size)
diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb
index c0ec078403..e63fdf32fd 100644
--- a/test/ruby/test_hash.rb
+++ b/test/ruby/test_hash.rb
@@ -1036,6 +1036,14 @@ class TestHash < Test::Unit::TestCase
assert_equal({}, {}.slice)
end
+ def test_except
+ h = @cls[1=>2,3=>4,5=>6]
+ assert_equal({5=>6}, h.except(1, 3))
+ assert_equal({1=>2,3=>4,5=>6}, h.except(7))
+ assert_equal({1=>2,3=>4,5=>6}, h.except)
+ assert_equal({}, {}.except)
+ end
+
def test_filter
assert_equal({3=>4,5=>6}, @cls[1=>2,3=>4,5=>6].filter {|k, v| k + v >= 7 })