提交 10cfd146 编写于 作者: B Brian Underwood 提交者: Damien Mathieu

Failing test to show problem when last argument of a memoized method is true

Signed-off-by: NDamien Mathieu <42@dmathieu.com>
上级 0ac0d7a0
......@@ -96,6 +96,15 @@ def fib(n)
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 @@ def test_reloadable_with_args
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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册