example_puzzles/compile_examples.rb
# Compares exit code and expected output to assert example executes correctly.
#
# @param example [Hash] the example to verify
# @return [Hash] the verified example
Compares exit code and expected output to assert example executes correctly.
Compares exit code and expected output to assert example executes correctly .
def verify(example)
  if example[:expected_output] then
    if example[:expected_output].strip != example[:stdout].strip then
      $stderr.puts "Expected:----\n#{example[:expected_output]}\n----"
      $stderr.puts "Stdout:------\n#{example[:stdout]}\n----"
      puts example.to_yaml
      fail "expected output did not match."
    end
  end
  if example[:expected_exit_code] then
    if example[:expected_exit_code] != example[:exit_code] then
      $stderr.puts example.to_yaml
      fail "Wrong exit code"
    end
  end
  example
end
def verify ( example ) if example [ :expected_output ] then if example [ :expected_output ] . strip != example [ :stdout ] . strip then $stderr . puts "Expected:----\n#{example[:expected_output]}\n----" $stderr . puts "Stdout:------\n#{example[:stdout]}\n----" puts example . to_yaml fail "expected output did not match." end end if example [ :expected_exit_code ] then if example [ :expected_exit_code ] != example [ :exit_code ] then $stderr . puts example . to_yaml fail "Wrong exit code" end end example end
Compares exit code and expected output to assert example executes correctly.
Compares exit code and expected output to assert example executes correctly .
the verified example
the verified example
Hash
example
the example to verify
the example to verify