From e9df41a75929ad72608eb9a2d3757b200ba1d23d Mon Sep 17 00:00:00 2001 From: Nicholas Seckar Date: Fri, 14 Oct 2005 03:26:16 +0000 Subject: Added Enumerable#first_match git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2578 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activesupport/test/core_ext/enumerable_test.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 activesupport/test/core_ext/enumerable_test.rb (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 new file mode 100644 index 0000000000..1fcaa9163e --- /dev/null +++ b/activesupport/test/core_ext/enumerable_test.rb @@ -0,0 +1,15 @@ +require 'test/unit' +require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/enumerable' + +class EnumerableTests < Test::Unit::TestCase + + def test_first_match_no_match + [[1, 2, 3, 4, 5], (1..9)].each {|a| a.first_match {|x| x > 10}} + end + + def test_first_match_with_match + assert_equal true, [1, 2, 3, 4, 5, 6].first_match {|x| x > 4} + assert_equal true, (1..10).first_match {|x| x > 9} + assert_equal :aba, {:a => 10, :aba => 50, :bac => 40}.first_match {|k, v| k if v > 45} + end +end \ No newline at end of file -- cgit v1.2.3