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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1338c0068efe487efdfbebcd74a333b124ade9f650b32bb95bbafb89c58cd902
|
4
|
+
data.tar.gz: 7767f2a41cbe53eeffc2f20a28930eb323c13b7d7366c4ce10a37d64d66daf13
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
#
|
4
|
+
# {Input} represents a single test case for a parameterized test.
|
5
5
|
class Input
|
6
|
-
|
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
|
24
|
-
# It is important to notice that
|
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
|
-
#
|
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
|
-
#
|
22
|
-
# @
|
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
|
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.
|
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-
|
11
|
+
date: 2024-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Parameterized testing utility
|
14
14
|
email:
|