Skip to content

Commit

Permalink
Add test for dup/clone copying over the default proc.
Browse files Browse the repository at this point in the history
  • Loading branch information
thedarkone committed Aug 27, 2012
1 parent 6dfaabb commit 389aa51
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion test/test_cache.rb
Expand Up @@ -450,7 +450,7 @@ def test_size

def test_dup_clone
[:dup, :clone].each do |meth|
cache = ThreadSafe::Cache.new
cache = ThreadSafe::Cache.new {|h, k| h[k] = :default_value}
cache[:a] = 1
dupped = cache.send(meth)
assert_equal 1, dupped[:a]
Expand All @@ -468,6 +468,19 @@ def test_dup_clone
end
assert_equal false, dupped.key?(:a)
assert_equal true, cache.key?(:a)
# test default proc
assert_size_change 1, cache do
assert_no_size_change dupped do
assert_equal :default_value, cache[:c]
assert_equal false, dupped.key?(:c)
end
end
assert_no_size_change cache do
assert_size_change 1, dupped do
assert_equal :default_value, dupped[:d]
assert_equal false, cache.key?(:d)
end
end
end
end

Expand Down

0 comments on commit 389aa51

Please sign in to comment.