spec/spec.google_hash.rb in google_hash-0.8.2 vs spec/spec.google_hash.rb in google_hash-0.8.3

- old
+ new

@@ -69,16 +69,10 @@ @subject.length.should == 0 @subject[33] = 'def' @subject[33].should == 'def' end - pending "they should all have a clear method" do - for kls in get_all_classes - kls.new.clear - end - end - it 'should not be able to set the absent key for double' do if OS.bits == 32 unreachable_int = 31 unreachable_long = 31 else @@ -131,14 +125,10 @@ it "should work with 0's" do @subject[0] = 'abc' @subject[0].should == 'abc' end - it "should do BigNums" do - pending "if necessary" - end - it "should do longs" do GoogleHashDenseLongToLong.new end if OS.bits == 64 @@ -206,11 +196,11 @@ a.length.should == 0 OS.rss_bytes.should be < 25_000_000 end it "should do delete from dense" do - GoogleHashDenseDoubleToInt.new.delete('a').should == nil + GoogleHashDenseDoubleToInt.new.delete(0).should == nil end it "should do int values as doubles" do a = GoogleHashDenseDoubleToInt.new a[1] = 1 @@ -237,11 +227,11 @@ a[10000000000000000000].should == 10000000000000000000 end it "should allow for storing true bignums" do pending - fail 'same as above plus the following:' + 'TODO: same as above plus the following:' a = GoogleHashDenseBignumToRuby.new a[10000000000000000000] = 'abc' end it "should have an Enumerator return for values, keys [?] instead of an array?" @@ -265,29 +255,39 @@ it "should skip GC when native to native" do pending 'caring, get from gc_bench.rb' end - def get_all_classes + def self.get_all_classes Object.constants.grep(/googlehash/i).map{|c| Object.const_get(c) } end - it "should allow for setting the right keys" do all_classes = get_all_classes all_classes.select{|c| c.to_s =~ /(int|long|double)to/i}.each{|c| - p c - keys = [0, 1, -1, 1<<29] + keys = [0, 1, -1, 2, -1, 1<<29] if OS.bits == 64 keys << (1<<61) end keys.each{|k| - instance = c.new - instance[k].should == nil - instance[k] = 0 - instance[k-1] = 2 - instance[k].should == 0 - instance[k-1].should == 2 + it "should allow for setting the right keys #{k} #{c}" do + instance = c.new + instance[k].should == nil + instance[k] = 0 + instance[k+1] = 3 + instance[k-1] = 2 + instance[k].should == 0 + instance[k-1].should == 2 + instance[k+1].should == 3 + instance.delete k + instance[k].should == nil + # delete should not affect neighbors + instance[k-1].should == 2 + instance[k+1].should == 3 + # test #clear too here, why not? :) + instance.clear + instance[k-1].should == nil + instance[k+1].should == nil + end } } - end end