26 lines
902 B
Ruby
26 lines
902 B
Ruby
require_relative 'helper'
|
|
|
|
class TestIf < MiniTest::Test
|
|
include Fragments
|
|
|
|
def test_if
|
|
@string_input = <<HERE
|
|
def itest(n)
|
|
if( n < 12)
|
|
putstring("then")
|
|
else
|
|
putstring("else")
|
|
end
|
|
end
|
|
|
|
itest(20)
|
|
HERE
|
|
@should = [0x0,0x40,0x2d,0xe9,0xc,0x0,0x51,0xe3,0x5,0x0,0x0,0xba,0x2,0x0,0x2d,0xe9,0x3c,0x10,0x8f,0xe2,0x8,0x20,0xa0,0xe3,0x7,0x0,0x0,0xeb,0x2,0x0,0xbd,0xe8,0x4,0x0,0x0,0xea,0x2,0x0,0x2d,0xe9,0x2c,0x10,0x8f,0xe2,0x8,0x20,0xa0,0xe3,0x1,0x0,0x0,0xeb,0x2,0x0,0xbd,0xe8,0x0,0x80,0xbd,0xe8,0x0,0x40,0x2d,0xe9,0xc,0x0,0x51,0xe3,0x5,0x0,0x0,0xba,0x2,0x0,0x2d,0xe9,0x3c,0x10,0x8f,0xe2,0x8,0x20,0xa0,0xe3,0x7,0x0,0x0,0xeb,0x2,0x0,0xbd,0xe8,0x4,0x0,0x0,0xea,0x2,0x0,0x2d,0xe9,0x2c,0x10,0x8f,0xe2,0x8,0x20,0xa0,0xe3,0x1,0x0,0x0,0xeb,0x2,0x0,0xbd,0xe8,0x0,0x80,0xbd,0xe8]
|
|
@output = "else "
|
|
@target = [:Object , :itest]
|
|
parse
|
|
write "if"
|
|
end
|
|
end
|
|
|