spec/spec.google_hash.rb in google_hash-0.5.1 vs spec/spec.google_hash.rb in google_hash-0.6.0
- old
+ new
@@ -1,8 +1,8 @@
-require 'rubygems' if RUBY_VERSION < '1.9'
+require 'rubygems'
require 'sane'
-require_relative '../ext/google_hash.so'
+require_relative '../ext/google_hash'
begin
require 'spec/autorun'
rescue LoadError
require 'rspec' # rspec2
end
@@ -11,12 +11,12 @@
before do
@subject = GoogleHashSparseIntToRuby.new
end
- it "should be instantiable" do
- # nothing
+ it "should be instantiable [new method should not raise]" do
+ GoogleHashSparseIntToRuby.new
end
it "should allow you to set a key" do
@subject[33] = 'abc'
end
@@ -34,27 +34,42 @@
all_got << v
}
assert all_got.sort == ['abc', 'def']
end
+ it "should have key methods" do
+ @subject = a = GoogleHashDenseDoubleToInt.new
+ @subject[33] = 3
+ for method in [:has_key?, :include?, :key?, :member?] do
+ @subject.send(method, 33).should == true
+ @subject.send(method, 34).should == false
+ end
+
+ end
+
it "should have all the methods desired" do
- pending "need"
# guess these could all be tests, themselves...
- @subject.each_key {}
- @subject.each_value{}
@subject.each{}
@subject[33] = 'abc'
@subject.length.should == 1
+ @subject.each{}
+ @subject.each{|k, v|
+ k.should == 33
+ v.should == 'abc'
+ }
@subject.delete(33).should == 'abc'
+ @subject.length.should == 0
+ @subject[33] = 'abc'
+ @subject.length.should == 1
@subject.clear
@subject.length.should == 0
end
-
- it "should not leak" do
- pending "testing if it leaks"
- end
+ it 'should not be able to set the absent key for double' do
+ fail
+ end
+
def populate(a)
a['abc'] = 'def'
a['bbc'] = 'yoyo'
end
@@ -107,12 +122,12 @@
it "should do BigNums" do
pending "if necessary"
end
- it "should do longs eventually" do
- pending "caring about 64 bit"
+ it "should do longs" do
+ GoogleHashDenseLongToLong.new
end
it "should do 63 bit thingy for longs on 64 bit" do
pending "caring about 64 bit"
end
@@ -167,10 +182,11 @@
a[10000000000000000000] = 1
a[10000000000000000000].should == 1
end
it "should not leak" do
+ pending 'something that might leak'
a = GoogleHashDenseIntToInt.new
100_000.times {
a[1] = 1
a[1]
a.each{|k, v|}
@@ -184,29 +200,31 @@
a[1] = 1
a[1].should == 1
end
it "should do float values as doubles" do
+ pending "interest in floats"
a = GoogleHashDenseDoubleToInt.new
a[1.0] = 1
a[1.0].should == 1
end
it "should do bignum to doubles et al" do
- pending
a = GoogleHashDenseDoubleToDouble.new
a[10000000000000000000] = 1
a[10000000000000000000].should == 1
a[1] = 10000000000000000000
a[1].should == 10000000000000000000
+ a[4] = 3
+ a[4].should == 3
a[10000000000000000000] = 10000000000000000000
a[10000000000000000000].should == 10000000000000000000
end
- it "should have really real bignums" do
+ it "should allow for storing true bignums" do
pending
- fail 'same as above plus'
+ fail 'same as above plus the following:'
a = GoogleHashDenseBignumToRuby.new
a[10000000000000000000] = 'abc'
end
it 'should be able to delete bignums without leaking' do
@@ -221,10 +239,15 @@
assert OS.rss_bytes < 100_000
end
it "should have an Enumerator for values, keys, an on demand, getNext enumerator object..."
- it "should have a block access for values, keys"
+ it "should have a block access for values, keys" do
+ pending "interest"
+ @a[3] = 4
+ a.each_value {}
+ a.each_key {}
+ end
it "should have sets, too, not just hashes"
it "should skip GC when native to native" do
end