hypothesis-specs 0.3.0 → 0.7.0

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
  SHA256:
3
- metadata.gz: 77c742dcfc65dfcab8e0eac24498eff24b10461abf17f502961ac9fc30bd1810
4
- data.tar.gz: 6a73fbe38f860e2b2b9f9fd68cde16a33657eb05d0117a3a2e78ab5dfa8e2226
3
+ metadata.gz: 3b45927dcad934674c4626592af6a233a6a203e780bdf452a707393236f58539
4
+ data.tar.gz: 5a64bedf3e625575165520dc367241a3cd7e1355d43bf8d511fea96add531a1c
5
5
  SHA512:
6
- metadata.gz: 8b0da0f3b0820c93b32af05eb040fd6d88e86748a8fd99c38609a204944a84b773f2e53bf757c103c0c0f5a6e66097fd65c839ca95c0ec8360c9ac1ae1814153
7
- data.tar.gz: 0a2d28a1fbc0e3b87fa96452a6028d0f0f8e00d223eb1440f1daf86eb3e40ec33c25c21222c9a2fc585d053dcca63e9de6d9d0e96ca7eb277e452e0baa77c2ac
6
+ metadata.gz: 725eaad1d61b219f67bd0cd3eaad7510952e7dcaf820e6b53346bb7d132b51198246e4ad6856a89ff1fafecd5c3eefbfd563008367208e1595c6bede67ba4444
7
+ data.tar.gz: c25843124c218554533f0bba87632d43ee642652d36410067e213a63f5e5c8a592c0ce3082ceb25fe93e6cf178be58c54819c91d49eab92e533f18d7b73936d2
data/CHANGELOG.md CHANGED
@@ -1,3 +1,39 @@
1
+ # Hypothesis for Ruby 0.7.0 (2021-03-12)
2
+
3
+ Moves rake from being a a runtime dependency to being a development dependency. Rake is used to run tests but is not required for consumers of hypothesis-ruby.
4
+
5
+ # Hypothesis for Ruby 0.6.1 (2021-02-01)
6
+
7
+ This patch contains minor performance improvements for `HypothesisCoreIntegers` class instantiation.
8
+
9
+ # Hypothesis for Ruby 0.6.0 (2021-01-27)
10
+
11
+ Adds support for skipping shrinking. While shrinking is extremely helpful and important in general, it has the potential to be quite time consuming. It can be useful to observe a raw failure before choosing to allow the engine to try to shrink. [hypothesis-python](https://hypothesis.readthedocs.io/en/latest/settings.html#phases) already provides the ability to skip shrinking, so there is precedent for this being useful. While `hypothesis-ruby` does not have the concept of other "Phases" yet, we can still start off the API by using this concept.
12
+
13
+ Usage:
14
+
15
+ ```
16
+ hypothesis(phases: Phase.excluding(:shrink)) do
17
+ # Failures here will be displayed directly and shrinking will be avoided
18
+ end
19
+ ```
20
+
21
+ # Hypothesis for Ruby 0.5.0 (2021-01-25)
22
+
23
+ Adds support for skipping shrinking. While shrinking is extremely helpful and important in general, it has the potential to be quite time consuming. It can be useful to observe a raw failure before choosing to allow the engine to try to shrink. [hypothesis-python](https://hypothesis.readthedocs.io/en/latest/settings.html#phases) already provides the ability to skip shrinking, so there is precedent for this being useful. While `hypothesis-ruby` does not have the concept of other "Phases" yet, we can still start off the API by using this concept.
24
+
25
+ Usage:
26
+
27
+ ```
28
+ hypothesis(phases: Phase.excluding(:shrink)) do
29
+ # Failures here will be displayed directly and shrinking will be avoided
30
+ end
31
+ ```
32
+
33
+ # Hypothesis for Ruby 0.4.0 (2021-01-12)
34
+
35
+ This removes hypothesis-ruby's dependence on RSpec. Now, it can be used with any Ruby test runner.
36
+
1
37
  # Hypothesis for Ruby 0.3.0 (2021-01-08)
2
38
 
3
39
  This release converts Hypothesis for Ruby to use [RuTie](https://github.com/danielpclark/rutie)
data/Cargo.toml CHANGED
@@ -1,7 +1,7 @@
1
1
  [package]
2
2
  name = "hypothesis-ruby"
3
3
  version = "0.1.0"
4
- authors = ["David R. MacIver <david@drmaciver.com>", "Alex Wiesberger <alex.m.weisberger@gmail.com>"]
4
+ authors = ["David R. MacIver <david@drmaciver.com>", "Alex Weisberger <alex.m.weisberger@gmail.com>"]
5
5
 
6
6
  [lib]
7
7
  name="hypothesis_ruby_core"
@@ -11,4 +11,4 @@ crate-type = ["cdylib"]
11
11
  rutie = {version="0.8.1"}
12
12
  lazy_static = "1.4.0"
13
13
  rand = '0.3'
14
- conjecture = '0.4.0'
14
+ conjecture = '0.7.0'
data/README.markdown CHANGED
@@ -71,7 +71,7 @@ Right now this is really more to allow you to try it out and provide feedback th
71
71
  The more feedback we get, the sooner it will get there!
72
72
 
73
73
  Note that in order to use Hypothesis for Ruby, you will need a rust toolchain installed.
74
- Please go to [https://www.rustup.rs](https://www.rustup.rs) and follow the instructions if you do not already have one.
74
+ Please go to [https://www.rustup.rs](https://www.rustup.rs) and follow the instructions if you do not already have one. You will most likely need to compile your Ruby executable with the `--enable-shared` option. See [here](https://github.com/danielpclark/rutie#dynamic-vs-static-builds).
75
75
 
76
76
  ## Project Status
77
77
 
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ require 'date'
5
5
  require 'open3'
6
6
 
7
7
  task :build do
8
- system('cargo build --release')
8
+ sh('cargo build --release')
9
9
  end
10
10
 
11
11
  begin
@@ -20,9 +20,25 @@ begin
20
20
  end
21
21
 
22
22
  task test: %i[build spec minitests]
23
+ task rspec: %i[build spec]
24
+ task minitest: %i[build without_rspec] do
25
+ begin
26
+ Rake::Task['minitests'].execute
27
+ ensure
28
+ Rake::Task['with_rspec'].execute
29
+ end
30
+ end
23
31
  rescue LoadError
24
32
  end
25
33
 
34
+ task :without_rspec do
35
+ sh('bundle config set without rspec')
36
+ end
37
+
38
+ task :with_rspec do
39
+ sh('bundle config unset without')
40
+ end
41
+
26
42
  def rubocop(fix:)
27
43
  sh "bundle exec rubocop #{'-a' if fix} lib spec minitests " \
28
44
  'Rakefile hypothesis-specs.gemspec'
data/lib/hypothesis.rb CHANGED
@@ -7,6 +7,28 @@ require_relative 'hypothesis/testcase'
7
7
  require_relative 'hypothesis/engine'
8
8
  require_relative 'hypothesis/world'
9
9
 
10
+ module Phase
11
+ SHRINK = :shrink
12
+
13
+ module_function
14
+
15
+ def all
16
+ [SHRINK]
17
+ end
18
+
19
+ def excluding(*phases)
20
+ unknown_phases = phases.reject { |phase| Phase.all.include?(phase) }
21
+ unless unknown_phases.empty?
22
+ raise(
23
+ ArgumentError,
24
+ "Attempting to exclude unknown phases: #{unknown_phases}"
25
+ )
26
+ end
27
+
28
+ all - phases
29
+ end
30
+ end
31
+
10
32
  # This is the main module for using Hypothesis.
11
33
  # It is expected that you will include this in your
12
34
  # tests, but its methods are also available on the
@@ -201,7 +223,12 @@ module Hypothesis
201
223
  # should store previously failing test cases. If it is nil, Hypothesis
202
224
  # will use a default of .hypothesis/examples in the current directory.
203
225
  # May also be set to false to disable the database functionality.
204
- def hypothesis(max_valid_test_cases: 200, database: nil, &block)
226
+ def hypothesis(
227
+ max_valid_test_cases: 200,
228
+ phases: Phase.all,
229
+ database: nil,
230
+ &block
231
+ )
205
232
  unless World.current_engine.nil?
206
233
  raise UsageError, 'Cannot nest hypothesis calls'
207
234
  end
@@ -210,6 +237,7 @@ module Hypothesis
210
237
  World.current_engine = Engine.new(
211
238
  hypothesis_stable_identifier,
212
239
  max_examples: max_valid_test_cases,
240
+ phases: phases,
213
241
  database: database
214
242
  )
215
243
  World.current_engine.run(&block)
@@ -2,14 +2,10 @@
2
2
 
3
3
  require 'rutie'
4
4
 
5
- require 'rspec/expectations'
6
-
7
5
  module Hypothesis
8
6
  DEFAULT_DATABASE_PATH = File.join(Dir.pwd, '.hypothesis', 'examples')
9
7
 
10
8
  class Engine
11
- include RSpec::Matchers
12
-
13
9
  attr_reader :current_source
14
10
  attr_accessor :is_find
15
11
 
@@ -23,7 +19,11 @@ module Hypothesis
23
19
  database = nil if database == false
24
20
 
25
21
  @core_engine = HypothesisCoreEngine.new(
26
- name, database, seed, options.fetch(:max_examples)
22
+ name,
23
+ database,
24
+ seed,
25
+ options.fetch(:max_examples),
26
+ options.fetch(:phases)
27
27
  )
28
28
 
29
29
  @exceptions_to_tags = Hash.new { |h, k| h[k] = h.size }
data/src/lib.rs CHANGED
@@ -4,15 +4,19 @@ extern crate rutie;
4
4
  extern crate lazy_static;
5
5
  extern crate conjecture;
6
6
 
7
+ use std::convert::TryFrom;
7
8
  use std::mem;
8
9
 
9
- use rutie::{AnyException, AnyObject, Boolean, Class, Float, Integer, NilClass, Object, RString, VM};
10
+ use rutie::{
11
+ AnyException, AnyObject, Array, Boolean, Class, Exception, Float, Integer, NilClass, Object,
12
+ RString, Symbol, VM,
13
+ };
10
14
 
11
15
  use conjecture::data::{DataSource, Status, TestResult};
12
16
  use conjecture::database::{BoxedDatabase, DirectoryDatabase, NoDatabase};
13
17
  use conjecture::distributions;
14
18
  use conjecture::distributions::Repeat;
15
- use conjecture::engine::Engine;
19
+ use conjecture::engine::{Engine, Phase};
16
20
 
17
21
  pub struct HypothesisCoreDataSourceStruct {
18
22
  source: Option<DataSource>,
@@ -46,6 +50,7 @@ wrappable_struct!(
46
50
 
47
51
  class!(HypothesisCoreDataSource);
48
52
 
53
+ #[rustfmt::skip]
49
54
  methods!(
50
55
  HypothesisCoreDataSource,
51
56
  itself,
@@ -77,6 +82,7 @@ impl HypothesisCoreEngineStruct {
77
82
  database_path: Option<String>,
78
83
  seed: u64,
79
84
  max_examples: u64,
85
+ phases: Vec<Phase>,
80
86
  ) -> HypothesisCoreEngineStruct {
81
87
  let xs: [u32; 2] = [seed as u32, (seed >> 32) as u32];
82
88
  let db: BoxedDatabase = match database_path {
@@ -85,7 +91,7 @@ impl HypothesisCoreEngineStruct {
85
91
  };
86
92
 
87
93
  HypothesisCoreEngineStruct {
88
- engine: Engine::new(name, max_examples, &xs, db),
94
+ engine: Engine::new(name, max_examples, phases, &xs, db),
89
95
  pending: None,
90
96
  interesting_examples: Vec::new(),
91
97
  }
@@ -144,6 +150,7 @@ wrappable_struct!(
144
150
 
145
151
  class!(HypothesisCoreEngine);
146
152
 
153
+ #[rustfmt::skip]
147
154
  methods!(
148
155
  HypothesisCoreEngine,
149
156
  itself,
@@ -151,13 +158,26 @@ methods!(
151
158
  name: RString,
152
159
  database_path: RString,
153
160
  seed: Integer,
154
- max_example: Integer
161
+ max_example: Integer,
162
+ phases: Array
155
163
  ) -> AnyObject {
164
+ let rust_phases = safe_access(phases)
165
+ .into_iter()
166
+ .map(|ruby_phase| {
167
+ let phase_sym = safe_access(ruby_phase.try_convert_to::<Symbol>());
168
+ let phase = Phase::try_from(phase_sym.to_str())
169
+ .map_err(|e| AnyException::new("ArgumentError", Some(&e)));
170
+
171
+ safe_access(phase)
172
+ })
173
+ .collect();
174
+
156
175
  let core_engine = HypothesisCoreEngineStruct::new(
157
176
  safe_access(name).to_string(),
158
177
  database_path.ok().map(|p| p.to_string()),
159
178
  safe_access(seed).to_u64(),
160
179
  safe_access(max_example).to_u64(),
180
+ rust_phases,
161
181
  );
162
182
 
163
183
  Class::from_existing("HypothesisCoreEngine")
@@ -259,6 +279,7 @@ wrappable_struct!(
259
279
 
260
280
  class!(HypothesisCoreIntegers);
261
281
 
282
+ #[rustfmt::skip]
262
283
  methods!(
263
284
  HypothesisCoreIntegers,
264
285
  itself,
@@ -315,6 +336,7 @@ wrappable_struct!(
315
336
 
316
337
  class!(HypothesisCoreRepeatValues);
317
338
 
339
+ #[rustfmt::skip]
318
340
  methods!(
319
341
  HypothesisCoreRepeatValues,
320
342
  itself,
@@ -376,6 +398,7 @@ wrappable_struct!(
376
398
 
377
399
  class!(HypothesisCoreBoundedIntegers);
378
400
 
401
+ #[rustfmt::skip]
379
402
  methods!(
380
403
  HypothesisCoreBoundedIntegers,
381
404
  itself,
@@ -465,5 +488,5 @@ fn mark_child_status(
465
488
  }
466
489
 
467
490
  fn safe_access<T>(value: Result<T, AnyException>) -> T {
468
- value.map_err(VM::raise_ex).unwrap()
491
+ value.map_err(VM::raise_ex).unwrap()
469
492
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hypothesis-specs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David R. Maciver
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-01-08 00:00:00.000000000 Z
12
+ date: 2021-03-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rutie
@@ -25,26 +25,6 @@ dependencies:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
27
  version: 0.0.3
28
- - !ruby/object:Gem::Dependency
29
- name: rake
30
- requirement: !ruby/object:Gem::Requirement
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
34
- version: '10.0'
35
- - - "<"
36
- - !ruby/object:Gem::Version
37
- version: '13.0'
38
- type: :runtime
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- requirements:
42
- - - ">="
43
- - !ruby/object:Gem::Version
44
- version: '10.0'
45
- - - "<"
46
- - !ruby/object:Gem::Version
47
- version: '13.0'
48
28
  description: 'Hypothesis is a powerful, flexible, and easy to use library for property-based
49
29
  testing.
50
30
 
@@ -89,7 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
89
69
  - !ruby/object:Gem::Version
90
70
  version: '0'
91
71
  requirements: []
92
- rubygems_version: 3.2.4
72
+ rubygems_version: 3.2.14
93
73
  signing_key:
94
74
  specification_version: 4
95
75
  summary: Hypothesis is a powerful, flexible, and easy to use library for property-based