google_hash 0.6.1 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.1
1
+ 0.6.2
@@ -22,16 +22,13 @@ if RUBY_VERSION < '1.9'
22
22
  end
23
23
 
24
24
  # create our files...
25
- # currently we're int only...hmm...
26
- # ltodo if I am using longs, this 31 needs to be a 63 on 64 bit machines...
27
- # if I ever use longs :)
28
-
29
- # my goal is...ruby friendly hashers
30
25
 
31
26
  if OS.bits == 32
32
27
  unreachable_int = 31
28
+ unreachable_long = 31
33
29
  else
34
- unreachable_int = 63
30
+ unreachable_int = 31
31
+ unreachable_long = 63
35
32
  end
36
33
 
37
34
  ruby_key = {:convert_keys_from_ruby => "", :convert_keys_to_ruby => "", :key_type => "VALUE", :english_key_type => "ruby",
@@ -39,13 +36,13 @@ ruby_key = {:convert_keys_from_ruby => "", :convert_keys_to_ruby => "", :key_ty
39
36
  int_key = {:assert_key_type => 'T_FIXNUM', :convert_keys_from_ruby => "FIX2INT",
40
37
  :convert_keys_to_ruby => "INT2FIX", :key_type => "int", :unreachable_key => "1<<#{unreachable_int}"}
41
38
 
42
- # "long" is useful on 64 bit...
43
- long_key = {:assert_key_type => 'T_FIXNUM', :convert_keys_from_ruby => "FIX2LONG",
44
- :convert_keys_to_ruby => "LONG2FIX", :key_type => "long", :unreachable_key => "1<<#{unreachable_int}"}
39
+ # "long" is useful on 64 bit...since it can handle a wider range of incoming int's
45
40
 
41
+ long_key = {:assert_key_type => 'T_FIXNUM', :convert_keys_from_ruby => "FIX2LONG",
42
+ :convert_keys_to_ruby => "LONG2FIX", :key_type => "long", :unreachable_key => "1<<#{unreachable_long}"}
46
43
 
47
44
  bignum_as_double_key = {:assert_key_type => ['T_BIGNUM', 'T_FIXNUM'], :convert_keys_from_ruby => "rb_big2dbl",
48
- :convert_keys_to_ruby => "rb_dbl2big", :key_type => "double", :unreachable_key => "1<<#{unreachable_int}", # LODO is this a bignum value though?
45
+ :convert_keys_to_ruby => "rb_dbl2big", :key_type => "double", :unreachable_key => "1<<#{unreachable_long}", # LODO is this a bignum value though? LODO TEST this key on 64 bit!
49
46
  :extra_hash_params => ", hashdouble, eqdouble",
50
47
  :extra_set_code => "if(TYPE(set_this) == T_FIXNUM)\nset_this = rb_int2big(FIX2INT(set_this));",
51
48
  :extra_get_code => "if(TYPE(get_this) == T_FIXNUM) \n get_this = rb_int2big(FIX2INT(get_this));"
@@ -56,7 +56,7 @@ describe "google_hash" do
56
56
  k.should == 33
57
57
  v.should == 'abc'
58
58
  }
59
- @subject.delete(33).should == 'abc'
59
+ @subject.delete(33).should == 'abc' # guess we don't do delete yet [?]
60
60
  @subject.length.should == 0
61
61
  @subject[33] = 'abc'
62
62
  @subject.length.should == 1
@@ -128,8 +128,8 @@ describe "google_hash" do
128
128
  GoogleHashDenseLongToLong.new
129
129
  end
130
130
 
131
- it "should do 63 bit thingy for longs on 64 bit" do
132
- pending "caring about 64 bit"
131
+ if OS.bits == 64
132
+ it "should disallow keys like 1<<40 for ints on 64 bit"
133
133
  end
134
134
 
135
135
  it "should have sets"
@@ -258,6 +258,23 @@ describe "google_hash" do
258
258
  it "should have sets, too, not just hashes"
259
259
 
260
260
  it "should skip GC when native to native" do
261
+ # tough to test...
262
+ end
263
+
264
+ it "should allow for setting the right keys" do
265
+ all_classes = Object.constants.grep(/googlehash/i).map{|c| Object.const_get(c) }
266
+ all_classes.select{|c| c.to_s =~ /(int|long)to/i}.each{|c|
267
+ p c
268
+ keys = [0, 1, -1, 1<<29]
269
+ if OS.bits == 64
270
+ keys << (1<<61)
271
+ end
272
+ keys.each{|k|
273
+ instance = c.new
274
+ instance[k] = 0
275
+ instance[k].should == 0
276
+ }
277
+ }
261
278
  end
262
279
 
263
280
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 6
8
- - 1
9
- version: 0.6.1
8
+ - 2
9
+ version: 0.6.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - rogerdpack
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-07-27 00:00:00 -06:00
17
+ date: 2010-12-17 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -36,7 +36,6 @@ executables: []
36
36
 
37
37
  extensions:
38
38
  - ext/extconf.rb
39
- - ext/temp/extconf.rb
40
39
  extra_rdoc_files:
41
40
  - README
42
41
  files:
@@ -129,7 +128,6 @@ files:
129
128
  - spec/scale.rb
130
129
  - spec/spec.google_hash.rb
131
130
  - types.txt
132
- - ext/temp/extconf.rb
133
131
  has_rdoc: true
134
132
  homepage: http://github.com/rdp/ruby_google_hash
135
133
  licenses: []
@@ -1,11 +0,0 @@
1
- # Loads mkmf which is used to make makefiles for Ruby extensions
2
- require 'mkmf'
3
-
4
- # Give it a name
5
- extension_name = 'mytest'
6
-
7
- # The destination
8
- dir_config(extension_name)
9
-
10
- # Do the work
11
- create_makefile(extension_name)