test/base/test_memoization.rb in nanoc-4.2.2 vs test/base/test_memoization.rb in nanoc-4.2.3
- old
+ new
@@ -23,10 +23,19 @@
@value * 100 + n
end
memoize :run
end
+ class Upcaser
+ extend Nanoc::Int::Memoization
+
+ def run(value)
+ value.upcase
+ end
+ memoize :run
+ end
+
def test_normal
sample1a = Sample1.new(10)
sample1b = Sample1.new(15)
sample2a = Sample2.new(20)
sample2b = Sample2.new(25)
@@ -35,7 +44,20 @@
assert_equal 10 * 10 + 5, sample1a.run(5)
assert_equal 10 * 15 + 7, sample1b.run(7)
assert_equal 100 * 20 + 5, sample2a.run(5)
assert_equal 100 * 25 + 7, sample2b.run(7)
end
+ end
+
+ def test_weak_inspect
+ upcaser = Upcaser.new
+ 10_000.times do |i|
+ upcaser.run("hello world #{i}")
+ end
+
+ GC.start
+ GC.start
+
+ # Should not raise
+ upcaser.inspect
end
end