groonga 0.0.7 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -22,6 +22,20 @@ module Test
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
+
def output_fault_backtrace(fault)
|
26
|
+
backtrace = fault.location
|
27
|
+
if backtrace.size == 1
|
28
|
+
output(fault.test_name +
|
29
|
+
backtrace[0].sub(/\A(.+:\d+).*/, ' [\\1]') +
|
30
|
+
":")
|
31
|
+
else
|
32
|
+
output(fault.test_name)
|
33
|
+
backtrace.each do |entry|
|
34
|
+
output(entry)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
25
39
|
def format_fault_failure(failure)
|
26
40
|
if failure.location.size == 1
|
27
41
|
location = failure.location[0]
|
@@ -14,6 +14,14 @@ module Test
|
|
14
14
|
end
|
15
15
|
@options = options
|
16
16
|
end
|
17
|
+
|
18
|
+
def diff_target_string?(string)
|
19
|
+
Assertions::AssertionMessage.diff_target_string?(string)
|
20
|
+
end
|
21
|
+
|
22
|
+
def prepare_for_diff(from, to)
|
23
|
+
Assertions::AssertionMessage.prepare_for_diff(from, to)
|
24
|
+
end
|
17
25
|
end
|
18
26
|
end
|
19
27
|
end
|
@@ -5,13 +5,15 @@
|
|
5
5
|
require 'test/unit'
|
6
6
|
require 'adder'
|
7
7
|
|
8
|
-
class
|
8
|
+
class TestAdder < Test::Unit::TestCase
|
9
9
|
def setup
|
10
10
|
@adder = Adder.new(5)
|
11
11
|
end
|
12
|
+
|
12
13
|
def test_add
|
13
14
|
assert_equal(7, @adder.add(2), "Should have added correctly")
|
14
15
|
end
|
16
|
+
|
15
17
|
def teardown
|
16
18
|
@adder = nil
|
17
19
|
end
|
@@ -5,13 +5,15 @@
|
|
5
5
|
require 'test/unit'
|
6
6
|
require 'subtracter'
|
7
7
|
|
8
|
-
class
|
8
|
+
class TestSubtracter < Test::Unit::TestCase
|
9
9
|
def setup
|
10
10
|
@subtracter = Subtracter.new(5)
|
11
11
|
end
|
12
|
+
|
12
13
|
def test_subtract
|
13
14
|
assert_equal(3, @subtracter.subtract(2), "Should have subtracted correctly")
|
14
15
|
end
|
16
|
+
|
15
17
|
def teardown
|
16
18
|
@subtracter = nil
|
17
19
|
end
|
@@ -66,7 +66,7 @@ class TestUnitCollectorDescendant < Test::Unit::TestCase
|
|
66
66
|
collector.filter = [Proc.new {false}, Proc.new {true}]
|
67
67
|
end
|
68
68
|
|
69
|
-
assert_collect(
|
69
|
+
assert_collect(empty_suite) do |collector|
|
70
70
|
collector.filter = [Proc.new {true}, Proc.new {false}]
|
71
71
|
end
|
72
72
|
|
@@ -90,13 +90,11 @@ class TestUnitCollectorDescendant < Test::Unit::TestCase
|
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
93
|
-
expected = empty_suite
|
94
93
|
suite1 = Test::Unit::TestSuite.new(@test_case1.name)
|
95
94
|
suite1 << @test_case1.new("test_1")
|
96
95
|
suite2 = Test::Unit::TestSuite.new(@test_case2.name)
|
97
96
|
suite2 << @test_case2.new("test_0")
|
98
|
-
|
99
|
-
assert_collect(expected) do |collector|
|
97
|
+
assert_collect(empty_suite) do |collector|
|
100
98
|
filters = [Proc.new {|test| test.method_name == 'test_1' ? true : nil},
|
101
99
|
Proc.new {|test| test.method_name == 'test_0' ? true : nil},
|
102
100
|
Proc.new {false}]
|
@@ -72,7 +72,7 @@ module Test
|
|
72
72
|
assert_equal(empty_suite, @c.collect)
|
73
73
|
|
74
74
|
@c.filter = [proc{true}, proc{false}]
|
75
|
-
assert_equal(
|
75
|
+
assert_equal(empty_suite, @c.collect)
|
76
76
|
|
77
77
|
@c.filter = [proc{nil}, proc{false}]
|
78
78
|
assert_equal(empty_suite, @c.collect)
|
@@ -87,10 +87,12 @@ module Test
|
|
87
87
|
assert_equal(expected, @c.collect)
|
88
88
|
|
89
89
|
expected = TestSuite.new(ObjectSpace::NAME)
|
90
|
-
|
91
|
-
|
92
|
-
@c.filter = [proc{|t| t.method_name == 'test_1' ? true : nil},
|
93
|
-
|
90
|
+
TestSuite.new(@tc1.name) << @tc1.new('test_1')
|
91
|
+
TestSuite.new(@tc2.name) << @tc2.new('test_0')
|
92
|
+
@c.filter = [proc{|t| t.method_name == 'test_1' ? true : nil},
|
93
|
+
proc{|t| t.method_name == 'test_0' ? true : nil},
|
94
|
+
proc{false}]
|
95
|
+
assert_equal(empty_suite, @c.collect)
|
94
96
|
end
|
95
97
|
end
|
96
98
|
end
|
data/test-unit/test/run-test.rb
CHANGED
@@ -12,6 +12,13 @@ class TestUnitColorScheme < Test::Unit::TestCase
|
|
12
12
|
color("blue", :foreground => false),
|
13
13
|
"suite" => color("white", :bold => true) +
|
14
14
|
color("green", :foreground => false),
|
15
|
+
"diff-inserted-tag" => color("red", :bold => true),
|
16
|
+
"diff-deleted-tag" => color("green", :bold => true),
|
17
|
+
"diff-difference-tag" => color("cyan", :bold => true),
|
18
|
+
"diff-inserted" => color("red", :foreground => false) +
|
19
|
+
color("white", :bold => true),
|
20
|
+
"diff-deleted" => color("green", :foreground => false) +
|
21
|
+
color("white", :bold => true),
|
15
22
|
},
|
16
23
|
Test::Unit::ColorScheme.default.to_hash)
|
17
24
|
end
|
data/test-unit/test/test-diff.rb
CHANGED
@@ -1,4 +1,9 @@
|
|
1
1
|
class TestUnitDiff < Test::Unit::TestCase
|
2
|
+
def test_binary_search_ranges
|
3
|
+
assert_found_binary_search_ranges(5, [1..2, 4..5, 7..9])
|
4
|
+
assert_not_found_binary_search_ranges(3, [1..2, 4..5, 7..9])
|
5
|
+
end
|
6
|
+
|
2
7
|
def test_to_indexes
|
3
8
|
assert_to_indexes({"abc def" => [0, 2], "abc" => [1]},
|
4
9
|
["abc def", "abc", "abc def"])
|
@@ -189,6 +194,21 @@ class TestUnitDiff < Test::Unit::TestCase
|
|
189
194
|
assert_ratio(0.80, "efg", "eg")
|
190
195
|
end
|
191
196
|
|
197
|
+
def test_1_length_readable_diff
|
198
|
+
differ = Test::Unit::Diff::ReadableDiffer.new(["0"], ["1"])
|
199
|
+
def differ.cut_off_ratio
|
200
|
+
0
|
201
|
+
end
|
202
|
+
def differ.default_ratio
|
203
|
+
0
|
204
|
+
end
|
205
|
+
assert_equal("- 0\n" +
|
206
|
+
"? ^\n" +
|
207
|
+
"+ 1\n" +
|
208
|
+
"? ^",
|
209
|
+
differ.diff.join("\n"))
|
210
|
+
end
|
211
|
+
|
192
212
|
def test_same_contents_readable_diff
|
193
213
|
assert_readable_diff(" aaa", ["aaa"], ["aaa"])
|
194
214
|
assert_readable_diff(" aaa\n" \
|
@@ -387,6 +407,18 @@ class TestUnitDiff < Test::Unit::TestCase
|
|
387
407
|
end
|
388
408
|
|
389
409
|
private
|
410
|
+
def assert_found_binary_search_ranges(numeric, ranges)
|
411
|
+
assert_true(Test::Unit::Diff::UTF8Line.send(:binary_search_ranges,
|
412
|
+
numeric,
|
413
|
+
ranges))
|
414
|
+
end
|
415
|
+
|
416
|
+
def assert_not_found_binary_search_ranges(numeric, ranges)
|
417
|
+
assert_false(Test::Unit::Diff::UTF8Line.send(:binary_search_ranges,
|
418
|
+
numeric,
|
419
|
+
ranges))
|
420
|
+
end
|
421
|
+
|
390
422
|
def assert_to_indexes(expected, to, &junk_predicate)
|
391
423
|
matcher = Test::Unit::Diff::SequenceMatcher.new([""], to, &junk_predicate)
|
392
424
|
assert_equal(expected, matcher.instance_variable_get("@to_indexes"))
|
@@ -451,21 +483,30 @@ class TestUnitDiff < Test::Unit::TestCase
|
|
451
483
|
from_start, from_end,
|
452
484
|
to_start, to_end)
|
453
485
|
differ = Test::Unit::Diff::ReadableDiffer.new(from, to)
|
454
|
-
|
455
|
-
|
456
|
-
|
486
|
+
result = []
|
487
|
+
differ.instance_variable_set("@result", result)
|
488
|
+
differ.send(:diff_lines,
|
489
|
+
from_start, from_end,
|
490
|
+
to_start, to_end)
|
491
|
+
assert_equal(expected, result)
|
457
492
|
end
|
458
493
|
|
459
494
|
def assert_diff_line(expected, from_line, to_line)
|
460
495
|
differ = Test::Unit::Diff::ReadableDiffer.new([""], [""])
|
461
|
-
|
496
|
+
result = []
|
497
|
+
differ.instance_variable_set("@result", result)
|
498
|
+
differ.send(:diff_line, from_line, to_line)
|
499
|
+
assert_equal(expected, result)
|
462
500
|
end
|
463
501
|
|
464
502
|
def assert_format_diff_point(expected, from_line, to_line, from_tags, to_tags)
|
465
503
|
differ = Test::Unit::Diff::ReadableDiffer.new([""], [""])
|
466
|
-
|
467
|
-
|
468
|
-
|
504
|
+
result = []
|
505
|
+
differ.instance_variable_set("@result", result)
|
506
|
+
differ.send(:format_diff_point,
|
507
|
+
from_line, to_line,
|
508
|
+
from_tags, to_tags)
|
509
|
+
assert_equal(expected, result)
|
469
510
|
end
|
470
511
|
|
471
512
|
def assert_interesting_line(expected, from, to, from_start, to_start)
|
@@ -68,7 +68,7 @@ class TestUnitOmission < Test::Unit::TestCase
|
|
68
68
|
|
69
69
|
def test_omit_with_condition_and_block
|
70
70
|
result = _run_test("test_omit_with_block_and_condition")
|
71
|
-
assert_equal("1 tests,
|
71
|
+
assert_equal("1 tests, 2 assertions, 0 failures, 0 errors, 0 pendings, " \
|
72
72
|
"1 omissions, 0 notifications",
|
73
73
|
result.to_s)
|
74
74
|
assert_fault_messages(["Should omit."], result.omissions)
|
@@ -490,6 +490,53 @@ module Test
|
|
490
490
|
end
|
491
491
|
end
|
492
492
|
|
493
|
+
def test_declarative_style
|
494
|
+
keep_test_order do
|
495
|
+
test_case = Class.new(Test::Unit::TestCase) do
|
496
|
+
test "declarative style test definition" do
|
497
|
+
end
|
498
|
+
|
499
|
+
test "include parenthesis" do
|
500
|
+
end
|
501
|
+
|
502
|
+
test "1 + 2 = 3" do
|
503
|
+
end
|
504
|
+
end
|
505
|
+
|
506
|
+
test_case.test_order = :defined
|
507
|
+
|
508
|
+
assert_equal(["test_declarative_style_test_definition",
|
509
|
+
"test_include_parenthesis",
|
510
|
+
"test_1_2_3"],
|
511
|
+
test_case.suite.tests.collect {|test| test.method_name})
|
512
|
+
|
513
|
+
assert_equal(["declarative style test definition",
|
514
|
+
"include parenthesis",
|
515
|
+
"1 + 2 = 3"],
|
516
|
+
test_case.suite.tests.collect {|test| test.description})
|
517
|
+
end
|
518
|
+
end
|
519
|
+
|
520
|
+
def test_redefine_method
|
521
|
+
test_case = Class.new(Test::Unit::TestCase) do
|
522
|
+
def test_name
|
523
|
+
end
|
524
|
+
alias_method :test_name2, :test_name
|
525
|
+
|
526
|
+
def test_name
|
527
|
+
end
|
528
|
+
end
|
529
|
+
|
530
|
+
suite = test_case.suite
|
531
|
+
assert_equal(["test_name", "test_name2"],
|
532
|
+
suite.tests.collect {|test| test.method_name})
|
533
|
+
result = TestResult.new
|
534
|
+
suite.run(result) {}
|
535
|
+
assert_equal("2 tests, 0 assertions, 0 failures, " +
|
536
|
+
"0 errors, 0 pendings, 0 omissions, 1 notifications",
|
537
|
+
result.summary)
|
538
|
+
end
|
539
|
+
|
493
540
|
private
|
494
541
|
def check(message, passed)
|
495
542
|
add_assertion
|
@@ -248,32 +248,66 @@ EOM
|
|
248
248
|
|
249
249
|
def test_assert_equal_with_large_string
|
250
250
|
message = <<-EOM.chomp
|
251
|
-
<#{("a\n" + "x" *
|
251
|
+
<#{("a\n" + "x" * 997).inspect}> expected but was
|
252
252
|
<#{"x".inspect}>.
|
253
253
|
|
254
254
|
diff:
|
255
255
|
+ x
|
256
256
|
- a
|
257
|
-
- #{"x" *
|
257
|
+
- #{"x" * 997}
|
258
258
|
|
259
259
|
folded diff:
|
260
260
|
+ x
|
261
261
|
- a
|
262
|
-
|
263
|
-
- #{"x" *
|
264
|
-
- #{"x" * 78}
|
265
|
-
- #{"x" * 63}
|
262
|
+
#{(["- " + ("x" * 78)] * 12).join("\n")}
|
263
|
+
- #{"x" * 61}
|
266
264
|
EOM
|
267
265
|
check_fails(message) do
|
268
|
-
assert_equal("a\n" + "x" *
|
266
|
+
assert_equal("a\n" + "x" * 997, "x")
|
269
267
|
end
|
270
268
|
|
271
269
|
message = <<-EOM.chomp
|
272
|
-
<#{("a\n" + "x" *
|
270
|
+
<#{("a\n" + "x" * 998).inspect}> expected but was
|
273
271
|
<#{"x".inspect}>.
|
274
272
|
EOM
|
275
273
|
check_fails(message) do
|
276
|
-
assert_equal("a\n" + "x" *
|
274
|
+
assert_equal("a\n" + "x" * 998, "x")
|
275
|
+
end
|
276
|
+
end
|
277
|
+
|
278
|
+
def test_assert_equal_with_max_diff_target_string_size
|
279
|
+
key = "TEST_UNIT_MAX_DIFF_TARGET_STRING_SIZE"
|
280
|
+
before_value = ENV[key]
|
281
|
+
ENV[key] = "100"
|
282
|
+
begin
|
283
|
+
message = <<-EOM.chomp
|
284
|
+
<#{("a\n" + "x" * 97).inspect}> expected but was
|
285
|
+
<#{"x".inspect}>.
|
286
|
+
|
287
|
+
diff:
|
288
|
+
+ x
|
289
|
+
- a
|
290
|
+
- #{"x" * 97}
|
291
|
+
|
292
|
+
folded diff:
|
293
|
+
+ x
|
294
|
+
- a
|
295
|
+
#{(["- " + ("x" * 78)]).join("\n")}
|
296
|
+
- #{"x" * 19}
|
297
|
+
EOM
|
298
|
+
check_fails(message) do
|
299
|
+
assert_equal("a\n" + "x" * 97, "x")
|
300
|
+
end
|
301
|
+
|
302
|
+
message = <<-EOM.chomp
|
303
|
+
<#{("a\n" + "x" * 98).inspect}> expected but was
|
304
|
+
<#{"x".inspect}>.
|
305
|
+
EOM
|
306
|
+
check_fails(message) do
|
307
|
+
assert_equal("a\n" + "x" * 98, "x")
|
308
|
+
end
|
309
|
+
ensure
|
310
|
+
ENV[key] = before_value
|
277
311
|
end
|
278
312
|
end
|
279
313
|
|
@@ -1063,8 +1097,43 @@ EOM
|
|
1063
1097
|
end
|
1064
1098
|
end
|
1065
1099
|
|
1100
|
+
def test_assert_alias_method
|
1101
|
+
object = Object.new
|
1102
|
+
class << object
|
1103
|
+
def original_method
|
1104
|
+
end
|
1105
|
+
alias_method :alias_method, :original_method
|
1106
|
+
|
1107
|
+
def other
|
1108
|
+
end
|
1109
|
+
end
|
1110
|
+
|
1111
|
+
check_nothing_fails do
|
1112
|
+
assert_alias_method(object, :alias_method, :original_method)
|
1113
|
+
end
|
1114
|
+
|
1115
|
+
check_nothing_fails do
|
1116
|
+
assert_alias_method(object, :original_method, :alias_method)
|
1117
|
+
end
|
1118
|
+
|
1119
|
+
check_fails("<#{object.method(:other).inspect}> is alias of\n" +
|
1120
|
+
"<#{object.method(:original_method).inspect}> expected") do
|
1121
|
+
assert_alias_method(object, :other, :original_method)
|
1122
|
+
end
|
1123
|
+
|
1124
|
+
check_fails("<#{object.inspect}>.nonexistent doesn't exist\n" +
|
1125
|
+
"(Class: <Object>)") do
|
1126
|
+
assert_alias_method(object, :nonexistent, :original_method)
|
1127
|
+
end
|
1128
|
+
|
1129
|
+
check_fails("<#{object.inspect}>.nonexistent doesn't exist\n" +
|
1130
|
+
"(Class: <Object>)") do
|
1131
|
+
assert_alias_method(object, :alias_method, :nonexistent)
|
1132
|
+
end
|
1133
|
+
end
|
1134
|
+
|
1066
1135
|
private
|
1067
|
-
def add_failure(message, location=caller)
|
1136
|
+
def add_failure(message, location=caller, options=nil)
|
1068
1137
|
unless @catch_assertions
|
1069
1138
|
super
|
1070
1139
|
end
|
data/test/groonga-test-utils.rb
CHANGED