268
269
270
271
272
273
274
275
276
277
278
279
|
# File 'lib/bparity/formal/deductive.rb', line 268
def validate(translation, callable, inputs)
inputs.each_with_index do |input, index|
ruby_value = observe { callable.call(*input) }
context = input.each_with_index.to_h { |value, position| [position, value] }
translated_value = observe { translation.term.evaluate(context) }
next if ruby_value == translated_value
mismatch = { "input" => input, "ruby" => ruby_value, "translation" => translated_value }
return Validation.new(valid: false, cases: index + 1, mismatch:)
end
Validation.new(valid: true, cases: inputs.length)
end
|