test name expr
This commit is contained in:
parent
7451493193
commit
cbff41b61d
@ -47,7 +47,7 @@ module Virtual
|
|||||||
if method.has_var(name)
|
if method.has_var(name)
|
||||||
# either an argument, so it's stored in message
|
# either an argument, so it's stored in message
|
||||||
if( index = method.has_arg(name))
|
if( index = method.has_arg(name))
|
||||||
method.source.add_code MessageGet.new(expression.name , index)
|
method.source.add_code Set.new( MessageSlot.new(expression.name) , Return.new)
|
||||||
else # or a local so it is in the frame
|
else # or a local so it is in the frame
|
||||||
method.source.add_code FrameGet.new(expression.name , index)
|
method.source.add_code FrameGet.new(expression.name , index)
|
||||||
end
|
end
|
||||||
|
@ -8,6 +8,7 @@ module CompilerHelper
|
|||||||
Virtual.machine.boot.compile_main @string_input
|
Virtual.machine.boot.compile_main @string_input
|
||||||
produced = Virtual.machine.space.get_main.source
|
produced = Virtual.machine.space.get_main.source
|
||||||
assert_equal @output , produced
|
assert_equal @output , produced
|
||||||
|
Virtual.machine.run_passes
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -11,6 +11,7 @@ module Fragments
|
|||||||
@expect.each_with_index do | should , i |
|
@expect.each_with_index do | should , i |
|
||||||
assert_equal should , expressions[i].class
|
assert_equal should , expressions[i].class
|
||||||
end
|
end
|
||||||
|
# Virtual.machine.run_passes
|
||||||
end
|
end
|
||||||
|
|
||||||
# helper to write the file
|
# helper to write the file
|
||||||
|
@ -7,11 +7,11 @@ class TestFunctions < MiniTest::Test
|
|||||||
@string_input = <<HERE
|
@string_input = <<HERE
|
||||||
def minus(a,b)
|
def minus(a,b)
|
||||||
a - b
|
a - b
|
||||||
end
|
end
|
||||||
def plus(a, b)
|
def plus(a, b)
|
||||||
a + b
|
a + b
|
||||||
end
|
end
|
||||||
def times(a, b)
|
def times(a, b)
|
||||||
if( b == 0 )
|
if( b == 0 )
|
||||||
a = 0
|
a = 0
|
||||||
else
|
else
|
||||||
@ -20,7 +20,6 @@ def minus(a,b)
|
|||||||
a = plus(a,t)
|
a = plus(a,t)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def t_seven()
|
def t_seven()
|
||||||
tim = times(7,6)
|
tim = times(7,6)
|
||||||
tim.putint()
|
tim.putint()
|
||||||
@ -28,10 +27,8 @@ end
|
|||||||
|
|
||||||
t_seven()
|
t_seven()
|
||||||
HERE
|
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]
|
@expect = [Virtual::Return ]
|
||||||
@output = " 42 "
|
check
|
||||||
@target = [:Object , :times]
|
|
||||||
parse
|
|
||||||
write "functions"
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user