dither 0.2.0.rc4 → 0.2.0.rc5

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: c7e321420a2ba706f3f24e8e3d2191da27fce614
4
- data.tar.gz: 094b5152e0d320355a6e465210ecd9c267f0c6f8
3
+ metadata.gz: 1b89c1351cf61afc147849279c2ade1e8775e790
4
+ data.tar.gz: 6981167c11357bbb08893a777f025a60dc61d267
5
5
  SHA512:
6
- metadata.gz: 06c79a55ca5dcfbef0a287120bebf8aa6b558f079a6ba08551c2786abd5b15bf7b95059ec231a71dcbca736c514a6a5a29e0ce24d57c94c9210ebe280ffbe7b1
7
- data.tar.gz: 456b3f07542dbb81a580910b7468ff2f39cc48b422e0704defcf8473c84cf7edf0676920b79b54aab72e176100afee574a2f55ba9c335e216f85477d6ebd8d70
6
+ metadata.gz: 1a16ca2e817c805d52b2c5480e380a7021ffcb4d88116fa50a0580fa681319e70e8919c3048b367939a7770fd7a39ae408604a5ac87483e023ce3e6c6991bece
7
+ data.tar.gz: 1584706a3366471444bd61ab035b4ac5b277dc1268150141b1dcd755511082a815c23a211d5d9c2fe38c5563cb2be69f599f4c7f8c6aeb070b79ba70aceab2ca
data/dither.gemspec CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
24
24
  if RUBY_PLATFORM =~ /java/
25
25
  s.platform = "java"
26
26
  # compile dither-java on jdk 8
27
- files << "lib/dither-0.1.3.jar"
27
+ files << "lib/dither-0.1.4.jar"
28
28
  files << "lib/choco-solver-3.3.1-with-dependencies.jar"
29
29
  else
30
30
  s.add_dependency "ffi", "~> 1.0"
@@ -12,7 +12,7 @@
12
12
 
13
13
  namespace dither {
14
14
 
15
- SimpleConstraintHandler::SimpleConstraintHandler(std::vector<dval>& ranges, std::vector<std::vector<dval>>& pconstraints) : params(ranges) {
15
+ SimpleConstraintHandler::SimpleConstraintHandler(std::vector<dval>& ranges, std::vector<std::vector<dval>>& pconstraints) : params(ranges), scratch(ranges.size(), -1) {
16
16
  for(auto it = pconstraints.cbegin(); it != pconstraints.cend(); ++it) {
17
17
  std::vector<std::pair<std::size_t, dval>> constraint;
18
18
  std::size_t i = 0;
@@ -27,6 +27,14 @@ namespace dither {
27
27
  }
28
28
 
29
29
  bool SimpleConstraintHandler::violate_constraints(const dtest_case &test_case) {
30
+ if(violate_constraints_(test_case)) {
31
+ return true;
32
+ }
33
+ std::copy(test_case.cbegin(), test_case.cend(), scratch.begin());
34
+ return !ground(scratch);
35
+ }
36
+
37
+ inline bool SimpleConstraintHandler::violate_constraints_(const dtest_case &test_case) {
30
38
  for(auto constraint = constraints.cbegin(); constraint != constraints.cend(); ++constraint) {
31
39
  if(violate_constraint(test_case, *constraint)) {
32
40
  return true;
@@ -46,32 +54,14 @@ namespace dither {
46
54
  }
47
55
 
48
56
  bool SimpleConstraintHandler::violate_constraints(const std::vector<param> &test_case) {
49
- for(auto constraint = constraints.cbegin(); constraint != constraints.cend(); ++constraint) {
50
- if(violate_constraint(test_case, *constraint)) {
51
- return true;
52
- }
53
- }
54
- return false;
55
- }
56
-
57
- inline bool SimpleConstraintHandler::violate_constraint(const std::vector<param>& test_case, const std::vector<std::pair<std::size_t, dval>>& constraint) {
58
- if(test_case.size() < constraint.size()) {
59
- return false;
60
- }
61
-
62
- std::size_t count = 0;
63
- for(auto it = constraint.cbegin(); it != constraint.cend(); ++it) {
64
- for(auto iit = test_case.cbegin(); iit != test_case.cend(); ++iit) {
65
- if((*iit).first == (*it).first && (*iit).second == (*it).second) {
66
- count++;
67
- break;
68
- }
69
- }
57
+ std::fill(scratch.begin(), scratch.end(), -1);
58
+ for(auto p : test_case) {
59
+ scratch[p.first] = p.second;
70
60
  }
71
- if(count == constraint.size()) {
61
+ if(violate_constraints_(scratch)) {
72
62
  return true;
73
63
  }
74
- return false;
64
+ return !ground(scratch);
75
65
  }
76
66
 
77
67
  bool SimpleConstraintHandler::ground(dtest_case &test_case) {
@@ -84,9 +74,6 @@ namespace dither {
84
74
  indexes.push_back(i);
85
75
  }
86
76
  }
87
- if(indexes.size() == 0) {
88
- return true;
89
- }
90
77
  std::vector<dval> bound_values(indexes.size(), -1);
91
78
  i = 0;
92
79
 
@@ -95,7 +82,7 @@ LOOP:while(i < indexes.size()) {
95
82
  const dval max = params[indexes[i]];
96
83
  for(dval value = bound_values[i] + 1; value <= max; value++) {
97
84
  test_case[indexes[i]] = value;
98
- if(violate_constraints(test_case)) {
85
+ if(violate_constraints_(test_case)) {
99
86
  continue;
100
87
  }
101
88
  bound_values[i] = value;
@@ -22,9 +22,10 @@ namespace dither {
22
22
  protected:
23
23
  std::vector<std::vector<std::pair<std::size_t, dval>>> constraints;
24
24
  std::vector<dval> params;
25
+ std::vector<dval> scratch;
25
26
 
26
27
  inline bool violate_constraint(const dtest_case& test_case, const std::vector<std::pair<std::size_t, dval>>& constraint);
27
- inline bool violate_constraint(const std::vector<param>& test_case, const std::vector<std::pair<std::size_t, dval>>& constraint);
28
+ inline bool violate_constraints_(const dtest_case &test_case);
28
29
 
29
30
  public:
30
31
  SimpleConstraintHandler(std::vector<dval>& ranges, std::vector<std::vector<dval>>& pconstraints);
@@ -1,4 +1,4 @@
1
1
 
2
2
  module Dither
3
- VERSION = '0.2.0.rc4'
3
+ VERSION = '0.2.0.rc5'
4
4
  end
data/lib/dither.rb CHANGED
@@ -62,7 +62,7 @@ module Dither
62
62
  end
63
63
  arr = Array.new(params.size)
64
64
  (0...params.size).each do |i|
65
- arr[i] = params[i].find(test_case[i]).first
65
+ arr[i] = params[i].find_index(test_case[i])
66
66
  end
67
67
  tested_scratch.write_array_of_int(arr)
68
68
  Dither::API.dither_ipog_add_previously_tested(pointer, tested_scratch, params.size)
@@ -97,7 +97,7 @@ require 'dither/graph'
97
97
  if RUBY_PLATFORM =~ /java/
98
98
  require 'java'
99
99
  require 'choco-solver-3.3.1-with-dependencies.jar'
100
- require 'dither-0.1.3.jar'
100
+ require 'dither-0.1.4.jar'
101
101
 
102
102
  require 'dither/java_ext/dither'
103
103
  else
@@ -63,7 +63,7 @@ describe Dither do
63
63
  end
64
64
 
65
65
  it 'can compute 3-way ipog with constraints' do
66
- params = [(0...2).to_a, (0...2).to_a, (0..3).to_a]
66
+ params = [[:a, :b], (0...2).to_a, (0..3).to_a]
67
67
  results = Dither.ipog(params, :t => 3,
68
68
  :constraints => [
69
69
  {0 => 0,
@@ -71,16 +71,16 @@ describe Dither do
71
71
  {0 => 0,
72
72
  1 => 1,
73
73
  2 => 0}],
74
- :previously_tested => [[0, 0, 0]]
74
+ :previously_tested => [[:a, 0, 0]]
75
75
  )
76
76
  results.each do |result|
77
- expect(result[0] == 0 && result[1] == 1 && result[2] == 0).to be false
77
+ expect(result[0] == :a && result[1] == 1 && result[2] == 0).to be false
78
78
  end
79
79
  results.each do |result|
80
- expect(result[0] == 0 && result[1] == 2).to be false
80
+ expect(result[0] == :a && result[1] == 2).to be false
81
81
  end
82
82
  results.each do |result|
83
- expect(result[0] == 0 && result[1] == 0 && result[2] == 0).to be false
83
+ expect(result[0] == :a && result[1] == 0 && result[2] == 0).to be false
84
84
  end
85
85
  end
86
86
 
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.2.0.rc4
4
+ version: 0.2.0.rc5
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-12-10 00:00:00.000000000 Z
11
+ date: 2015-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -140,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
140
  version: 1.3.1
141
141
  requirements: []
142
142
  rubyforge_project: dither
143
- rubygems_version: 2.2.0
143
+ rubygems_version: 2.4.5.1
144
144
  signing_key:
145
145
  specification_version: 4
146
146
  summary: Collection of test generation strategies