prop_check 0.10.2 → 0.10.3

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: 88b54994bb83cb44c77b887dfc6839e19b467bddd8a32dd7d1fe91e624261799
4
- data.tar.gz: e515d1522c939cb72eed02ed9fd98b458b1944a16b6c1f50f6c6bbc7076caaa5
3
+ metadata.gz: 4011263e2c1f768286c567c0e5ff57388a2a788d951ff8681d9eebd0afcab75a
4
+ data.tar.gz: c3494f2bb245d923facbdde4c0517ccfc8e4238c2ca35f7459d710b840039c36
5
5
  SHA512:
6
- metadata.gz: 3ba9d57ffa4e1d1f7d15b9c202cf232b5a931a57ac6d2d2bba4537030400e892d3154d2ab2db9ce97f6896bf97bb3a64a3cbdba02ac9cc15a561c815e7963aa6
7
- data.tar.gz: 90a2fd3a15cf2ed27fc1eb1aea4273e75c39143df861bcf0a25b456c6373a088452a7d4b5e1b52aa52a0f61b1c94b0ceceef442bf3507793417d38ad91bcb2b3
6
+ metadata.gz: ef736e1441b8a1b34c60904ce981f35184de019939b4e1a07453cd78135405506194856c7a6956e14a8b07192358d1473aaa1a4c58675b88268455533cae5a4a
7
+ data.tar.gz: 808fef14337c957754b470d4abdd628030fcfb09649bc44118dce34c91e9dfbf7b4c8f138b8ed388ce6ebe29555374c0d6d319157ab7dde8d7190827d8c9ea02
@@ -10,6 +10,7 @@ module PropCheck
10
10
  class Generator
11
11
  @@default_size = 10
12
12
  @@default_rng = Random.new
13
+ @@max_consecutive_attempts = 100
13
14
 
14
15
  ##
15
16
  # Being a special kind of Proc, a Generator wraps a block.
@@ -20,8 +21,19 @@ module PropCheck
20
21
  ##
21
22
  # Given a `size` (integer) and a random number generator state `rng`,
22
23
  # generate a LazyTree.
23
- def generate(size = @@default_size, rng = @@default_rng)
24
- @block.call(size, rng)
24
+ def generate(size = @@default_size, rng = @@default_rng, max_consecutive_attempts = @@max_consecutive_attempts)
25
+ (0..max_consecutive_attempts).each do
26
+ res = @block.call(size, rng)
27
+ next if res == :"PropCheck.filter_me"
28
+
29
+ return res
30
+ end
31
+
32
+ raise Errors::GeneratorExhaustedError, """
33
+ Exhausted #{max_consecutive_attempts} consecutive generation attempts.
34
+
35
+ Probably too few generator results were adhering to a `where` condition.
36
+ """
25
37
  end
26
38
 
27
39
  ##
@@ -1,3 +1,3 @@
1
1
  module PropCheck
2
- VERSION = '0.10.2'
2
+ VERSION = '0.10.3'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prop_check
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.2
4
+ version: 0.10.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Qqwy/Wiebe-Marten Wijnja