test/cache_test.rb in lru_redux-0.0.4 vs test/cache_test.rb in lru_redux-0.0.5
- old
+ new
@@ -19,9 +19,28 @@
assert_equal [[:d,4],[:c,3],[:b,2]], @c.to_a
assert_nil @c[:a]
end
+ def test_fetch
+ @c[:a] = nil
+ @c[:b] = 2
+ assert_equal @c.fetch(:a){1}, nil
+ assert_equal @c.fetch(:c){3}, 3
+
+ assert_equal [[:a,nil],[:b,2]], @c.to_a
+ end
+
+ def test_getset
+ @c.getset(:a){1}
+ @c.getset(:b){2}
+ assert_equal @c.getset(:a){11}, 1
+ @c.getset(:c){3}
+ @c.getset(:d){4}
+
+ assert_equal [[:d,4],[:c,3],[:a,1]], @c.to_a
+ end
+
def test_pushes_lru_to_back
@c[:a] = 1
@c[:b] = 2
@c[:c] = 3