Fix if logic error
ifs may have an empty true block Especially for unlesses thet is normal, so allow
This commit is contained in:
parent
9bd2195a15
commit
11c5389e24
@ -23,7 +23,7 @@ module Ruby
|
||||
|
||||
def to_vool
|
||||
cond , rest = *normalize_name(@condition)
|
||||
me = Vool::IfStatement.new(cond.to_vool , @if_true.to_vool, @if_false&.to_vool)
|
||||
me = Vool::IfStatement.new(cond.to_vool , @if_true&.to_vool, @if_false&.to_vool)
|
||||
return me unless rest
|
||||
Vool::Statements.new([ rest.to_vool , me])
|
||||
end
|
||||
@ -37,7 +37,8 @@ module Ruby
|
||||
end
|
||||
|
||||
def to_s(depth = 0)
|
||||
parts = ["if(#{@condition})" , @if_true.to_s(depth + 1) ]
|
||||
parts = ["if(#{@condition})" ]
|
||||
parts << @if_true.to_s(depth + 1) if(@if_true)
|
||||
parts += ["else" , @if_false.to_s(depth + 1)] if(@if_false)
|
||||
parts << "end"
|
||||
at_depth(depth , *parts )
|
||||
|
@ -6,17 +6,19 @@ module RubyX
|
||||
def setup
|
||||
end
|
||||
def ruby_to_risc(input , options = {})
|
||||
mom = ruby_to_mom(input)
|
||||
mom = ruby_to_mom(input , options)
|
||||
mom.translate(options[:platform] || :interpreter)
|
||||
end
|
||||
def ruby_to_vool(input, options = {})
|
||||
RubyXCompiler.new(RubyX.default_test_options).ruby_to_vool(input)
|
||||
options = RubyX.default_test_options.merge(options)
|
||||
RubyXCompiler.new(options).ruby_to_vool(input)
|
||||
end
|
||||
def ruby_to_mom(input , options = {})
|
||||
RubyXCompiler.new(RubyX.default_test_options).ruby_to_mom(input)
|
||||
options = RubyX.default_test_options.merge(options)
|
||||
RubyXCompiler.new(options).ruby_to_mom(input)
|
||||
end
|
||||
def compile_in_test( input , options = {})
|
||||
vool = ruby_to_vool in_Test(input)
|
||||
vool = ruby_to_vool(in_Test(input) , options)
|
||||
vool.to_mom(nil)
|
||||
itest = Parfait.object_space.get_class_by_name(:Test)
|
||||
assert itest
|
||||
|
Loading…
Reference in New Issue
Block a user