Sha256: c7132355de57424d3229ae3014b4a88a2eee43311705f7b772b90fa72cf1c6ee
Contents?: true
Size: 1.63 KB
Versions: 1
Compression:
Stored size: 1.63 KB
Contents
require_relative '../../spec_helper' describe Arachni::Cache::LeastCostReplacement do before { @cache = Arachni::Cache::LeastCostReplacement.new } it 'prunes itself by removing the least costly entries' do @cache.max_size = 3 @cache.store( :k, '1', :high ) @cache.store( :k2, '2', :high ) @cache.store( :k3, '3', :medium ) @cache.store( :k4, '4', :low ) @cache.size.should == 3 @cache[:k4].should be_true @cache[:k3].should be_nil @cache[:k2].should be_true @cache[:k].should be_true @cache.clear @cache.max_size = 1 @cache.store( :k, '1', :medium ) @cache.store( :k2, '2', :low ) @cache.store( :k3, '3', :low ) @cache.store( :k4, '4', :low ) @cache.size.should == 1 @cache[:k4].should be_true @cache[:k3].should be_nil @cache[:k2].should be_nil @cache[:k].should be_nil end describe '#store' do it 'stores an object by key' do v = 'val' @cache.store( :key, v, :low ).should == v @cache[:key].should == v end it 'assigns cost to object' do v = 'val' @cache.store( :key, v, :low ).should == v @cache[:key].should == v end end describe '#[]=' do it 'stores an object' do v = 'val' (@cache[:key] = v).should == v @cache[:key].should == v end it 'alias of #store' do v = 'val2' @cache.store( :key2, v ).should == v @cache[:key2].should == v end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
arachni-0.4.2 | spec/arachni/cache/least_cost_replacement_spec.rb |