class Qsim::Checker

Public Instance Methods

check(result, example) click to toggle source
Calls superclass method
# File lib/checker.rb, line 3
def check(result, example)
  @output_options = example[:output]
  super
end
check_equal(result, state) click to toggle source
# File lib/checker.rb, line 8
def check_equal(result, state)
  state.each do |target, expected|
    actual = target_value result, target
    fail I18n.t(:check_equal_failure, record: target, expected: expected, actual: actual) unless actual == expected
  end
end
render_error_output(result, error) click to toggle source
# File lib/checker.rb, line 19
def render_error_output(result, error)
  "#{error}\n#{renderer.render(result, @output_options)}"
end
render_success_output(result) click to toggle source
# File lib/checker.rb, line 15
def render_success_output(result)
  renderer.render(result, @output_options)
end

Private Instance Methods

renderer() click to toggle source
# File lib/checker.rb, line 36
def renderer
  @renderer ||= Qsim::HtmlRenderer.new
end
target_value(result, target) click to toggle source
# File lib/checker.rb, line 25
def target_value(result, target)
  case target
  when /R\d/
    result[:records][target]
  when /[0-9A-F]{4}/
    result[:memory][target]
  else
    error I18n.t :unknown_target, target: target
  end
end