rufus-tokyo 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,9 @@
1
+
2
+ dp = File.dirname(__FILE__)
3
+
4
+ Dir.new(dp).entries.select { |e|
5
+ e.match(/\_test.rb$/)
6
+ }.sort.each { |e|
7
+ require "#{dp}/#{e}"
8
+ }
9
+
@@ -0,0 +1,86 @@
1
+
2
+ #
3
+ # Testing rufus-tokyo
4
+ #
5
+ # Tue Jan 27 16:30:34 JST 2009
6
+ #
7
+
8
+ require File.dirname(__FILE__) + '/../test_base'
9
+
10
+ require 'rufus/tokyo/cabinet/util'
11
+
12
+
13
+ class UtilOne < Test::Unit::TestCase
14
+
15
+ def test_list_0
16
+
17
+ l = Rufus::Tokyo::List.new
18
+
19
+ assert_nil l.pop
20
+ assert_nil l.shift
21
+
22
+ l << 'alpha'
23
+ l << 'bravo'
24
+ l << 'charly'
25
+
26
+ assert_equal 3, l.size
27
+ assert_equal 'bravo', l[1]
28
+ assert_equal 'charly', l[-1]
29
+ assert_equal %w{ alpha bravo }, l[0, 2]
30
+ assert_equal %w{ alpha bravo charly }, l[0..-1]
31
+ assert_equal %w{ alpha bravo }, l[0..1]
32
+ assert_nil l[0, -1]
33
+
34
+ assert_equal %w{ ALPHA BRAVO CHARLY }, l.collect { |e| e.upcase }
35
+
36
+ assert_equal 'charly', l.pop
37
+ assert_equal 2, l.size
38
+
39
+ l.unshift('delta')
40
+ assert_equal 3, l.size
41
+
42
+ assert_equal 'delta', l.shift
43
+ assert_equal 2, l.size
44
+
45
+ l.push 'echo', 'foxtrott'
46
+ assert_equal 4, l.size
47
+
48
+ l.close
49
+ end
50
+
51
+ def test_list_1
52
+
53
+ l = Rufus::Tokyo::List.new
54
+
55
+ #assert_raises RuntimeError do
56
+ # l << nil
57
+ #end
58
+
59
+ l << '-'
60
+ l << '-'
61
+ l << '-'
62
+ l << '-'
63
+ l << '4'
64
+
65
+ l[0, 3] = [ 'a', 'b', 'c' ]
66
+ assert_equal %w{ a b c - 4 }, l.to_a
67
+
68
+ l[1..2] = [ '1', '2' ]
69
+ assert_equal %w{ a 1 2 - 4 }, l.to_a
70
+
71
+ l[0, 2] = '?'
72
+ assert_equal %w{ ? 2 - 4 }, l.to_a
73
+
74
+ l[0..2] = 'A'
75
+ assert_equal %w{ A 4 }, l.to_a
76
+
77
+ l[-1] = 'Z'
78
+ assert_equal %w{ A Z }, l.to_a
79
+
80
+ l[1..-1] = nil
81
+ assert_equal %w{ A }, l.to_a
82
+
83
+ l.free
84
+ end
85
+ end
86
+
@@ -0,0 +1,69 @@
1
+
2
+ #
3
+ # Testing rufus-tokyo
4
+ #
5
+ # Mon Jan 26 15:10:03 JST 2009
6
+ #
7
+
8
+ require File.dirname(__FILE__) + '/../test_base'
9
+
10
+ require 'rufus/tokyo/cabinet/util'
11
+
12
+
13
+ class UtilZero < Test::Unit::TestCase
14
+
15
+ def test_map_0
16
+
17
+ m = Rufus::Tokyo::Map.new
18
+ m['a'] = 'b'
19
+ m['c'] = 'd'
20
+
21
+ assert_equal 'b', m['a']
22
+ assert_equal nil, m['Z']
23
+
24
+ assert_equal [ 'a', 'c' ], m.keys
25
+ assert_equal [ 'b', 'd' ], m.values
26
+
27
+ assert_equal 'a=b&c=d', m.collect { |k, v| "#{k}=#{v}" }.join('&')
28
+
29
+ assert_equal 2, m.size
30
+ assert_equal 2, m.length
31
+
32
+ m.delete('a')
33
+ assert_equal 1, m.size
34
+
35
+ m.clear
36
+ assert_equal 0, m.length
37
+
38
+ m.destroy
39
+
40
+ assert_raises RuntimeError do
41
+ m['c']
42
+ end
43
+ end
44
+
45
+ def test_map_to_from_h
46
+
47
+ h = { 'a' => 'A', 'b' => 'B' }
48
+ m = Rufus::Tokyo::Map.from_h(h)
49
+
50
+ assert_equal 'A', m['a']
51
+
52
+ h1 = m.to_h
53
+ assert_kind_of Hash, h1
54
+ assert_equal h, h1
55
+
56
+ m.free
57
+ end
58
+
59
+ def test_map_merge
60
+
61
+ m = Rufus::Tokyo::Map.from_h({ 'a' => 'A', 'b' => 'B' })
62
+ m.merge!('c' => 'C')
63
+
64
+ assert_equal 3, m.size
65
+
66
+ m.free
67
+ end
68
+ end
69
+
@@ -0,0 +1,9 @@
1
+
2
+ dp = File.dirname(__FILE__)
3
+
4
+ Dir.new(dp).entries.select { |e|
5
+ e.match(/\_test.rb$/)
6
+ }.sort.each { |e|
7
+ require "#{dp}/#{e}"
8
+ }
9
+
@@ -0,0 +1,22 @@
1
+
2
+ #
3
+ # Testing rufus-tokyo
4
+ #
5
+ # Mon Jan 26 12:54:32 JST 2009
6
+ #
7
+
8
+ require File.dirname(__FILE__) + '/../test_base'
9
+
10
+ require 'rufus/tokyo/dystopia/words'
11
+
12
+
13
+ class CabinetZero < Test::Unit::TestCase
14
+
15
+ def test_open_missing
16
+
17
+ e = assert_raises Rufus::Tokyo::DystopianError do
18
+ db = Rufus::Tokyo::Words.new('missing.tcw')
19
+ end
20
+ end
21
+ end
22
+
data/test/mem1.rb ADDED
@@ -0,0 +1,44 @@
1
+
2
+ %w{ lib test }.each do |path|
3
+ path = File.expand_path(File.dirname(__FILE__) + '/../' + path)
4
+ $: << path unless $:.include?(path)
5
+ end
6
+
7
+ require 'fileutils'
8
+
9
+
10
+ def self_ps
11
+ ps = `ps -v #{$$}`.split("\n").last.split(' ')
12
+ %w{
13
+ pid stat time sl re pagein vsz rss lim tsiz pcpu pmem command
14
+ }.inject({}) { |h, k|
15
+ h[k.intern] = ps.shift; h
16
+ }
17
+ end
18
+
19
+ def pmem (msg)
20
+ p [ msg, "#{self_ps[:vsz].to_i / 1024}k" ]
21
+ end
22
+
23
+ pmem 'starting'
24
+
25
+ require 'rubygems'
26
+ require 'rufus/tokyo/util'
27
+
28
+ pmem 'required'
29
+
30
+ l = Rufus::Tokyo::List.new
31
+
32
+ 100000.times { |i| l << i.to_s }
33
+
34
+ pmem 'stored'
35
+
36
+ #100000.times { |i| l.delete_at(0) }
37
+ #100000.times { |i| s = l.delete_at(0); Rufus::Tokyo::CabinetLib.tcfree(s) }
38
+ s = nil
39
+ 100000.times { |i| s ||= l.delete_at(0); }
40
+ p s.class
41
+ p s.public_methods.sort
42
+
43
+ pmem 'cleared'
44
+
data/test/test.rb CHANGED
@@ -1,5 +1,8 @@
1
1
 
2
- require File.dirname(__FILE__) + '/test_base'
2
+ dirpath = File.dirname(__FILE__)
3
3
 
4
- require 'cabinet_0_test'
4
+ require dirpath + '/test_base'
5
+
6
+ require dirpath + '/cabinet/test'
7
+ require dirpath + '/dystopia/test'
5
8
 
data/test/test_base.rb CHANGED
@@ -4,3 +4,5 @@
4
4
  $: << path unless $:.include?(path)
5
5
  end
6
6
 
7
+ require 'test/unit'
8
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rufus-tokyo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Mettraux
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-01-23 00:00:00 +09:00
12
+ date: 2009-01-29 00:00:00 +09:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -34,10 +34,35 @@ extra_rdoc_files:
34
34
  - CREDITS.txt
35
35
  files:
36
36
  - lib/rufus
37
+ - lib/rufus/tokyo
38
+ - lib/rufus/tokyo/base.rb
39
+ - lib/rufus/tokyo/cabinet
40
+ - lib/rufus/tokyo/cabinet/abstract.rb
41
+ - lib/rufus/tokyo/cabinet/lib.rb
42
+ - lib/rufus/tokyo/cabinet/table.rb
43
+ - lib/rufus/tokyo/cabinet/util.rb
44
+ - lib/rufus/tokyo/cabinet.rb
45
+ - lib/rufus/tokyo/dystopia
46
+ - lib/rufus/tokyo/dystopia/lib.rb
47
+ - lib/rufus/tokyo/dystopia/words.rb
48
+ - lib/rufus/tokyo/hmethods.rb
37
49
  - lib/rufus/tokyo.rb
38
50
  - lib/rufus-tokyo.rb
39
- - test/cabinet_0_test.rb
51
+ - test/cabinet
52
+ - test/cabinet/abstract_0_test.rb
53
+ - test/cabinet/abstract_1_test.rb
54
+ - test/cabinet/api_0_test.rb
55
+ - test/cabinet/hmethods_test.rb
56
+ - test/cabinet/table_0_test.rb
57
+ - test/cabinet/table_1_test.rb
58
+ - test/cabinet/test.rb
59
+ - test/cabinet/util_list_test.rb
60
+ - test/cabinet/util_map_test.rb
61
+ - test/dystopia
62
+ - test/dystopia/test.rb
63
+ - test/dystopia/words_0_test.rb
40
64
  - test/mem.rb
65
+ - test/mem1.rb
41
66
  - test/test.rb
42
67
  - test/test_base.rb
43
68
  - README.txt