From f451f0e5cfa358e88ac9d03d813a9c84facd6648 Mon Sep 17 00:00:00 2001 From: Damian Janowski Date: Tue, 18 Nov 2008 18:53:06 -0200 Subject: Added Enumerable#none? to check that none of the elements match the block [#1408 state:committed] Signed-off-by: David Heinemeier Hansson --- activesupport/test/core_ext/enumerable_test.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'activesupport/test/core_ext/enumerable_test.rb') diff --git a/activesupport/test/core_ext/enumerable_test.rb b/activesupport/test/core_ext/enumerable_test.rb index deb9b7544d..288ce14b2c 100644 --- a/activesupport/test/core_ext/enumerable_test.rb +++ b/activesupport/test/core_ext/enumerable_test.rb @@ -79,4 +79,14 @@ class EnumerableTests < Test::Unit::TestCase assert ![ 1, 2 ].many? {|x| x > 1 } assert [ 1, 2, 2 ].many? {|x| x > 1 } end + + def test_none + assert [].none? + assert [ 1 ].none? + + assert [].none? {|x| x > 1 } + assert ![ 2 ].none? {|x| x > 1 } + assert ![ 1, 2 ].none? {|x| x > 1 } + assert [ 1, 1 ].none? {|x| x > 1 } + end end -- cgit v1.2.3