50379a1fea
basic semantics remain, but have to improve test for new functionality that has to be written for new branch types
61 lines
749 B
Ruby
61 lines
749 B
Ruby
require_relative 'helper'
|
|
|
|
class TestIf < MiniTest::Test
|
|
include Fragments
|
|
|
|
def test_if_basic
|
|
@string_input = <<HERE
|
|
class Object
|
|
int main()
|
|
int n = 10
|
|
if_plus( n - 12)
|
|
return 3
|
|
else
|
|
return 4
|
|
end
|
|
end
|
|
end
|
|
HERE
|
|
@length = 17
|
|
check
|
|
end
|
|
|
|
def test_if_small
|
|
@string_input = <<HERE
|
|
class Object
|
|
int main()
|
|
int n = 10
|
|
if_minus(8 - n )
|
|
"10".putstring()
|
|
end
|
|
end
|
|
end
|
|
HERE
|
|
@length = 33
|
|
@stdout = "10"
|
|
check
|
|
end
|
|
|
|
|
|
def test_if_puts
|
|
@string_input = <<HERE
|
|
class Object
|
|
int itest(int n)
|
|
if_zero( n - 12)
|
|
"then".putstring()
|
|
else
|
|
"else".putstring()
|
|
end
|
|
end
|
|
|
|
int main()
|
|
itest(20)
|
|
end
|
|
end
|
|
HERE
|
|
@length = 40
|
|
@stdout = "else"
|
|
check
|
|
end
|
|
end
|