1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

all?, any?, one?, none? of empty Enumerable

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51142 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2015-07-04 11:54:04 +00:00
parent aebf152ea4
commit 39be41cb21

View file

@ -238,6 +238,8 @@ class TestEnumerable < Test::Unit::TestCase
assert_equal(false, @obj.all? {|x| x < 3 })
assert_equal(true, @obj.all?)
assert_equal(false, [true, true, false].all?)
assert_equal(true, [].all?)
assert_equal(true, @empty.all?)
end
def test_any
@ -245,6 +247,8 @@ class TestEnumerable < Test::Unit::TestCase
assert_equal(false, @obj.any? {|x| x > 3 })
assert_equal(true, @obj.any?)
assert_equal(false, [false, false, false].any?)
assert_equal(false, [].any?)
assert_equal(false, @empty.any?)
end
def test_one
@ -256,6 +260,8 @@ class TestEnumerable < Test::Unit::TestCase
assert(!(%w{ant bear cat}.one? {|word| word.length < 4}))
assert(!([ nil, true, 99 ].one?))
assert([ nil, true, false ].one?)
assert(![].one?)
assert(!@empty.one?)
end
def test_none
@ -268,6 +274,7 @@ class TestEnumerable < Test::Unit::TestCase
assert([nil].none?)
assert([nil,false].none?)
assert(![nil,false,true].none?)
assert(@empty.none?)
end
def test_min