ruby-changes:39061
From: nobu <ko1@a...>
Date: Sat, 4 Jul 2015 20:54:16 +0900 (JST)
Subject: [ruby-changes:39061] nobu:r51142 (trunk): all?, any?, one?, none? of empty Enumerable
nobu 2015-07-04 20:54:04 +0900 (Sat, 04 Jul 2015) New Revision: 51142 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=51142 Log: all?, any?, one?, none? of empty Enumerable Modified files: trunk/test/ruby/test_enum.rb Index: test/ruby/test_enum.rb =================================================================== --- test/ruby/test_enum.rb (revision 51141) +++ test/ruby/test_enum.rb (revision 51142) @@ -238,6 +238,8 @@ class TestEnumerable < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/ruby/test_enum.rb#L238 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::TestC https://github.com/ruby/ruby/blob/trunk/test/ruby/test_enum.rb#L247 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::TestC https://github.com/ruby/ruby/blob/trunk/test/ruby/test_enum.rb#L260 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::TestC https://github.com/ruby/ruby/blob/trunk/test/ruby/test_enum.rb#L274 assert([nil].none?) assert([nil,false].none?) assert(![nil,false,true].none?) + assert(@empty.none?) end def test_min -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/