aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorBrian Underwood <bunderwood@rbmtechnologies.com>2011-06-14 19:11:09 -0400
committerDamien Mathieu <42@dmathieu.com>2011-06-15 09:44:21 +0200
commit10cfd146495964b01e6e195598bdb0d91c6011ad (patch)
treece506dfc1af9be6c80418359eb178ac4f1b11cd1 /activesupport/test
parent0ac0d7a0f03da3d08440c74477d653622d61a26e (diff)
downloadrails-10cfd146495964b01e6e195598bdb0d91c6011ad.tar.gz
rails-10cfd146495964b01e6e195598bdb0d91c6011ad.tar.bz2
rails-10cfd146495964b01e6e195598bdb0d91c6011ad.zip
Failing test to show problem when last argument of a memoized method is true
Signed-off-by: Damien Mathieu <42@dmathieu.com>
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/memoizable_test.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/activesupport/test/memoizable_test.rb b/activesupport/test/memoizable_test.rb
index bceac1315b..7ffe132b80 100644
--- a/activesupport/test/memoizable_test.rb
+++ b/activesupport/test/memoizable_test.rb
@@ -96,6 +96,15 @@ class MemoizableTest < ActiveSupport::TestCase
end
memoize :fib
+ def add_or_subtract(i, j, add)
+ if add
+ i + j
+ else
+ i - j
+ end
+ end
+ memoize :add_or_subtract
+
def counter
@count ||= 0
@count += 1
@@ -199,6 +208,11 @@ class MemoizableTest < ActiveSupport::TestCase
assert_equal 13, @calculator.fib_calls
end
+ def test_memoization_with_boolean_arg
+ assert_equal 4, @calculator.add_or_subtract(2, 2, true)
+ assert_equal 2, @calculator.add_or_subtract(4, 2, false)
+ end
+
def test_object_memoization
[Company.new, Company.new, Company.new].each do |company|
company.extend ActiveSupport::Memoizable