make condition brackets optional
This commit is contained in:
@ -3,16 +3,23 @@ require_relative "helper"
|
||||
class TestConditional < MiniTest::Test
|
||||
# include the magic (setup and parse -> test method translation), see there
|
||||
include ParserHelper
|
||||
|
||||
def test_conditional_brackets
|
||||
check("(0)")
|
||||
end
|
||||
def test_conditional_no_brackets
|
||||
check("0")
|
||||
end
|
||||
|
||||
def test_conditional
|
||||
@string_input = <<HERE
|
||||
if(0)
|
||||
def check cond
|
||||
input = <<HERE
|
||||
|
||||
42
|
||||
else
|
||||
667
|
||||
end
|
||||
HERE
|
||||
@string_input.chop!
|
||||
@string_input = "if #{cond} " + input.chop!
|
||||
@parse_output = {:if=>"if", :conditional=>{:integer=>"0"},
|
||||
:if_true=>{:expressions=>[{:integer=>"42"}], :else=>"else"},
|
||||
:if_false=>{:expressions=>[{:integer=>"667"}], :end=>"end"}}
|
||||
|
Reference in New Issue
Block a user