Permalink
Browse files

+ terminate early specs

  • Loading branch information...
floere committed Dec 1, 2011
1 parent b09ca88 commit 009f973ba080519c0461d20589c1312c042d2339
Showing with 15 additions and 0 deletions.
  1. +1 −0 server/lib/picky/query/allocations.rb
  2. +14 −0 server/spec/functional/terminate_early_spec.rb
@@ -11,6 +11,7 @@ class Allocations # :nodoc:all
:first,
:inject,
:size,
+ :map,
:to => :@allocations
def initialize allocations = []
@@ -85,6 +85,12 @@
try.search('hello', 13, 12).to_hash[:allocations].size.should == 4
try.search('hello', 13, 16).to_hash[:allocations].size.should == 4
+ try.search('hello', 13).allocations.map(&:count).should == [6, 6, 6, nil]
+ try.search('hello', 13, 4).allocations.map(&:count).should == [6, 6, 6, nil]
+ try.search('hello', 13, 8).allocations.map(&:count).should == [6, 6, 6, 6]
+ try.search('hello', 13, 12).allocations.map(&:count).should == [6, 6, 6, 6]
+ try.search('hello', 13, 16).allocations.map(&:count).should == [6, 6, 6, 6]
+
try = Picky::Search.new index do
terminate_early with_extra_allocations: 2
end
@@ -112,6 +118,14 @@
try.search('hello', 1, 20).to_hash[:allocations].size.should == 4
try.search('hello', 1, 24).to_hash[:allocations].size.should == 4
+ try.search('hello', 1).allocations.map(&:count).should == [6, 6, nil, nil]
+ try.search('hello', 1, 4).allocations.map(&:count).should == [6, 6, nil, nil]
+ try.search('hello', 1, 8).allocations.map(&:count).should == [6, 6, nil, nil]
+ try.search('hello', 1, 12).allocations.map(&:count).should == [6, 6, 6, nil]
+ try.search('hello', 1, 16).allocations.map(&:count).should == [6, 6, 6, nil]
+ try.search('hello', 1, 20).allocations.map(&:count).should == [6, 6, 6, 6]
+ try.search('hello', 1, 24).allocations.map(&:count).should == [6, 6, 6, 6]
+
GC.start
try_slow = Picky::Search.new index

0 comments on commit 009f973

Please sign in to comment.