dither 0.0.12-java → 0.0.13-java
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/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 +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 09eb8f9c172f2c8272ce2ecebfca696fb3f0bd96
|
4
|
+
data.tar.gz: 8fe24e47535703bfcdbf0d7b89d98057f5b7f58b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 264f35c17cd6cb3b438b16f203d6b1ecf080eff713311c20d84c0bb98205ebeb2a8732bd62753df961ee45c27bd95981f91cbea667ed990f109f113cc0a41cef
|
7
|
+
data.tar.gz: 70ab8e5682939a65c83eb0672de26fc8adfdee41207b7093e7815f7533508219cf1beb61544674f8cc45482a337eaa7a6c8ec66504e58c94be4e8981cf1ec3b9
|
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,14 +1,14 @@
|
|
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.13
|
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-09-
|
11
|
+
date: 2015-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -68,7 +68,6 @@ files:
|
|
68
68
|
- README.md
|
69
69
|
- Rakefile
|
70
70
|
- dither.gemspec
|
71
|
-
- lib/dither.jar
|
72
71
|
- lib/dither.rb
|
73
72
|
- lib/dither/ateg.rb
|
74
73
|
- lib/dither/ateg_pairwise.rb
|
@@ -84,6 +83,7 @@ files:
|
|
84
83
|
- spec/dither/chinese_postman_problem_spec.rb
|
85
84
|
- spec/dither/dither_spec.rb
|
86
85
|
- spec/spec_helper.rb
|
86
|
+
- lib/dither.jar
|
87
87
|
homepage: https://github.com/jesg/dither
|
88
88
|
licenses:
|
89
89
|
- MIT
|
@@ -104,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
104
|
version: '0'
|
105
105
|
requirements: []
|
106
106
|
rubyforge_project: dither
|
107
|
-
rubygems_version: 2.
|
107
|
+
rubygems_version: 2.1.9
|
108
108
|
signing_key:
|
109
109
|
specification_version: 4
|
110
110
|
summary: Collection of test generation strategies
|