rroonga 1.0.8 → 1.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. data/NEWS.ja.rdoc +47 -0
  2. data/NEWS.rdoc +48 -0
  3. data/README.ja.rdoc +1 -0
  4. data/README.rdoc +1 -0
  5. data/Rakefile +32 -13
  6. data/benchmark/create-wikipedia-database.rb +212 -0
  7. data/benchmark/repeat-load.rb +213 -0
  8. data/benchmark/select.rb +1052 -0
  9. data/ext/groonga/mkmf.log +99 -0
  10. data/ext/groonga/rb-grn-column.c +57 -6
  11. data/ext/groonga/rb-grn-context.c +15 -9
  12. data/ext/groonga/rb-grn-expression.c +7 -7
  13. data/ext/groonga/{rb-grn-operation.c → rb-grn-operator.c} +89 -87
  14. data/ext/groonga/rb-grn-patricia-trie.c +5 -5
  15. data/ext/groonga/rb-grn-query.c +4 -4
  16. data/ext/groonga/rb-grn-table.c +16 -19
  17. data/ext/groonga/rb-grn.h +3 -3
  18. data/ext/groonga/rb-groonga.c +1 -1
  19. data/html/index.html +4 -4
  20. data/lib/groonga/context.rb +34 -0
  21. data/lib/groonga/expression-builder.rb +34 -2
  22. data/lib/groonga/record.rb +8 -6
  23. data/lib/groonga/schema.rb +40 -4
  24. data/rroonga-build.rb +2 -2
  25. data/test-unit/Rakefile +5 -18
  26. data/test-unit/html/classic.html +15 -0
  27. data/test-unit/html/index.html +13 -235
  28. data/test-unit/html/index.html.ja +15 -258
  29. data/test-unit/lib/test/unit.rb +1 -6
  30. data/test-unit/lib/test/unit/assertions.rb +11 -115
  31. data/test-unit/lib/test/unit/autorunner.rb +2 -5
  32. data/test-unit/lib/test/unit/collector/load.rb +1 -1
  33. data/test-unit/lib/test/unit/color-scheme.rb +2 -6
  34. data/test-unit/lib/test/unit/diff.rb +1 -17
  35. data/test-unit/lib/test/unit/testcase.rb +0 -7
  36. data/test-unit/lib/test/unit/testresult.rb +2 -34
  37. data/test-unit/lib/test/unit/ui/console/testrunner.rb +45 -9
  38. data/test-unit/lib/test/unit/ui/tap/testrunner.rb +12 -2
  39. data/test-unit/lib/test/unit/ui/testrunner.rb +0 -25
  40. data/test-unit/lib/test/unit/util/backtracefilter.rb +0 -1
  41. data/test-unit/lib/test/unit/version.rb +1 -1
  42. data/test-unit/test/test-color-scheme.rb +2 -4
  43. data/test-unit/test/test_assertions.rb +5 -51
  44. data/test/test-column.rb +31 -1
  45. data/test/test-context-select.rb +45 -14
  46. data/test/test-context.rb +36 -0
  47. data/test/test-database.rb +13 -0
  48. data/test/test-expression-builder.rb +32 -5
  49. data/test/test-record.rb +34 -1
  50. data/test/test-schema.rb +52 -2
  51. data/test/test-table-select-weight.rb +20 -1
  52. data/test/test-table.rb +58 -0
  53. metadata +13 -41
  54. data/test-unit-notify/Rakefile +0 -47
  55. data/test-unit-notify/lib/test/unit/notify.rb +0 -104
  56. data/test-unit/COPYING +0 -56
  57. data/test-unit/GPL +0 -340
  58. data/test-unit/PSFL +0 -271
  59. data/test-unit/html/bar.svg +0 -153
  60. data/test-unit/html/developer.svg +0 -469
  61. data/test-unit/html/favicon.ico +0 -0
  62. data/test-unit/html/favicon.svg +0 -82
  63. data/test-unit/html/heading-mark.svg +0 -393
  64. data/test-unit/html/install.svg +0 -636
  65. data/test-unit/html/logo.svg +0 -483
  66. data/test-unit/html/test-unit.css +0 -339
  67. data/test-unit/html/tutorial.svg +0 -559
  68. data/test-unit/lib/test/unit/util/output.rb +0 -31
  69. data/test-unit/test/ui/test_tap.rb +0 -33
  70. data/test-unit/test/util/test-output.rb +0 -11
@@ -90,13 +90,8 @@ module Test # :nodoc:
90
90
  #
91
91
  # Test::Unit is copyright (c) 2000-2003 Nathaniel Talbott. It is free
92
92
  # software, and is distributed under the Ruby license. See the COPYING
93
- # file.
93
+ # file in the standard Ruby distribution for details.
94
94
  #
95
- # Exception: lib/test/unit/diff.rb is copyright (c)
96
- # 2008-2010 Kouhei Sutou and 2001-2008 Python Software
97
- # Foundation. It is free software, and is distributed
98
- # under the Ruby license and/or the PSF license. See the
99
- # COPYING file and PSFL file.
100
95
  #
101
96
  # == Warranty
102
97
  #
@@ -1,6 +1,6 @@
1
1
  # Author:: Nathaniel Talbott.
2
2
  # Copyright:: Copyright (c) 2000-2003 Nathaniel Talbott. All rights reserved.
3
- # Copyright (c) 2009-2010 Kouhei Sutou. All rights reserved.
3
+ # Copyright (c) 2009 Kouhei Sutou.
4
4
  # License:: Ruby license.
5
5
 
6
6
  require 'test/unit/assertionfailederror'
@@ -80,23 +80,10 @@ module Test
80
80
  public
81
81
  def assert_equal(expected, actual, message=nil)
82
82
  diff = AssertionMessage.delayed_diff(expected, actual)
83
- if expected.respond_to?(:encoding) and
84
- actual.respond_to?(:encoding) and
85
- expected.encoding != actual.encoding
86
- format = <<EOT
87
- <?>(?) expected but was
88
- <?>(?).?
89
- EOT
90
- full_message = build_message(message, format,
91
- expected, expected.encoding.name,
92
- actual, actual.encoding.name,
93
- diff)
94
- else
95
- full_message = build_message(message, <<EOT, expected, actual, diff)
83
+ full_message = build_message(message, <<EOT, expected, actual, diff)
96
84
  <?> expected but was
97
85
  <?>.?
98
86
  EOT
99
- end
100
87
  begin
101
88
  assert_block(full_message) { expected == actual }
102
89
  rescue AssertionFailedError => failure
@@ -552,73 +539,18 @@ EOT
552
539
  public
553
540
  def assert_in_delta(expected_float, actual_float, delta, message="")
554
541
  _wrap_assertion do
555
- _assert_in_delta_validate_arguments(expected_float,
556
- actual_float,
557
- delta)
558
- full_message = _assert_in_delta_message(expected_float,
559
- actual_float,
560
- delta,
561
- message)
562
- assert_block(full_message) do
563
- (expected_float.to_f - actual_float.to_f).abs <= delta.to_f
564
- end
565
- end
566
- end
567
-
568
- # :stopdoc:
569
- private
570
- def _assert_in_delta_validate_arguments(expected_float,
571
- actual_float,
572
- delta)
573
- {
574
- expected_float => "first float",
575
- actual_float => "second float",
576
- delta => "delta"
577
- }.each do |float, name|
578
- assert_respond_to(float, :to_f,
579
- "The arguments must respond to to_f; " +
580
- "the #{name} did not")
581
- end
582
- assert_operator(delta, :>=, 0.0, "The delta should not be negative")
583
- end
584
-
585
- def _assert_in_delta_message(expected_float, actual_float, delta,
586
- message)
587
- format = <<-EOT
588
- <?> expected but was
589
- <?> (tolerance <?>).
542
+ {expected_float => "first float", actual_float => "second float", delta => "delta"}.each do |float, name|
543
+ assert_respond_to(float, :to_f, "The arguments must respond to to_f; the #{name} did not")
544
+ end
545
+ assert_operator(delta, :>=, 0.0, "The delta should not be negative")
546
+ full_message = build_message(message, <<EOT, expected_float, actual_float, delta)
547
+ <?> and
548
+ <?> expected to be within
549
+ <?> of each other.
590
550
  EOT
591
- arguments = [expected_float, actual_float, delta]
592
- normalized_expected = expected_float.to_f
593
- normalized_actual = actual_float.to_f
594
- normalized_delta = delta.to_f
595
- relation_format = nil
596
- relation_arguments = nil
597
- if normalized_actual < normalized_expected - normalized_delta
598
- relation_format = "<<?> < <?>-<?>(?) <= <?>+<?>(?)>"
599
- relation_arguments = [actual_float,
600
- expected_float, delta, expected_float - delta,
601
- expected_float, delta, expected_float + delta]
602
- elsif normalized_expected - normalized_delta < normalized_actual
603
- relation_format = "<<?>-<?>(?) <= <?>+<?>(?) < <?>>"
604
- relation_arguments = [expected_float, delta, expected_float - delta,
605
- expected_float, delta, expected_float + delta,
606
- actual_float]
551
+ assert_block(full_message) { (expected_float.to_f - actual_float.to_f).abs <= delta.to_f }
607
552
  end
608
-
609
- if relation_format
610
- format << <<-EOT
611
-
612
- Relation:
613
- #{relation_format}
614
- EOT
615
- arguments.concat(relation_arguments)
616
- end
617
-
618
- build_message(message, format, *arguments)
619
553
  end
620
- public
621
- # :startdoc:
622
554
 
623
555
  ##
624
556
  # Passes if the method send returns a true value.
@@ -914,42 +846,6 @@ EOT
914
846
  end
915
847
  end
916
848
 
917
- ##
918
- # Passes if +path+ exists.
919
- #
920
- # Example:
921
- # assert_path_exist("/tmp") # -> pass
922
- # assert_path_exist("/bin/sh") # -> pass
923
- # assert_path_exist("/nonexistent") # -> fail
924
- def assert_path_exist(path, message=nil)
925
- _wrap_assertion do
926
- failure_message = build_message(message,
927
- "<?> expected to exist",
928
- path)
929
- assert_block(failure_message) do
930
- File.exist?(path)
931
- end
932
- end
933
- end
934
-
935
- ##
936
- # Passes if +path+ doesn't exist.
937
- #
938
- # Example:
939
- # assert_path_not_exist("/nonexistent") # -> pass
940
- # assert_path_not_exist("/tmp") # -> fail
941
- # assert_path_not_exist("/bin/sh") # -> fail
942
- def assert_path_not_exist(path, message=nil)
943
- _wrap_assertion do
944
- failure_message = build_message(message,
945
- "<?> expected to not exist",
946
- path)
947
- assert_block(failure_message) do
948
- not File.exist?(path)
949
- end
950
- end
951
- end
952
-
953
849
  ##
954
850
  # Builds a failure message. +head+ is added before the +template+ and
955
851
  # +arguments+ replaces the '?'s positionally in the template.
@@ -99,7 +99,7 @@ module Test
99
99
 
100
100
  attr_reader :suite, :runner_options
101
101
  attr_accessor :filters, :to_run, :pattern, :exclude, :base, :workdir
102
- attr_accessor :color_scheme, :listeners
102
+ attr_accessor :color_scheme
103
103
  attr_writer :runner, :collector
104
104
 
105
105
  def initialize(standalone)
@@ -113,7 +113,6 @@ module Test
113
113
  @runner_options = {}
114
114
  @default_arguments = []
115
115
  @workdir = nil
116
- @listeners = []
117
116
  config_file = "test-unit.yml"
118
117
  if File.exist?(config_file)
119
118
  load_config(config_file)
@@ -301,8 +300,6 @@ module Test
301
300
  runner = @runner[self]
302
301
  return false if runner.nil?
303
302
  @runner_options[:color_scheme] ||= @color_scheme
304
- @runner_options[:listeners] ||= []
305
- @runner_options[:listeners].concat(@listeners)
306
303
  Dir.chdir(@workdir) if @workdir
307
304
  runner.run(suite, @runner_options).passed?
308
305
  end
@@ -345,7 +342,7 @@ module Test
345
342
  end
346
343
 
347
344
  def global_config_file
348
- File.expand_path("~/.test-unit.yml")
345
+ File.expand_path("~/.test-unit.xml")
349
346
  rescue ArgumentError
350
347
  nil
351
348
  end
@@ -95,7 +95,7 @@ module Test
95
95
 
96
96
  def collect_file(path, test_suites, already_gathered)
97
97
  @program_file ||= File.expand_path($0)
98
- return if @program_file == path.expand_path.to_s
98
+ return if @program_file == path.to_s
99
99
  add_load_path(path.expand_path.dirname) do
100
100
  require(path.to_s)
101
101
  find_test_cases(already_gathered).each do |test_case|
@@ -8,12 +8,8 @@ module Test
8
8
  class << self
9
9
  @@default = nil
10
10
  def default
11
- @@default ||= new("pass" =>
12
- Color.new("green", :foreground => false) +
13
- Color.new("white", :bold => true),
14
- "failure" =>
15
- Color.new("red", :foreground => false) +
16
- Color.new("white", :bold => true),
11
+ @@default ||= new("success" => Color.new("green", :bold => true),
12
+ "failure" => Color.new("red", :bold => true),
17
13
  "pending" => Color.new("magenta", :bold => true),
18
14
  "omission" => Color.new("blue", :bold => true),
19
15
  "notification" => Color.new("cyan", :bold => true),
@@ -1,11 +1,4 @@
1
1
  # port of Python's difflib.
2
- #
3
- # Copyright (c) 2001-2008 Python Software Foundation; All Rights Reserved
4
- # Copyright (c) 2008-2010 Kouhei Sutou; All Rights Reserved
5
- #
6
- # It is free software, and is distributed under the Ruby
7
- # license and/or the PSF license. See the COPYING file and
8
- # PSFL file.
9
2
 
10
3
  module Test
11
4
  module Unit
@@ -724,16 +717,7 @@ module Test
724
717
 
725
718
  def diff(differ_class, from, to, options={})
726
719
  differ = differ_class.new(from.split(/\r?\n/), to.split(/\r?\n/))
727
- lines = differ.diff(options)
728
- if Object.const_defined?(:EncodingError)
729
- begin
730
- lines.join("\n")
731
- rescue EncodingError
732
- lines.collect {|line| line.force_encoding("ASCII-8BIT")}.join("\n")
733
- end
734
- else
735
- lines.join("\n")
736
- end
720
+ differ.diff(options).join("\n")
737
721
  end
738
722
  end
739
723
  end
@@ -19,7 +19,6 @@ require 'test/unit/priority'
19
19
  require 'test/unit/testsuite'
20
20
  require 'test/unit/assertionfailederror'
21
21
  require 'test/unit/util/backtracefilter'
22
- require 'test/unit/util/output'
23
22
  require 'test/unit/util/method-owner-finder'
24
23
 
25
24
  module Test
@@ -83,7 +82,6 @@ module Test
83
82
  include Priority
84
83
  include Assertions
85
84
  include Util::BacktraceFilter
86
- include Util::Output
87
85
 
88
86
  STARTED = name + "::STARTED" # :nodoc:
89
87
  FINISHED = name + "::FINISHED" # :nodoc:
@@ -450,7 +448,6 @@ module Test
450
448
  notify("#{self.class}\##{@method_name} was redefined")
451
449
  end
452
450
  __send__(@method_name)
453
- add_pass
454
451
  end
455
452
 
456
453
  def handle_exception(exception)
@@ -474,10 +471,6 @@ module Test
474
471
  def add_assertion
475
472
  current_result.add_assertion
476
473
  end
477
-
478
- def add_pass
479
- current_result.add_pass
480
- end
481
474
  end
482
475
  end
483
476
  end
@@ -34,11 +34,11 @@ module Test
34
34
  CHANGED = "CHANGED"
35
35
  FAULT = "FAULT"
36
36
 
37
- attr_reader :run_count, :pass_count, :assertion_count, :faults
37
+ attr_reader :run_count, :assertion_count, :faults
38
38
 
39
39
  # Constructs a new, empty TestResult.
40
40
  def initialize
41
- @run_count, @pass_count, @assertion_count = 0, 0, 0
41
+ @run_count, @assertion_count = 0, 0
42
42
  @summary_generators = []
43
43
  @problem_checkers = []
44
44
  @faults = []
@@ -51,10 +51,6 @@ module Test
51
51
  notify_changed
52
52
  end
53
53
 
54
- def add_pass
55
- @pass_count += 1
56
- end
57
-
58
54
  # Records an individual assertion.
59
55
  def add_assertion
60
56
  @assertion_count += 1
@@ -69,25 +65,6 @@ module Test
69
65
  *@summary_generators.collect {|generator| send(generator)}].join(", ")
70
66
  end
71
67
 
72
- # Returnes a string that shows result status.
73
- def status
74
- if passed?
75
- if pending_count > 0
76
- "pending"
77
- elsif omission_count > 0
78
- "omission"
79
- elsif notification_count > 0
80
- "notification"
81
- else
82
- "pass"
83
- end
84
- elsif error_count > 0
85
- "error"
86
- elsif failure_count > 0
87
- "failure"
88
- end
89
- end
90
-
91
68
  def to_s
92
69
  summary
93
70
  end
@@ -98,15 +75,6 @@ module Test
98
75
  @problem_checkers.all? {|checker| not send(checker)}
99
76
  end
100
77
 
101
- def pass_percentage
102
- n_tests = @run_count - omission_count
103
- if n_tests.zero?
104
- 0
105
- else
106
- 100.0 * (@pass_count / n_tests.to_f)
107
- end
108
- end
109
-
110
78
  private
111
79
  def notify_changed
112
80
  notify_listeners(CHANGED, self)
@@ -38,14 +38,23 @@ module Test
38
38
  @progress_row_max = @options[:progress_row_max]
39
39
  @progress_row_max ||= guess_progress_row_max
40
40
  @already_outputted = false
41
+ @n_successes = 0
42
+ @n_omissions = 0
41
43
  @indent = 0
42
44
  @top_level = true
43
45
  @faults = []
44
46
  end
45
47
 
48
+ # Begins the test run.
49
+ def start
50
+ setup_mediator
51
+ attach_to_mediator
52
+ return start_mediator
53
+ end
54
+
46
55
  private
47
56
  def setup_mediator
48
- super
57
+ @mediator = create_mediator(@suite)
49
58
  output_setup_end
50
59
  end
51
60
 
@@ -55,6 +64,10 @@ module Test
55
64
  output("Loaded suite #{suite_name}")
56
65
  end
57
66
 
67
+ def create_mediator(suite)
68
+ return TestRunnerMediator.new(suite)
69
+ end
70
+
58
71
  def attach_to_mediator
59
72
  @mediator.add_listener(TestResult::FAULT, &method(:add_fault))
60
73
  @mediator.add_listener(TestRunnerMediator::STARTED, &method(:started))
@@ -65,9 +78,14 @@ module Test
65
78
  @mediator.add_listener(TestSuite::FINISHED, &method(:test_suite_finished))
66
79
  end
67
80
 
81
+ def start_mediator
82
+ return @mediator.run_suite
83
+ end
84
+
68
85
  def add_fault(fault)
69
86
  @faults << fault
70
87
  output_progress(fault.single_character_display, fault_color(fault))
88
+ @n_omissions += 1 if fault.is_a?(Omission)
71
89
  @already_outputted = true if fault.critical?
72
90
  end
73
91
 
@@ -91,7 +109,13 @@ module Test
91
109
  output("Finished in #{elapsed_time} seconds.")
92
110
  nl
93
111
  output(@result, result_color)
94
- output("%g%% passed" % @result.pass_percentage, result_color)
112
+ n_tests = @result.run_count - @n_omissions
113
+ if n_tests.zero?
114
+ pass_percentage = 0
115
+ else
116
+ pass_percentage = 100.0 * (@n_successes / n_tests.to_f)
117
+ end
118
+ output("%g%% passed" % pass_percentage, result_color)
95
119
  end
96
120
 
97
121
  def output_fault(fault)
@@ -135,7 +159,7 @@ module Test
135
159
  def output_fault_message(fault)
136
160
  output(fault.user_message) if fault.user_message
137
161
  output_single("<")
138
- output_single(fault.inspected_expected, color("pass"))
162
+ output_single(fault.inspected_expected, color("success"))
139
163
  output("> expected but was")
140
164
  output_single("<")
141
165
  output_single(fault.inspected_actual, color("failure"))
@@ -171,7 +195,8 @@ module Test
171
195
 
172
196
  def test_finished(name)
173
197
  unless @already_outputted
174
- output_progress(".", color("pass"))
198
+ @n_successes += 1
199
+ output_progress(".", color("success"))
175
200
  end
176
201
  @already_outputted = false
177
202
 
@@ -247,10 +272,7 @@ module Test
247
272
  end
248
273
 
249
274
  def color(name)
250
- _color = @color_scheme[name]
251
- _color ||= @color_scheme["success"] if name == "pass"
252
- _color ||= ColorScheme.default[name]
253
- _color
275
+ @color_scheme[name] || ColorScheme.default[name]
254
276
  end
255
277
 
256
278
  def fault_color(fault)
@@ -258,7 +280,21 @@ module Test
258
280
  end
259
281
 
260
282
  def result_color
261
- color(@result.status)
283
+ if @result.passed?
284
+ if @result.pending_count > 0
285
+ color("pending")
286
+ elsif @result.omission_count > 0
287
+ color("omission")
288
+ elsif @result.notification_count > 0
289
+ color("notification")
290
+ else
291
+ color("success")
292
+ end
293
+ elsif @result.error_count > 0
294
+ color("error")
295
+ elsif @result.failure_count > 0
296
+ color("failure")
297
+ end
262
298
  end
263
299
 
264
300
  def guess_color_availability