citifying test harness
This commit is contained in:
parent
00600d5364
commit
69e29efbd4
@ -1,12 +1,5 @@
|
||||
require_relative "setup"
|
||||
require "parslet/convenience"
|
||||
|
||||
# remove the line numbers on assert fails, so it's easy to copy paste the result as the expected result
|
||||
Parslet::Slice.class_eval do
|
||||
def inspect
|
||||
'"' + to_s + '"'
|
||||
end
|
||||
end
|
||||
# Included in parser test will create tests methods
|
||||
module ParserHelper
|
||||
|
||||
@ -17,14 +10,13 @@ module ParserHelper
|
||||
|
||||
module InstanceMethods
|
||||
def setup
|
||||
@parser = Parser::Salama.new
|
||||
@transform = Parser::Transform.new
|
||||
@parser = Keywords
|
||||
end
|
||||
|
||||
# check that @string_input parses correctly to @parse_output
|
||||
def check_parse
|
||||
is = @parser.parse_with_debug(@string_input)
|
||||
assert_equal @parse_output , is
|
||||
is = @parser.parse(@string_input , :root => @root)
|
||||
assert_equal @string_input , is
|
||||
end
|
||||
|
||||
#check that @parse_output transforms to @transform_output
|
||||
@ -36,10 +28,9 @@ module ParserHelper
|
||||
|
||||
# check that @string_input parses and transforms to @transform_output
|
||||
def check_ast
|
||||
syntax = @parser.parse(@string_input)
|
||||
is = @transform.apply(syntax)
|
||||
syntax = @parser.parse(@string_input , :root => @root)
|
||||
#puts is.inspect
|
||||
assert_equal @transform_output , is
|
||||
assert_equal @transform_output , syntax.value
|
||||
end
|
||||
end
|
||||
|
||||
@ -50,7 +41,7 @@ module ParserHelper
|
||||
def runnable_methods
|
||||
tests = []
|
||||
public_instance_methods(true).grep(/^test_/).map(&:to_s).each do |test|
|
||||
["ast" , "transform" , "parse"].each do |what|
|
||||
["ast" , "parse"].each do |what|
|
||||
name = "#{test}_#{what}"
|
||||
tests << name
|
||||
self.send(:define_method, name ) do
|
||||
|
Loading…
x
Reference in New Issue
Block a user