lib/prop_check/property.rb in prop_check-0.17.0 vs lib/prop_check/property.rb in prop_check-0.18.0
- old
+ new
@@ -40,15 +40,12 @@
# If you do not pass a block right away,
# a Property object is returned, which you can call the other instance methods
# of this class on before finally passing a block to it using `#check`.
# (so `forall(Generators.integer) do |val| ... end` and forall(Generators.integer).check do |val| ... end` are the same)
def self.forall(*bindings, **kwbindings, &block)
- property = new(*bindings, **kwbindings)
-
- return property.check(&block) if block_given?
-
- property
+ new(*bindings, **kwbindings)
+ .check(&block)
end
##
# Returns the default configuration of the library as it is configured right now
# for introspection.
@@ -104,13 +101,11 @@
def with_config(**config, &block)
duplicate = dup
duplicate.instance_variable_set(:@config, @config.merge(config))
duplicate.freeze
- return duplicate.check(&block) if block_given?
-
- duplicate
+ duplicate.check(&block)
end
##
# Resizes all generators in this property with the given function.
#
@@ -246,9 +241,11 @@
end
##
# Checks the property (after settings have been altered using the other instance methods in this class.)
def check(&block)
+ return self unless block_given?
+
n_runs = 0
n_successful = 0
# Loop stops at first exception
attempts_enum(@gen).each do |generator_result|