From 692b51a9de58118400af23200e2f9071cab71140 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Sat, 19 Sep 2015 14:54:22 +0300 Subject: [PATCH] way to fix current test cases (if known to be correct) --- test/test_all.rb | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/test/test_all.rb b/test/test_all.rb index bff9a20..81bbb17 100644 --- a/test/test_all.rb +++ b/test/test_all.rb @@ -1,17 +1,32 @@ require_relative "setup" require "parslet/convenience" require "ast/sexp" +require "pp" class TestAll < MiniTest::Test include AST::Sexp + SEPERATOR = "-- -- --" def check_file file - inn , out = File.new(file).read.split("-- -- --") + inn , out = File.new(file).read.split(SEPERATOR) sexp = eval(out) syntax = Parser::Salama.new.parse_with_debug(inn) result = Parser::Transform.new.apply(syntax) - equal = (sexp == result) - puts "\n" + result.inspect unless equal + equal = (sexp == result) + unless equal + if ENV["FIX"] + out_file = File.new(file, "w") + out_file.puts inn + out_file.puts SEPERATOR + out_file.puts result.inspect + out_file.close + puts "Fixed #{file}" + sexp = result + else + pp syntax + puts result.inspect + end + end assert_equal sexp , result end