449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
|
# File 'lib/bparity/formal/deductive.rb', line 449
def call(result:, subject_name:, operation_name:)
counterexample = result.counterexample
input = counterexample.fetch("input")
expected = counterexample.fetch("expected")
<<~RUBY
# frozen_string_literal: true
require "bparity"
require ENV["BPARITY_REPLACEMENT"] if ENV["BPARITY_REPLACEMENT"]
load ENV.fetch("BPARITY_ADAPTER")
RSpec.describe "F4 counterexample for #{subject_name}#{operation_name}" do
it "reproduces solver input #{input.inspect}" do
binding = Bparity.adapter_definition.subjects.fetch(#{subject_name.inspect})
operation = binding.operations.fetch(#{operation_name.inspect})
begin
value = operation.invoke(binding.build({}), #{input.inspect}, {})
value = operation.map_return(value)
actual = { "kind" => "return", "value" => Bparity::Recording::Serializer.dump(value) }
rescue StandardError => error
mapped = operation.map_error(error).transform_keys(&:to_s)
mapped["cause"] = error.cause&.class&.name unless mapped.key?("cause")
actual = { "kind" => "raise", **mapped }
end
expect(actual).to eq(#{expected.inspect})
end
end
RUBY
end
|