dither 0.0.9-java → 0.0.10-java

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: f7b9a6a3077ab3312022ea6a5e4d1bc0bb66c597
4
- data.tar.gz: 7de614370ed33a979147bc9249afa8cb4733f4fc
3
+ metadata.gz: f604e88d5d8eac1f835c1dda247b4fd0772002ea
4
+ data.tar.gz: 4dbd069d8a778df29828151bbb176093885f0f3b
5
5
  SHA512:
6
- metadata.gz: 6a127e281dee369094061ff7511282ee5de76c212e762afac1d91784696b92cc2c0b24b8bfde4c0dd0a7a583c6b7858488670acc870bb3b8c12a5542e0820dee
7
- data.tar.gz: 5bc538d91a0fc3d8ea851336bfd7abf3e98a3e84a3b0af1f159f3cd987d553a69f91a0982c2026fee4e3ea009a08d120ed66a916f012e46505ce1ffd592ce969
6
+ metadata.gz: b648cc3b440e1f2cd88dd47d85cd84e31a6755fe5c6912b11aa23c1fa405155c55a25a74f80e37b37a91ec5fe40e62abb74adba574eb87d86abe4968521adfd2
7
+ data.tar.gz: 20ef90a73de9b0f31bc43f3435c33f5202b1eef2aa8ecc7971eb42900dde8b4a1f243ff1dba5ede919cf5555a0f2e4d114bf5011d3793f15b845fa6df0273b08
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
data/lib/dither.jar CHANGED
Binary file
@@ -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: java
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