parameterized_testing 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1ae68ed889f8978f18434df681d55770938eca2ec6a68622daddcc623c110d0d
4
- data.tar.gz: be9768a8b3c3faaead709c2de45eea17aed72d8d5c56aca9e849ef1fb7d3e23f
3
+ metadata.gz: 1338c0068efe487efdfbebcd74a333b124ade9f650b32bb95bbafb89c58cd902
4
+ data.tar.gz: 7767f2a41cbe53eeffc2f20a28930eb323c13b7d7366c4ce10a37d64d66daf13
5
5
  SHA512:
6
- metadata.gz: d0aa5bae0c96de4f2e184ccf9e62f1df1b0aee661ad030aa72caa1814cad1fb1066a262e706e29d300c3e9350b2b6ec92c7cf19bb72eabd70bc0c5fca373ac59
7
- data.tar.gz: 2a091aa7e143f39ace374a1b1ce8c881284577449cda9737edd960b7763be98d4ce3534a3a66bc5eaa43dcc8aa4bd728dff6505d89ab7286baa654e1d23cc230
6
+ metadata.gz: 4c54e9ebf7945ffd4b721ff71085dbe25e2059e8424fb68d0c5b5786006a1f437769a467fa3409f8355784659e5e92fdf7add45d0f0b321ef7c773e73e052db0
7
+ data.tar.gz: 6e78907450a1555e590e19758c2387f1ca9ee5927133dd0c1f4002bbd5eddc15095c542a7c154dc45ae138b1bee92270025e87dc4283ff40c31c4cad40d3e754
@@ -1,13 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ParameterizedTesting
4
- # `Input` represents a single test case for a parameterized test.
4
+ # {Input} represents a single test case for a parameterized test.
5
5
  class Input
6
- attr_reader :index, :location, :initializer
6
+ # @return [Integer] index of the input
7
+ attr_reader :index
8
+ # @return [Thread::Backtrace::Location] the location of the <code>input { ... }</code> block
9
+ attr_reader :location
10
+ # @return [Proc] the block to compute the value of this input
11
+ attr_reader :initializer
7
12
 
8
- # @param index [Integer]
9
- # @param location [Thread::Backtrace::Location]
10
- # @param initializer [Proc]
11
13
  def initialize(index:, location:, initializer:)
12
14
  @index = index
13
15
  @location = location
@@ -20,9 +22,9 @@ module ParameterizedTesting
20
22
  "input[#{index}] at line #{location.lineno}"
21
23
  end
22
24
 
23
- # Collects all `input { ... }` in a block.
24
- # It is important to notice that `#parameterized` collects inputs by actually `instance_exec`uting
25
- # the block in a dedicated context in order to get the line number of input.
25
+ # Collects all <code>input { ... }</code> in a block.
26
+ # It is important to notice that this method collects inputs by actually <code>#instance_exec</code>uting
27
+ # the block in a dedicated context, in order to get the line number of input.
26
28
  # In this context, all other method calls are ignored.
27
29
  # @return [Array<Input>]
28
30
  def self.collect(&)
@@ -52,5 +54,6 @@ module ParameterizedTesting
52
54
  true
53
55
  end
54
56
  end
57
+ private_constant :Collector
55
58
  end
56
59
  end
@@ -1,11 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ParameterizedTesting
4
- # `Signature` represents the signature that each `Input` in the parameterized test must satisfy.
4
+ # {Signature} represents the signature that each {Input} in the parameterized test must satisfy.
5
5
  class Signature
6
+ # @return [Array<Symbol>] names of the parameters
6
7
  attr_reader :params
7
8
 
8
- # @param params [Array<Symbol>]
9
9
  def initialize(*params)
10
10
  raise ArgumentError, "parameter name must be a symbol" if params.any? { !_1.is_a?(Symbol) }
11
11
  raise ArgumentError, "parameter names must be unique" if params.uniq.size != params.size
@@ -13,13 +13,15 @@ module ParameterizedTesting
13
13
  @params = params
14
14
  end
15
15
 
16
- # @return [Symbol]
16
+ # @return [Symbol] a symbol for temporary variables that are unique for each signature
17
17
  def temporary_variable_name
18
18
  @temporary_variable_name ||= :"_input_#{params.join("_")}"
19
19
  end
20
20
 
21
- # @param value [Object]
22
- # @return [Hash<Symbol, Object>, nil] Mapping of parameters and values, or `nil` if mapping fails
21
+ # Compute the mapping between parameters and values, or <code>nil</code> if map fails.
22
+ # @param value [Object] An array with the same number of elements as the number of parameters,
23
+ # or a hash with each parameter name as a key. For other objects, map will fail.
24
+ # @return [Hash{Symbol => Object}, nil]
23
25
  def map(value)
24
26
  case value
25
27
  when Array
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ParameterizedTesting
4
- VERSION = "0.1.1"
4
+ VERSION = "0.2.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parameterized_testing
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - yubrot
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-05-08 00:00:00.000000000 Z
11
+ date: 2024-05-10 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Parameterized testing utility
14
14
  email: