prop_check 0.10.2 → 0.10.3
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/lib/prop_check/generator.rb +14 -2
- data/lib/prop_check/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4011263e2c1f768286c567c0e5ff57388a2a788d951ff8681d9eebd0afcab75a
|
4
|
+
data.tar.gz: c3494f2bb245d923facbdde4c0517ccfc8e4238c2ca35f7459d710b840039c36
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef736e1441b8a1b34c60904ce981f35184de019939b4e1a07453cd78135405506194856c7a6956e14a8b07192358d1473aaa1a4c58675b88268455533cae5a4a
|
7
|
+
data.tar.gz: 808fef14337c957754b470d4abdd628030fcfb09649bc44118dce34c91e9dfbf7b4c8f138b8ed388ce6ebe29555374c0d6d319157ab7dde8d7190827d8c9ea02
|
data/lib/prop_check/generator.rb
CHANGED
@@ -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
|
-
|
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
|
##
|
data/lib/prop_check/version.rb
CHANGED