diff options
author | Marc-Andre Lafortune <github@marc-andre.ca> | 2011-07-23 15:31:56 -0400 |
---|---|---|
committer | Marc-Andre Lafortune <github@marc-andre.ca> | 2011-07-23 15:52:37 -0400 |
commit | 0b5386f4229a76222e2be096cb9f0e401e633ad3 (patch) | |
tree | 41b604579ef6969ea8878ebef382c78fa20a8bc0 /activesupport | |
parent | 2115068476e49b1e377d97e0c00e6d98263543d5 (diff) | |
download | rails-0b5386f4229a76222e2be096cb9f0e401e633ad3.tar.gz rails-0b5386f4229a76222e2be096cb9f0e401e633ad3.tar.bz2 rails-0b5386f4229a76222e2be096cb9f0e401e633ad3.zip |
Make tests more precise
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/test/core_ext/enumerable_test.rb | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/activesupport/test/core_ext/enumerable_test.rb b/activesupport/test/core_ext/enumerable_test.rb index 4655bfe519..dd59898e5d 100644 --- a/activesupport/test/core_ext/enumerable_test.rb +++ b/activesupport/test/core_ext/enumerable_test.rb @@ -29,10 +29,10 @@ class EnumerableTests < Test::Unit::TestCase def test_sums assert_equal 30, [5, 15, 10].sum - assert_equal 30, [5, 15, 10].sum { |i| i } + assert_equal 60, [5, 15, 10].sum { |i| i * 2} assert_equal 'abc', %w(a b c).sum - assert_equal 'abc', %w(a b c).sum { |i| i } + assert_equal 'aabbcc', %w(a b c).sum { |i| i * 2 } payments = [ Payment.new(5), Payment.new(15), Payment.new(10) ] assert_equal 30, payments.sum(&:price) @@ -56,11 +56,11 @@ class EnumerableTests < Test::Unit::TestCase def test_empty_sums assert_equal 0, [].sum - assert_equal 0, [].sum { |i| i } + assert_equal 0, [].sum { |i| i + 10 } assert_equal Payment.new(0), [].sum(Payment.new(0)) end - def test_enumerable_sums + def test_range_sums assert_equal 20, (1..4).sum { |i| i * 2 } assert_equal 10, (1..4).sum assert_equal 10, (1..4.5).sum @@ -80,18 +80,18 @@ class EnumerableTests < Test::Unit::TestCase end def test_many - assert ![].many? - assert ![ 1 ].many? - assert [ 1, 2 ].many? - - assert ![].many? {|x| x > 1 } - assert ![ 2 ].many? {|x| x > 1 } - assert ![ 1, 2 ].many? {|x| x > 1 } - assert [ 1, 2, 2 ].many? {|x| x > 1 } + assert_equal false, [].many? + assert_equal false, [ 1 ].many? + assert_equal true, [ 1, 2 ].many? + + assert_equal false, [].many? {|x| x > 1 } + assert_equal false, [ 2 ].many? {|x| x > 1 } + assert_equal false, [ 1, 2 ].many? {|x| x > 1 } + assert_equal true, [ 1, 2, 2 ].many? {|x| x > 1 } end def test_exclude? - assert [ 1 ].exclude?(2) - assert ![ 1 ].exclude?(1) + assert_equal true, [ 1 ].exclude?(2) + assert_equal false, [ 1 ].exclude?(1) end end |