groonga 0.0.7 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/NEWS.ja.rdoc +56 -0
- data/NEWS.rdoc +58 -0
- data/Rakefile +2 -3
- data/benchmark/read-write-many-small-items.rb +16 -32
- data/benchmark/write-many-small-items.rb +14 -28
- data/example/bookmark.rb +19 -17
- data/example/index-html.rb +11 -1
- data/example/search/config.ru +14 -9
- data/ext/rb-grn-array.c +6 -6
- data/ext/rb-grn-column.c +348 -18
- data/ext/rb-grn-context.c +8 -4
- data/ext/rb-grn-database.c +6 -7
- data/ext/rb-grn-exception.c +101 -5
- data/ext/rb-grn-expression.c +206 -23
- data/ext/rb-grn-fix-size-column.c +6 -39
- data/ext/rb-grn-hash.c +24 -24
- data/ext/rb-grn-index-column.c +74 -19
- data/ext/rb-grn-logger.c +48 -0
- data/ext/rb-grn-object.c +281 -67
- data/ext/rb-grn-operation.c +1 -1
- data/ext/rb-grn-patricia-trie-cursor.c +10 -1
- data/ext/rb-grn-patricia-trie.c +268 -7
- data/ext/rb-grn-query.c +52 -1
- data/ext/rb-grn-record.c +8 -2
- data/ext/rb-grn-snippet.c +63 -1
- data/ext/rb-grn-table-cursor-key-support.c +15 -1
- data/ext/rb-grn-table-cursor.c +57 -0
- data/ext/rb-grn-table-key-support.c +382 -46
- data/ext/rb-grn-table.c +729 -192
- data/ext/rb-grn-type.c +63 -12
- data/ext/rb-grn-utils.c +156 -158
- data/ext/rb-grn-variable.c +18 -0
- data/ext/rb-grn.h +85 -21
- data/ext/rb-groonga.c +13 -3
- data/extconf.rb +19 -4
- data/html/developer.html +1 -1
- data/html/header.html.erb +1 -1
- data/html/index.html +4 -4
- data/lib/groonga.rb +10 -0
- data/lib/groonga/expression-builder.rb +81 -42
- data/lib/groonga/patricia-trie.rb +13 -0
- data/lib/groonga/record.rb +158 -13
- data/lib/groonga/schema.rb +339 -33
- data/pkg-config.rb +6 -1
- data/test-unit/lib/test/unit.rb +23 -42
- data/test-unit/lib/test/unit/assertionfailederror.rb +11 -0
- data/test-unit/lib/test/unit/assertions.rb +87 -9
- data/test-unit/lib/test/unit/autorunner.rb +20 -11
- data/test-unit/lib/test/unit/collector.rb +1 -8
- data/test-unit/lib/test/unit/collector/load.rb +2 -3
- data/test-unit/lib/test/unit/color-scheme.rb +13 -1
- data/test-unit/lib/test/unit/diff.rb +223 -37
- data/test-unit/lib/test/unit/error.rb +4 -0
- data/test-unit/lib/test/unit/failure.rb +31 -5
- data/test-unit/lib/test/unit/notification.rb +8 -4
- data/test-unit/lib/test/unit/omission.rb +51 -3
- data/test-unit/lib/test/unit/pending.rb +4 -0
- data/test-unit/lib/test/unit/testcase.rb +55 -4
- data/test-unit/lib/test/unit/ui/console/testrunner.rb +190 -4
- data/test-unit/lib/test/unit/ui/emacs/testrunner.rb +14 -0
- data/test-unit/lib/test/unit/ui/testrunner.rb +8 -0
- data/test-unit/lib/test/unit/version.rb +1 -1
- data/test-unit/sample/{tc_adder.rb → test_adder.rb} +3 -1
- data/test-unit/sample/{tc_subtracter.rb → test_subtracter.rb} +3 -1
- data/test-unit/sample/test_user.rb +1 -0
- data/test-unit/test/collector/test-descendant.rb +2 -4
- data/test-unit/test/collector/test_objectspace.rb +7 -5
- data/test-unit/test/run-test.rb +2 -0
- data/test-unit/test/test-color-scheme.rb +7 -0
- data/test-unit/test/test-diff.rb +48 -7
- data/test-unit/test/test-omission.rb +1 -1
- data/test-unit/test/test-testcase.rb +47 -0
- data/test-unit/test/test_assertions.rb +79 -10
- data/test/groonga-test-utils.rb +6 -1
- data/test/test-array.rb +29 -14
- data/test/test-column.rb +107 -55
- data/test/test-context.rb +5 -0
- data/test/test-database.rb +2 -37
- data/test/test-exception.rb +9 -1
- data/test/test-expression-builder.rb +23 -5
- data/test/test-expression.rb +44 -8
- data/test/test-fix-size-column.rb +16 -5
- data/test/test-gqtp.rb +70 -0
- data/test/test-hash.rb +142 -43
- data/test/test-index-column.rb +9 -9
- data/test/test-patricia-trie.rb +79 -20
- data/test/test-procedure.rb +4 -2
- data/test/test-record.rb +32 -20
- data/test/test-remote.rb +3 -2
- data/test/test-schema.rb +226 -92
- data/test/test-table-cursor.rb +103 -1
- data/test/test-table-offset-and-limit.rb +102 -0
- data/test/test-table-select-normalize.rb +4 -4
- data/test/test-table-select.rb +52 -8
- data/test/test-table.rb +235 -116
- data/test/test-type.rb +2 -2
- data/test/test-variable-size-column.rb +21 -5
- data/test/test-vector-column.rb +76 -0
- data/{TUTORIAL.ja.rdoc → text/TUTORIAL.ja.rdoc} +52 -52
- data/text/expression.rdoc +284 -0
- metadata +11 -7
- data/test-unit/sample/ts_examples.rb +0 -7
data/test/test-array.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright (C) 2009 Kouhei Sutou <kou@clear-code.com>
|
|
1
|
+
# Copyright (C) 2009-2010 Kouhei Sutou <kou@clear-code.com>
|
|
2
2
|
#
|
|
3
3
|
# This library is free software; you can redistribute it and/or
|
|
4
4
|
# modify it under the terms of the GNU Lesser General Public
|
|
@@ -28,8 +28,8 @@ class ArrayTest < Test::Unit::TestCase
|
|
|
28
28
|
"id: <#{contain_table.id}>, " +
|
|
29
29
|
"name: <name>, " +
|
|
30
30
|
"path: <#{path}>, " +
|
|
31
|
-
"domain:
|
|
32
|
-
"range:
|
|
31
|
+
"domain: (nil), " +
|
|
32
|
+
"range: (nil), " +
|
|
33
33
|
"flags: <>, " +
|
|
34
34
|
"size: <3>>",
|
|
35
35
|
contain_table.inspect)
|
|
@@ -41,21 +41,21 @@ class ArrayTest < Test::Unit::TestCase
|
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
def test_add
|
|
44
|
-
users = Groonga::Array.create(:name => "
|
|
45
|
-
users.define_column("name", "
|
|
44
|
+
users = Groonga::Array.create(:name => "Users")
|
|
45
|
+
users.define_column("name", "Text")
|
|
46
46
|
me = users.add(:name => "me")
|
|
47
47
|
assert_equal("me", me[:name])
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
def test_define_index_column
|
|
51
|
-
users = Groonga::Array.create(:name => "
|
|
52
|
-
users.define_column("name", "
|
|
53
|
-
bookmarks = Groonga::Array.create(:name => "
|
|
54
|
-
bookmarks.define_column("title", "
|
|
51
|
+
users = Groonga::Array.create(:name => "Users")
|
|
52
|
+
users.define_column("name", "Text")
|
|
53
|
+
bookmarks = Groonga::Array.create(:name => "Bookmarks")
|
|
54
|
+
bookmarks.define_column("title", "Text")
|
|
55
55
|
bookmarks.define_column("user", users)
|
|
56
56
|
|
|
57
57
|
index = users.define_index_column("bookmarks", bookmarks,
|
|
58
|
-
:source => "
|
|
58
|
+
:source => "Bookmarks.user")
|
|
59
59
|
morita = users.add(:name => "morita")
|
|
60
60
|
gunyara_kun = users.add(:name => "gunyara-kun")
|
|
61
61
|
groonga = bookmarks.add(:title => "groonga", :user => morita)
|
|
@@ -67,16 +67,31 @@ class ArrayTest < Test::Unit::TestCase
|
|
|
67
67
|
end
|
|
68
68
|
|
|
69
69
|
def test_create_duplicated_name
|
|
70
|
-
Groonga::Array.create(:name => "
|
|
70
|
+
Groonga::Array.create(:name => "Users")
|
|
71
71
|
assert_raise(Groonga::InvalidArgument) do
|
|
72
|
-
Groonga::Array.create(:name => "
|
|
72
|
+
Groonga::Array.create(:name => "Users")
|
|
73
73
|
end
|
|
74
74
|
end
|
|
75
75
|
|
|
76
76
|
def test_open_same_name
|
|
77
|
-
users_created = Groonga::Array.create(:name => "
|
|
78
|
-
users_opened = Groonga::Array.open(:name => "
|
|
77
|
+
users_created = Groonga::Array.create(:name => "Users")
|
|
78
|
+
users_opened = Groonga::Array.open(:name => "Users")
|
|
79
79
|
users_opened.add
|
|
80
80
|
assert_equal(1, users_created.size)
|
|
81
81
|
end
|
|
82
|
+
|
|
83
|
+
def test_value
|
|
84
|
+
users = Groonga::Array.create(:value_type => "Int32")
|
|
85
|
+
user_id = users.add.id
|
|
86
|
+
users.set_value(user_id, 29)
|
|
87
|
+
assert_equal(29, users.value(user_id))
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def test_column_value
|
|
91
|
+
users = Groonga::Array.create(:name => "Users")
|
|
92
|
+
name = users.define_column("name", "ShortText")
|
|
93
|
+
morita_id = users.add.id
|
|
94
|
+
users.set_column_value(morita_id, "name", "morita")
|
|
95
|
+
assert_equal("morita", users.column_value(morita_id, "name"))
|
|
96
|
+
end
|
|
82
97
|
end
|
data/test/test-column.rb
CHANGED
|
@@ -26,31 +26,31 @@ class ColumnTest < Test::Unit::TestCase
|
|
|
26
26
|
|
|
27
27
|
def setup_users_table
|
|
28
28
|
@users_path = @tables_dir + "users"
|
|
29
|
-
@users = Groonga::Array.create(:name => "
|
|
29
|
+
@users = Groonga::Array.create(:name => "Users",
|
|
30
30
|
:path => @users_path.to_s)
|
|
31
31
|
|
|
32
32
|
@users_name_column_path = @columns_dir + "name"
|
|
33
33
|
@users_name_column =
|
|
34
|
-
@users.define_column("name", "
|
|
34
|
+
@users.define_column("name", "ShortText",
|
|
35
35
|
:path => @users_name_column_path.to_s)
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
def setup_bookmarks_table
|
|
39
39
|
@bookmarks_path = @tables_dir + "bookmarks"
|
|
40
|
-
@bookmarks = Groonga::Array.create(:name => "
|
|
40
|
+
@bookmarks = Groonga::Array.create(:name => "Bookmarks",
|
|
41
41
|
:path => @bookmarks_path.to_s)
|
|
42
42
|
|
|
43
43
|
@uri_column_path = @columns_dir + "uri"
|
|
44
|
-
@bookmarks_uri = @bookmarks.define_column("uri", "
|
|
44
|
+
@bookmarks_uri = @bookmarks.define_column("uri", "ShortText",
|
|
45
45
|
:path => @uri_column_path.to_s)
|
|
46
46
|
|
|
47
47
|
@comment_column_path = @columns_dir + "comment"
|
|
48
48
|
@bookmarks_comment =
|
|
49
|
-
@bookmarks.define_column("comment", "
|
|
49
|
+
@bookmarks.define_column("comment", "Text",
|
|
50
50
|
:path => @comment_column_path.to_s)
|
|
51
51
|
|
|
52
52
|
@content_column_path = @columns_dir + "content"
|
|
53
|
-
@bookmarks_content = @bookmarks.define_column("content", "
|
|
53
|
+
@bookmarks_content = @bookmarks.define_column("content", "LongText")
|
|
54
54
|
|
|
55
55
|
@user_column_path = @columns_dir + "user"
|
|
56
56
|
@bookmarks_user = @bookmarks.define_column("user", @users)
|
|
@@ -117,16 +117,16 @@ class ColumnTest < Test::Unit::TestCase
|
|
|
117
117
|
end
|
|
118
118
|
|
|
119
119
|
def test_accessor
|
|
120
|
-
posts = Groonga::Hash.create(:name => "
|
|
121
|
-
posts.define_column("body", "
|
|
122
|
-
comments = Groonga::Hash.create(:name => "
|
|
123
|
-
:key_type => "
|
|
124
|
-
content = comments.define_column("content", "
|
|
120
|
+
posts = Groonga::Hash.create(:name => "Posts", :key_type => "ShortText")
|
|
121
|
+
posts.define_column("body", "Text")
|
|
122
|
+
comments = Groonga::Hash.create(:name => "Comments",
|
|
123
|
+
:key_type => "ShortText")
|
|
124
|
+
content = comments.define_column("content", "ShortText")
|
|
125
125
|
comments.define_column("post", posts)
|
|
126
126
|
|
|
127
|
-
index = Groonga::PatriciaTrie.create(:name => "
|
|
128
|
-
:key_type => "
|
|
129
|
-
index.default_tokenizer = "
|
|
127
|
+
index = Groonga::PatriciaTrie.create(:name => "Terms",
|
|
128
|
+
:key_type => "ShortText")
|
|
129
|
+
index.default_tokenizer = "TokenBigram"
|
|
130
130
|
content_index = index.define_index_column("content_index", comments,
|
|
131
131
|
:with_position => true)
|
|
132
132
|
content_index.source = content
|
|
@@ -143,7 +143,7 @@ class ColumnTest < Test::Unit::TestCase
|
|
|
143
143
|
result = content_index.search("drive")
|
|
144
144
|
assert_equal([["I'm also like drive", "My Hobby"]],
|
|
145
145
|
result.records.collect do |record|
|
|
146
|
-
[record[".content"], record[".post
|
|
146
|
+
[record[".content"], record[".post._key"]]
|
|
147
147
|
end)
|
|
148
148
|
end
|
|
149
149
|
|
|
@@ -158,71 +158,85 @@ class ColumnTest < Test::Unit::TestCase
|
|
|
158
158
|
end
|
|
159
159
|
|
|
160
160
|
def test_array_set_with_key_of_table
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
161
|
+
languages = Groonga::Hash.create(:name => "Languages",
|
|
162
|
+
:key_type => "ShortText")
|
|
163
|
+
sites = Groonga::Hash.create(:name => "Sites")
|
|
164
|
+
sites.define_column("language", languages)
|
|
165
|
+
|
|
166
|
+
languages.add("Ruby")
|
|
167
|
+
taiyaki_ru = sites.add("http://taiyaki.ru/", :language => "Ruby")
|
|
168
|
+
assert_equal("Ruby", taiyaki_ru[:language].key)
|
|
168
169
|
end
|
|
169
170
|
|
|
170
171
|
def test_local_name
|
|
171
|
-
items = Groonga::Array.create(:name => "
|
|
172
|
-
title = items.define_column("title", "
|
|
173
|
-
assert_equal("
|
|
172
|
+
items = Groonga::Array.create(:name => "Items")
|
|
173
|
+
title = items.define_column("title", "ShortText")
|
|
174
|
+
assert_equal("Items.title", title.name)
|
|
174
175
|
assert_equal("title", title.local_name)
|
|
175
176
|
end
|
|
176
177
|
|
|
177
|
-
def
|
|
178
|
-
|
|
179
|
-
body = posts.define_column("body", "<text>")
|
|
178
|
+
def test_select_query
|
|
179
|
+
populate_table_for_select
|
|
180
180
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
181
|
+
result = @body.select("drive")
|
|
182
|
+
assert_equal(["Drive and Eat"],
|
|
183
|
+
result.records.collect do |record|
|
|
184
|
+
record["body"]
|
|
185
|
+
end)
|
|
186
|
+
assert_equal("#<Groonga::Expression noname(?0:\"\")" +
|
|
187
|
+
"{body GET_VALUE \"drive\" MATCH}>",
|
|
188
|
+
result.expression.inspect)
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
def test_select_query_with_parser
|
|
192
|
+
populate_table_for_select
|
|
188
193
|
|
|
189
|
-
|
|
190
|
-
hobby = posts.add("My Hobby", :body => "Drive and Eat")
|
|
191
|
-
|
|
192
|
-
result = body.select("drive")
|
|
194
|
+
result = @body.select("body @ \"drive\"", :syntax => :script)
|
|
193
195
|
assert_equal(["Drive and Eat"],
|
|
194
196
|
result.records.collect do |record|
|
|
195
197
|
record["body"]
|
|
196
198
|
end)
|
|
199
|
+
assert_equal("#<Groonga::Expression noname(?0:\"\")" +
|
|
200
|
+
"{body GET_VALUE \"drive\" MATCH}>",
|
|
201
|
+
result.expression.inspect)
|
|
197
202
|
end
|
|
198
203
|
|
|
199
|
-
def
|
|
200
|
-
|
|
201
|
-
body = posts.define_column("body", "<text>")
|
|
204
|
+
def test_select_expression
|
|
205
|
+
populate_table_for_select
|
|
202
206
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
207
|
+
expression = Groonga::Expression.new
|
|
208
|
+
variable = expression.define_variable(:domain => @posts)
|
|
209
|
+
expression.append_object(variable)
|
|
210
|
+
expression.parse("body:%drive", :syntax => :query)
|
|
211
|
+
expression.compile
|
|
212
|
+
result = @body.select(expression)
|
|
213
|
+
assert_equal(["Drive and Eat"],
|
|
214
|
+
result.records.collect do |record|
|
|
215
|
+
record["body"]
|
|
216
|
+
end)
|
|
217
|
+
assert_equal("#<Groonga::Expression noname(?0:\"\")" +
|
|
218
|
+
"{?0 body GET_VALUE \"drive\" MATCH}>",
|
|
219
|
+
result.expression.inspect)
|
|
220
|
+
end
|
|
210
221
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
result = body.select do |column|
|
|
222
|
+
def test_select_with_block
|
|
223
|
+
populate_table_for_select
|
|
224
|
+
|
|
225
|
+
result = @body.select do |column|
|
|
215
226
|
column =~ "drive"
|
|
216
227
|
end
|
|
217
228
|
assert_equal(["Drive and Eat"],
|
|
218
229
|
result.records.collect do |record|
|
|
219
230
|
record["body"]
|
|
220
231
|
end)
|
|
232
|
+
assert_equal("#<Groonga::Expression noname(?0:\"\")" +
|
|
233
|
+
"{?0 body GET_VALUE \"drive\" MATCH}>",
|
|
234
|
+
result.expression.inspect)
|
|
221
235
|
end
|
|
222
236
|
|
|
223
237
|
def test_set_time
|
|
224
|
-
posts = Groonga::Hash.create(:name => "
|
|
225
|
-
body = posts.define_column("issued", "
|
|
238
|
+
posts = Groonga::Hash.create(:name => "Posts", :key_type => "ShortText")
|
|
239
|
+
body = posts.define_column("issued", "Time")
|
|
226
240
|
|
|
227
241
|
post = posts.add("hello", :issued => 123456)
|
|
228
242
|
assert_equal(Time.at(123456), post[".issued"])
|
|
@@ -232,6 +246,28 @@ class ColumnTest < Test::Unit::TestCase
|
|
|
232
246
|
assert_in_delta(Time.at(1251380635.1234567).usec, post[".issued"].usec, 10)
|
|
233
247
|
end
|
|
234
248
|
|
|
249
|
+
def test_set_nil_to_time
|
|
250
|
+
posts = Groonga::Hash.create(:name => "Posts", :key_type => "ShortText")
|
|
251
|
+
body = posts.define_column("issued", "Time")
|
|
252
|
+
|
|
253
|
+
post = posts.add("hello", :issued => nil)
|
|
254
|
+
assert_equal(Time.at(0), post["issued"])
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
def test_bool
|
|
258
|
+
posts = Groonga::Hash.create(:name => "Posts", :key_type => "ShortText")
|
|
259
|
+
hidden = posts.define_column("hidden", "Bool")
|
|
260
|
+
|
|
261
|
+
post = posts.add("hello")
|
|
262
|
+
assert_false(post["hidden"])
|
|
263
|
+
|
|
264
|
+
post["hidden"] = true
|
|
265
|
+
assert_true(post["hidden"])
|
|
266
|
+
|
|
267
|
+
post["hidden"] = false
|
|
268
|
+
assert_false(post["hidden"])
|
|
269
|
+
end
|
|
270
|
+
|
|
235
271
|
private
|
|
236
272
|
def assert_content_search(expected_records, term)
|
|
237
273
|
records = @bookmarks_index_content.search(term).records
|
|
@@ -243,4 +279,20 @@ class ColumnTest < Test::Unit::TestCase
|
|
|
243
279
|
end
|
|
244
280
|
assert_equal(expected_contents, actual_contents)
|
|
245
281
|
end
|
|
282
|
+
|
|
283
|
+
def populate_table_for_select
|
|
284
|
+
@posts = Groonga::Hash.create(:name => "Posts", :key_type => "ShortText")
|
|
285
|
+
@body = @posts.define_column("body", "Text")
|
|
286
|
+
|
|
287
|
+
index = Groonga::PatriciaTrie.create(:name => "Terms",
|
|
288
|
+
:key_type => "ShortText",
|
|
289
|
+
:key_normalize => true)
|
|
290
|
+
index.default_tokenizer = "TokenBigram"
|
|
291
|
+
body_index = index.define_index_column("body_index", @posts,
|
|
292
|
+
:with_position => true,
|
|
293
|
+
:source => @body)
|
|
294
|
+
|
|
295
|
+
first_post = @posts.add("Hello!", :body => "World")
|
|
296
|
+
hobby = @posts.add("My Hobby", :body => "Drive and Eat")
|
|
297
|
+
end
|
|
246
298
|
end
|
data/test/test-context.rb
CHANGED
data/test/test-database.rb
CHANGED
|
@@ -63,43 +63,8 @@ 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
|
-
|
|
67
|
-
|
|
68
|
-
"Int16",
|
|
69
|
-
"Int32",
|
|
70
|
-
"Int64",
|
|
71
|
-
"Int8",
|
|
72
|
-
"LongText",
|
|
73
|
-
"Object",
|
|
74
|
-
"ShortText",
|
|
75
|
-
"Text",
|
|
76
|
-
"Time",
|
|
77
|
-
"TokenBigram",
|
|
78
|
-
"TokenDelimit",
|
|
79
|
-
"TokenMecab",
|
|
80
|
-
"TokenTrigram",
|
|
81
|
-
"TokenUnigram",
|
|
82
|
-
"TokyoGeoPoint",
|
|
83
|
-
"UInt16",
|
|
84
|
-
"UInt32",
|
|
85
|
-
"UInt64",
|
|
86
|
-
"UInt8",
|
|
87
|
-
"WGS84GeoPoint",
|
|
88
|
-
"column_create",
|
|
89
|
-
"column_list",
|
|
90
|
-
"define_selector",
|
|
91
|
-
"expr_missing",
|
|
92
|
-
"load",
|
|
93
|
-
"now",
|
|
94
|
-
"quit",
|
|
95
|
-
"rand",
|
|
96
|
-
"select",
|
|
97
|
-
"shutdown",
|
|
98
|
-
"status",
|
|
99
|
-
"table_create",
|
|
100
|
-
"table_list",
|
|
101
|
-
"view_add"],
|
|
102
|
-
database.collect {|object| object.name}.sort)
|
|
66
|
+
default_object_names = database.collect {|object| object.name}.sort
|
|
67
|
+
assert_send([default_object_names, :include?, "Bool"])
|
|
103
68
|
end
|
|
104
69
|
|
|
105
70
|
def test_encoding
|
data/test/test-exception.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright (C) 2009 Kouhei Sutou <kou@clear-code.com>
|
|
1
|
+
# Copyright (C) 2009-2010 Kouhei Sutou <kou@clear-code.com>
|
|
2
2
|
#
|
|
3
3
|
# This library is free software; you can redistribute it and/or
|
|
4
4
|
# modify it under the terms of the GNU Lesser General Public
|
|
@@ -19,6 +19,9 @@ class ExceptionTest < Test::Unit::TestCase
|
|
|
19
19
|
def test_defined
|
|
20
20
|
assert_not_const_defined(Groonga, :Success)
|
|
21
21
|
|
|
22
|
+
assert_const_defined(Groonga, :Error)
|
|
23
|
+
assert_const_defined(Groonga, :ObjectClosed)
|
|
24
|
+
|
|
22
25
|
assert_const_defined(Groonga, :EndOfData)
|
|
23
26
|
assert_const_defined(Groonga, :UnknownError)
|
|
24
27
|
assert_const_defined(Groonga, :OperationNotPermitted)
|
|
@@ -81,5 +84,10 @@ class ExceptionTest < Test::Unit::TestCase
|
|
|
81
84
|
assert_const_defined(Groonga, :AddressIsInUse)
|
|
82
85
|
assert_const_defined(Groonga, :ZLibError)
|
|
83
86
|
assert_const_defined(Groonga, :LZOError)
|
|
87
|
+
assert_const_defined(Groonga, :StackOverFlow)
|
|
88
|
+
assert_const_defined(Groonga, :SyntaxError)
|
|
89
|
+
assert_const_defined(Groonga, :RetryMax)
|
|
90
|
+
assert_const_defined(Groonga, :IncompatibleFileFormat)
|
|
91
|
+
assert_const_defined(Groonga, :UpdateNotAllowed)
|
|
84
92
|
end
|
|
85
93
|
end
|
|
@@ -21,15 +21,15 @@ class ExpressionBuilderTest < Test::Unit::TestCase
|
|
|
21
21
|
setup :setup_data
|
|
22
22
|
|
|
23
23
|
def setup_tables
|
|
24
|
-
@users = Groonga::Hash.create(:name => "
|
|
25
|
-
@name = @users.define_column("name", "
|
|
26
|
-
@hp = @users.define_column("hp", "
|
|
24
|
+
@users = Groonga::Hash.create(:name => "Users")
|
|
25
|
+
@name = @users.define_column("name", "ShortText")
|
|
26
|
+
@hp = @users.define_column("hp", "UInt32")
|
|
27
27
|
|
|
28
|
-
@terms = Groonga::PatriciaTrie.create(:name => "
|
|
28
|
+
@terms = Groonga::PatriciaTrie.create(:name => "Terms",
|
|
29
29
|
:default_tokenizer => "TokenBigram")
|
|
30
30
|
@terms.define_index_column("user-name", @users, :source => @name)
|
|
31
31
|
|
|
32
|
-
@bookmarks = Groonga::Array.create(:name => "
|
|
32
|
+
@bookmarks = Groonga::Array.create(:name => "Bookmarks")
|
|
33
33
|
@bookmarks.define_column("user", @users)
|
|
34
34
|
@bookmarks.define_column("uri", "ShortText")
|
|
35
35
|
end
|
|
@@ -135,4 +135,22 @@ class ExpressionBuilderTest < Test::Unit::TestCase
|
|
|
135
135
|
assert_equal(["http://groonga.org/", "http://ruby-lang.org/"],
|
|
136
136
|
result.collect {|record| record.key["uri"]})
|
|
137
137
|
end
|
|
138
|
+
|
|
139
|
+
def test_nested_column
|
|
140
|
+
result = @bookmarks.select do |record|
|
|
141
|
+
record[".user.name"] == @morita["name"]
|
|
142
|
+
end
|
|
143
|
+
assert_equal(["http://groonga.org/", "http://ruby-lang.org/"],
|
|
144
|
+
result.collect {|record| record.key["uri"]})
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
def test_nil_match
|
|
148
|
+
@users.select do |record|
|
|
149
|
+
exception = ArgumentError.new("match word should not be nil: Users.name")
|
|
150
|
+
assert_raise(exception) do
|
|
151
|
+
record["name"] =~ nil
|
|
152
|
+
end
|
|
153
|
+
record["name"] == "dummy"
|
|
154
|
+
end
|
|
155
|
+
end
|
|
138
156
|
end
|