Class: Bparity::Formal::PropertyRunner

Inherits:
Object
  • Object
show all
Defined in:
lib/bparity/formal/bounded.rb

Instance Method Summary collapse

Constructor Details

#initialize(callable:, invariants:, inputs:, preconditions: [], checker: ContractChecker.new) ⇒ PropertyRunner

Returns a new instance of PropertyRunner.



435
436
437
438
439
440
441
# File 'lib/bparity/formal/bounded.rb', line 435

def initialize(callable:, invariants:, inputs:, preconditions: [], checker: ContractChecker.new)
  @callable = callable
  @invariants = invariants
  @inputs = inputs
  @preconditions = preconditions
  @checker = checker
end

Instance Method Details

#runObject



443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
# File 'lib/bparity/formal/bounded.rb', line 443

def run
  checked = 0
  @inputs.each do |args|
    next unless preconditions_hold?(args)

    checked += 1
    violations = violations_for(args)
    unless violations.empty?
      input = minimize(args)
      return { "input" => input, "violations" => violations_for(input) }
    end
  end
  if checked.zero?
    raise ConfigurationError,
          "Property verification generated no input satisfying the preconditions. Expand the input domain."
  end
  nil
end