groonga 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/NEWS.ja.rdoc +13 -0
- data/NEWS.rdoc +13 -0
- data/README.ja.rdoc +2 -1
- data/README.rdoc +2 -1
- data/Rakefile +0 -1
- data/TUTORIAL.ja.rdoc +49 -4
- data/benchmark/read-write-many-small-items.rb +5 -4
- data/benchmark/write-many-small-items.rb +5 -4
- data/example/bookmark.rb +30 -1
- data/example/index-html.rb +79 -0
- data/example/search/config.ru +182 -0
- data/example/search/public/css/groonga.css +122 -0
- data/ext/rb-grn-array.c +12 -9
- data/ext/rb-grn-column.c +13 -8
- data/ext/rb-grn-context.c +34 -16
- data/ext/rb-grn-database.c +3 -2
- data/ext/rb-grn-expression-builder.c +8 -2
- data/ext/rb-grn-expression.c +3 -3
- data/ext/rb-grn-hash.c +13 -10
- data/ext/rb-grn-object.c +127 -19
- data/ext/rb-grn-patricia-trie.c +8 -7
- data/ext/rb-grn-table-cursor.c +2 -40
- data/ext/rb-grn-table.c +154 -42
- data/ext/rb-grn-type.c +18 -10
- data/ext/rb-grn-utils.c +22 -20
- data/ext/rb-grn.h +9 -12
- data/extconf.rb +1 -1
- data/html/developer.html +1 -1
- data/html/index.html +2 -2
- data/lib/groonga/expression-builder.rb +133 -63
- data/lib/groonga/schema.rb +229 -37
- data/test/groonga-test-utils.rb +1 -1
- data/test/test-array.rb +1 -0
- data/test/test-context.rb +7 -1
- data/test/test-database.rb +11 -3
- data/test/test-expression-builder.rb +26 -2
- data/test/test-fix-size-column.rb +2 -1
- data/test/test-hash.rb +6 -1
- data/test/test-record.rb +2 -1
- data/test/test-schema.rb +85 -10
- data/test/test-table.rb +99 -3
- data/test/test-type.rb +3 -2
- data/test/test-variable-size-column.rb +2 -1
- data/test-unit/Rakefile +6 -1
- data/test-unit/lib/test/unit/autorunner.rb +26 -3
- data/test-unit/lib/test/unit/priority.rb +21 -1
- data/test-unit/lib/test/unit/testcase.rb +101 -36
- data/test-unit/lib/test/unit/ui/console/testrunner.rb +7 -4
- data/test-unit/test/{test_testcase.rb → test-testcase.rb} +30 -1
- data/test-unit/test/test_assertions.rb +1 -1
- metadata +9 -6
data/test/test-database.rb
CHANGED
@@ -63,8 +63,7 @@ class DatabaseTest < Test::Unit::TestCase
|
|
63
63
|
def test_each
|
64
64
|
db_path = @tmp_dir + "db"
|
65
65
|
database = Groonga::Database.create(:path => db_path.to_s)
|
66
|
-
assert_equal(["
|
67
|
-
"Bool",
|
66
|
+
assert_equal(["Bool",
|
68
67
|
"Float",
|
69
68
|
"Int16",
|
70
69
|
"Int32",
|
@@ -83,7 +82,16 @@ class DatabaseTest < Test::Unit::TestCase
|
|
83
82
|
"UInt16",
|
84
83
|
"UInt32",
|
85
84
|
"UInt64",
|
86
|
-
"UInt8"
|
85
|
+
"UInt8",
|
86
|
+
"column_create",
|
87
|
+
"column_list",
|
88
|
+
"define_selector",
|
89
|
+
"expr_missing",
|
90
|
+
"load",
|
91
|
+
"select",
|
92
|
+
"status",
|
93
|
+
"table_create",
|
94
|
+
"table_list"],
|
87
95
|
database.collect {|object| object.name}.sort)
|
88
96
|
end
|
89
97
|
|
@@ -28,6 +28,10 @@ class ExpressionBuilderTest < Test::Unit::TestCase
|
|
28
28
|
@terms = Groonga::PatriciaTrie.create(:name => "<terms>",
|
29
29
|
:default_tokenizer => "TokenBigram")
|
30
30
|
@terms.define_index_column("user-name", @users, :source => @name)
|
31
|
+
|
32
|
+
@bookmarks = Groonga::Array.create(:name => "bookmarks")
|
33
|
+
@bookmarks.define_column("user", @users)
|
34
|
+
@bookmarks.define_column("uri", "ShortText")
|
31
35
|
end
|
32
36
|
|
33
37
|
def setup_data
|
@@ -40,6 +44,11 @@ class ExpressionBuilderTest < Test::Unit::TestCase
|
|
40
44
|
@yu = @users.add("yu",
|
41
45
|
:name => "Yutaro Shimamura",
|
42
46
|
:hp => 200)
|
47
|
+
|
48
|
+
@groonga = @bookmarks.add(:user => @morita, :uri => "http://groonga.org/")
|
49
|
+
@ruby = @bookmarks.add(:user => @morita, :uri => "http://ruby-lang.org/")
|
50
|
+
@nico_dict = @bookmarks.add(:user => @gunyara_kun,
|
51
|
+
:uri => "http://dic.nicovideo.jp/")
|
43
52
|
end
|
44
53
|
|
45
54
|
def test_equal
|
@@ -106,9 +115,24 @@ class ExpressionBuilderTest < Test::Unit::TestCase
|
|
106
115
|
end
|
107
116
|
|
108
117
|
def test_query_string
|
109
|
-
|
110
|
-
result = @name.select("ro")
|
118
|
+
result = @users.select("name:%ro")
|
111
119
|
assert_equal(["morita", "yu"],
|
112
120
|
result.collect {|record| record.key.key})
|
113
121
|
end
|
122
|
+
|
123
|
+
def test_record
|
124
|
+
result = @bookmarks.select do |record|
|
125
|
+
record["user"] == @morita
|
126
|
+
end
|
127
|
+
assert_equal(["http://groonga.org/", "http://ruby-lang.org/"],
|
128
|
+
result.collect {|record| record.key["uri"]})
|
129
|
+
end
|
130
|
+
|
131
|
+
def test_record_id
|
132
|
+
result = @bookmarks.select do |record|
|
133
|
+
record["user"] == @morita.id
|
134
|
+
end
|
135
|
+
assert_equal(["http://groonga.org/", "http://ruby-lang.org/"],
|
136
|
+
result.collect {|record| record.key["uri"]})
|
137
|
+
end
|
114
138
|
end
|
@@ -38,7 +38,8 @@ class FixSizeColumnTest < Test::Unit::TestCase
|
|
38
38
|
"name: <bookmarks.viewed>, " +
|
39
39
|
"path: <#{@viewed_column_path}>, " +
|
40
40
|
"domain: <#{@bookmarks.inspect}>, " +
|
41
|
-
"range: <#{context['<int>'].inspect}
|
41
|
+
"range: <#{context['<int>'].inspect}>, " +
|
42
|
+
"flags: <KEY_INT>" +
|
42
43
|
">",
|
43
44
|
@viewed.inspect)
|
44
45
|
end
|
data/test/test-hash.rb
CHANGED
@@ -42,11 +42,12 @@ class HashTest < Test::Unit::TestCase
|
|
42
42
|
|
43
43
|
def test_array_reference
|
44
44
|
value = "groonga"
|
45
|
+
value_type = Groonga::Type.new("Text#{value.size}", :size => value.size)
|
45
46
|
bookmarks_path = @tables_dir + "bookmarks"
|
46
47
|
bookmarks = Groonga::Hash.create(:name => "bookmarks",
|
47
48
|
:path => bookmarks_path.to_s,
|
48
49
|
:key_type => "<shorttext>",
|
49
|
-
:
|
50
|
+
:value_type => value_type)
|
50
51
|
bookmarks["http://google.com/"] = value
|
51
52
|
assert_equal(value, bookmarks["http://google.com/"])
|
52
53
|
end
|
@@ -70,6 +71,7 @@ class HashTest < Test::Unit::TestCase
|
|
70
71
|
"path: <#{path}>, " +
|
71
72
|
"domain: <nil>, " +
|
72
73
|
"range: <nil>, " +
|
74
|
+
"flags: <>, " +
|
73
75
|
"encoding: <#{encoding.inspect}>, " +
|
74
76
|
"size: <0>>",
|
75
77
|
anonymous_table.inspect)
|
@@ -83,6 +85,7 @@ class HashTest < Test::Unit::TestCase
|
|
83
85
|
"path: (temporary), " +
|
84
86
|
"domain: <nil>, " +
|
85
87
|
"range: <nil>, " +
|
88
|
+
"flags: <>, " +
|
86
89
|
"encoding: <#{encoding.inspect}>, " +
|
87
90
|
"size: <0>>",
|
88
91
|
anonymous_table.inspect)
|
@@ -97,6 +100,7 @@ class HashTest < Test::Unit::TestCase
|
|
97
100
|
"path: <#{path}>, " +
|
98
101
|
"domain: <nil>, " +
|
99
102
|
"range: <nil>, " +
|
103
|
+
"flags: <>, " +
|
100
104
|
"encoding: <#{encoding.inspect}>, " +
|
101
105
|
"size: <0>>",
|
102
106
|
named_table.inspect)
|
@@ -110,6 +114,7 @@ class HashTest < Test::Unit::TestCase
|
|
110
114
|
"path: (temporary), " +
|
111
115
|
"domain: <nil>, " +
|
112
116
|
"range: <nil>, " +
|
117
|
+
"flags: <>, " +
|
113
118
|
"encoding: <#{encoding.inspect}>, " +
|
114
119
|
"size: <0>>",
|
115
120
|
named_table.inspect)
|
data/test/test-record.rb
CHANGED
@@ -55,8 +55,9 @@ class RecordTest < Test::Unit::TestCase
|
|
55
55
|
|
56
56
|
def setup_bookmarks_table
|
57
57
|
@bookmarks_path = @tables_dir + "bookmarks"
|
58
|
+
value_type = Groonga::Type.new("Text512", :size => 512)
|
58
59
|
@bookmarks = Groonga::Array.create(:name => "bookmarks",
|
59
|
-
:
|
60
|
+
:value_type => value_type,
|
60
61
|
:path => @bookmarks_path.to_s)
|
61
62
|
|
62
63
|
@uri_column_path = @columns_dir + "uri"
|
data/test/test-schema.rb
CHANGED
@@ -25,6 +25,24 @@ class SchemaTest < Test::Unit::TestCase
|
|
25
25
|
assert_not_nil(context["<posts>"])
|
26
26
|
end
|
27
27
|
|
28
|
+
def test_create_table_force
|
29
|
+
Groonga::Schema.create_table("posts") do |table|
|
30
|
+
end
|
31
|
+
assert_raise(Groonga::InvalidArgument) do
|
32
|
+
Groonga::Schema.create_table("posts") do |table|
|
33
|
+
end
|
34
|
+
end
|
35
|
+
Groonga::Schema.create_table("posts", :force => true) do |table|
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_remove_table
|
40
|
+
Groonga::Array.create(:name => "posts")
|
41
|
+
assert_not_nil(context["posts"])
|
42
|
+
Groonga::Schema.remove_table("posts")
|
43
|
+
assert_nil(context["posts"])
|
44
|
+
end
|
45
|
+
|
28
46
|
def test_define_hash
|
29
47
|
Groonga::Schema.create_table("<posts>", :type => :hash) do |table|
|
30
48
|
end
|
@@ -34,11 +52,12 @@ class SchemaTest < Test::Unit::TestCase
|
|
34
52
|
def test_define_hash_with_full_option
|
35
53
|
path = @tmp_dir + "hash.groonga"
|
36
54
|
tokenizer = context["<token:trigram>"]
|
55
|
+
type = Groonga::Type.new("Niku", :size => 29)
|
37
56
|
Groonga::Schema.create_table("<posts>",
|
38
57
|
:type => :hash,
|
39
58
|
:key_type => "integer",
|
40
59
|
:path => path.to_s,
|
41
|
-
:
|
60
|
+
:value_type => type,
|
42
61
|
:default_tokenizer => tokenizer) do |table|
|
43
62
|
end
|
44
63
|
table = context["<posts>"]
|
@@ -47,7 +66,8 @@ class SchemaTest < Test::Unit::TestCase
|
|
47
66
|
"name: <<posts>>, " +
|
48
67
|
"path: <#{path}>, " +
|
49
68
|
"domain: <#{context['<int>'].inspect}>, " +
|
50
|
-
"range:
|
69
|
+
"range: <#{type.inspect}>, " +
|
70
|
+
"flags: <>, " +
|
51
71
|
"encoding: <#{Groonga::Encoding.default.inspect}>, " +
|
52
72
|
"size: <0>>",
|
53
73
|
table.inspect)
|
@@ -62,11 +82,12 @@ class SchemaTest < Test::Unit::TestCase
|
|
62
82
|
|
63
83
|
def test_define_patricia_trie_with_full_option
|
64
84
|
path = @tmp_dir + "patricia-trie.groonga"
|
85
|
+
type = Groonga::Type.new("Niku", :size => 29)
|
65
86
|
Groonga::Schema.create_table("<posts>",
|
66
87
|
:type => :patricia_trie,
|
67
88
|
:key_type => "integer",
|
68
89
|
:path => path.to_s,
|
69
|
-
:
|
90
|
+
:value_type => type,
|
70
91
|
:default_tokenizer => "<token:bigram>",
|
71
92
|
:key_normalize => true,
|
72
93
|
:key_with_sis => true) do |table|
|
@@ -77,7 +98,8 @@ class SchemaTest < Test::Unit::TestCase
|
|
77
98
|
"name: <<posts>>, " +
|
78
99
|
"path: <#{path}>, " +
|
79
100
|
"domain: <#{context['<int>'].inspect}>, " +
|
80
|
-
"range:
|
101
|
+
"range: <#{type.inspect}>, " +
|
102
|
+
"flags: <KEY_WITH_SIS|KEY_NORMALIZE|WITH_SECTION>, " +
|
81
103
|
"encoding: <#{Groonga::Encoding.default.inspect}>, " +
|
82
104
|
"size: <0>>",
|
83
105
|
table.inspect)
|
@@ -92,10 +114,11 @@ class SchemaTest < Test::Unit::TestCase
|
|
92
114
|
|
93
115
|
def test_define_array_with_full_option
|
94
116
|
path = @tmp_dir + "array.groonga"
|
117
|
+
type = Groonga::Type.new("Niku", :size => 29)
|
95
118
|
Groonga::Schema.create_table("<posts>",
|
96
119
|
:type => :array,
|
97
120
|
:path => path.to_s,
|
98
|
-
:
|
121
|
+
:value_type => type) do |table|
|
99
122
|
end
|
100
123
|
table = context["<posts>"]
|
101
124
|
assert_equal("#<Groonga::Array " +
|
@@ -103,7 +126,8 @@ class SchemaTest < Test::Unit::TestCase
|
|
103
126
|
"name: <<posts>>, " +
|
104
127
|
"path: <#{path}>, " +
|
105
128
|
"domain: <nil>, " +
|
106
|
-
"range:
|
129
|
+
"range: <#{type.inspect}>, " +
|
130
|
+
"flags: <>, " +
|
107
131
|
"size: <0>>",
|
108
132
|
table.inspect)
|
109
133
|
end
|
@@ -180,28 +204,79 @@ class SchemaTest < Test::Unit::TestCase
|
|
180
204
|
assert_equal(context["<longtext>"], context["<posts>.content"].range)
|
181
205
|
end
|
182
206
|
|
207
|
+
def test_remove_column
|
208
|
+
Groonga::Schema.create_table("posts") do |table|
|
209
|
+
table.long_text :content
|
210
|
+
end
|
211
|
+
assert_not_nil(context["posts.content"])
|
212
|
+
|
213
|
+
Groonga::Schema.change_table("posts") do |table|
|
214
|
+
table.remove_column("content")
|
215
|
+
end
|
216
|
+
assert_nil(context["posts.content"])
|
217
|
+
end
|
218
|
+
|
183
219
|
def test_index
|
184
220
|
assert_nil(context["<terms>.content"])
|
185
221
|
Groonga::Schema.create_table("<posts>") do |table|
|
186
222
|
table.long_text :content
|
187
223
|
end
|
188
224
|
Groonga::Schema.create_table("<terms>") do |table|
|
189
|
-
table.index
|
225
|
+
table.index "<posts>.content"
|
190
226
|
end
|
191
227
|
assert_equal([context["<posts>.content"]],
|
192
|
-
context["<terms
|
228
|
+
context["<terms>.<posts>_content"].sources)
|
193
229
|
end
|
194
230
|
|
195
231
|
def test_dump
|
196
232
|
Groonga::Schema.define do |schema|
|
197
|
-
schema.create_table("
|
233
|
+
schema.create_table("posts") do |table|
|
198
234
|
table.short_text :title
|
199
235
|
end
|
200
236
|
end
|
201
237
|
assert_equal(<<-EOS, Groonga::Schema.dump)
|
202
|
-
create_table("
|
238
|
+
create_table("posts") do |table|
|
239
|
+
table.short_text("title")
|
240
|
+
end
|
241
|
+
EOS
|
242
|
+
end
|
243
|
+
|
244
|
+
def test_reference_dump
|
245
|
+
Groonga::Schema.define do |schema|
|
246
|
+
schema.create_table("items") do |table|
|
247
|
+
table.short_text("title")
|
248
|
+
end
|
249
|
+
|
250
|
+
schema.create_table("users") do |table|
|
251
|
+
table.short_text("name")
|
252
|
+
end
|
253
|
+
|
254
|
+
schema.create_table("comments") do |table|
|
255
|
+
table.reference("item", "items")
|
256
|
+
table.reference("author", "users")
|
257
|
+
table.text("content")
|
258
|
+
table.time("issued")
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
assert_equal(<<-EOS, Groonga::Schema.dump)
|
263
|
+
create_table("comments") do |table|
|
264
|
+
table.text("content")
|
265
|
+
table.time("issued")
|
266
|
+
end
|
267
|
+
|
268
|
+
create_table("items") do |table|
|
203
269
|
table.short_text("title")
|
204
270
|
end
|
271
|
+
|
272
|
+
create_table("users") do |table|
|
273
|
+
table.short_text("name")
|
274
|
+
end
|
275
|
+
|
276
|
+
change_table("comments") do |table|
|
277
|
+
table.reference("author", "users")
|
278
|
+
table.reference("item", "items")
|
279
|
+
end
|
205
280
|
EOS
|
206
281
|
end
|
207
282
|
end
|
data/test/test-table.rb
CHANGED
@@ -158,9 +158,10 @@ class TableTest < Test::Unit::TestCase
|
|
158
158
|
end
|
159
159
|
|
160
160
|
def test_set_value
|
161
|
+
value_type = Groonga::Type.new("Text512", :size => 512)
|
161
162
|
table_path = @tables_dir + "bookmarks"
|
162
163
|
bookmarks = Groonga::Hash.create(:name => "bookmarks",
|
163
|
-
:
|
164
|
+
:value_type => value_type,
|
164
165
|
:path => table_path.to_s)
|
165
166
|
comment_column_path = @columns_dir + "comment"
|
166
167
|
bookmarks_comment =
|
@@ -178,8 +179,9 @@ class TableTest < Test::Unit::TestCase
|
|
178
179
|
end
|
179
180
|
|
180
181
|
def test_array_set
|
182
|
+
value_type = Groonga::Type.new("Text512", :size => 512)
|
181
183
|
bookmarks = Groonga::Hash.create(:name => "bookmarks",
|
182
|
-
:
|
184
|
+
:value_type => value_type)
|
183
185
|
url = "http://groonga.org/"
|
184
186
|
bookmarks["groonga"] = "#{url}\0"
|
185
187
|
|
@@ -205,10 +207,12 @@ class TableTest < Test::Unit::TestCase
|
|
205
207
|
users_path = @tables_dir + "users"
|
206
208
|
users = Groonga::Hash.create(:name => "users",
|
207
209
|
:path => users_path.to_s)
|
210
|
+
|
211
|
+
value_type = Groonga::Type.new("Text512", :size => 512)
|
208
212
|
bookmarks_path = @tables_dir + "bookmarks"
|
209
213
|
bookmarks = Groonga::Hash.create(:name => "bookmarks",
|
210
214
|
:key_type => users,
|
211
|
-
:
|
215
|
+
:value_type => value_type,
|
212
216
|
:path => bookmarks_path.to_s)
|
213
217
|
morita = users.add("morita")
|
214
218
|
groonga = bookmarks.add(morita.id)
|
@@ -229,6 +233,15 @@ class TableTest < Test::Unit::TestCase
|
|
229
233
|
bookmarks.columns.collect {|column| column.name}.sort)
|
230
234
|
end
|
231
235
|
|
236
|
+
def test_column_by_symbol
|
237
|
+
bookmarks_path = @tables_dir + "bookmarks"
|
238
|
+
bookmarks = Groonga::Array.create(:name => "bookmarks",
|
239
|
+
:path => bookmarks_path.to_s)
|
240
|
+
|
241
|
+
uri_column = bookmarks.define_column("uri", "Text")
|
242
|
+
assert_equal(uri_column, bookmarks.column(:uri))
|
243
|
+
end
|
244
|
+
|
232
245
|
def test_size
|
233
246
|
bookmarks_path = @tables_dir + "bookmarks"
|
234
247
|
bookmarks = Groonga::Array.create(:name => "bookmarks",
|
@@ -343,6 +356,19 @@ class TableTest < Test::Unit::TestCase
|
|
343
356
|
results.collect {|record| record["id"]})
|
344
357
|
end
|
345
358
|
|
359
|
+
def test_sort_by_array
|
360
|
+
bookmarks = Groonga::Array.create(:name => "<bookmarks>")
|
361
|
+
id_column = bookmarks.define_column("id", "<int>")
|
362
|
+
100.times do |i|
|
363
|
+
bookmark = bookmarks.add
|
364
|
+
bookmark["id"] = i + 100
|
365
|
+
end
|
366
|
+
|
367
|
+
results = bookmarks.sort([["id", "descending"]], :limit => 20)
|
368
|
+
assert_equal((180..199).to_a.reverse,
|
369
|
+
results.collect {|record| record["id"]})
|
370
|
+
end
|
371
|
+
|
346
372
|
def test_sort_without_limit
|
347
373
|
bookmarks = Groonga::Array.create(:name => "<bookmarks>")
|
348
374
|
id_column = bookmarks.define_column("id", "<int>")
|
@@ -356,6 +382,15 @@ class TableTest < Test::Unit::TestCase
|
|
356
382
|
results.collect {|record| record["id"]})
|
357
383
|
end
|
358
384
|
|
385
|
+
def test_select_without_block
|
386
|
+
comments = Groonga::Array.create(:name => "comments")
|
387
|
+
comment1 = comments.add
|
388
|
+
comment2 = comments.add
|
389
|
+
comment3 = comments.add
|
390
|
+
assert_equal([comment1, comment2, comment3],
|
391
|
+
comments.select.collect {|record| record.key})
|
392
|
+
end
|
393
|
+
|
359
394
|
def test_group
|
360
395
|
bookmarks = Groonga::Hash.create(:name => "<bookmarks>")
|
361
396
|
bookmarks.define_column("title", "<text>")
|
@@ -391,6 +426,67 @@ class TableTest < Test::Unit::TestCase
|
|
391
426
|
end)
|
392
427
|
end
|
393
428
|
|
429
|
+
def test_union!
|
430
|
+
bookmarks = Groonga::Hash.create(:name => "bookmarks")
|
431
|
+
bookmarks.define_column("title", "ShortText")
|
432
|
+
|
433
|
+
groonga = bookmarks.add("http://groonga.org/", :title => "groonga")
|
434
|
+
ruby = bookmarks.add("http://ruby-lang.org/", :title => "Ruby")
|
435
|
+
|
436
|
+
ruby_bookmarks = bookmarks.select {|record| record["title"] == "Ruby"}
|
437
|
+
groonga_bookmarks = bookmarks.select {|record| record["title"] == "groonga"}
|
438
|
+
assert_equal(["Ruby", "groonga"],
|
439
|
+
ruby_bookmarks.union!(groonga_bookmarks).collect do |record|
|
440
|
+
record[".title"]
|
441
|
+
end)
|
442
|
+
end
|
443
|
+
|
444
|
+
def test_intersection!
|
445
|
+
bookmarks = Groonga::Hash.create(:name => "bookmarks")
|
446
|
+
bookmarks.define_column("title", "ShortText")
|
447
|
+
|
448
|
+
bookmarks.add("http://groonga.org/", :title => "groonga")
|
449
|
+
bookmarks.add("http://ruby-lang.org/", :title => "Ruby")
|
450
|
+
|
451
|
+
ruby_bookmarks = bookmarks.select {|record| record["title"] == "Ruby"}
|
452
|
+
all_bookmarks = bookmarks.select
|
453
|
+
assert_equal(["Ruby"],
|
454
|
+
ruby_bookmarks.intersection!(all_bookmarks).collect do |record|
|
455
|
+
record[".title"]
|
456
|
+
end)
|
457
|
+
end
|
458
|
+
|
459
|
+
def test_difference!
|
460
|
+
bookmarks = Groonga::Hash.create(:name => "bookmarks")
|
461
|
+
bookmarks.define_column("title", "ShortText")
|
462
|
+
|
463
|
+
bookmarks.add("http://groonga.org/", :title => "groonga")
|
464
|
+
bookmarks.add("http://ruby-lang.org/", :title => "Ruby")
|
465
|
+
|
466
|
+
ruby_bookmarks = bookmarks.select {|record| record["title"] == "Ruby"}
|
467
|
+
all_bookmarks = bookmarks.select
|
468
|
+
assert_equal(["groonga"],
|
469
|
+
all_bookmarks.difference!(ruby_bookmarks).collect do |record|
|
470
|
+
record[".title"]
|
471
|
+
end)
|
472
|
+
end
|
473
|
+
|
474
|
+
def test_merge!
|
475
|
+
omit("should write a test")
|
476
|
+
bookmarks = Groonga::Hash.create(:name => "bookmarks")
|
477
|
+
bookmarks.define_column("title", "ShortText")
|
478
|
+
|
479
|
+
bookmarks.add("http://groonga.org/", :title => "groonga")
|
480
|
+
bookmarks.add("http://ruby-lang.org/", :title => "Ruby")
|
481
|
+
|
482
|
+
ruby_bookmarks = bookmarks.select {|record| record["title"] == "Ruby"}
|
483
|
+
all_bookmarks = bookmarks.select
|
484
|
+
assert_equal(["groonga"],
|
485
|
+
all_bookmarks.merge!(ruby_bookmarks).collect do |record|
|
486
|
+
[record[".title"], record[".:score"]]
|
487
|
+
end)
|
488
|
+
end
|
489
|
+
|
394
490
|
def test_lock
|
395
491
|
bookmarks = Groonga::Array.create(:name => "<bookmarks>")
|
396
492
|
bookmark = bookmarks.add
|
data/test/test-type.rb
CHANGED
@@ -19,7 +19,7 @@ class TypeTest < Test::Unit::TestCase
|
|
19
19
|
setup :setup_database
|
20
20
|
|
21
21
|
def test_new
|
22
|
-
type = Groonga::Type.new("user-id", :
|
22
|
+
type = Groonga::Type.new("user-id", :option => :integer)
|
23
23
|
assert_equal("user-id", type.name)
|
24
24
|
end
|
25
25
|
|
@@ -47,7 +47,8 @@ class TypeTest < Test::Unit::TestCase
|
|
47
47
|
"name: <LongText>, " +
|
48
48
|
"path: (temporary), " +
|
49
49
|
"domain: <nil>, " +
|
50
|
-
"range: <2147483648
|
50
|
+
"range: <2147483648>, " +
|
51
|
+
"flags: <>>",
|
51
52
|
context["<longtext>"].inspect)
|
52
53
|
end
|
53
54
|
|
@@ -38,7 +38,8 @@ class VariableSizeColumnTest < Test::Unit::TestCase
|
|
38
38
|
"name: <users.name>, " +
|
39
39
|
"path: <#{@users_name_column_path}>, " +
|
40
40
|
"domain: <#{@users.inspect}>, " +
|
41
|
-
"range: <#{context['<shorttext>'].inspect}
|
41
|
+
"range: <#{context['<shorttext>'].inspect}>, " +
|
42
|
+
"flags: <>" +
|
42
43
|
">",
|
43
44
|
@name.inspect)
|
44
45
|
end
|
data/test-unit/Rakefile
CHANGED
@@ -1,12 +1,17 @@
|
|
1
1
|
# -*- ruby -*-
|
2
2
|
|
3
3
|
require 'rubygems'
|
4
|
+
gem 'rdoc'
|
4
5
|
require 'hoe'
|
5
6
|
require './lib/test/unit/version.rb'
|
6
7
|
|
8
|
+
ENV["NODOT"] = "yes"
|
9
|
+
|
7
10
|
version = Test::Unit::VERSION
|
8
11
|
ENV["VERSION"] = version
|
9
|
-
Hoe.
|
12
|
+
Hoe.spec('test-unit') do |p|
|
13
|
+
Hoe::Test::SUPPORTED_TEST_FRAMEWORKS[:testunit2] = "test/run-test.rb"
|
14
|
+
p.version = version
|
10
15
|
p.developer('Kouhei Sutou', 'kou@cozmixng.org')
|
11
16
|
p.developer('Ryan Davis', 'ryand-ruby@zenspider.com')
|
12
17
|
|
@@ -203,6 +203,13 @@ module Test
|
|
203
203
|
end
|
204
204
|
end
|
205
205
|
|
206
|
+
o.on("--default-priority=PRIORITY",
|
207
|
+
Priority.available_values,
|
208
|
+
"Uses PRIORITY as default priority",
|
209
|
+
"(#{keyword_display(Priority.available_values)})") do |priority|
|
210
|
+
Priority.default = priority
|
211
|
+
end
|
212
|
+
|
206
213
|
o.on('-I', "--load-path=DIR[#{File::PATH_SEPARATOR}DIR...]",
|
207
214
|
"Appends directory list to $LOAD_PATH.") do |dirs|
|
208
215
|
$LOAD_PATH.concat(dirs.split(File::PATH_SEPARATOR))
|
@@ -220,6 +227,12 @@ module Test
|
|
220
227
|
load_config(file)
|
221
228
|
end
|
222
229
|
|
230
|
+
o.on("--order=ORDER", TestCase::AVAILABLE_ORDERS,
|
231
|
+
"Run tests in a test case in ORDER order.",
|
232
|
+
"(#{keyword_display(TestCase::AVAILABLE_ORDERS)})") do |order|
|
233
|
+
TestCase.test_order = order
|
234
|
+
end
|
235
|
+
|
223
236
|
ADDITIONAL_OPTIONS.each do |option_builder|
|
224
237
|
option_builder.call(self, o)
|
225
238
|
end
|
@@ -251,10 +264,20 @@ module Test
|
|
251
264
|
end
|
252
265
|
|
253
266
|
def keyword_display(keywords)
|
254
|
-
keywords.collect do |keyword, _|
|
267
|
+
keywords = keywords.collect do |keyword, _|
|
255
268
|
keyword.to_s
|
256
|
-
end.uniq.sort
|
257
|
-
|
269
|
+
end.uniq.sort
|
270
|
+
|
271
|
+
i = 0
|
272
|
+
keywords.collect do |keyword|
|
273
|
+
if (i > 0 and keyword[0] == keywords[i - 1][0]) or
|
274
|
+
((i < keywords.size - 1) and (keyword[0] == keywords[i + 1][0]))
|
275
|
+
n = 2
|
276
|
+
else
|
277
|
+
n = 1
|
278
|
+
end
|
279
|
+
i += 1
|
280
|
+
keyword.sub(/^(.{#{n}})([A-Za-z]+)(?=\w*$)/, '\\1[\\2]')
|
258
281
|
end.join(", ")
|
259
282
|
end
|
260
283
|
|
@@ -26,6 +26,19 @@ module Test
|
|
26
26
|
def disable
|
27
27
|
@@enabled = false
|
28
28
|
end
|
29
|
+
|
30
|
+
@@default = :normal
|
31
|
+
def default
|
32
|
+
@@default || :normal
|
33
|
+
end
|
34
|
+
|
35
|
+
def default=(default)
|
36
|
+
@@default = default
|
37
|
+
end
|
38
|
+
|
39
|
+
def available_values
|
40
|
+
Checker.available_priorities
|
41
|
+
end
|
29
42
|
end
|
30
43
|
|
31
44
|
class Checker
|
@@ -36,7 +49,7 @@ module Test
|
|
36
49
|
end
|
37
50
|
|
38
51
|
def need_to_run?(test)
|
39
|
-
priority = test[:priority] ||
|
52
|
+
priority = test[:priority] || Priority.default
|
40
53
|
if have_priority?(priority)
|
41
54
|
send(priority_check_method_name(priority), test)
|
42
55
|
else
|
@@ -44,6 +57,13 @@ module Test
|
|
44
57
|
end
|
45
58
|
end
|
46
59
|
|
60
|
+
def available_priorities
|
61
|
+
methods(false).collect do |name|
|
62
|
+
/\Arun_priority_(.+)\?\z/ =~ name.to_s
|
63
|
+
$1
|
64
|
+
end.compact
|
65
|
+
end
|
66
|
+
|
47
67
|
def run_priority_must?(test)
|
48
68
|
true
|
49
69
|
end
|