Hello community,

here is the log from the commit of package rubygem-test-unit for 
openSUSE:Factory checked in at 2019-01-21 10:25:36
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/rubygem-test-unit (Old)
 and      /work/SRC/openSUSE:Factory/.rubygem-test-unit.new.28833 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "rubygem-test-unit"

Mon Jan 21 10:25:36 2019 rev:33 rq:656372 version:3.2.9

Changes:
--------
--- /work/SRC/openSUSE:Factory/rubygem-test-unit/rubygem-test-unit.changes      
2018-05-16 18:44:49.896272965 +0200
+++ 
/work/SRC/openSUSE:Factory/.rubygem-test-unit.new.28833/rubygem-test-unit.changes
   2019-01-21 10:25:38.137732021 +0100
@@ -1,0 +2,77 @@
+Sat Dec  8 16:32:16 UTC 2018 - Stephan Kulow <co...@suse.com>
+
+- updated to version 3.2.9
+ see installed news.md
+
+  ## 3.2.9 - 2018-12-01 {#version-3-2-9}
+  
+  ### Improvements
+  
+    * Added support for data generation by method. `data_#{test_name}`
+      is called to generate data for `test_name` test.
+  
+    * Added support for data matrix generation.
+  
+      Example:
+  
+      ```ruby
+      data(:a, [0, 1, 2])
+      data(:b, [:x, :y])
+      def test_data(data)
+      end
+      ```
+  
+      This example generates the following data matrix:
+  
+        * label: `"a: 0, b: :x"`, data: `{a: 0, b: :x}`
+        * label: `"a: 0, b: :y"`, data: `{a: 0, b: :y}`
+        * label: `"a: 1, b: :x"`, data: `{a: 1, b: :x}`
+        * label: `"a: 1, b: :y"`, data: `{a: 1, b: :y}`
+        * label: `"a: 2, b: :x"`, data: `{a: 2, b: :x}`
+        * label: `"a: 2, b: :y"`, data: `{a: 2, b: :y}`
+  
+    * Added `Test::Unit::TestCase#data` that returns the current data.
+  
+    * Added support for using test method that doesn't have no
+      parameters as data driven test.
+  
+      Example:
+  
+      ```ruby
+      data("label", :value)
+      def test_data # Available since this release
+        p data # :value
+      end
+      ```
+  
+    * Added support for `:keep` option to `Test::Unit::TestCase.data`.
+  
+    * Added support for `:group` option to
+      `Test::Unit::TestCase.data`. It's useful to generate multiple data
+      matrix groups.
+  
+      ```ruby
+      # Group1
+      data(:a, [0, 1, 2], group: :g1)
+      data(:b, [:x, :y], group: :g1)
+      # Group2
+      data(:a, [:x, :y], group: :g2)
+      data(:c, [-1, -2], group: :g2)
+      def test_data(data)
+      end
+      ```
+  
+      This example generates the following data matrix:
+  
+        * label: `"group: :g1, a: 0, b: :x"`, data: `{a: 0, b: :x}`
+        * label: `"group: :g1, a: 0, b: :y"`, data: `{a: 0, b: :y}`
+        * label: `"group: :g1, a: 1, b: :x"`, data: `{a: 1, b: :x}`
+        * label: `"group: :g1, a: 1, b: :y"`, data: `{a: 1, b: :y}`
+        * label: `"group: :g1, a: 2, b: :x"`, data: `{a: 2, b: :x}`
+        * label: `"group: :g1, a: 2, b: :y"`, data: `{a: 2, b: :y}`
+        * label: `"group: :g2, a: :x, b: -1"`, data: `{a: :x, b: -1}`
+        * label: `"group: :g2, a: :x, b: -2"`, data: `{a: :x, b: -2}`
+        * label: `"group: :g2, a: :y, b: -1"`, data: `{a: :y, b: -1}`
+        * label: `"group: :g2, a: :y, b: -2"`, data: `{a: :y, b: -2}`
+
+-------------------------------------------------------------------

Old:
----
  test-unit-3.2.8.gem

New:
----
  test-unit-3.2.9.gem

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ rubygem-test-unit.spec ++++++
--- /var/tmp/diff_new_pack.fwFpwk/_old  2019-01-21 10:25:39.385730649 +0100
+++ /var/tmp/diff_new_pack.fwFpwk/_new  2019-01-21 10:25:39.385730649 +0100
@@ -12,7 +12,7 @@
 # license that conforms to the Open Source Definition (Version 1.9)
 # published by the Open Source Initiative.
 
-# Please submit bugfixes or comments via http://bugs.opensuse.org/
+# Please submit bugfixes or comments via https://bugs.opensuse.org/
 #
 
 
@@ -24,7 +24,7 @@
 #
 
 Name:           rubygem-test-unit
-Version:        3.2.8
+Version:        3.2.9
 Release:        0
 %define mod_name test-unit
 %define mod_full_name %{mod_name}-%{version}

++++++ test-unit-3.2.8.gem -> test-unit-3.2.9.gem ++++++
Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/doc/text/news.md new/doc/text/news.md
--- old/doc/text/news.md        2018-05-13 04:09:16.000000000 +0200
+++ new/doc/text/news.md        2018-12-01 08:57:50.000000000 +0100
@@ -1,5 +1,76 @@
 # News
 
+## 3.2.9 - 2018-12-01 {#version-3-2-9}
+
+### Improvements
+
+  * Added support for data generation by method. `data_#{test_name}`
+    is called to generate data for `test_name` test.
+
+  * Added support for data matrix generation.
+
+    Example:
+
+    ```ruby
+    data(:a, [0, 1, 2])
+    data(:b, [:x, :y])
+    def test_data(data)
+    end
+    ```
+
+    This example generates the following data matrix:
+
+      * label: `"a: 0, b: :x"`, data: `{a: 0, b: :x}`
+      * label: `"a: 0, b: :y"`, data: `{a: 0, b: :y}`
+      * label: `"a: 1, b: :x"`, data: `{a: 1, b: :x}`
+      * label: `"a: 1, b: :y"`, data: `{a: 1, b: :y}`
+      * label: `"a: 2, b: :x"`, data: `{a: 2, b: :x}`
+      * label: `"a: 2, b: :y"`, data: `{a: 2, b: :y}`
+
+  * Added `Test::Unit::TestCase#data` that returns the current data.
+
+  * Added support for using test method that doesn't have no
+    parameters as data driven test.
+
+    Example:
+
+    ```ruby
+    data("label", :value)
+    def test_data # Available since this release
+      p data # :value
+    end
+    ```
+
+  * Added support for `:keep` option to `Test::Unit::TestCase.data`.
+
+  * Added support for `:group` option to
+    `Test::Unit::TestCase.data`. It's useful to generate multiple data
+    matrix groups.
+
+    ```ruby
+    # Group1
+    data(:a, [0, 1, 2], group: :g1)
+    data(:b, [:x, :y], group: :g1)
+    # Group2
+    data(:a, [:x, :y], group: :g2)
+    data(:c, [-1, -2], group: :g2)
+    def test_data(data)
+    end
+    ```
+
+    This example generates the following data matrix:
+
+      * label: `"group: :g1, a: 0, b: :x"`, data: `{a: 0, b: :x}`
+      * label: `"group: :g1, a: 0, b: :y"`, data: `{a: 0, b: :y}`
+      * label: `"group: :g1, a: 1, b: :x"`, data: `{a: 1, b: :x}`
+      * label: `"group: :g1, a: 1, b: :y"`, data: `{a: 1, b: :y}`
+      * label: `"group: :g1, a: 2, b: :x"`, data: `{a: 2, b: :x}`
+      * label: `"group: :g1, a: 2, b: :y"`, data: `{a: 2, b: :y}`
+      * label: `"group: :g2, a: :x, b: -1"`, data: `{a: :x, b: -1}`
+      * label: `"group: :g2, a: :x, b: -2"`, data: `{a: :x, b: -2}`
+      * label: `"group: :g2, a: :y, b: -1"`, data: `{a: :y, b: -1}`
+      * label: `"group: :g2, a: :y, b: -2"`, data: `{a: :y, b: -2}`
+
 ## 3.2.8 - 2018-05-13 {#version-3-2-8}
 
 ### Improvements
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/test/unit/attribute.rb 
new/lib/test/unit/attribute.rb
--- old/lib/test/unit/attribute.rb      2018-05-13 04:09:16.000000000 +0200
+++ new/lib/test/unit/attribute.rb      2018-12-01 08:57:50.000000000 +0100
@@ -43,7 +43,11 @@
           kept_attributes = StringifyKeyHash.new
           @current_attributes.each do |attribute_name, attribute|
             attributes[attribute_name] = attribute[:value]
-            kept_attributes[attribute_name] = attribute if attribute[:keep]
+            if attribute[:keep]
+              keep_hook = attribute[:keep_hook]
+              attribute = keep_hook.call(attribute) if keep_hook
+              kept_attributes[attribute_name] = attribute
+            end
           end
           set_attributes(name, attributes)
           @current_attributes = kept_attributes
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/test/unit/data-sets.rb 
new/lib/test/unit/data-sets.rb
--- old/lib/test/unit/data-sets.rb      1970-01-01 01:00:00.000000000 +0100
+++ new/lib/test/unit/data-sets.rb      2018-12-01 08:57:50.000000000 +0100
@@ -0,0 +1,116 @@
+module Test
+  module Unit
+    class DataSets
+      def initialize
+        @variables = []
+        @procs = []
+        @value_sets = []
+      end
+
+      def add(data_set, options=nil)
+        options ||= {}
+        if data_set.respond_to?(:call)
+          @procs << [data_set, options]
+        elsif data_set.is_a?(Array)
+          @variables << [data_set, options]
+        else
+          @value_sets << [data_set, options]
+        end
+      end
+
+      def <<(data_set)
+        add(data_set)
+      end
+
+      def keep
+        new_data_sets = self.class.new
+        all_data_sets = Enumerator.new do |yielder|
+          block = lambda do |(data_set, options)|
+            yielder << [data_set, options]
+          end
+          @procs.each(&block)
+          @variables.each(&block)
+          @value_sets.each(&block)
+        end
+        all_data_sets.each do |data_set, options|
+          next if options.nil?
+          next unless options[:keep]
+          new_data_sets.add(data_set, options)
+        end
+        new_data_sets
+      end
+
+      def each
+        variables = @variables
+        value_sets = @value_sets
+        @procs.each do |proc, options|
+          data_set = proc.call
+          case data_set
+          when Array
+            variables += [[data_set, options]]
+          else
+            value_sets += [[data_set, options]]
+          end
+        end
+
+        value_sets.each do |values, _options|
+          values.each do |label, data|
+            yield(label, data)
+          end
+        end
+
+        each_pattern(variables) do |label, data|
+          yield(label, data)
+        end
+      end
+
+      def ==(other)
+        @variables == other.instance_variable_get(:@variables) and
+          @procs == other.instance_variable_get(:@procs) and
+          @value_sets == other.instance_variable_get(:@value_sets)
+      end
+
+      def eql?(other)
+        self == other
+      end
+
+      def hash
+        [@variables, @procs, @value_sets].hash
+      end
+
+      private
+      def each_pattern(variables)
+        grouped_variables = variables.group_by do |_, options|
+          options[:group]
+        end
+        grouped_variables.each do |group, variables|
+          each_raw_pattern(variables) do |cell|
+            label = String.new
+            label << "group: #{group.inspect}" unless group.nil?
+            data = {}
+            cell.each do |variable, pattern|
+              label << ", " unless label.empty?
+              label << "#{variable}: #{pattern.inspect}"
+              data[variable] = pattern
+            end
+            yield(label, data)
+          end
+        end
+      end
+
+      def each_raw_pattern(variables, &block)
+        return if variables.empty?
+
+        sorted_variables = variables.sort_by do |(variable, _), _|
+          variable
+        end
+        all_patterns = sorted_variables.collect do |(variable, patterns), _|
+          patterns.collect do |pattern|
+            [variable, pattern]
+          end
+        end
+        all_patterns[0].product(*all_patterns[1..-1], &block)
+      end
+    end
+  end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/test/unit/data.rb new/lib/test/unit/data.rb
--- old/lib/test/unit/data.rb   2018-05-13 04:09:16.000000000 +0200
+++ new/lib/test/unit/data.rb   2018-12-01 08:57:50.000000000 +0100
@@ -1,3 +1,5 @@
+require "test/unit/data-sets"
+
 module Test
   module Unit
     module Data
@@ -12,9 +14,12 @@
         #
         # Define test data in the test code.
         #
-        # @overload data(label, data)
+        # @overload data(label, data, options={})
         #   @param [String] label specify test case name.
         #   @param data specify test data.
+        #   @param [Hash] options specify options.
+        #   @option options [Boolean] :keep whether or not to use
+        #     this data in the following test methods
         #
         #   @example data(label, data)
         #     data("empty string", [true, ""])
@@ -24,9 +29,39 @@
         #       assert_equal(expected, target.empty?)
         #     end
         #
-        # @overload data(data_set)
+        # @overload data(variable, patterns, options={})
+        #   @param [Symbol] variable specify test pattern variable name.
+        #   @param [Array] patterns specify test patterns for the variable.
+        #   @param [Hash] options specify options.
+        #   @option options [Boolean] :keep whether or not to use
+        #     this data in the following test methods
+        #   @option options [Object] :group the test pattern group.
+        #     Test matrix is generated for each test pattern group separately.
+        #
+        #   @example data(variable, patterns)
+        #     data(:x, [1, 2, 3])
+        #     data(:y, ["a", "b"])
+        #     def test_patterns(data)
+        #       # 3 * 2 times executed
+        #       # 3: the number of patterns of :x
+        #       # 2: the number of patterns of :y
+        #       p data
+        #         # => {:x => 1, :y => "a"}
+        #         # => {:x => 1, :y => "b"}
+        #         # => {:x => 2, :y => "a"}
+        #         # => {:x => 2, :y => "b"}
+        #         # => {:x => 3, :y => "a"}
+        #         # => {:x => 3, :y => "b"}
+        #     end
+        #
+        #   Generates test matrix from variable and patterns pairs.
+        #
+        # @overload data(data_set, options={})
         #   @param [Hash] data_set specify test data as a Hash that
         #     key is test label and value is test data.
+        #   @param [Hash] options specify options.
+        #   @option options [Boolean] :keep whether or not to use
+        #     this data in the following test methods
         #
         #   @example data(data_set)
         #     data("empty string" => [true, ""],
@@ -36,9 +71,12 @@
         #       assert_equal(expected, target.empty?)
         #     end
         #
-        # @overload data(&block)
-        #   @yieldreturn [Hash] return test data set as a Hash that
-        #     key is test label and value is test data.
+        # @overload data(options={}, &block)
+        #   @param [Hash] options specify options.
+        #   @option options [Boolean] :keep whether or not to use
+        #     this data in the following test methods
+        #   @yieldreturn [Hash<String, Object>] return test data set
+        #     as a Hash that key is test label and value is test data.
         #
         #   @example data(&block)
         #     data do
@@ -52,22 +90,93 @@
         #       assert_equal(expected, target.empty?)
         #     end
         #
+        # @overload data(options={}, &block)
+        #   @param [Hash] options specify options.
+        #   @option options [Boolean] :keep whether or not to use
+        #     this data in the following test methods
+        #   @yieldreturn [Array<Symbol, Array>] return test data set
+        #     as an Array of variable and patterns.
+        #
+        #   @example data(&block)
+        #     data do
+        #       patterns = 3.times.to_a
+        #       [:x, patterns]
+        #     end
+        #     data do
+        #       patterns = []
+        #       character = "a"
+        #       2.times.each do
+        #         patterns << character
+        #         character = character.succ
+        #       end
+        #       [:y, patterns]
+        #     end
+        #     def test_patterns(data)
+        #       # 3 * 2 times executed
+        #       # 3: the number of patterns of :x
+        #       # 2: the number of patterns of :y
+        #       p data
+        #         # => {:x => 0, :y => "a"}
+        #         # => {:x => 0, :y => "b"}
+        #         # => {:x => 1, :y => "a"}
+        #         # => {:x => 1, :y => "b"}
+        #         # => {:x => 2, :y => "a"}
+        #         # => {:x => 2, :y => "b"}
+        #     end
+        #
+        #   Generates test matrix from variable and patterns pairs.
+        #
         def data(*arguments, &block)
+          options = nil
           n_arguments = arguments.size
           case n_arguments
           when 0
             raise ArgumentError, "no block is given" unless block_given?
             data_set = block
           when 1
-            data_set = arguments[0]
+            if block_given?
+              data_set = block
+              options = arguments[1]
+            else
+              data_set = arguments[0]
+            end
           when 2
-            data_set = {arguments[0] => arguments[1]}
+            case arguments[0]
+            when String
+              data_set = {arguments[0] => arguments[1]}
+            when Hash
+              data_set = arguments[0]
+              options = arguments[1]
+            else
+              variable = arguments[0]
+              patterns = arguments[1]
+              data_set = [variable, patterns]
+            end
+          when 3
+            case arguments[0]
+            when String
+              data_set = {arguments[0] => arguments[1]}
+              options = arguments[2]
+            else
+              variable = arguments[0]
+              patterns = arguments[1]
+              data_set = [variable, patterns]
+              options = arguments[2]
+            end
           else
-            message = "wrong number arguments(#{n_arguments} for 1..2)"
+            message = "wrong number arguments(#{n_arguments} for 0..3)"
             raise ArgumentError, message
           end
-          current_data = current_attribute(:data)[:value] || []
-          attribute(:data, current_data + [data_set])
+          options ||= {}
+          data_sets = current_attribute(:data)[:value] || DataSets.new
+          data_sets.add(data_set, options)
+          if options[:keep]
+            keep_hook = lambda do |attr|
+              attr.merge(value: attr[:value].keep)
+            end
+            options = options.merge(keep_hook: keep_hook)
+          end
+          attribute(:data, data_sets, options)
         end
 
         # This method provides Data-Driven-Test functionality.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/test/unit/test-suite-creator.rb 
new/lib/test/unit/test-suite-creator.rb
--- old/lib/test/unit/test-suite-creator.rb     2018-05-13 04:09:16.000000000 
+0200
+++ new/lib/test/unit/test-suite-creator.rb     2018-12-01 08:57:51.000000000 
+0100
@@ -5,6 +5,8 @@
 #   * Copyright (c) 2011 Kouhei Sutou <tt><k...@clear-code.com></tt>
 # License:: Ruby license.
 
+require "test/unit/data-sets"
+
 module Test
   module Unit
     class TestSuiteCreator # :nodoc:
@@ -22,15 +24,11 @@
       def create
         suite = TestSuite.new(@test_case.name, @test_case)
         collect_test_names.each do |test_name|
-          data_sets = @test_case.find_attribute(test_name, :data,
-                                                :recursive => false)
+          data_sets = extract_data_sets(test_name)
           if data_sets
-            data_sets.each do |data_set|
-              data_set = data_set.call if data_set.respond_to?(:call)
-              data_set.each do |label, data|
-                append_test(suite, test_name) do |test|
-                  test.assign_test_data(label, data)
-                end
+            data_sets.each do |label, data|
+              append_test(suite, test_name) do |test|
+                test.assign_test_data(label, data)
               end
             end
           else
@@ -42,6 +40,22 @@
       end
 
       private
+      def extract_data_sets(test_name)
+        data_sets = @test_case.find_attribute(test_name,
+                                              :data,
+                                              :recursive => false)
+        data_method_name = "data_#{test_name}"
+        test = @test_case.new(test_name)
+        if test.respond_to?(data_method_name)
+          data_method = test.method(data_method_name)
+          if data_method.arity <= 0
+            data_sets ||= DataSets.new
+            data_sets << data_method
+          end
+        end
+        data_sets
+      end
+
       def append_test(suite, test_name)
         test = @test_case.new(test_name)
         yield(test) if block_given?
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/test/unit/testcase.rb 
new/lib/test/unit/testcase.rb
--- old/lib/test/unit/testcase.rb       2018-05-13 04:09:16.000000000 +0200
+++ new/lib/test/unit/testcase.rb       2018-12-01 08:57:51.000000000 +0100
@@ -678,6 +678,12 @@
         @internal_data.test_data_label
       end
 
+      # Returns test data for the test. If the test isn't associated
+      # with any test data, it returns +nil+.
+      def data
+        @internal_data.test_data
+      end
+
       # Returns a human-readable name for the specific test that
       # this instance of TestCase represents.
       def name
@@ -779,15 +785,11 @@
         end
         if @internal_data.have_test_data?
           test_method = method(@method_name)
-          if test_method.arity == 1 or test_method.arity < 0
-            __send__(@method_name, @internal_data.test_data)
+          arity = test_method.arity
+          if arity.zero?
+            __send__(@method_name)
           else
-            locations = self.class.find_locations(:method_name => @method_name)
-            backtrace = locations.collect do |location|
-              "#{location[:path]}:#{location[:line]}"
-            end
-            notify("<#{signature}> misses a parameter to take test data",
-                   :backtrace => backtrace)
+            __send__(@method_name, @internal_data.test_data)
           end
         else
           __send__(@method_name)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/test/unit/version.rb new/lib/test/unit/version.rb
--- old/lib/test/unit/version.rb        2018-05-13 04:09:16.000000000 +0200
+++ new/lib/test/unit/version.rb        2018-12-01 08:57:51.000000000 +0100
@@ -1,5 +1,5 @@
 module Test
   module Unit
-    VERSION = "3.2.8"
+    VERSION = "3.2.9"
   end
 end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/metadata new/metadata
--- old/metadata        2018-05-13 04:09:15.000000000 +0200
+++ new/metadata        2018-12-01 08:57:50.000000000 +0100
@@ -1,7 +1,7 @@
 --- !ruby/object:Gem::Specification
 name: test-unit
 version: !ruby/object:Gem::Version
-  version: 3.2.8
+  version: 3.2.9
 platform: ruby
 authors:
 - Kouhei Sutou
@@ -9,7 +9,7 @@
 autorequire: 
 bindir: bin
 cert_chain: []
-date: 2018-05-13 00:00:00.000000000 Z
+date: 2018-12-01 00:00:00.000000000 Z
 dependencies:
 - !ruby/object:Gem::Dependency
   name: power_assert
@@ -133,6 +133,7 @@
 - lib/test/unit/collector/xml.rb
 - lib/test/unit/color-scheme.rb
 - lib/test/unit/color.rb
+- lib/test/unit/data-sets.rb
 - lib/test/unit/data.rb
 - lib/test/unit/diff.rb
 - lib/test/unit/error.rb
@@ -231,7 +232,7 @@
       version: '0'
 requirements: []
 rubyforge_project: 
-rubygems_version: 2.7.6
+rubygems_version: 3.0.0.beta2
 signing_key: 
 specification_version: 4
 summary: An xUnit family unit testing framework for Ruby.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/test/test-data.rb new/test/test-data.rb
--- old/test/test-data.rb       2018-05-13 04:09:16.000000000 +0200
+++ new/test/test-data.rb       2018-12-01 08:57:51.000000000 +0100
@@ -46,7 +46,7 @@
     end
 
     class TestDynamicDataSet < TestCalc
-      data do
+      DATA_PROC = lambda do
         data_set = {}
         data_set["positive positive"] = {
           :expected => 3,
@@ -60,7 +60,8 @@
         }
         data_set
       end
-      DATA_PROC = current_attribute(:data)[:value].first
+
+      data(&DATA_PROC)
       def test_plus(data)
         assert_equal(data[:expected],
                      @calc.plus(data[:augend], data[:addend]))
@@ -90,6 +91,48 @@
         end
       end
     end
+
+    class TestMethod < TestCalc
+      def data_test_plus
+        {
+          "positive positive" => {:expected => 4, :augend => 3, :addend => 1},
+          "positive negative" => {:expected => -1, :augend => 1, :addend => 
-2},
+        }
+      end
+
+      def test_plus(data)
+        assert_equal(data[:expected],
+                     @calc.plus(data[:augend], data[:addend]))
+      end
+    end
+
+    class TestPatterns < TestCalc
+      data(:x, [-1, 1, 0])
+      data(:y, [-100, 100])
+      data(:z, ["a", "b", "c"])
+      def test_use_data(data)
+      end
+    end
+
+    class TestPatternsKeep < TestCalc
+      data(:x, [-1, 1, 0], keep: true)
+      data(:y, [-100, 100])
+      data(:z, ["a", "b", "c"], keep: true)
+      def test_use_data(data)
+      end
+
+      def test_use_data_keep(data)
+      end
+    end
+
+    class TestPatternsGroup < TestCalc
+      data(:a, [-1, 1, 0], group: 1)
+      data(:b, [:a, :b], group: 1)
+      data(:x, [2, 9], group: :z)
+      data(:y, ["a", "b", "c"], group: :z)
+      def test_use_data(data)
+      end
+    end
   end
 
   def setup
@@ -109,64 +152,90 @@
   data("data set",
        {
          :test_case => TestCalc::TestDataSet,
-         :data_set => [{
-                         "positive positive" => {
-                           :expected => 4,
-                           :augend => 3,
-                           :addend => 1,
-                         },
-                         "positive negative" => {
-                           :expected => -1,
-                           :augend => 1,
-                           :addend => -2,
-                         },
-                       }],
+         :data_sets => [
+           {
+             "positive positive" => {
+               :expected => 4,
+               :augend => 3,
+               :addend => 1,
+             },
+             "positive negative" => {
+               :expected => -1,
+               :augend => 1,
+               :addend => -2,
+             },
+           },
+         ],
        })
   data("n-data",
        {
          :test_case => TestCalc::TestNData,
-         :data_set => [{
-                         "positive positive" => {
-                           :expected => 4,
-                           :augend => 3,
-                           :addend => 1,
-                         },
-                       },
-                       {
-                         "positive negative" => {
-                           :expected => -1,
-                           :augend => 1,
-                           :addend => -2,
-                         },
-                       }],
+         :data_sets => [
+           {
+             "positive positive" => {
+               :expected => 4,
+               :augend => 3,
+               :addend => 1,
+             },
+           },
+           {
+             "positive negative" => {
+               :expected => -1,
+               :augend => 1,
+               :addend => -2,
+             },
+           },
+         ],
        })
   data("dynamic-data-set",
        {
          :test_case => TestCalc::TestDynamicDataSet,
-         :data_set => [TestCalc::TestDynamicDataSet::DATA_PROC],
+         :data_sets => [TestCalc::TestDynamicDataSet::DATA_PROC],
        })
   data("load-data-set",
        {
          :test_case => TestCalc::TestLoadDataSet,
-         :data_set => [{
-                         "positive positive" => {
-                           "expected" => 4,
-                           "augend" => 3,
-                           "addend" => 1,
-                         },
-                       },
-                       {
-                         "positive negative" => {
-                           "expected" => -1,
-                           "augend" => 1,
-                           "addend" => -2,
-                         },
-                       }],
-         })
+         :data_sets => [
+           {
+             "positive positive" => {
+               "expected" => 4,
+               "augend" => 3,
+               "addend" => 1,
+             },
+           },
+           {
+             "positive negative" => {
+               "expected" => -1,
+               "augend" => 1,
+               "addend" => -2,
+             },
+           },
+         ],
+       })
   def test_data(data)
     test_plus = data[:test_case].new("test_plus")
-    assert_equal(data[:data_set], test_plus[:data])
-    assert_not_nil(data[:data_set])
+    data_sets = Test::Unit::DataSets.new
+    data[:data_sets].each do |data_set|
+      data_sets.add(data_set)
+    end
+    assert_equal(data_sets, test_plus[:data])
+  end
+
+  def test_data_patterns
+    test = TestCalc::TestPatterns.new("test_use_data")
+    data_sets = Test::Unit::DataSets.new
+    data_sets << [:x, [-1, 1, 0]]
+    data_sets << [:y, [-100, 100]]
+    data_sets << [:z, ["a", "b", "c"]]
+    assert_equal(data_sets, test[:data])
+  end
+
+  def test_data_patterns_keep
+    test = TestCalc::TestPatternsKeep.new("test_use_data_keep")
+    data_sets = Test::Unit::DataSets.new
+    data_sets.add([:x, [-1, 1, 0]], {keep: true})
+    data_sets.add([:z, ["a", "b", "c"]], {keep: true})
+    assert_equal(data_sets, test[:data])
   end
 
   data("data set"         => TestCalc::TestDataSet,
@@ -180,11 +249,58 @@
                  suite.tests.collect {|test| test.name}.sort)
   end
 
+  def test_suite_patterns
+    test_case = TestCalc::TestPatterns
+    suite = test_case.suite
+    assert_equal([
+                   "test_use_data[x: -1, y: -100, z: 
\"a\"](#{test_case.name})",
+                   "test_use_data[x: -1, y: -100, z: 
\"b\"](#{test_case.name})",
+                   "test_use_data[x: -1, y: -100, z: 
\"c\"](#{test_case.name})",
+                   "test_use_data[x: -1, y: 100, z: \"a\"](#{test_case.name})",
+                   "test_use_data[x: -1, y: 100, z: \"b\"](#{test_case.name})",
+                   "test_use_data[x: -1, y: 100, z: \"c\"](#{test_case.name})",
+                   "test_use_data[x: 0, y: -100, z: \"a\"](#{test_case.name})",
+                   "test_use_data[x: 0, y: -100, z: \"b\"](#{test_case.name})",
+                   "test_use_data[x: 0, y: -100, z: \"c\"](#{test_case.name})",
+                   "test_use_data[x: 0, y: 100, z: \"a\"](#{test_case.name})",
+                   "test_use_data[x: 0, y: 100, z: \"b\"](#{test_case.name})",
+                   "test_use_data[x: 0, y: 100, z: \"c\"](#{test_case.name})",
+                   "test_use_data[x: 1, y: -100, z: \"a\"](#{test_case.name})",
+                   "test_use_data[x: 1, y: -100, z: \"b\"](#{test_case.name})",
+                   "test_use_data[x: 1, y: -100, z: \"c\"](#{test_case.name})",
+                   "test_use_data[x: 1, y: 100, z: \"a\"](#{test_case.name})",
+                   "test_use_data[x: 1, y: 100, z: \"b\"](#{test_case.name})",
+                   "test_use_data[x: 1, y: 100, z: \"c\"](#{test_case.name})",
+                 ],
+                 suite.tests.collect {|test| test.name}.sort)
+  end
+
+  def test_suite_patterns_group
+    test_case = TestCalc::TestPatternsGroup
+    suite = test_case.suite
+    assert_equal([
+                   "test_use_data[group: 1, a: -1, b: :a](#{test_case.name})",
+                   "test_use_data[group: 1, a: -1, b: :b](#{test_case.name})",
+                   "test_use_data[group: 1, a: 0, b: :a](#{test_case.name})",
+                   "test_use_data[group: 1, a: 0, b: :b](#{test_case.name})",
+                   "test_use_data[group: 1, a: 1, b: :a](#{test_case.name})",
+                   "test_use_data[group: 1, a: 1, b: :b](#{test_case.name})",
+                   "test_use_data[group: :z, x: 2, y: 
\"a\"](#{test_case.name})",
+                   "test_use_data[group: :z, x: 2, y: 
\"b\"](#{test_case.name})",
+                   "test_use_data[group: :z, x: 2, y: 
\"c\"](#{test_case.name})",
+                   "test_use_data[group: :z, x: 9, y: 
\"a\"](#{test_case.name})",
+                   "test_use_data[group: :z, x: 9, y: 
\"b\"](#{test_case.name})",
+                   "test_use_data[group: :z, x: 9, y: 
\"c\"](#{test_case.name})",
+                 ],
+                 suite.tests.collect {|test| test.name}.sort)
+  end
+
   data("data set"         => TestCalc::TestDataSet,
        "n-data"           => TestCalc::TestNData,
        "dynamic-data-set" => TestCalc::TestDynamicDataSet,
        "load-data-set"    => TestCalc::TestLoadDataSet,
-       "superclass"       => TestCalc::TestSuperclass)
+       "superclass"       => TestCalc::TestSuperclass,
+       "method"           => TestCalc::TestMethod)
   def test_run(test_case)
     result = _run_test(test_case)
     assert_equal("2 tests, 2 assertions, 0 failures, 0 errors, 0 pendings, " \
@@ -249,20 +365,20 @@
              "tsv" => "header.tsv")
         def test_normal(file_name)
           self.class.load_data(fixture_file_path(file_name))
-          assert_equal([
-                         {
-                           "empty string" => {
-                             "expected" => true,
-                             "target"   => ""
-                           }
-                         },
-                         {
-                           "plain string" => {
-                             "expected" => false,
-                             "target"   => "hello"
-                           }
-                         }
-                       ],
+          data_sets = Test::Unit::DataSets.new
+          data_sets << {
+            "empty string" => {
+              "expected" => true,
+              "target"   => ""
+            }
+          }
+          data_sets << {
+            "plain string" => {
+              "expected" => false,
+              "target"   => "hello"
+            }
+          }
+          assert_equal(data_sets,
                        self.class.current_attribute(:data)[:value])
         end
 
@@ -270,20 +386,20 @@
              "tsv" => "header-label.tsv")
         def test_label(file_name)
           self.class.load_data(fixture_file_path(file_name))
-          assert_equal([
-                         {
-                           "upper case" => {
-                             "expected" => "HELLO",
-                             "label"    => "HELLO"
-                           }
-                         },
-                         {
-                           "lower case" => {
-                             "expected" => "Hello",
-                             "label"    => "hello"
-                           }
-                         }
-                       ],
+          data_sets = Test::Unit::DataSets.new
+          data_sets << {
+            "upper case" => {
+              "expected" => "HELLO",
+              "label"    => "HELLO"
+            }
+          }
+          data_sets << {
+            "lower case" => {
+              "expected" => "Hello",
+              "label"    => "hello"
+            }
+          }
+          assert_equal(data_sets,
                        self.class.current_attribute(:data)[:value])
         end
       end
@@ -292,10 +408,10 @@
            "tsv" => "no-header.tsv")
       def test_without_header(file_name)
         self.class.load_data(fixture_file_path(file_name))
-        assert_equal([
-                       {"empty string" => [true, ""]},
-                       {"plain string" => [false, "hello"]}
-                     ],
+        data_sets = Test::Unit::DataSets.new
+        data_sets << {"empty string" => [true, ""]}
+        data_sets << {"plain string" => [false, "hello"]}
+        assert_equal(data_sets,
                      self.class.current_attribute(:data)[:value])
       end
     end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/test/test-test-case.rb new/test/test-test-case.rb
--- old/test/test-test-case.rb  2018-05-13 04:09:16.000000000 +0200
+++ new/test/test-test-case.rb  2018-12-01 08:57:52.000000000 +0100
@@ -546,6 +546,7 @@
         test_case = Class.new(TestCase) do
           data("label" => "value")
           def test_without_parameter
+            assert_equal("value", data)
           end
         end
 
@@ -554,8 +555,8 @@
                      suite.tests.collect {|test| test.method_name})
         result = TestResult.new
         suite.run(result) {}
-        assert_equal("1 tests, 0 assertions, 0 failures, " +
-                     "0 errors, 0 pendings, 0 omissions, 1 notifications",
+        assert_equal("1 tests, 1 assertions, 0 failures, " +
+                     "0 errors, 0 pendings, 0 omissions, 0 notifications",
                      result.summary)
       end
 


Reply via email to