rroonga 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/NEWS.ja.rdoc +46 -0
- data/NEWS.rdoc +46 -0
- data/README.ja.rdoc +2 -2
- data/README.rdoc +2 -3
- data/Rakefile +148 -11
- data/example/bookmark.rb +94 -91
- data/ext/groonga/extconf.rb +25 -25
- data/ext/groonga/groonga.def +2 -0
- data/ext/groonga/mkmf.log +7 -7
- data/ext/groonga/rb-grn-column.c +66 -0
- data/ext/groonga/rb-grn-context.c +92 -5
- data/ext/groonga/rb-grn-database.c +24 -1
- data/ext/groonga/rb-grn-exception.c +15 -0
- data/ext/groonga/rb-grn-hash.c +2 -2
- data/ext/groonga/rb-grn-index-column.c +8 -4
- data/ext/groonga/rb-grn-object.c +4 -2
- data/ext/groonga/rb-grn-patricia-trie.c +2 -2
- data/ext/groonga/rb-grn-snippet.c +1 -0
- data/ext/groonga/rb-grn-table-key-support.c +22 -19
- data/ext/groonga/rb-grn-table.c +63 -5
- data/ext/groonga/rb-grn.h +1 -1
- data/ext/groonga/rb-groonga.c +1 -0
- data/extconf.rb +1 -1
- data/html/developer.html +8 -2
- data/html/favicon.ico +0 -0
- data/html/favicon.svg +591 -0
- data/html/index.html +71 -8
- data/html/logo.svg +612 -0
- data/html/ranguba.css +92 -7
- data/html/readme.svg +256 -0
- data/lib/groonga/expression-builder.rb +8 -4
- data/lib/groonga/record.rb +77 -7
- data/lib/groonga/schema.rb +429 -100
- data/rroonga-build.rb +1 -1
- data/test/run-test.rb +1 -1
- data/test/test-array.rb +4 -0
- data/test/test-context.rb +8 -0
- data/test/test-database.rb +8 -1
- data/test/test-expression-builder.rb +14 -0
- data/test/test-fix-size-column.rb +4 -0
- data/test/test-hash.rb +10 -4
- data/test/test-index-column.rb +11 -0
- data/test/test-patricia-trie.rb +7 -1
- data/test/test-record.rb +14 -0
- data/test/test-remote.rb +3 -2
- data/test/test-schema-create-table.rb +32 -2
- data/test/test-schema.rb +108 -11
- data/test/test-table-select-normalize.rb +7 -3
- data/test/test-table-select.rb +12 -0
- data/test/test-table.rb +7 -0
- data/test/test-variable-size-column.rb +4 -0
- data/test-unit/Rakefile +40 -0
- data/test-unit/TODO +5 -0
- data/test-unit/bin/testrb +5 -0
- data/test-unit/html/classic.html +15 -0
- data/test-unit/html/index.html +25 -0
- data/test-unit/html/index.html.ja +27 -0
- data/test-unit/lib/test/unit/assertionfailederror.rb +25 -0
- data/test-unit/lib/test/unit/assertions.rb +1230 -0
- data/test-unit/lib/test/unit/attribute.rb +125 -0
- data/test-unit/lib/test/unit/autorunner.rb +360 -0
- data/test-unit/lib/test/unit/collector/descendant.rb +23 -0
- data/test-unit/lib/test/unit/collector/dir.rb +108 -0
- data/test-unit/lib/test/unit/collector/load.rb +144 -0
- data/test-unit/lib/test/unit/collector/objectspace.rb +34 -0
- data/test-unit/lib/test/unit/collector.rb +36 -0
- data/test-unit/lib/test/unit/color-scheme.rb +102 -0
- data/test-unit/lib/test/unit/color.rb +96 -0
- data/test-unit/lib/test/unit/diff.rb +724 -0
- data/test-unit/lib/test/unit/error.rb +130 -0
- data/test-unit/lib/test/unit/exceptionhandler.rb +39 -0
- data/test-unit/lib/test/unit/failure.rb +136 -0
- data/test-unit/lib/test/unit/fixture.rb +176 -0
- data/test-unit/lib/test/unit/notification.rb +129 -0
- data/test-unit/lib/test/unit/omission.rb +191 -0
- data/test-unit/lib/test/unit/pending.rb +150 -0
- data/test-unit/lib/test/unit/priority.rb +180 -0
- data/test-unit/lib/test/unit/runner/console.rb +52 -0
- data/test-unit/lib/test/unit/runner/emacs.rb +8 -0
- data/test-unit/lib/test/unit/runner/tap.rb +8 -0
- data/test-unit/lib/test/unit/testcase.rb +476 -0
- data/test-unit/lib/test/unit/testresult.rb +89 -0
- data/test-unit/lib/test/unit/testsuite.rb +110 -0
- data/test-unit/lib/test/unit/ui/console/outputlevel.rb +14 -0
- data/test-unit/lib/test/unit/ui/console/testrunner.rb +466 -0
- data/test-unit/lib/test/unit/ui/emacs/testrunner.rb +63 -0
- data/test-unit/lib/test/unit/ui/tap/testrunner.rb +92 -0
- data/test-unit/lib/test/unit/ui/testrunner.rb +28 -0
- data/test-unit/lib/test/unit/ui/testrunnermediator.rb +77 -0
- data/test-unit/lib/test/unit/ui/testrunnerutilities.rb +41 -0
- data/test-unit/lib/test/unit/util/backtracefilter.rb +41 -0
- data/test-unit/lib/test/unit/util/method-owner-finder.rb +28 -0
- data/test-unit/lib/test/unit/util/observable.rb +90 -0
- data/test-unit/lib/test/unit/util/procwrapper.rb +48 -0
- data/test-unit/lib/test/unit/version.rb +7 -0
- data/test-unit/lib/test/unit.rb +323 -0
- data/test-unit/sample/adder.rb +13 -0
- data/test-unit/sample/subtracter.rb +12 -0
- data/test-unit/sample/test_adder.rb +20 -0
- data/test-unit/sample/test_subtracter.rb +20 -0
- data/test-unit/sample/test_user.rb +23 -0
- data/test-unit/test/collector/test-descendant.rb +133 -0
- data/test-unit/test/collector/test-load.rb +442 -0
- data/test-unit/test/collector/test_dir.rb +406 -0
- data/test-unit/test/collector/test_objectspace.rb +100 -0
- data/test-unit/test/run-test.rb +15 -0
- data/test-unit/test/test-attribute.rb +86 -0
- data/test-unit/test/test-color-scheme.rb +67 -0
- data/test-unit/test/test-color.rb +47 -0
- data/test-unit/test/test-diff.rb +518 -0
- data/test-unit/test/test-emacs-runner.rb +60 -0
- data/test-unit/test/test-fixture.rb +287 -0
- data/test-unit/test/test-notification.rb +33 -0
- data/test-unit/test/test-omission.rb +81 -0
- data/test-unit/test/test-pending.rb +70 -0
- data/test-unit/test/test-priority.rb +119 -0
- data/test-unit/test/test-testcase.rb +544 -0
- data/test-unit/test/test_assertions.rb +1151 -0
- data/test-unit/test/test_error.rb +26 -0
- data/test-unit/test/test_failure.rb +33 -0
- data/test-unit/test/test_testresult.rb +113 -0
- data/test-unit/test/test_testsuite.rb +129 -0
- data/test-unit/test/testunit-test-util.rb +14 -0
- data/test-unit/test/ui/test_testrunmediator.rb +20 -0
- data/test-unit/test/util/test-method-owner-finder.rb +38 -0
- data/test-unit/test/util/test_backtracefilter.rb +41 -0
- data/test-unit/test/util/test_observable.rb +102 -0
- data/test-unit/test/util/test_procwrapper.rb +36 -0
- data/text/{TUTORIAL.ja.rdoc → tutorial.ja.rdoc} +165 -126
- metadata +106 -16
- data/html/favicon.xcf +0 -0
- data/html/logo.xcf +0 -0
- data/license/GPL +0 -340
- data/license/RUBY +0 -59
- data/pkg-config.rb +0 -333
data/rroonga-build.rb
CHANGED
data/test/run-test.rb
CHANGED
@@ -67,7 +67,7 @@ $LOAD_PATH.unshift(test_dir)
|
|
67
67
|
require 'groonga-test-utils'
|
68
68
|
|
69
69
|
pkg_config = File.join(base_dir, "vendor", "local", "lib", "pkgconfig")
|
70
|
-
|
70
|
+
PKGConfig.add_path(pkg_config)
|
71
71
|
|
72
72
|
Dir.glob("#{base_dir}/test/**/test{_,-}*.rb") do |file|
|
73
73
|
require file.sub(/\.rb$/, '')
|
data/test/test-array.rb
CHANGED
@@ -18,6 +18,10 @@ class ArrayTest < Test::Unit::TestCase
|
|
18
18
|
|
19
19
|
setup :setup_database
|
20
20
|
|
21
|
+
def test_support_key?
|
22
|
+
assert_not_predicate(Groonga::Array.create(:name => "Users"), :support_key?)
|
23
|
+
end
|
24
|
+
|
21
25
|
def test_inspect_size
|
22
26
|
path = @tables_dir + "named.groonga"
|
23
27
|
contain_table = Groonga::Array.create(:name => "name", :path => path.to_s)
|
data/test/test-context.rb
CHANGED
@@ -70,4 +70,12 @@ class ContextTest < Test::Unit::TestCase
|
|
70
70
|
Groonga::Database.create
|
71
71
|
assert_equal("ShortText", Groonga["ShortText"].name)
|
72
72
|
end
|
73
|
+
|
74
|
+
def test_support_zlib?
|
75
|
+
assert_boolean(Groonga::Context.default.support_zlib?)
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_support_lzo?
|
79
|
+
assert_boolean(Groonga::Context.default.support_lzo?)
|
80
|
+
end
|
73
81
|
end
|
data/test/test-database.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
|
@@ -110,4 +110,11 @@ class DatabaseTest < Test::Unit::TestCase
|
|
110
110
|
database.clear_lock
|
111
111
|
assert_not_predicate(database, :locked?)
|
112
112
|
end
|
113
|
+
|
114
|
+
def test_touch
|
115
|
+
database = Groonga::Database.create
|
116
|
+
assert_nothing_raised do
|
117
|
+
database.touch
|
118
|
+
end
|
119
|
+
end
|
113
120
|
end
|
@@ -140,6 +140,20 @@ class ExpressionBuilderTest < Test::Unit::TestCase
|
|
140
140
|
result.collect {|record| record.key["uri"]})
|
141
141
|
end
|
142
142
|
|
143
|
+
def test_record_id_object
|
144
|
+
morita = Object.new
|
145
|
+
morita_singleton_class = (class << morita; self; end)
|
146
|
+
morita_id = @morita.id
|
147
|
+
morita_singleton_class.send(:define_method, :record_id) do
|
148
|
+
morita_id
|
149
|
+
end
|
150
|
+
result = @bookmarks.select do |record|
|
151
|
+
record["user"] == morita
|
152
|
+
end
|
153
|
+
assert_equal(["http://groonga.org/", "http://ruby-lang.org/"],
|
154
|
+
result.collect {|record| record.key["uri"]})
|
155
|
+
end
|
156
|
+
|
143
157
|
def test_nested_column
|
144
158
|
result = @bookmarks.select do |record|
|
145
159
|
record[".user.name"] == @morita["name"]
|
@@ -32,6 +32,10 @@ class FixSizeColumnTest < Test::Unit::TestCase
|
|
32
32
|
:path => @viewed_column_path.to_s)
|
33
33
|
end
|
34
34
|
|
35
|
+
def test_index_column?
|
36
|
+
assert_not_predicate(@viewed, :index_column?)
|
37
|
+
end
|
38
|
+
|
35
39
|
def test_inspect
|
36
40
|
assert_equal("#<Groonga::FixSizeColumn " +
|
37
41
|
"id: <#{@viewed.id}>, " +
|
data/test/test-hash.rb
CHANGED
@@ -19,6 +19,12 @@ class HashTest < Test::Unit::TestCase
|
|
19
19
|
|
20
20
|
setup :setup_database
|
21
21
|
|
22
|
+
def test_support_key?
|
23
|
+
assert_predicate(Groonga::Hash.create(:name => "Users",
|
24
|
+
:key_type => "ShortText"),
|
25
|
+
:support_key?)
|
26
|
+
end
|
27
|
+
|
22
28
|
def test_delete
|
23
29
|
bookmarks_path = @tables_dir + "bookmarks"
|
24
30
|
bookmarks = Groonga::Hash.create(:name => "Bookmarks",
|
@@ -77,7 +83,7 @@ class HashTest < Test::Unit::TestCase
|
|
77
83
|
"id: <#{anonymous_table.id}>, " +
|
78
84
|
"name: (anonymous), " +
|
79
85
|
"path: <#{path}>, " +
|
80
|
-
"domain:
|
86
|
+
"domain: <ShortText>, " +
|
81
87
|
"range: (nil), " +
|
82
88
|
"flags: <>, " +
|
83
89
|
"encoding: <#{encoding.inspect}>, " +
|
@@ -91,7 +97,7 @@ class HashTest < Test::Unit::TestCase
|
|
91
97
|
"id: <#{anonymous_table.id}>, " +
|
92
98
|
"name: (anonymous), " +
|
93
99
|
"path: (temporary), " +
|
94
|
-
"domain:
|
100
|
+
"domain: <ShortText>, " +
|
95
101
|
"range: (nil), " +
|
96
102
|
"flags: <>, " +
|
97
103
|
"encoding: <#{encoding.inspect}>, " +
|
@@ -106,7 +112,7 @@ class HashTest < Test::Unit::TestCase
|
|
106
112
|
"id: <#{named_table.id}>, " +
|
107
113
|
"name: <Users>, " +
|
108
114
|
"path: <#{path}>, " +
|
109
|
-
"domain:
|
115
|
+
"domain: <ShortText>, " +
|
110
116
|
"range: (nil), " +
|
111
117
|
"flags: <>, " +
|
112
118
|
"encoding: <#{encoding.inspect}>, " +
|
@@ -120,7 +126,7 @@ class HashTest < Test::Unit::TestCase
|
|
120
126
|
"id: <#{named_table.id}>, " +
|
121
127
|
"name: (anonymous), " +
|
122
128
|
"path: (temporary), " +
|
123
|
-
"domain:
|
129
|
+
"domain: <ShortText>, " +
|
124
130
|
"range: (nil), " +
|
125
131
|
"flags: <>, " +
|
126
132
|
"encoding: <#{encoding.inspect}>, " +
|
data/test/test-index-column.rb
CHANGED
@@ -22,6 +22,17 @@ class IndexColumnTest < Test::Unit::TestCase
|
|
22
22
|
setup_database
|
23
23
|
end
|
24
24
|
|
25
|
+
def test_index_column?
|
26
|
+
articles = Groonga::Array.create(:name => "Articles")
|
27
|
+
articles.define_column("content", "Text")
|
28
|
+
|
29
|
+
terms = Groonga::Hash.create(:name => "Terms",
|
30
|
+
:default_tokenizer => "TokenBigram")
|
31
|
+
content_index = terms.define_index_column("content", articles,
|
32
|
+
:with_section => true)
|
33
|
+
assert_predicate(content_index, :index_column?)
|
34
|
+
end
|
35
|
+
|
25
36
|
def test_array_set_with_record
|
26
37
|
articles = Groonga::Array.create(:name => "Articles")
|
27
38
|
articles.define_column("content", "Text")
|
data/test/test-patricia-trie.rb
CHANGED
@@ -21,6 +21,12 @@ class PatriciaTrieTest < Test::Unit::TestCase
|
|
21
21
|
|
22
22
|
setup :setup_database
|
23
23
|
|
24
|
+
def test_support_key?
|
25
|
+
assert_predicate(Groonga::PatriciaTrie.create(:name => "Users",
|
26
|
+
:key_type => "ShortText"),
|
27
|
+
:support_key?)
|
28
|
+
end
|
29
|
+
|
24
30
|
def test_encoding
|
25
31
|
assert_equal(Groonga::Encoding.default,
|
26
32
|
Groonga::PatriciaTrie.create.encoding)
|
@@ -57,7 +63,7 @@ class PatriciaTrieTest < Test::Unit::TestCase
|
|
57
63
|
|
58
64
|
def test_add
|
59
65
|
users = Groonga::PatriciaTrie.create(:name => "Users")
|
60
|
-
users.define_column("address", "
|
66
|
+
users.define_column("address", "Text")
|
61
67
|
me = users.add("me", :address => "me@example.com")
|
62
68
|
assert_equal("me@example.com", me[:address])
|
63
69
|
end
|
data/test/test-record.rb
CHANGED
@@ -164,6 +164,13 @@ class RecordTest < Test::Unit::TestCase
|
|
164
164
|
assert_true(bookmark.reference_column?("user"))
|
165
165
|
end
|
166
166
|
|
167
|
+
def test_index_column?
|
168
|
+
bookmark = @bookmarks.add
|
169
|
+
assert_false(bookmark.index_column?("uri"))
|
170
|
+
index = @bookmarks_index.add("token")
|
171
|
+
assert_true(index.index_column?("content"))
|
172
|
+
end
|
173
|
+
|
167
174
|
def test_score
|
168
175
|
groonga = @bookmarks.add
|
169
176
|
groonga["content"] = "full text search search search engine."
|
@@ -268,4 +275,11 @@ class RecordTest < Test::Unit::TestCase
|
|
268
275
|
groonga = @bookmarks.add(:user => morita, :uri => "http://groonga.org")
|
269
276
|
assert_equal("morita", groonga.user.key)
|
270
277
|
end
|
278
|
+
|
279
|
+
def test_support_sub_records
|
280
|
+
morita = @users.add("morita")
|
281
|
+
assert_not_predicate(morita, :support_sub_records?)
|
282
|
+
users = @users.select {|record| record.key == "morita"}
|
283
|
+
assert_predicate(users.to_a[0], :support_sub_records?)
|
284
|
+
end
|
271
285
|
end
|
data/test/test-remote.rb
CHANGED
@@ -47,8 +47,9 @@ class RemoteTest < Test::Unit::TestCase
|
|
47
47
|
id, result = _context.receive
|
48
48
|
assert_equal(0, id)
|
49
49
|
values = JSON.load(result)
|
50
|
-
assert_equal(["alloc_count", "cache_hit_rate", "
|
51
|
-
"
|
50
|
+
assert_equal(["alloc_count", "cache_hit_rate", "command_version",
|
51
|
+
"default_command_version", "max_command_version",
|
52
|
+
"n_queries", "starttime", "uptime", "version"],
|
52
53
|
values.keys.sort)
|
53
54
|
end
|
54
55
|
|
@@ -87,7 +87,7 @@ module SchemaCreateTableTests
|
|
87
87
|
assert_true(context["Posts"].support_sub_records?)
|
88
88
|
end
|
89
89
|
|
90
|
-
def
|
90
|
+
def test_different_sub_records
|
91
91
|
Groonga::Schema.create_table("Posts",
|
92
92
|
options(:sub_records => true)) do |table|
|
93
93
|
end
|
@@ -99,6 +99,35 @@ module SchemaCreateTableTests
|
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
102
|
+
def test_same_path
|
103
|
+
path = (@tmp_dir + "posts.groonga").to_s
|
104
|
+
Groonga::Schema.create_table("Posts", options(:path => path)) do |table|
|
105
|
+
end
|
106
|
+
|
107
|
+
Groonga::Schema.create_table("Posts", options(:path => path)) do |table|
|
108
|
+
end
|
109
|
+
assert_equal(path, context["Posts"].path)
|
110
|
+
end
|
111
|
+
|
112
|
+
def test_different_path
|
113
|
+
path = (@tmp_dir + "posts.groonga").to_s
|
114
|
+
Groonga::Schema.create_table("Posts", options(:path => path)) do |table|
|
115
|
+
end
|
116
|
+
|
117
|
+
assert_raise(Groonga::Schema::TableCreationWithDifferentOptions) do
|
118
|
+
path = (@tmp_dir + "posts.grn").to_s
|
119
|
+
Groonga::Schema.create_table("Posts", options(:path => path)) do |table|
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
def test_default_path
|
125
|
+
Groonga::Schema.create_table("Posts", options) do |table|
|
126
|
+
end
|
127
|
+
assert_equal("#{@database_path}.tables/Posts",
|
128
|
+
context["Posts"].path)
|
129
|
+
end
|
130
|
+
|
102
131
|
private
|
103
132
|
def options(addional_options={})
|
104
133
|
default_options.merge(addional_options)
|
@@ -118,7 +147,8 @@ module SchemaCreateTableWithKeyTests
|
|
118
147
|
end
|
119
148
|
|
120
149
|
def test_differnt_key_type
|
121
|
-
Groonga::Schema.create_table("Posts",
|
150
|
+
Groonga::Schema.create_table("Posts",
|
151
|
+
options(:key_type => "Int32")) do |table|
|
122
152
|
end
|
123
153
|
|
124
154
|
assert_raise(Groonga::Schema::TableCreationWithDifferentOptions) do
|
data/test/test-schema.rb
CHANGED
@@ -28,7 +28,9 @@ class SchemaTest < Test::Unit::TestCase
|
|
28
28
|
def test_define_hash
|
29
29
|
Groonga::Schema.create_table("Posts", :type => :hash) do |table|
|
30
30
|
end
|
31
|
-
|
31
|
+
posts = context["Posts"]
|
32
|
+
assert_kind_of(Groonga::Hash, posts)
|
33
|
+
assert_equal("#{@database_path}.tables/Posts", posts.path)
|
32
34
|
end
|
33
35
|
|
34
36
|
def test_define_hash_with_full_option
|
@@ -58,7 +60,9 @@ class SchemaTest < Test::Unit::TestCase
|
|
58
60
|
def test_define_patricia_trie
|
59
61
|
Groonga::Schema.create_table("Posts", :type => :patricia_trie) do |table|
|
60
62
|
end
|
61
|
-
|
63
|
+
posts = context["Posts"]
|
64
|
+
assert_kind_of(Groonga::PatriciaTrie, posts)
|
65
|
+
assert_equal("#{@database_path}.tables/Posts", posts.path)
|
62
66
|
end
|
63
67
|
|
64
68
|
def test_define_patricia_trie_with_full_option
|
@@ -89,7 +93,9 @@ class SchemaTest < Test::Unit::TestCase
|
|
89
93
|
def test_define_array
|
90
94
|
Groonga::Schema.create_table("Posts", :type => :array) do |table|
|
91
95
|
end
|
92
|
-
|
96
|
+
posts = context["Posts"]
|
97
|
+
assert_kind_of(Groonga::Array, posts)
|
98
|
+
assert_equal("#{@database_path}.tables/Posts", posts.path)
|
93
99
|
end
|
94
100
|
|
95
101
|
def test_define_array_with_full_option
|
@@ -183,6 +189,16 @@ class SchemaTest < Test::Unit::TestCase
|
|
183
189
|
assert_equal(context["Time"], context["Posts.last_modified"].range)
|
184
190
|
end
|
185
191
|
|
192
|
+
def test_timestamps
|
193
|
+
assert_nil(context["Posts.created_at"])
|
194
|
+
assert_nil(context["Posts.updated_at"])
|
195
|
+
Groonga::Schema.create_table("Posts") do |table|
|
196
|
+
table.timestamps
|
197
|
+
end
|
198
|
+
assert_equal(context["Time"], context["Posts.created_at"].range)
|
199
|
+
assert_equal(context["Time"], context["Posts.updated_at"].range)
|
200
|
+
end
|
201
|
+
|
186
202
|
def test_short_text_column
|
187
203
|
assert_nil(context["Posts.title"])
|
188
204
|
Groonga::Schema.create_table("Posts") do |table|
|
@@ -221,9 +237,7 @@ class SchemaTest < Test::Unit::TestCase
|
|
221
237
|
end
|
222
238
|
assert_not_nil(context["Posts.content"])
|
223
239
|
|
224
|
-
Groonga::Schema.
|
225
|
-
table.remove_column("content")
|
226
|
-
end
|
240
|
+
Groonga::Schema.remove_column("Posts", "content")
|
227
241
|
assert_nil(context["Posts.content"])
|
228
242
|
end
|
229
243
|
|
@@ -363,6 +377,48 @@ class SchemaTest < Test::Unit::TestCase
|
|
363
377
|
end
|
364
378
|
end
|
365
379
|
|
380
|
+
def test_remove_index
|
381
|
+
Groonga::Schema.create_table("Posts") do |table|
|
382
|
+
table.long_text :content
|
383
|
+
end
|
384
|
+
Groonga::Schema.create_table("Terms") do |table|
|
385
|
+
table.index "Posts.content"
|
386
|
+
end
|
387
|
+
assert_equal([context["Posts.content"]],
|
388
|
+
context["Terms.Posts_content"].sources)
|
389
|
+
Groonga::Schema.change_table("Terms") do |table|
|
390
|
+
table.remove_index("Posts.content")
|
391
|
+
end
|
392
|
+
assert_nil(context["Terms.Posts_content"])
|
393
|
+
end
|
394
|
+
|
395
|
+
def test_reference_guess
|
396
|
+
Groonga::Schema.define do |schema|
|
397
|
+
schema.create_table("Items", :type => :hash) do |table|
|
398
|
+
table.short_text("title")
|
399
|
+
end
|
400
|
+
|
401
|
+
schema.create_table("Users", :type => :hash) do |table|
|
402
|
+
table.reference("item")
|
403
|
+
end
|
404
|
+
end
|
405
|
+
|
406
|
+
assert_equal(context["Items"], context["Users.item"].range)
|
407
|
+
end
|
408
|
+
|
409
|
+
def test_reference_ungeussable
|
410
|
+
candidates = ["item", "items", "Items"]
|
411
|
+
exception =
|
412
|
+
Groonga::Schema::UnguessableReferenceTable.new("item", candidates)
|
413
|
+
assert_raise(exception) do
|
414
|
+
Groonga::Schema.define do |schema|
|
415
|
+
schema.create_table("Users", :type => :hash) do |table|
|
416
|
+
table.reference("item")
|
417
|
+
end
|
418
|
+
end
|
419
|
+
end
|
420
|
+
end
|
421
|
+
|
366
422
|
def test_dump
|
367
423
|
Groonga::Schema.define do |schema|
|
368
424
|
schema.create_table("Posts") do |table|
|
@@ -370,13 +426,14 @@ class SchemaTest < Test::Unit::TestCase
|
|
370
426
|
end
|
371
427
|
end
|
372
428
|
assert_equal(<<-EOS, Groonga::Schema.dump)
|
373
|
-
create_table("Posts"
|
429
|
+
create_table("Posts",
|
430
|
+
:force => true) do |table|
|
374
431
|
table.short_text("title")
|
375
432
|
end
|
376
433
|
EOS
|
377
434
|
end
|
378
435
|
|
379
|
-
def
|
436
|
+
def test_dump_reference
|
380
437
|
Groonga::Schema.define do |schema|
|
381
438
|
schema.create_table("Items") do |table|
|
382
439
|
table.short_text("title")
|
@@ -395,16 +452,19 @@ EOS
|
|
395
452
|
end
|
396
453
|
|
397
454
|
assert_equal(<<-EOS, Groonga::Schema.dump)
|
398
|
-
create_table("Comments"
|
455
|
+
create_table("Comments",
|
456
|
+
:force => true) do |table|
|
399
457
|
table.text("content")
|
400
458
|
table.time("issued")
|
401
459
|
end
|
402
460
|
|
403
|
-
create_table("Items"
|
461
|
+
create_table("Items",
|
462
|
+
:force => true) do |table|
|
404
463
|
table.short_text("title")
|
405
464
|
end
|
406
465
|
|
407
|
-
create_table("Users"
|
466
|
+
create_table("Users",
|
467
|
+
:force => true) do |table|
|
408
468
|
table.short_text("name")
|
409
469
|
end
|
410
470
|
|
@@ -415,6 +475,43 @@ end
|
|
415
475
|
EOS
|
416
476
|
end
|
417
477
|
|
478
|
+
def test_dump_index
|
479
|
+
Groonga::Schema.define do |schema|
|
480
|
+
schema.create_table("Items",
|
481
|
+
:type => :patricia_trie,
|
482
|
+
:key_type => "ShortText") do |table|
|
483
|
+
table.short_text("title")
|
484
|
+
end
|
485
|
+
|
486
|
+
schema.create_table("Terms",
|
487
|
+
:type => :patricia_trie,
|
488
|
+
:key_type => "ShortText") do |table|
|
489
|
+
table.index("Items", "_key")
|
490
|
+
table.index("Items", "title")
|
491
|
+
end
|
492
|
+
end
|
493
|
+
|
494
|
+
assert_equal(<<-EOS, Groonga::Schema.dump)
|
495
|
+
create_table("Items",
|
496
|
+
:type => :patricia_trie,
|
497
|
+
:key_type => "ShortText",
|
498
|
+
:force => true) do |table|
|
499
|
+
table.short_text("title")
|
500
|
+
end
|
501
|
+
|
502
|
+
create_table("Terms",
|
503
|
+
:type => :patricia_trie,
|
504
|
+
:key_type => "ShortText",
|
505
|
+
:force => true) do |table|
|
506
|
+
end
|
507
|
+
|
508
|
+
change_table("Terms") do |table|
|
509
|
+
table.index("Items", "_key", :name => "Items__key")
|
510
|
+
table.index("Items", "title", :name => "Items_title")
|
511
|
+
end
|
512
|
+
EOS
|
513
|
+
end
|
514
|
+
|
418
515
|
def test_explicit_context_create_table
|
419
516
|
context = Groonga::Context.default
|
420
517
|
Groonga::Context.default = nil
|
@@ -25,11 +25,15 @@ class TableSelectNormalizeTest < Test::Unit::TestCase
|
|
25
25
|
@comments = Groonga::Array.create(:name => "Comments")
|
26
26
|
@comments.define_column("content", "Text")
|
27
27
|
@comments.define_column("created_at", "Time")
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
options = {
|
29
|
+
:name => "Terms",
|
30
|
+
:default_tokenizer => "TokenBigramSplitSymbol",
|
31
|
+
:key_normalize => true,
|
32
|
+
}
|
33
|
+
terms = Groonga::PatriciaTrie.create(options)
|
31
34
|
terms.define_index_column("comment_content", @comments,
|
32
35
|
:with_section => true,
|
36
|
+
:with_position => true,
|
33
37
|
:source => "Comments.content")
|
34
38
|
@japanese_comment =
|
35
39
|
@comments.add(:content => "うちのボロTV(アナログ...)はまだ現役です",
|
data/test/test-table-select.rb
CHANGED
@@ -33,7 +33,12 @@ class TableSelectTest < Test::Unit::TestCase
|
|
33
33
|
:default_tokenizer => "TokenBigram")
|
34
34
|
terms.define_index_column("comment_content", @comments,
|
35
35
|
:with_section => true,
|
36
|
+
:with_position => true,
|
36
37
|
:source => "content")
|
38
|
+
terms.define_index_column("users_key", @users,
|
39
|
+
:with_section => true,
|
40
|
+
:with_position => true,
|
41
|
+
:source => "_key")
|
37
42
|
@comment1 = @comments.add(:content => "Hello Good-bye!",
|
38
43
|
:created_at => Time.parse("2009-08-09"),
|
39
44
|
:user => "morita")
|
@@ -147,4 +152,11 @@ class TableSelectTest < Test::Unit::TestCase
|
|
147
152
|
end
|
148
153
|
assert_equal_select_result([], result)
|
149
154
|
end
|
155
|
+
|
156
|
+
def test_select_query_key
|
157
|
+
result = @users.select do |record|
|
158
|
+
record["_key"] =~ "mori"
|
159
|
+
end
|
160
|
+
assert_equal_select_result([@users["morita"]], result)
|
161
|
+
end
|
150
162
|
end
|
data/test/test-table.rb
CHANGED
@@ -594,6 +594,13 @@ class TableTest < Test::Unit::TestCase
|
|
594
594
|
assert_false(users.have_column?("description"), "description")
|
595
595
|
end
|
596
596
|
|
597
|
+
def test_exist?
|
598
|
+
users = Groonga::Hash.create(:name => "Users")
|
599
|
+
morita = users.add("morita")
|
600
|
+
assert_true(users.exist?(morita.id))
|
601
|
+
assert_false(users.exist?(morita.id + 1))
|
602
|
+
end
|
603
|
+
|
597
604
|
private
|
598
605
|
def create_bookmarks
|
599
606
|
bookmarks = Groonga::Array.create(:name => "Bookmarks")
|
@@ -50,6 +50,10 @@ class VariableSizeColumnTest < Test::Unit::TestCase
|
|
50
50
|
@yu = @users.add(:name => "Yutaro Shimamura")
|
51
51
|
end
|
52
52
|
|
53
|
+
def test_index_column?
|
54
|
+
assert_not_predicate(@nick_names, :index_column?)
|
55
|
+
end
|
56
|
+
|
53
57
|
def test_inspect
|
54
58
|
assert_equal("#<Groonga::VariableSizeColumn " +
|
55
59
|
"id: <#{@name.id}>, " +
|
data/test-unit/Rakefile
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
gem 'rdoc'
|
5
|
+
require 'hoe'
|
6
|
+
require './lib/test/unit/version.rb'
|
7
|
+
|
8
|
+
ENV["NODOT"] = "yes"
|
9
|
+
|
10
|
+
version = Test::Unit::VERSION
|
11
|
+
ENV["VERSION"] = version
|
12
|
+
Hoe.spec('test-unit') do |p|
|
13
|
+
Hoe::Test::SUPPORTED_TEST_FRAMEWORKS[:testunit2] = "test/run-test.rb"
|
14
|
+
p.version = version
|
15
|
+
p.developer('Kouhei Sutou', 'kou@cozmixng.org')
|
16
|
+
p.developer('Ryan Davis', 'ryand-ruby@zenspider.com')
|
17
|
+
|
18
|
+
# Ex-Parrot:
|
19
|
+
# p.developer('Nathaniel Talbott', 'nathaniel@talbott.ws')
|
20
|
+
end
|
21
|
+
|
22
|
+
task :check_manifest => :clean_test_result
|
23
|
+
task :check_manifest => :clean_coverage
|
24
|
+
|
25
|
+
task :clean_test_result do
|
26
|
+
test_results = Dir.glob("**/.test-result")
|
27
|
+
sh("rm", "-rf", *test_results) unless test_results.empty?
|
28
|
+
end
|
29
|
+
|
30
|
+
task :clean_coverage do
|
31
|
+
sh("rm", "-rf", "coverage")
|
32
|
+
end
|
33
|
+
|
34
|
+
task :tag do
|
35
|
+
message = "Released Test::Unit #{version}!"
|
36
|
+
base = "svn+ssh://#{ENV['USER']}@rubyforge.org/var/svn/test-unit/"
|
37
|
+
sh 'svn', 'copy', '-m', message, "#{base}trunk", "#{base}tags/#{version}"
|
38
|
+
end
|
39
|
+
|
40
|
+
# vim: syntax=Ruby
|
data/test-unit/TODO
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Test::Unit (Classic)</title>
|
5
|
+
</head>
|
6
|
+
<body bgcolor="red">
|
7
|
+
<p style="text-align: center">
|
8
|
+
<img height="161" width="308" src="test-unit-classic.png">
|
9
|
+
<br>
|
10
|
+
<br>
|
11
|
+
<br>
|
12
|
+
Read the <a href="classic/test-unit/">rdoc</a>
|
13
|
+
</p>
|
14
|
+
</body>
|
15
|
+
</html>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8" ?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
|
6
|
+
<head>
|
7
|
+
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
|
8
|
+
<title>Test::Unit - a Unit Testing Framework for Ruby</title>
|
9
|
+
</head>
|
10
|
+
<body>
|
11
|
+
<h1>Test::Unit - a Unit Testing Framework for Ruby</h1>
|
12
|
+
<p>[<a href="index.html.ja">Japanese</a>]</p>
|
13
|
+
<ul>
|
14
|
+
<li><a href="http://rubyforge.org/projects/test-unit/">Project Page</a></li>
|
15
|
+
<li>
|
16
|
+
<a href="test-unit/">RDoc</a>
|
17
|
+
<!--(<a href="ja/test-unit/">ja</a>)-->
|
18
|
+
</li>
|
19
|
+
<li>
|
20
|
+
<a href="classic.html">Classic</a>
|
21
|
+
<!--(<a href="ja/classic.html">ja</a>)-->
|
22
|
+
</li>
|
23
|
+
</ul>
|
24
|
+
</body>
|
25
|
+
</html>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8" ?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
<html xmlns="http://www.w3.org/1999/xhtml" lang="ja" xml:lang="ja">
|
6
|
+
<head>
|
7
|
+
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
|
8
|
+
<title>Test::Unit - Ruby用単体テストフレームワーク</title>
|
9
|
+
</head>
|
10
|
+
<body>
|
11
|
+
<h1>Test::Unit - Ruby用単体テストフレームワーク</h1>
|
12
|
+
<p>[<a href="./">English</a>]</p>
|
13
|
+
<ul>
|
14
|
+
<li>
|
15
|
+
<a href="http://rubyforge.org/projects/test-unit/">プロジェクトページ</a>
|
16
|
+
</li>
|
17
|
+
<li>
|
18
|
+
<!--<a href="ja/test-unit/">RDoc</a>-->
|
19
|
+
RDoc(<a href="test-unit/">en</a>)
|
20
|
+
</li>
|
21
|
+
<li>
|
22
|
+
<!--<a href="classic.html.html">Classic</a>-->
|
23
|
+
Classic(<a href="classic.html">en</a>)
|
24
|
+
</li>
|
25
|
+
</ul>
|
26
|
+
</body>
|
27
|
+
</html>
|