test name expr
This commit is contained in:
@ -11,6 +11,7 @@ module Fragments
|
||||
@expect.each_with_index do | should , i |
|
||||
assert_equal should , expressions[i].class
|
||||
end
|
||||
# Virtual.machine.run_passes
|
||||
end
|
||||
|
||||
# helper to write the file
|
||||
|
@ -7,20 +7,19 @@ class TestFunctions < MiniTest::Test
|
||||
@string_input = <<HERE
|
||||
def minus(a,b)
|
||||
a - b
|
||||
end
|
||||
def plus(a, b)
|
||||
a + b
|
||||
end
|
||||
def times(a, b)
|
||||
if( b == 0 )
|
||||
a = 0
|
||||
else
|
||||
m = minus(b, 1)
|
||||
t = times(a, m)
|
||||
a = plus(a,t)
|
||||
end
|
||||
end
|
||||
|
||||
def plus(a, b)
|
||||
a + b
|
||||
end
|
||||
def times(a, b)
|
||||
if( b == 0 )
|
||||
a = 0
|
||||
else
|
||||
m = minus(b, 1)
|
||||
t = times(a, m)
|
||||
a = plus(a,t)
|
||||
end
|
||||
end
|
||||
def t_seven()
|
||||
tim = times(7,6)
|
||||
tim.putint()
|
||||
@ -28,10 +27,8 @@ end
|
||||
|
||||
t_seven()
|
||||
HERE
|
||||
@should = [0x0,0x40,0x2d,0xe9,0x0,0x0,0x54,0xe3,0x10,0x0,0x0,0xa,0x8,0x0,0x2d,0xe9,0x4,0x30,0xa0,0xe1,0x1,0x40,0xa0,0xe3,0xf2,0xff,0xff,0xeb,0x8,0x0,0xbd,0xe8,0x0,0x50,0xa0,0xe1,0x8,0x0,0x2d,0xe9,0x5,0x40,0xa0,0xe1,0xf3,0xff,0xff,0xeb,0x8,0x0,0xbd,0xe8,0x0,0x60,0xa0,0xe1,0x10,0x0,0x2d,0xe9,0x6,0x40,0xa0,0xe1,0xeb,0xff,0xff,0xeb,0x10,0x0,0xbd,0xe8,0x0,0x30,0xa0,0xe1,0x0,0x0,0x0,0xea,0x0,0x30,0xa0,0xe3,0x3,0x0,0xa0,0xe1,0x0,0x80,0xbd,0xe8]
|
||||
@output = " 42 "
|
||||
@target = [:Object , :times]
|
||||
parse
|
||||
write "functions"
|
||||
@expect = [Virtual::Return ]
|
||||
check
|
||||
|
||||
end
|
||||
end
|
||||
|
@ -18,11 +18,11 @@ HERE
|
||||
def ttest_if_function
|
||||
@string_input = <<HERE
|
||||
def itest(n)
|
||||
if( n < 12)
|
||||
"then".putstring()
|
||||
else
|
||||
"else".putstring()
|
||||
end
|
||||
if( n < 12)
|
||||
"then".putstring()
|
||||
else
|
||||
"else".putstring()
|
||||
end
|
||||
end
|
||||
|
||||
itest(20)
|
||||
|
Reference in New Issue
Block a user