create more nice to haves
This commit is contained in:
parent
b7b81f4578
commit
12fff4de12
@ -26,6 +26,17 @@ HERE
|
||||
@parser = @parser
|
||||
end
|
||||
|
||||
def pest_function_no_braces_and_args
|
||||
@string_input = <<HERE
|
||||
def foo n , m
|
||||
n
|
||||
end
|
||||
HERE
|
||||
@parse_output = {:expression_list=>[{:function_name=>{:name=>"foo"}, :expressions=>[{:name=>"n"}], :end=>"end"}]}
|
||||
@transform_output = Ast::ExpressionList.new( [Ast::FunctionExpression.new(:foo, [] , [Ast::NameExpression.new(:n)] ,nil )])
|
||||
@parser = @parser
|
||||
end
|
||||
|
||||
def test_class_function
|
||||
@string_input = <<HERE
|
||||
def String.length(x)
|
||||
@ -37,6 +48,18 @@ HERE
|
||||
@parser = @parser
|
||||
end
|
||||
|
||||
def pest_function_default_args
|
||||
@string_input = <<HERE
|
||||
def foo(x = true )
|
||||
abba = 5
|
||||
2 + 5
|
||||
end
|
||||
HERE
|
||||
@parse_output = {:expression_list=>[{:function_name=>{:name=>"foo"}, :parameter_list=>[{:parameter=>{:name=>"x"}}], :expressions=>[{:l=>{:name=>"abba"}, :o=>"= ", :r=>{:integer=>"5"}}, {:l=>{:integer=>"2"}, :o=>"+ ", :r=>{:integer=>"5"}}], :end=>"end"}]}
|
||||
@transform_output = Ast::ExpressionList.new( [Ast::FunctionExpression.new(:foo, [Ast::NameExpression.new(:x)] , [Ast::AssignmentExpression.new(Ast::NameExpression.new(:abba),Ast::IntegerExpression.new(5)),Ast::OperatorExpression.new("+", Ast::IntegerExpression.new(2),Ast::IntegerExpression.new(5))] ,nil )])
|
||||
@parser = @parser
|
||||
end
|
||||
|
||||
def test_function_ops
|
||||
@string_input = <<HERE
|
||||
def foo(x)
|
||||
|
@ -16,6 +16,13 @@ HERE
|
||||
@parser = @parser
|
||||
end
|
||||
|
||||
def pest_while_reverse
|
||||
@string_input = "puts "1" while true "
|
||||
@parse_output = {:expression_list=>[{:while=>"while", :while_cond=>{:integer=>"1"}, :do=>"do", :body=>{:expressions=>[{:l=>{:name=>"tmp"}, :o=>"= ", :r=>{:name=>"a"}}, {:call_site=>{:name=>"puts"}, :argument_list=>[{:argument=>{:name=>"b"}}]}], :end=>"end"}}]}
|
||||
@transform_output = Ast::ExpressionList.new( [Ast::WhileExpression.new(Ast::IntegerExpression.new(1), [Ast::AssignmentExpression.new(Ast::NameExpression.new(:tmp),Ast::NameExpression.new(:a)), Ast::CallSiteExpression.new(:puts, [Ast::NameExpression.new(:b)] ,Ast::NameExpression.new(:self))] )])
|
||||
@parser = @parser
|
||||
end
|
||||
|
||||
def test_while_method
|
||||
@string_input = <<HERE
|
||||
while(1) do
|
||||
|
@ -17,6 +17,13 @@ HERE
|
||||
@parser = @parser.while_do
|
||||
end
|
||||
|
||||
def pest_while_reverse
|
||||
@string_input = "puts "1" while true "
|
||||
@parse_output = {:while=>"while", :while_cond=>{:integer=>"1"}, :do=>"do", :body=>{:expressions=>[{:l=>{:name=>"tmp"}, :o=>"= ", :r=>{:name=>"a"}}, {:call_site=>{:name=>"puts"}, :argument_list=>[{:argument=>{:name=>"b"}}]}], :end=>"end"}}
|
||||
@transform_output = Ast::WhileExpression.new(Ast::IntegerExpression.new(1), [Ast::AssignmentExpression.new(Ast::NameExpression.new(:tmp),Ast::NameExpression.new(:a)), Ast::CallSiteExpression.new(:puts, [Ast::NameExpression.new(:b)] ,Ast::NameExpression.new(:self))] )
|
||||
@parser = @parser.while_do
|
||||
end
|
||||
|
||||
def test_while_method
|
||||
@string_input = <<HERE
|
||||
while(1) do
|
||||
|
Loading…
Reference in New Issue
Block a user