hypothesis-specs 0.4.0 → 0.7.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 748dfd8fb0c05573aecd17da1fb658a3d3add0ae731e16dc8f3f9274cd5db006
4
- data.tar.gz: ffd23f44bd8fa7eaca616cc00bc497033d6c9557761c8ffacdc756d3b6bad080
3
+ metadata.gz: cbb474ec8dfa5611bdcd0b7c49b03f55f93aadc178fb4b826561085b1d18b7a1
4
+ data.tar.gz: 0261acdf7ba9861d1bbe2bed050fc6949bbc37636a6813bc035fa2f4b5305f14
5
5
  SHA512:
6
- metadata.gz: a1e26c552c6baaf4fcf3fa1ef3784ad911c5a06c1582b3153daf09b6f618900656ac08f2377c9fba834e5a1ecd2a2ae90d6f33a542b457fb23db30760265b058
7
- data.tar.gz: 2fd4b38d077f32f978010612c72a613b4692f6299b4d5b66885afffe6b22180a4f834d5769f456b29f00a7eb3dc2b31246cae7a7410e2532d183aa61c5651b02
6
+ metadata.gz: 522ffc7e052fbe1da4d8aa30e310858f9b2dde70dddf279a3e9271b0a927df0e9bb73911f471315d1620d703498144fed8a7a87f0929f450eeb087c9cb081e01
7
+ data.tar.gz: ca528d9fe8f1aaf1b39cbad52b0bb043da0940e9c26e2b866b9ae9a2595267a8cdd8e93c5a207898f2ca785bfa3db85f175e49a6443a9e1141c8137b17fe653f
data/CHANGELOG.md CHANGED
@@ -1,3 +1,39 @@
1
+ # Hypothesis for Ruby 0.7.1 (2021-03-27)
2
+
3
+ This patch fixes some internal typos. There is no user-visible change.
4
+
5
+ # Hypothesis for Ruby 0.7.0 (2021-03-12)
6
+
7
+ 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.
8
+
9
+ # Hypothesis for Ruby 0.6.1 (2021-02-01)
10
+
11
+ This patch contains minor performance improvements for `HypothesisCoreIntegers` class instantiation.
12
+
13
+ # Hypothesis for Ruby 0.6.0 (2021-01-27)
14
+
15
+ 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.
16
+
17
+ Usage:
18
+
19
+ ```
20
+ hypothesis(phases: Phase.excluding(:shrink)) do
21
+ # Failures here will be displayed directly and shrinking will be avoided
22
+ end
23
+ ```
24
+
25
+ # Hypothesis for Ruby 0.5.0 (2021-01-25)
26
+
27
+ 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.
28
+
29
+ Usage:
30
+
31
+ ```
32
+ hypothesis(phases: Phase.excluding(:shrink)) do
33
+ # Failures here will be displayed directly and shrinking will be avoided
34
+ end
35
+ ```
36
+
1
37
  # Hypothesis for Ruby 0.4.0 (2021-01-12)
2
38
 
3
39
  This removes hypothesis-ruby's dependence on RSpec. Now, it can be used with any Ruby test runner.
@@ -16,7 +52,7 @@ manually pass a seed.
16
52
 
17
53
  # Hypothesis for Ruby 0.1.2 (2018-09-24)
18
54
 
19
- This release makes the code useable via a direct require.
55
+ This release makes the code usable via a direct require.
20
56
  I.e. no need for rubygems or any special LOAD_PATH.
21
57
 
22
58
  For example, if the base directory were in /opt, you'd just say:
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/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
@@ -47,7 +69,7 @@ module Hypothesis
47
69
  # the previous examples.
48
70
 
49
71
  # Note that essentially any answer to this method is
50
- # "fine" in that the failure mode is that sometiems we
72
+ # "fine" in that the failure mode is that sometimes we
51
73
  # just won't run the same test, but it's nice to keep
52
74
  # this as stable as possible if the code isn't changing.
53
75
 
@@ -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)
@@ -19,7 +19,11 @@ module Hypothesis
19
19
  database = nil if database == false
20
20
 
21
21
  @core_engine = HypothesisCoreEngine.new(
22
- name, database, seed, options.fetch(:max_examples)
22
+ name,
23
+ database,
24
+ seed,
25
+ options.fetch(:max_examples),
26
+ options.fetch(:phases)
23
27
  )
24
28
 
25
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.4.0
4
+ version: 0.7.1
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-12 00:00:00.000000000 Z
12
+ date: 2021-03-27 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.5
72
+ rubygems_version: 3.2.15
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