dither 0.0.12 → 0.0.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +6 -2
- data/lib/dither/ateg_pairwise.rb +29 -17
- data/lib/dither/version.rb +1 -1
- data/spec/dither/dither_spec.rb +3 -1
- metadata +16 -24
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9829bb305420c2e6fb9cbd6da97d6acdd2bed25f
|
4
|
+
data.tar.gz: 6a8d1840275f51bc12248eeab6b1fc1b7f567373
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0953062cebd3d188febf90eec51f5007b64d37fb6ce37662dd0a9cde9cc41ba80457cbc9afbc3369ccfcb7ec251da6244390c2227da88bed64e7003cfed25bb3
|
7
|
+
data.tar.gz: edc6ad4837848718ee1ff1f3c030aa5dcfcf08f7aeca64d25d6eb6f7734afb779b49025c6a913185d5f8516ad9667adaf3ae8652fa6a1b616c080a8602233080
|
data/README.md
CHANGED
@@ -48,8 +48,12 @@ Dither.ateg([[true, false],
|
|
48
48
|
[:cat, :dog, :mouse],
|
49
49
|
(0...5).to_a],
|
50
50
|
:t => 3,
|
51
|
-
:seed => 0 # set the seed on the random number generator
|
52
|
-
|
51
|
+
:seed => 0, # set the seed on the random number generator
|
52
|
+
:constraints => [
|
53
|
+
{ 1 => 0, 2 => 0 }, # exclude true and cat
|
54
|
+
{ 1 => 0, 2 => 1, 3 => 4 }, # exclude true :dog 4 combinations
|
55
|
+
],
|
56
|
+
:previously_tested => [[true, true, :cat, 0]])
|
53
57
|
```
|
54
58
|
|
55
59
|
## Graph Models (Experimental)
|
data/lib/dither/ateg_pairwise.rb
CHANGED
@@ -13,19 +13,7 @@ module Dither
|
|
13
13
|
def in_test_case?(test_case)
|
14
14
|
self.all? { |pair| pair.j == test_case[pair.i] }
|
15
15
|
end
|
16
|
-
|
17
|
-
alias_method :orig_method_missing, :method_missing
|
18
|
-
|
19
|
-
def method_missing(method, *args, &block)
|
20
|
-
if method == :cached_hash
|
21
|
-
orig_hash = hash
|
22
|
-
self.class.define_method(:cached_hash) do
|
23
|
-
orig_hash
|
24
|
-
end
|
25
|
-
end
|
26
|
-
orig_method_missing(method, *args, &block)
|
27
|
-
end
|
28
|
-
end
|
16
|
+
end # Pairs
|
29
17
|
|
30
18
|
def initialize(params, opts = {})
|
31
19
|
|
@@ -39,16 +27,36 @@ module Dither
|
|
39
27
|
@scratch = Array.new(@n)
|
40
28
|
seed = opts[:seed] || Random.new.seed
|
41
29
|
@random = Random.new(seed)
|
42
|
-
|
30
|
+
|
43
31
|
@pair_cache = Array.new(params.length)
|
44
32
|
params.each_with_index do |param, i|
|
45
33
|
pair_cache[i] = (0...param.length).map { |j| Pair.new(i, j).freeze }
|
46
34
|
end
|
35
|
+
if opts[:previously_tested]
|
36
|
+
opts[:constraints] = [] unless opts[:constraints]
|
37
|
+
opts[:previously_tested].each do |a|
|
38
|
+
arr = []
|
39
|
+
a.each_with_index { |b,i| arr << [i, b] }
|
40
|
+
opts[:constraints] << Hash[arr]
|
41
|
+
end
|
42
|
+
end
|
43
|
+
@constraints = nil
|
44
|
+
if opts[:constraints]
|
45
|
+
@constraints = []
|
46
|
+
opts[:constraints].each do |a|
|
47
|
+
constraint = a.map { |k, v| pair_cache[k][v] }
|
48
|
+
constraint.extend(Pairs)
|
49
|
+
@constraints << constraint
|
50
|
+
end
|
51
|
+
end
|
47
52
|
@comb = []
|
48
53
|
@t = opts[:t]
|
49
54
|
(0...params.length).to_a.combination(t).each do |a|
|
50
|
-
|
51
|
-
|
55
|
+
car, *cdr = a.map { |b| pair_cache[b] }
|
56
|
+
tmp = car.product(*cdr)
|
57
|
+
tmp.each { |b| b.extend(Pairs) }
|
58
|
+
tmp.reject! { |b| constraints.any? { |c| c.all? { |d| b.include?(d)} } } if constraints
|
59
|
+
@comb.push(*tmp)
|
52
60
|
end
|
53
61
|
end
|
54
62
|
|
@@ -60,10 +68,14 @@ module Dither
|
|
60
68
|
|
61
69
|
def filter
|
62
70
|
return unless constraints
|
71
|
+
scratch.each_with_index do |e, i|
|
72
|
+
scratch[i] = nil if constraints.any? { |a| a.in_test_case?(e) }
|
73
|
+
end
|
63
74
|
end
|
64
75
|
|
65
76
|
def best_fit
|
66
|
-
|
77
|
+
max, _ = scratch.compact
|
78
|
+
.map { |a| [a, comb.count { |b| b.in_test_case?(a) }] }
|
67
79
|
.max { |a, b| a[1] <=> b[1] }
|
68
80
|
comb.delete_if { |a| a.in_test_case?(max) }
|
69
81
|
max
|
data/lib/dither/version.rb
CHANGED
data/spec/dither/dither_spec.rb
CHANGED
@@ -173,6 +173,8 @@ describe Dither do
|
|
173
173
|
|
174
174
|
it 'can run 4-way ateg with seed' do
|
175
175
|
params = [(0...2).to_a, (0...2).to_a, (0...2).to_a, (0..3).to_a]
|
176
|
-
expect(Dither.ateg(params, :t => 4, :seed => 0
|
176
|
+
expect(Dither.ateg(params, :t => 4, :seed => 0, :constraints => [
|
177
|
+
{ 0 => 1, 1 => 1, 2 => 1, 3 => 1 },
|
178
|
+
], :previously_tested => [[1,1,1,2]]).length).to eq 30
|
177
179
|
end
|
178
180
|
end
|
metadata
CHANGED
@@ -1,62 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dither
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.13
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Jason Gowan
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-19 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rspec
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- - ~>
|
17
|
+
- - "~>"
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '3.2'
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- - ~>
|
24
|
+
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '3.2'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rake
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- - ~>
|
31
|
+
- - "~>"
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: 0.9.2
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- - ~>
|
38
|
+
- - "~>"
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: 0.9.2
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: coveralls
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - ">="
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '0'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - ">="
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '0'
|
62
55
|
description: Efficient test generation strategies
|
@@ -66,9 +59,9 @@ executables: []
|
|
66
59
|
extensions: []
|
67
60
|
extra_rdoc_files: []
|
68
61
|
files:
|
69
|
-
- .gitignore
|
70
|
-
- .ruby-version
|
71
|
-
- .travis.yml
|
62
|
+
- ".gitignore"
|
63
|
+
- ".ruby-version"
|
64
|
+
- ".travis.yml"
|
72
65
|
- Gemfile
|
73
66
|
- Gemfile.lock
|
74
67
|
- LICENSE
|
@@ -93,27 +86,26 @@ files:
|
|
93
86
|
homepage: https://github.com/jesg/dither
|
94
87
|
licenses:
|
95
88
|
- MIT
|
89
|
+
metadata: {}
|
96
90
|
post_install_message:
|
97
91
|
rdoc_options: []
|
98
92
|
require_paths:
|
99
93
|
- lib
|
100
94
|
required_ruby_version: !ruby/object:Gem::Requirement
|
101
|
-
none: false
|
102
95
|
requirements:
|
103
|
-
- -
|
96
|
+
- - ">="
|
104
97
|
- !ruby/object:Gem::Version
|
105
98
|
version: '0'
|
106
99
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
|
-
none: false
|
108
100
|
requirements:
|
109
|
-
- -
|
101
|
+
- - ">="
|
110
102
|
- !ruby/object:Gem::Version
|
111
103
|
version: '0'
|
112
104
|
requirements: []
|
113
105
|
rubyforge_project: dither
|
114
|
-
rubygems_version:
|
106
|
+
rubygems_version: 2.2.0
|
115
107
|
signing_key:
|
116
|
-
specification_version:
|
108
|
+
specification_version: 4
|
117
109
|
summary: Collection of test generation strategies
|
118
110
|
test_files:
|
119
111
|
- spec/dither/chinese_postman_problem_spec.rb
|