dither 0.0.1 → 0.0.2
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 +4 -4
- data/Gemfile.lock +1 -0
- data/lib/dither/ipog.rb +37 -14
- data/lib/dither/version.rb +1 -1
- data/lib/dither.rb +2 -2
- data/spec/dither/dither_spec.rb +63 -15
- metadata +19 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b1a1dd2b611fde7eca72c6f9a9b859e8b38d15eb
|
4
|
+
data.tar.gz: f6c9f9b7783fc64ad0603bdcf0cadd1d56729e50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8fb409da9c6ba2699ce18c64ab4d18ec4ab6a31644323f66af0f38466dfe8810cf689f34f1ff001dec747d6475658439f466adea0adaa3c57c222d5eb09b8dd
|
7
|
+
data.tar.gz: 341b6f7240542c9697e3f18876fe1619ad39f2c53f4155e1149cfe77f5fa05804eb59b61c06d14bc0139331416f25033e1f08c2021088e329fb5a2283a95ee18
|
data/Gemfile.lock
CHANGED
data/lib/dither/ipog.rb
CHANGED
@@ -1,12 +1,18 @@
|
|
1
1
|
|
2
2
|
module Dither
|
3
3
|
class IPOG
|
4
|
-
attr_reader :params, :t, :prng
|
5
|
-
private :params, :t, :prng
|
4
|
+
attr_reader :params, :t, :prng, :constraints
|
5
|
+
private :params, :t, :prng, :constraints
|
6
6
|
|
7
|
-
def initialize(params, t)
|
7
|
+
def initialize(params, t, opts = {})
|
8
8
|
@params = params
|
9
9
|
@t = t
|
10
|
+
@constraints = opts[:constraints]
|
11
|
+
unless constraints.nil?
|
12
|
+
@constraints = constraints.map(&:to_a)
|
13
|
+
.map { |a| a.map { |b| Param.new(*b) } }
|
14
|
+
.map(&:to_set)
|
15
|
+
end
|
10
16
|
@prng = Random.new
|
11
17
|
raise 't must be >= 2' if t < 2
|
12
18
|
raise 't must be <= params.length' if t > params.length
|
@@ -16,14 +22,16 @@ module Dither
|
|
16
22
|
end
|
17
23
|
|
18
24
|
def run
|
19
|
-
ts = comb
|
25
|
+
ts = comb
|
20
26
|
(t...params.length).each do |i|
|
21
|
-
ts = ts.zip(params[i].
|
27
|
+
ts = ts.zip((0...params[i].length).cycle)
|
28
|
+
.map { |a| a[0] << Param.new(i, a[1]) }
|
29
|
+
.delete_if { |a| violates_constraints?(a) }
|
22
30
|
|
23
31
|
comb_i(i).each do |a|
|
24
|
-
|
32
|
+
next if violates_constraints?(a)
|
33
|
+
next if ts.any? { |test| a.subset?(test) }
|
25
34
|
|
26
|
-
next if in_ts
|
27
35
|
existing_test = false
|
28
36
|
ts.select { |c| c.length <= i }
|
29
37
|
.each do |b|
|
@@ -42,15 +50,25 @@ module Dither
|
|
42
50
|
end
|
43
51
|
|
44
52
|
ts.map { |a| fill_unbound(a) }
|
53
|
+
.delete_if(&:nil?)
|
45
54
|
end
|
46
55
|
|
47
|
-
def
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
56
|
+
def violates_constraints?(params)
|
57
|
+
return false if constraints.nil?
|
58
|
+
constraints.any? { |b| b.subset?(params) }
|
59
|
+
end
|
60
|
+
|
61
|
+
def comb
|
62
|
+
ranges = (0...t).to_a.inject([]) do |a, i|
|
63
|
+
a << (0...params[i].length).map { |j| Param.new(i, j) }
|
64
|
+
end
|
65
|
+
|
66
|
+
products = ranges[1..-1].inject(ranges[0]) do |a, b|
|
67
|
+
a = a.product(b)
|
53
68
|
end
|
69
|
+
|
70
|
+
products.map(&:flatten)
|
71
|
+
.map(&:to_set)
|
54
72
|
end
|
55
73
|
|
56
74
|
def comb_i(param_i)
|
@@ -77,8 +95,13 @@ module Dither
|
|
77
95
|
end
|
78
96
|
|
79
97
|
arr.each_with_index do |e, i|
|
80
|
-
|
98
|
+
if e.nil?
|
99
|
+
j = prng.rand(0...params[i].length)
|
100
|
+
arr[i] = params[i][j]
|
101
|
+
data << Param.new(i,j)
|
102
|
+
end
|
81
103
|
end
|
104
|
+
return nil if violates_constraints?(data)
|
82
105
|
arr
|
83
106
|
end
|
84
107
|
|
data/lib/dither/version.rb
CHANGED
data/lib/dither.rb
CHANGED
data/spec/dither/dither_spec.rb
CHANGED
@@ -14,6 +14,19 @@ describe Dither do
|
|
14
14
|
expect { Dither.all_pairs([[], []], 2) }.to raise_error('param length must be > 1')
|
15
15
|
end
|
16
16
|
|
17
|
+
it 'can compute 2-way ipog using symbols' do
|
18
|
+
params = [[:a, :b, :c], [:d, :e, :f], [:h, :i]]
|
19
|
+
expect(Dither.all_pairs(params)).to eq([[:a, :d, :h],
|
20
|
+
[:a, :e, :i],
|
21
|
+
[:a, :f, :h],
|
22
|
+
[:b, :d, :i],
|
23
|
+
[:b, :e, :h],
|
24
|
+
[:b, :f, :i],
|
25
|
+
[:c, :d, :h],
|
26
|
+
[:c, :e, :i],
|
27
|
+
[:c, :f, :h]])
|
28
|
+
end
|
29
|
+
|
17
30
|
it 'can compute 2-way ipog' do
|
18
31
|
params = [(0...2).to_a, (0..3).to_a]
|
19
32
|
expect(Dither.all_pairs(params)).to eq([
|
@@ -46,20 +59,55 @@ describe Dither do
|
|
46
59
|
[1, 1, 1],
|
47
60
|
[1, 1, 2],
|
48
61
|
[1, 1, 3]])
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
[
|
61
|
-
[
|
62
|
-
[
|
63
|
-
[
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'can compute 3-way ipog with constraints' do
|
65
|
+
params = [(0...2).to_a, (0...2).to_a, (0..3).to_a]
|
66
|
+
expect(Dither.all_pairs(params, 3,
|
67
|
+
:constraints => [
|
68
|
+
{0 => 0,
|
69
|
+
2 => 2},
|
70
|
+
{0 => 0,
|
71
|
+
1 => 1,
|
72
|
+
2 => 0}
|
73
|
+
])).to eq([[0, 0, 0],
|
74
|
+
[0, 0, 1],
|
75
|
+
[0, 0, 3],
|
76
|
+
[0, 1, 1],
|
77
|
+
[0, 1, 3],
|
78
|
+
[1, 0, 0],
|
79
|
+
[1, 0, 1],
|
80
|
+
[1, 0, 2],
|
81
|
+
[1, 0, 3],
|
82
|
+
[1, 1, 0],
|
83
|
+
[1, 1, 1],
|
84
|
+
[1, 1, 2],
|
85
|
+
[1, 1, 3]])
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'another 3-way ipog with constraints' do
|
89
|
+
params = [(0...2).to_a, (0...2).to_a, (0...2).to_a, (0..3).to_a]
|
90
|
+
expect(Dither.all_pairs(params, 3,
|
91
|
+
:constraints => [
|
92
|
+
{0 => 0,
|
93
|
+
2 => 2},
|
94
|
+
{0 => 0,
|
95
|
+
1 => 1,
|
96
|
+
2 => 0}
|
97
|
+
])).to eq([[0, 0, 0, 0],
|
98
|
+
[0, 0, 1, 1],
|
99
|
+
[0, 1, 1, 3],
|
100
|
+
[1, 0, 0, 0],
|
101
|
+
[1, 0, 1, 1],
|
102
|
+
[1, 1, 0, 2],
|
103
|
+
[1, 1, 1, 3],
|
104
|
+
[0, 0, 0, 2],
|
105
|
+
[0, 0, 0, 3],
|
106
|
+
[0, 1, 1, 0],
|
107
|
+
[0, 1, 1, 2],
|
108
|
+
[1, 0, 1, 2],
|
109
|
+
[1, 0, 0, 3],
|
110
|
+
[1, 1, 1, 0],
|
111
|
+
[1, 1, 0, 1]])
|
64
112
|
end
|
65
113
|
end
|
metadata
CHANGED
@@ -1,41 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dither
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Gowan
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05-
|
11
|
+
date: 2015-05-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
14
15
|
requirement: !ruby/object:Gem::Requirement
|
15
16
|
requirements:
|
16
|
-
- - ~>
|
17
|
+
- - "~>"
|
17
18
|
- !ruby/object:Gem::Version
|
18
19
|
version: '3.2'
|
19
|
-
name: rspec
|
20
|
-
prerelease: false
|
21
20
|
type: :development
|
21
|
+
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '3.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
28
29
|
requirement: !ruby/object:Gem::Requirement
|
29
30
|
requirements:
|
30
|
-
- - ~>
|
31
|
+
- - "~>"
|
31
32
|
- !ruby/object:Gem::Version
|
32
33
|
version: 0.9.2
|
33
|
-
name: rake
|
34
|
-
prerelease: false
|
35
34
|
type: :development
|
35
|
+
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 0.9.2
|
41
41
|
description: Efficient test generation strategies
|
@@ -45,9 +45,9 @@ executables: []
|
|
45
45
|
extensions: []
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
|
-
- .gitignore
|
49
|
-
- .ruby-version
|
50
|
-
- .travis.yml
|
48
|
+
- ".gitignore"
|
49
|
+
- ".ruby-version"
|
50
|
+
- ".travis.yml"
|
51
51
|
- Gemfile
|
52
52
|
- Gemfile.lock
|
53
53
|
- LICENSE
|
@@ -64,24 +64,24 @@ homepage: https://github.com/jesg/dither
|
|
64
64
|
licenses:
|
65
65
|
- MIT
|
66
66
|
metadata: {}
|
67
|
-
post_install_message:
|
67
|
+
post_install_message:
|
68
68
|
rdoc_options: []
|
69
69
|
require_paths:
|
70
70
|
- lib
|
71
71
|
required_ruby_version: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
77
|
requirements:
|
78
|
-
- -
|
78
|
+
- - ">="
|
79
79
|
- !ruby/object:Gem::Version
|
80
80
|
version: '0'
|
81
81
|
requirements: []
|
82
82
|
rubyforge_project: dither
|
83
|
-
rubygems_version: 2.
|
84
|
-
signing_key:
|
83
|
+
rubygems_version: 2.2.0
|
84
|
+
signing_key:
|
85
85
|
specification_version: 4
|
86
86
|
summary: Collection of test generation strategies
|
87
87
|
test_files:
|