dither 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9574ed6c2c949edec919c9278fb913429c877e77
4
- data.tar.gz: 801a8c1dfc56648d97d62b456037a1132e1b418b
3
+ metadata.gz: e6aeec317ee301c987fa9f850ae1d131ae2e5fc6
4
+ data.tar.gz: 5258de5745ae92ca80c7040911e7cf0d9a8156ff
5
5
  SHA512:
6
- metadata.gz: 63d2f2ab3792d6a711a96543328df659d84a43f83909d6a3f392f4ad77e00898a9d652fb8b36cf8c85c35e68d0de257f0f59bd22089c4ad1b0ea8c57da2e607b
7
- data.tar.gz: 5e997a1f04704678feb68b925a85bc82d66dcb91818c2ec22aba056bf3bbd2bfdbb1f3fd05219fe8f90cf125d9ce59157e56fd566ddfb781a884167d9ea72aee
6
+ metadata.gz: 771652b00d5078fcc02585ac67caa0c891081f6dd4ad75747cd08491242f8fd019030a07b4a2cfbc5154723c6dba8b54f8ab614bd043f6268b35d358a5b0068f
7
+ data.tar.gz: 08ab024560ddd9a7cde11f8ca7ae6ae77e69267e4478b7c6dad079ede63b626ed9b7a52d3ef0a0ab5053dc05ba6aaaa9b871c27542f804572a4482abca5ff9eb
data/README.md CHANGED
@@ -3,42 +3,32 @@ Collection of combinatorial test generation strategies.
3
3
 
4
4
  # Usage
5
5
 
6
- Use 2-Way IPOG
7
6
  ```ruby
8
7
  require 'dither'
9
8
 
10
- results = Dither.ipog([[true, false],
11
- [:cat, :dog, :mouse],
12
- (0...3).to_a])
13
-
14
- results.each { |a| puts "#{a}" }
15
-
16
- # output
17
- [true, :cat, 0]
18
- [true, :dog, 1]
19
- [true, :mouse, 2]
20
- [false, :cat, 0]
21
- [false, :dog, 1]
22
- [false, :mouse, 2]
23
- [true, :cat, 0]
24
- [true, :dog, 1]
25
- [true, :mouse, 2]
26
- ```
27
-
28
- Use 3-Way IPOG
29
- ```ruby
30
- require 'dither'
31
-
32
- results = Dither.ipog([[true, false],
33
- [true, false],
34
- [:cat, :dog, :mouse],
35
- (0...5).to_a], :t => 3)
36
-
37
- results.each { |a| puts "#{a}" }
9
+ # 2-way
10
+ Dither.ipog([[true, false],
11
+ [:cat, :dog, :mouse],
12
+ (0...3).to_a])
13
+ # 3-way
14
+ Dither.ipog([[true, false],
15
+ [true, false],
16
+ [:cat, :dog, :mouse],
17
+ (0...5).to_a],
18
+ :t => 3)
19
+
20
+ # 3-way with constraints and previously tested cases
21
+ Dither.ipog([[true, false],
22
+ [true, false],
23
+ [:cat, :dog, :mouse],
24
+ (0...5).to_a],
25
+ :t => 3,
26
+ :constraints => [
27
+ { 1 => 0, 2 => 0 }, # exclude true and cat
28
+ { 1 => 0, 2 => 1, 3 => 4 }, # exclude true :dog 4 combinations
29
+ ],
30
+ :previously_tested => [[true, true, :cat, 0]])
38
31
 
39
- # output
40
- [true, true, :cat, 0]
41
- ...
42
32
  ```
43
33
 
44
34
  # Note on Patches/Pull Requests
@@ -2,11 +2,11 @@
2
2
 
3
3
  module Dither
4
4
  module IPOGHelper
5
- attr_reader :params, :t, :constraints, :test_set, :orig_params, :unbound_param_pool
6
- private :params, :t, :constraints, :test_set, :orig_params, :unbound_param_pool
5
+ attr_reader :params, :t, :constraints, :test_set, :orig_params, :unbound_param_pool, :tested
6
+ private :params, :t, :constraints, :test_set, :orig_params, :unbound_param_pool, :tested
7
7
 
8
8
  def initialize(params, opts = {})
9
- init_params(params)
9
+ init_params(params, (opts[:previously_tested] || []))
10
10
  @t = opts[:t]
11
11
  unless opts[:constraints].nil?
12
12
  @constraints = opts[:constraints].map(&:to_a)
@@ -21,24 +21,40 @@ module Dither
21
21
  end
22
22
  end
23
23
 
24
- def init_params(user_params)
24
+ def init_params(user_params, previously_tested)
25
25
  tmp = []
26
26
  @input_params = user_params
27
27
  user_params.each_with_index { |e, i| tmp << [i, e] }
28
28
  @orig_params = tmp.sort_by { |a| a[1].length }
29
29
  .reverse!
30
30
 
31
+ orig_param_map = {}
31
32
  @map_to_orig_index = {}
32
33
  @orig_params.each_with_index do |e, i|
33
34
  @map_to_orig_index[i] = e[0]
35
+ orig_param_map[e[0]] = {}
34
36
  end
35
37
 
36
38
  @params = []
37
39
  @unbound_param_pool = []
38
40
  orig_params.each_with_index do |e, i|
39
- @params << (0...e[1].length).map { |j| Param.new(i, j) }
41
+ @params << (0...e[1].length).map do |j|
42
+ local_param = Param.new(i, j)
43
+ orig_param_map[e[0]][e[1][j]] = local_param
44
+ local_param
45
+ end
40
46
  @unbound_param_pool << UnboundParam.new(i)
41
47
  end
48
+
49
+ @tested = []
50
+ previously_tested.each do |a|
51
+ local_params = []
52
+ a.each_with_index do |e, i|
53
+ local_params << orig_param_map[i][e]
54
+ end
55
+ @tested << TestCase.create(params, unbound_param_pool, local_params)
56
+ end
57
+
42
58
  params
43
59
  end
44
60
 
@@ -88,7 +104,7 @@ module Dither
88
104
 
89
105
  result = products.map(&:flatten)
90
106
  .map { |a| TestCase.create(params, unbound_param_pool, a) }
91
- result
107
+ result.reject { |a| tested?(a) }
92
108
  end
93
109
 
94
110
  def comb_i(param_i)
@@ -101,11 +117,14 @@ module Dither
101
117
  result += a[1..-1]
102
118
  .inject((0...params[a[0]].length).map { |b| params[a[0]][b] }) { |p, i| p.product((0...params[i].length).to_a.map { |c| params[i][c] }) }
103
119
  .map(&:flatten)
104
- .map { |a| TestCase.create(params, unbound_param_pool, a) }
120
+ .map { |b| TestCase.create(params, unbound_param_pool, b) }
105
121
  end
106
- result.to_set
122
+ result.reject { |a| tested?(a) }.to_set
107
123
  end
108
124
 
125
+ def tested?(test_case)
126
+ @tested.any? { |a| test_case.subset?(a) }
127
+ end
109
128
 
110
129
  def fill_unbound(data)
111
130
  arr = Array.new(params.length)
@@ -134,6 +153,7 @@ module Dither
134
153
  end
135
154
 
136
155
  return nil if violates_constraints?(data)
156
+ return nil if tested?(data)
137
157
 
138
158
  arr
139
159
  end
@@ -7,7 +7,8 @@ module Dither
7
7
  com.github.jesg.dither.Dither.ipog(
8
8
  opts[:t].to_java(:int),
9
9
  params.map(&:to_java).to_java,
10
- constraints).to_a
10
+ constraints,
11
+ (opts[:previously_tested] || []).map(&:to_java).to_java).to_a
11
12
  rescue com.github.jesg.dither.DitherError => e
12
13
  raise Dither::Error.new(e.message)
13
14
  end
@@ -1,4 +1,4 @@
1
1
 
2
2
  module Dither
3
- VERSION = '0.0.9'
3
+ VERSION = '0.0.10'
4
4
  end
@@ -117,13 +117,13 @@ describe Dither do
117
117
  it 'can compute 3-way ipog with constraints' do
118
118
  params = [(0...2).to_a, (0...2).to_a, (0..3).to_a]
119
119
  expect(Dither.ipog(params, :t => 3,
120
- :constraints => [
121
- {0 => 0,
122
- 2 => 2},
123
- {0 => 0,
124
- 1 => 1,
125
- 2 => 0}
126
- ]).to_set).to eq([[0, 0, 0],
120
+ :constraints => [
121
+ {0 => 0,
122
+ 2 => 2},
123
+ {0 => 0,
124
+ 1 => 1,
125
+ 2 => 0}],
126
+ :previously_tested => [[0, 0, 0]]).to_set).to eq([
127
127
  [1, 0, 0],
128
128
  [1, 1, 0],
129
129
  [0, 0, 1],
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dither
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Gowan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-03 00:00:00.000000000 Z
11
+ date: 2015-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec