rubyx/test/compiler/statements/test_call.rb
Torsten Ruger 6c7e4c0fe2 stop pinning self and frame
before: r0-message , r1-self , r2-frame , r3-new_message , r4 + tmps
now: r0-message , r1-new_message , r2 + tmps
programs got smaller, less fuss
also fix in return implementation that got the address from the wrong
message
2015-10-18 17:20:19 +03:00

105 lines
2.0 KiB
Ruby

require_relative 'helper'
module Register
class TestCallStatement < MiniTest::Test
include Statements
def test_call_constant_int
@string_input = <<HERE
class Integer
int putint()
return 1
end
end
class Object
int main()
42.putint()
end
end
HERE
@expect = [[Virtual::MethodEnter,GetSlot,LoadConstant,
SetSlot,LoadConstant,SetSlot,Virtual::MethodCall,GetSlot] ,
[Virtual::MethodReturn]]
check
end
def test_call_constant_string
@string_input = <<HERE
class Word
int putstring()
return 1
end
end
class Object
int main()
"Hello".putstring()
end
end
HERE
@expect = [[Virtual::MethodEnter,GetSlot,LoadConstant,
SetSlot,LoadConstant,SetSlot,Virtual::MethodCall,GetSlot] ,
[Virtual::MethodReturn]]
check
end
def test_call_local_int
@string_input = <<HERE
class Integer
int putint()
return 1
end
end
class Object
int main()
int testi = 20
testi.putint()
end
end
HERE
@expect = [ [Virtual::MethodEnter,LoadConstant,GetSlot,SetSlot,GetSlot,
GetSlot,GetSlot,SetSlot,LoadConstant,SetSlot,Virtual::MethodCall,
GetSlot] ,[Virtual::MethodReturn] ]
check
end
def test_call_local_class
@string_input = <<HERE
class List < Object
int add()
return 1
end
end
class Object
int main()
List test_l
test_l.add()
end
end
HERE
@expect = [ [Virtual::MethodEnter,GetSlot,GetSlot,GetSlot,SetSlot,
LoadConstant,SetSlot,Virtual::MethodCall,
GetSlot] ,[Virtual::MethodReturn] ]
check
end
def test_call_puts
@string_input = <<HERE
class Object
int puts(Word str)
return str
end
int main()
puts("Hello")
end
end
HERE
@expect = [ [Virtual::MethodEnter , GetSlot,GetSlot,SetSlot,LoadConstant,SetSlot,LoadConstant,
SetSlot,Virtual::MethodCall,GetSlot],
[Virtual::MethodReturn]]
check
end
end
end