fix tests for NameExpression split
also necessitates giving method name without the wrapping expression which is simpler anyway
This commit is contained in:
parent
5f7ea08a43
commit
8dbbffd58e
@ -13,7 +13,7 @@ class HelloTest < MiniTest::Test
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_string_put
|
def test_string_put
|
||||||
@input = s(:statements, s(:return, s(:call, s(:name, :putstring), s(:arguments),
|
@input = s(:statements, s(:return, s(:call, :putstring, s(:arguments),
|
||||||
s(:receiver, s(:string, "Hello again\\n")))))
|
s(:receiver, s(:string, "Hello again\\n")))))
|
||||||
check
|
check
|
||||||
end
|
end
|
||||||
|
@ -13,7 +13,7 @@ module Register
|
|||||||
end
|
end
|
||||||
HERE
|
HERE
|
||||||
@input = s(:statements, s(:call,
|
@input = s(:statements, s(:call,
|
||||||
s(:name, :set_internal_byte),
|
:set_internal_byte ,
|
||||||
s(:arguments, s(:int, 1), s(:int, 104)),
|
s(:arguments, s(:int, 1), s(:int, 104)),
|
||||||
s(:receiver, s(:string, "Hello"))))
|
s(:receiver, s(:string, "Hello"))))
|
||||||
super
|
super
|
||||||
|
@ -21,16 +21,16 @@ module Register
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
HERE
|
HERE
|
||||||
@input = s(:statements, s(:call, s(:name, :itest), s(:arguments, s(:int, 20))))
|
@input = s(:statements, s(:call, :itest , s(:arguments, s(:int, 20))))
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
|
|
||||||
# must be after boot, but before main compile, to define method
|
# must be after boot, but before main compile, to define method
|
||||||
def do_clean_compile
|
def do_clean_compile
|
||||||
clean_compile :Space , :itest , {:n => :Integer} ,
|
clean_compile :Space , :itest , {:n => :Integer} ,
|
||||||
s(:statements, s(:if_statement, :zero, s(:condition, s(:operator_value, :-, s(:name, :n), s(:int, 12))),
|
s(:statements, s(:if_statement, :zero, s(:condition, s(:operator_value, :-, s(:arg, :n), s(:int, 12))),
|
||||||
s(:true_statements, s(:call, s(:name, :putstring), s(:arguments), s(:receiver, s(:string, "then")))),
|
s(:true_statements, s(:call, :putstring , s(:arguments), s(:receiver, s(:string, "then")))),
|
||||||
s(:false_statements, s(:call, s(:name, :putstring), s(:arguments), s(:receiver, s(:string, "else"))))))
|
s(:false_statements, s(:call, :putstring , s(:arguments), s(:receiver, s(:string, "else"))))))
|
||||||
end
|
end
|
||||||
def test_if
|
def test_if
|
||||||
#show_ticks # get output of what is
|
#show_ticks # get output of what is
|
||||||
|
@ -12,7 +12,7 @@ module Register
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
HERE
|
HERE
|
||||||
@input = s(:statements, s(:call, s(:name, :putstring), s(:arguments), s(:receiver, s(:string, "Hello again"))))
|
@input = s(:statements, s(:call, :putstring, s(:arguments), s(:receiver, s(:string, "Hello again"))))
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ module Register
|
|||||||
end
|
end
|
||||||
HERE
|
HERE
|
||||||
@input = s(:statements, s(:call,
|
@input = s(:statements, s(:call,
|
||||||
s(:name, :get_internal_byte),
|
:get_internal_byte,
|
||||||
s(:arguments, s(:int, 1)),
|
s(:arguments, s(:int, 1)),
|
||||||
s(:receiver, s(:string, "Hello"))))
|
s(:receiver, s(:string, "Hello"))))
|
||||||
super
|
super
|
||||||
|
@ -18,8 +18,8 @@ module Register
|
|||||||
end
|
end
|
||||||
HERE
|
HERE
|
||||||
@input = s(:statements, s(:if_statement, :zero, s(:condition, s(:operator_value, :-, s(:int, 10), s(:int, 12))),
|
@input = s(:statements, s(:if_statement, :zero, s(:condition, s(:operator_value, :-, s(:int, 10), s(:int, 12))),
|
||||||
s(:true_statements, s(:call, s(:name, :putstring), s(:arguments), s(:receiver, s(:string, "then")))),
|
s(:true_statements, s(:call, :putstring, s(:arguments), s(:receiver, s(:string, "then")))),
|
||||||
s(:false_statements, s(:call, s(:name, :putstring), s(:arguments), s(:receiver, s(:string, "else"))))))
|
s(:false_statements, s(:call, :putstring, s(:arguments), s(:receiver, s(:string, "else"))))))
|
||||||
|
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#statements
|
#statements
|
||||||
require_relative "test_assignment"
|
require_relative "test_assignment"
|
||||||
require_relative "test_call_site"
|
require_relative "test_call_site"
|
||||||
require_relative "test_class"
|
|
||||||
require_relative "test_fields"
|
require_relative "test_fields"
|
||||||
require_relative "test_if_statement"
|
require_relative "test_if_statement"
|
||||||
require_relative "test_return_statement"
|
require_relative "test_return_statement"
|
||||||
|
@ -7,7 +7,7 @@ module Register
|
|||||||
def test_assign_op
|
def test_assign_op
|
||||||
Parfait.object_space.get_main.add_local(:r , :Integer)
|
Parfait.object_space.get_main.add_local(:r , :Integer)
|
||||||
|
|
||||||
@input = s(:statements, s(:l_assignment, s(:name, :r), s(:operator_value, :+, s(:int, 10), s(:int, 1))))
|
@input = s(:statements, s(:l_assignment, s(:local, :r), s(:operator_value, :+, s(:int, 10), s(:int, 1))))
|
||||||
|
|
||||||
@expect = [Label, LoadConstant, LoadConstant, OperatorInstruction, SlotToReg, RegToSlot ,
|
@expect = [Label, LoadConstant, LoadConstant, OperatorInstruction, SlotToReg, RegToSlot ,
|
||||||
LoadConstant, SlotToReg, RegToSlot, Label, FunctionReturn]
|
LoadConstant, SlotToReg, RegToSlot, Label, FunctionReturn]
|
||||||
@ -15,15 +15,15 @@ module Register
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_assign_ivar_notpresent
|
def test_assign_ivar_notpresent
|
||||||
@input =s(:statements, s(:i_assignment, s(:name, :r), s(:int, 5)))
|
@input =s(:statements, s(:i_assignment, s(:ivar, :r), s(:int, 5)))
|
||||||
@expect = []
|
@expect = []
|
||||||
assert_raises{ check_nil }
|
assert_raises{ check_nil }
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_assign_ivar
|
def test_assign_ivar
|
||||||
add_space_field(:r , :Integer)
|
add_space_field(:r , :Integer)
|
||||||
|
|
||||||
@input =s(:statements, s(:i_assignment, s(:name, :r), s(:int, 5)))
|
@input =s(:statements, s(:i_assignment, s(:ivar, :r), s(:int, 5)))
|
||||||
|
|
||||||
@expect = [Label, LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg ,
|
@expect = [Label, LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg ,
|
||||||
RegToSlot, Label, FunctionReturn]
|
RegToSlot, Label, FunctionReturn]
|
||||||
@ -33,7 +33,7 @@ module Register
|
|||||||
def test_assign_local_assign
|
def test_assign_local_assign
|
||||||
Parfait.object_space.get_main.add_local(:r , :Integer)
|
Parfait.object_space.get_main.add_local(:r , :Integer)
|
||||||
|
|
||||||
@input = s(:statements, s(:l_assignment, s(:name, :r), s(:int, 5)))
|
@input = s(:statements, s(:l_assignment, s(:local, :r), s(:int, 5)))
|
||||||
|
|
||||||
@expect = [Label, LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg ,
|
@expect = [Label, LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg ,
|
||||||
RegToSlot, Label, FunctionReturn]
|
RegToSlot, Label, FunctionReturn]
|
||||||
@ -42,7 +42,7 @@ module Register
|
|||||||
|
|
||||||
def test_assign_call
|
def test_assign_call
|
||||||
Parfait.object_space.get_main.add_local(:r , :Integer)
|
Parfait.object_space.get_main.add_local(:r , :Integer)
|
||||||
@input = s(:statements, s(:l_assignment, s(:name, :r), s(:call, s(:name, :main), s(:arguments))))
|
@input = s(:statements, s(:l_assignment, s(:local, :r), s(:call, :main, s(:arguments))))
|
||||||
@expect = [Label, SlotToReg, SlotToReg, RegToSlot, LoadConstant, RegToSlot ,
|
@expect = [Label, SlotToReg, SlotToReg, RegToSlot, LoadConstant, RegToSlot ,
|
||||||
LoadConstant, SlotToReg, RegToSlot, LoadConstant, RegToSlot, RegisterTransfer ,
|
LoadConstant, SlotToReg, RegToSlot, LoadConstant, RegToSlot, RegisterTransfer ,
|
||||||
FunctionCall, Label, RegisterTransfer, SlotToReg, SlotToReg, SlotToReg ,
|
FunctionCall, Label, RegisterTransfer, SlotToReg, SlotToReg, SlotToReg ,
|
||||||
@ -52,7 +52,7 @@ module Register
|
|||||||
|
|
||||||
def test_named_list_get
|
def test_named_list_get
|
||||||
Parfait.object_space.get_main.add_local(:r , :Integer)
|
Parfait.object_space.get_main.add_local(:r , :Integer)
|
||||||
@input = s(:statements, s(:l_assignment, s(:name, :r), s(:int, 5)), s(:return, s(:name, :r)))
|
@input = s(:statements, s(:l_assignment, s(:local, :r), s(:int, 5)), s(:return, s(:local, :r)))
|
||||||
@expect = [Label, LoadConstant, SlotToReg, RegToSlot, SlotToReg, SlotToReg ,
|
@expect = [Label, LoadConstant, SlotToReg, RegToSlot, SlotToReg, SlotToReg ,
|
||||||
RegToSlot, LoadConstant, SlotToReg, RegToSlot, Label, FunctionReturn]
|
RegToSlot, LoadConstant, SlotToReg, RegToSlot, Label, FunctionReturn]
|
||||||
was = check_return
|
was = check_return
|
||||||
@ -63,7 +63,7 @@ module Register
|
|||||||
|
|
||||||
def test_assign_local_int
|
def test_assign_local_int
|
||||||
Parfait.object_space.get_main.add_local(:r , :Integer)
|
Parfait.object_space.get_main.add_local(:r , :Integer)
|
||||||
@input = s(:statements, s(:l_assignment, s(:name, :r), s(:int, 5)) )
|
@input = s(:statements, s(:l_assignment, s(:local, :r), s(:int, 5)) )
|
||||||
@expect = [Label, LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg ,
|
@expect = [Label, LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg ,
|
||||||
RegToSlot, Label, FunctionReturn]
|
RegToSlot, Label, FunctionReturn]
|
||||||
was = check_return
|
was = check_return
|
||||||
@ -74,14 +74,14 @@ module Register
|
|||||||
|
|
||||||
def test_misassign_local
|
def test_misassign_local
|
||||||
Parfait.object_space.get_main.add_local(:r , :Integer)
|
Parfait.object_space.get_main.add_local(:r , :Integer)
|
||||||
@input = s(:statements, s(:l_assignment, s(:name, :r), s(:string, "5")) )
|
@input = s(:statements, s(:l_assignment, s(:local, :r), s(:string, "5")) )
|
||||||
@expect = [Label, LoadConstant, SlotToReg, RegToSlot, Label, FunctionReturn]
|
@expect = [Label, LoadConstant, SlotToReg, RegToSlot, Label, FunctionReturn]
|
||||||
assert_raises {check }
|
assert_raises {check }
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_assign_arg
|
def test_assign_arg
|
||||||
Parfait.object_space.get_main.add_argument(:blar , :Integer)
|
Parfait.object_space.get_main.add_argument(:blar , :Integer)
|
||||||
@input = s(:statements, s(:a_assignment, s(:name, :blar), s(:int, 5)))
|
@input = s(:statements, s(:a_assignment, s(:arg, :blar), s(:int, 5)))
|
||||||
@expect = [Label, LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg ,
|
@expect = [Label, LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg ,
|
||||||
RegToSlot, Label, FunctionReturn]
|
RegToSlot, Label, FunctionReturn]
|
||||||
was = check_return
|
was = check_return
|
||||||
@ -92,7 +92,7 @@ module Register
|
|||||||
|
|
||||||
def test_misassign_arg
|
def test_misassign_arg
|
||||||
Parfait.object_space.get_main.add_argument(:blar , :Integer)
|
Parfait.object_space.get_main.add_argument(:blar , :Integer)
|
||||||
@input = s(:statements, s(:a_assignment, s(:name, :blar), s(:string, "5")))
|
@input = s(:statements, s(:a_assignment, s(:arg, :blar), s(:string, "5")))
|
||||||
@expect = [Label, LoadConstant, SlotToReg, RegToSlot, Label, FunctionReturn]
|
@expect = [Label, LoadConstant, SlotToReg, RegToSlot, Label, FunctionReturn]
|
||||||
assert_raises {check }
|
assert_raises {check }
|
||||||
end
|
end
|
||||||
@ -100,7 +100,7 @@ module Register
|
|||||||
def test_arg_get
|
def test_arg_get
|
||||||
# have to define bar externally, just because redefining main. Otherwise that would be automatic
|
# have to define bar externally, just because redefining main. Otherwise that would be automatic
|
||||||
Parfait.object_space.get_main.add_argument(:balr , :Integer)
|
Parfait.object_space.get_main.add_argument(:balr , :Integer)
|
||||||
@input = s(:statements, s(:return, s(:name, :balr)))
|
@input = s(:statements, s(:return, s(:arg, :balr)))
|
||||||
@expect = [Label, SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg ,
|
@expect = [Label, SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg ,
|
||||||
RegToSlot, Label, FunctionReturn]
|
RegToSlot, Label, FunctionReturn]
|
||||||
was = check_return
|
was = check_return
|
||||||
|
@ -29,7 +29,7 @@ module Register
|
|||||||
check
|
check
|
||||||
end
|
end
|
||||||
def test_self
|
def test_self
|
||||||
@input = s(:name, :self)
|
@input = s(:known, :self)
|
||||||
check
|
check
|
||||||
end
|
end
|
||||||
def test_string
|
def test_string
|
||||||
|
@ -11,31 +11,31 @@ module Register
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_call_main_plain
|
def test_call_main_plain
|
||||||
@input = s(:call,s(:name, :main),s(:arguments))
|
@input = s(:call , :main ,s(:arguments))
|
||||||
check
|
check
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_call_main_int
|
def test_call_main_int
|
||||||
Parfait.object_space.get_main.add_argument(:blar , :Integer)
|
Parfait.object_space.get_main.add_argument(:blar , :Integer)
|
||||||
@input =s(:call,s(:name, :main),s(:arguments , s(:int, 1)))
|
@input =s(:call, :main ,s(:arguments , s(:int, 1)))
|
||||||
check
|
check
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_call_main_string
|
def test_call_main_string
|
||||||
Parfait.object_space.get_main.add_argument(:blar , :Word)
|
Parfait.object_space.get_main.add_argument(:blar , :Word)
|
||||||
@input =s(:call,s(:name, :main),s(:arguments , s(:string, "1") ))
|
@input =s(:call, :main ,s(:arguments , s(:string, "1") ))
|
||||||
check
|
check
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_call_main_op
|
def test_call_main_op
|
||||||
Parfait.object_space.get_main.add_local(:bar , :Integer)
|
Parfait.object_space.get_main.add_local(:bar , :Integer)
|
||||||
Parfait.object_space.get_main.add_argument(:blar , :Integer)
|
Parfait.object_space.get_main.add_argument(:blar , :Integer)
|
||||||
@input =s(:call,s(:name, :main),s(:arguments , s(:name, :bar) ))
|
@input =s(:call, :main ,s(:arguments , s(:local, :bar) ))
|
||||||
check
|
check
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_call_string_put
|
def test_call_string_put
|
||||||
@input = s(:call,s(:name, :putstring),s(:arguments),s(:receiver,s(:string, "Hello Raisa, I am salama")))
|
@input = s(:call, :putstring,s(:arguments),s(:receiver,s(:string, "Hello Raisa, I am salama")))
|
||||||
check
|
check
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ module Register
|
|||||||
|
|
||||||
def test_call_constant_int
|
def test_call_constant_int
|
||||||
clean_compile :Integer, :puti, {}, s(:statements, s(:return, s(:int, 1)))
|
clean_compile :Integer, :puti, {}, s(:statements, s(:return, s(:int, 1)))
|
||||||
@input = s(:call, s(:name, :puti), s(:arguments), s(:receiver, s(:int, 42)))
|
@input = s(:call, :puti , s(:arguments), s(:receiver, s(:int, 42)))
|
||||||
@expect = [Label, SlotToReg, LoadConstant, RegToSlot, LoadConstant, RegToSlot, LoadConstant ,
|
@expect = [Label, SlotToReg, LoadConstant, RegToSlot, LoadConstant, RegToSlot, LoadConstant ,
|
||||||
SlotToReg, RegToSlot, LoadConstant, RegToSlot, RegisterTransfer, FunctionCall, Label ,
|
SlotToReg, RegToSlot, LoadConstant, RegToSlot, RegisterTransfer, FunctionCall, Label ,
|
||||||
RegisterTransfer, SlotToReg, SlotToReg, LoadConstant, SlotToReg, RegToSlot, Label ,
|
RegisterTransfer, SlotToReg, SlotToReg, LoadConstant, SlotToReg, RegToSlot, Label ,
|
||||||
@ -19,7 +19,7 @@ module Register
|
|||||||
def test_call_constant_string
|
def test_call_constant_string
|
||||||
clean_compile :Word, :putstr,{}, s(:statements, s(:return, s(:int, 1)))
|
clean_compile :Word, :putstr,{}, s(:statements, s(:return, s(:int, 1)))
|
||||||
|
|
||||||
@input =s(:call, s(:name, :putstr), s(:arguments), s(:receiver, s(:string, "Hello")))
|
@input =s(:call, :putstr, s(:arguments), s(:receiver, s(:string, "Hello")))
|
||||||
@expect = [Label, SlotToReg, LoadConstant, RegToSlot, LoadConstant, RegToSlot, LoadConstant ,
|
@expect = [Label, SlotToReg, LoadConstant, RegToSlot, LoadConstant, RegToSlot, LoadConstant ,
|
||||||
SlotToReg, RegToSlot, LoadConstant, RegToSlot, RegisterTransfer, FunctionCall, Label ,
|
SlotToReg, RegToSlot, LoadConstant, RegToSlot, RegisterTransfer, FunctionCall, Label ,
|
||||||
RegisterTransfer, SlotToReg, SlotToReg, LoadConstant, SlotToReg, RegToSlot, Label ,
|
RegisterTransfer, SlotToReg, SlotToReg, LoadConstant, SlotToReg, RegToSlot, Label ,
|
||||||
@ -30,7 +30,7 @@ module Register
|
|||||||
def test_call_local_int
|
def test_call_local_int
|
||||||
Parfait.object_space.get_main.add_local(:testi , :Integer)
|
Parfait.object_space.get_main.add_local(:testi , :Integer)
|
||||||
clean_compile :Integer, :putint, {}, s(:statements, s(:return, s(:int, 1)))
|
clean_compile :Integer, :putint, {}, s(:statements, s(:return, s(:int, 1)))
|
||||||
@input = s(:statements, s(:l_assignment, s(:name, :testi), s(:int, 20)), s(:call, s(:name, :putint), s(:arguments), s(:receiver, s(:name, :testi))))
|
@input = s(:statements, s(:l_assignment, s(:local, :testi), s(:int, 20)), s(:call, :putint, s(:arguments), s(:receiver, s(:local, :testi))))
|
||||||
|
|
||||||
@expect = [Label, LoadConstant, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg ,
|
@expect = [Label, LoadConstant, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg ,
|
||||||
RegToSlot, LoadConstant, RegToSlot, LoadConstant, SlotToReg, RegToSlot, LoadConstant ,
|
RegToSlot, LoadConstant, RegToSlot, LoadConstant, SlotToReg, RegToSlot, LoadConstant ,
|
||||||
@ -43,7 +43,7 @@ module Register
|
|||||||
Parfait.object_space.get_main.add_local(:test_l , :List)
|
Parfait.object_space.get_main.add_local(:test_l , :List)
|
||||||
clean_compile :List, :add, {}, s(:statements, s(:return, s(:int, 1)))
|
clean_compile :List, :add, {}, s(:statements, s(:return, s(:int, 1)))
|
||||||
|
|
||||||
@input =s(:statements, s(:call, s(:name, :add), s(:arguments), s(:receiver, s(:name, :test_l))))
|
@input =s(:statements, s(:call, :add, s(:arguments), s(:receiver, s(:local, :test_l))))
|
||||||
@expect = [Label, SlotToReg, SlotToReg, SlotToReg, RegToSlot, LoadConstant, RegToSlot ,
|
@expect = [Label, SlotToReg, SlotToReg, SlotToReg, RegToSlot, LoadConstant, RegToSlot ,
|
||||||
LoadConstant, SlotToReg, RegToSlot, LoadConstant, RegToSlot, RegisterTransfer, FunctionCall ,
|
LoadConstant, SlotToReg, RegToSlot, LoadConstant, RegToSlot, RegisterTransfer, FunctionCall ,
|
||||||
Label, RegisterTransfer, SlotToReg, SlotToReg, LoadConstant, SlotToReg, RegToSlot ,
|
Label, RegisterTransfer, SlotToReg, SlotToReg, LoadConstant, SlotToReg, RegToSlot ,
|
||||||
@ -52,8 +52,8 @@ module Register
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_call_puts
|
def test_call_puts
|
||||||
clean_compile :Space, :putstr, {str: :Word}, s(:statements, s(:return, s(:name, :str)))
|
clean_compile :Space, :putstr, {str: :Word}, s(:statements, s(:return, s(:arg, :str)))
|
||||||
@input =s(:call, s(:name, :putstr), s(:arguments, s(:string, "Hello") ) )
|
@input =s(:call, :putstr , s(:arguments, s(:string, "Hello") ) )
|
||||||
@expect = [Label, SlotToReg, SlotToReg, RegToSlot, LoadConstant, RegToSlot ,
|
@expect = [Label, SlotToReg, SlotToReg, RegToSlot, LoadConstant, RegToSlot ,
|
||||||
LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot ,
|
LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot ,
|
||||||
LoadConstant, RegToSlot, RegisterTransfer, FunctionCall, Label, RegisterTransfer ,
|
LoadConstant, RegToSlot, RegisterTransfer, FunctionCall, Label, RegisterTransfer ,
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
require_relative 'helper'
|
|
||||||
|
|
||||||
module Register
|
|
||||||
class TestClassStatements < MiniTest::Test
|
|
||||||
include Statements
|
|
||||||
|
|
||||||
def class_def
|
|
||||||
clean_compile :Bar, :buh, {}, s(:statements, s(:return, s(:int, 1)))
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_class_call
|
|
||||||
#FIXME class call
|
|
||||||
# class_def
|
|
||||||
# @input = s(:statements, s(:return, s(:call, s(:name, :buh), s(:arguments), s(:receiver, s(:class_name, :Bar)))))
|
|
||||||
#
|
|
||||||
# @expect = [Label, SlotToReg, LoadConstant, RegToSlot, LoadConstant, RegToSlot, LoadConstant ,
|
|
||||||
# RegToSlot, LoadConstant, RegToSlot, RegisterTransfer, FunctionCall, Label, RegisterTransfer ,
|
|
||||||
# SlotToReg, SlotToReg, RegToSlot, Label, FunctionReturn]
|
|
||||||
# check
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_class_field
|
|
||||||
# clean_compile :Space, s(:class_field, :Integer, :boo2)
|
|
||||||
#FIXME class_field handling unclear at the moment
|
|
||||||
# @input =s(:statements, s(:return, s(:field_access, s(:receiver, s(:name, :self)),
|
|
||||||
# s(:field,s(:name, :boo2)))))
|
|
||||||
# @expect = [Label, SlotToReg,SlotToReg,RegToSlot,Label,FunctionReturn]
|
|
||||||
# check
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
@ -11,13 +11,13 @@ module Register
|
|||||||
|
|
||||||
def test_field_not_defined
|
def test_field_not_defined
|
||||||
@root = :field_access
|
@root = :field_access
|
||||||
@input = s(:field_access, s(:receiver, s(:name, :self)), s(:field, s(:name, :a)))
|
@input = s(:field_access, s(:receiver, s(:known, :self)), s(:field, s(:ivar, :a)))
|
||||||
assert_raises(RuntimeError) { check }
|
assert_raises(RuntimeError) { check }
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_field_not_space
|
def test_field_not_space
|
||||||
@root = :field_access
|
@root = :field_access
|
||||||
@input = s(:field_access, s(:receiver, s(:name, :self)), s(:field, s(:name, :space)))
|
@input = s(:field_access, s(:receiver, s(:known, :self)), s(:field, s(:ivar, :space)))
|
||||||
|
|
||||||
assert_raises(RuntimeError) { check }
|
assert_raises(RuntimeError) { check }
|
||||||
end
|
end
|
||||||
@ -25,7 +25,7 @@ module Register
|
|||||||
def test_field
|
def test_field
|
||||||
add_space_field(:bro,:Object)
|
add_space_field(:bro,:Object)
|
||||||
@root = :field_access
|
@root = :field_access
|
||||||
@input = s(:field_access,s(:receiver, s(:name, :self)),s(:field,s(:name, :bro)))
|
@input = s(:field_access,s(:receiver, s(:known, :self)),s(:field,s(:ivar, :bro)))
|
||||||
@output = Register::RegisterValue
|
@output = Register::RegisterValue
|
||||||
check
|
check
|
||||||
end
|
end
|
||||||
|
@ -8,7 +8,7 @@ module Register
|
|||||||
def test_field_named_list
|
def test_field_named_list
|
||||||
Parfait.object_space.get_main.add_local( :m , :Message)
|
Parfait.object_space.get_main.add_local( :m , :Message)
|
||||||
@input = s(:statements, s(:return, s(:field_access,
|
@input = s(:statements, s(:return, s(:field_access,
|
||||||
s(:receiver, s(:name, :m)), s(:field, s(:name, :name)))))
|
s(:receiver, s(:local, :m)), s(:field, s(:ivar, :name)))))
|
||||||
@expect = [Label, SlotToReg, SlotToReg, SlotToReg, RegToSlot, LoadConstant ,
|
@expect = [Label, SlotToReg, SlotToReg, SlotToReg, RegToSlot, LoadConstant ,
|
||||||
SlotToReg, RegToSlot, Label, FunctionReturn]
|
SlotToReg, RegToSlot, Label, FunctionReturn]
|
||||||
assert_nil msg = check_nil , msg
|
assert_nil msg = check_nil , msg
|
||||||
@ -18,8 +18,8 @@ module Register
|
|||||||
Parfait.object_space.get_main.add_local( :m , :Message)
|
Parfait.object_space.get_main.add_local( :m , :Message)
|
||||||
clean_compile :Space, :get_name, { :main => :Message},
|
clean_compile :Space, :get_name, { :main => :Message},
|
||||||
s(:statements, s(:return, s(:field_access,
|
s(:statements, s(:return, s(:field_access,
|
||||||
s(:receiver, s(:name, :main)), s(:field, s(:name, :name)))))
|
s(:receiver, s(:arg, :main)), s(:field, s(:ivar, :name)))))
|
||||||
@input =s(:statements, s(:return, s(:call, s(:name, :get_name), s(:arguments, s(:name, :m)))))
|
@input =s(:statements, s(:return, s(:call, :get_name, s(:arguments, s(:local, :m)))))
|
||||||
|
|
||||||
@expect = [Label, SlotToReg, SlotToReg, RegToSlot, LoadConstant, RegToSlot ,
|
@expect = [Label, SlotToReg, SlotToReg, RegToSlot, LoadConstant, RegToSlot ,
|
||||||
LoadConstant, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg ,
|
LoadConstant, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg ,
|
||||||
@ -31,7 +31,7 @@ module Register
|
|||||||
|
|
||||||
def test_message_field
|
def test_message_field
|
||||||
Parfait.object_space.get_main.add_local(:name , :Word)
|
Parfait.object_space.get_main.add_local(:name , :Word)
|
||||||
@input = s(:statements, s(:l_assignment, s(:name, :name), s(:field_access, s(:receiver, s(:name, :message)), s(:field, s(:name, :name)))), s(:return, s(:name, :name)))
|
@input = s(:statements, s(:l_assignment, s(:local, :name), s(:field_access, s(:receiver, s(:known, :message)), s(:field, s(:ivar, :name)))), s(:return, s(:local, :name)))
|
||||||
|
|
||||||
@expect = [Label, RegisterTransfer, SlotToReg, SlotToReg, RegToSlot, SlotToReg ,
|
@expect = [Label, RegisterTransfer, SlotToReg, SlotToReg, RegToSlot, SlotToReg ,
|
||||||
SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot, Label ,
|
SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot, Label ,
|
||||||
|
@ -11,21 +11,21 @@ module Register
|
|||||||
|
|
||||||
def test_local
|
def test_local
|
||||||
Parfait.object_space.get_main.add_local(:bar , :Integer)
|
Parfait.object_space.get_main.add_local(:bar , :Integer)
|
||||||
@input = s(:name, :bar)
|
@input = s(:local, :bar)
|
||||||
@output = Register::RegisterValue
|
@output = Register::RegisterValue
|
||||||
check
|
check
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_space
|
def test_space
|
||||||
@root = :name
|
@root = :name
|
||||||
@input = s(:name, :space)
|
@input = s(:known, :space)
|
||||||
@output = Register::RegisterValue
|
@output = Register::RegisterValue
|
||||||
check
|
check
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_args
|
def test_args
|
||||||
Parfait.object_space.get_main.add_argument(:bar , :Integer)
|
Parfait.object_space.get_main.add_argument(:bar , :Integer)
|
||||||
@input = s(:name, :bar)
|
@input = s(:arg, :bar)
|
||||||
@output = Register::RegisterValue
|
@output = Register::RegisterValue
|
||||||
check
|
check
|
||||||
end
|
end
|
||||||
|
@ -22,24 +22,24 @@ module Register
|
|||||||
end
|
end
|
||||||
def test_local_int
|
def test_local_int
|
||||||
Parfait.object_space.get_main.add_local(:bar , :Integer)
|
Parfait.object_space.get_main.add_local(:bar , :Integer)
|
||||||
@input = s(:operator_value, :+, s(:name, :bar), s(:int, 3))
|
@input = s(:operator_value, :+, s(:local, :bar), s(:int, 3))
|
||||||
check
|
check
|
||||||
end
|
end
|
||||||
def test_int_local
|
def test_int_local
|
||||||
Parfait.object_space.get_main.add_local(:bar , :Integer)
|
Parfait.object_space.get_main.add_local(:bar , :Integer)
|
||||||
@input = s(:operator_value, :+, s(:int, 3), s(:name, :bar))
|
@input = s(:operator_value, :+, s(:int, 3), s(:local, :bar))
|
||||||
check
|
check
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_field_int
|
def test_field_int
|
||||||
add_space_field(:bro,:Integer)
|
add_space_field(:bro,:Integer)
|
||||||
@input = s(:operator_value, :+, s(:field_access,s(:receiver, s(:name, :self)), s(:field, s(:name, :bro))), s(:int, 3))
|
@input = s(:operator_value, :+, s(:field_access,s(:receiver, s(:known, :self)), s(:field, s(:ivar, :bro))), s(:int, 3))
|
||||||
check
|
check
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_int_field
|
def test_int_field
|
||||||
add_space_field(:bro,:Integer)
|
add_space_field(:bro,:Integer)
|
||||||
@input = s(:operator_value, :+, s(:int, 3), s(:field_access, s(:receiver, s(:name, :self)), s(:field,s(:name, :bro))))
|
@input = s(:operator_value, :+, s(:int, 3), s(:field_access, s(:receiver, s(:known, :self)), s(:field,s(:ivar, :bro))))
|
||||||
check
|
check
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -13,7 +13,7 @@ module Register
|
|||||||
|
|
||||||
def test_return_local
|
def test_return_local
|
||||||
Parfait.object_space.get_main.add_local(:runner , :Integer)
|
Parfait.object_space.get_main.add_local(:runner , :Integer)
|
||||||
@input = s(:statements, s(:return, s(:name, :runner)))
|
@input = s(:statements, s(:return, s(:local , :runner)))
|
||||||
@expect = [Label, SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg ,
|
@expect = [Label, SlotToReg, SlotToReg, RegToSlot, LoadConstant, SlotToReg ,
|
||||||
RegToSlot, Label, FunctionReturn]
|
RegToSlot, Label, FunctionReturn]
|
||||||
assert_nil msg = check_nil , msg
|
assert_nil msg = check_nil , msg
|
||||||
@ -21,14 +21,14 @@ module Register
|
|||||||
|
|
||||||
def test_return_local_assign
|
def test_return_local_assign
|
||||||
Parfait.object_space.get_main.add_local(:runner , :Integer)
|
Parfait.object_space.get_main.add_local(:runner , :Integer)
|
||||||
@input = s(:statements, s(:l_assignment, s(:name, :runner), s(:int, 5)), s(:return, s(:name, :runner)))
|
@input = s(:statements, s(:l_assignment, s(:local, :runner), s(:int, 5)), s(:return, s(:local, :runner)))
|
||||||
@expect = [Label, LoadConstant, SlotToReg, RegToSlot, SlotToReg, SlotToReg ,
|
@expect = [Label, LoadConstant, SlotToReg, RegToSlot, SlotToReg, SlotToReg ,
|
||||||
RegToSlot, LoadConstant, SlotToReg, RegToSlot, Label, FunctionReturn]
|
RegToSlot, LoadConstant, SlotToReg, RegToSlot, Label, FunctionReturn]
|
||||||
assert_nil msg = check_nil , msg
|
assert_nil msg = check_nil , msg
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_return_call
|
def test_return_call
|
||||||
@input =s(:statements, s(:return, s(:call, s(:name, :main), s(:arguments))))
|
@input =s(:statements, s(:return, s(:call, :main, s(:arguments))))
|
||||||
@expect = [Label, SlotToReg, SlotToReg, RegToSlot, LoadConstant, RegToSlot ,
|
@expect = [Label, SlotToReg, SlotToReg, RegToSlot, LoadConstant, RegToSlot ,
|
||||||
LoadConstant, SlotToReg, RegToSlot, LoadConstant, RegToSlot, RegisterTransfer ,
|
LoadConstant, SlotToReg, RegToSlot, LoadConstant, RegToSlot, RegisterTransfer ,
|
||||||
FunctionCall, Label, RegisterTransfer, SlotToReg, SlotToReg, RegToSlot ,
|
FunctionCall, Label, RegisterTransfer, SlotToReg, SlotToReg, RegToSlot ,
|
||||||
@ -38,7 +38,7 @@ module Register
|
|||||||
|
|
||||||
def pest_return_space_length # need to add runtime first
|
def pest_return_space_length # need to add runtime first
|
||||||
Parfait.object_space.get_main.add_local(:l , :Type)
|
Parfait.object_space.get_main.add_local(:l , :Type)
|
||||||
@input = s(:statements, s(:l_assignment, s(:name, :l), s(:call, s(:name, :get_type), s(:arguments), s(:receiver, s(:name, :space)))), s(:return, s(:field_access, s(:receiver, s(:name, :self)), s(:field, s(:name, :runner)))))
|
@input = s(:statements, s(:l_assignment, s(:local, :l), s(:call, :get_type, s(:arguments), s(:receiver, s(:known, :space)))), s(:return, s(:field_access, s(:receiver, s(:known, :self)), s(:field, s(:ivar, :runner)))))
|
||||||
@expect = [Label, SlotToReg,SlotToReg ,RegToSlot,Label,FunctionReturn]
|
@expect = [Label, SlotToReg,SlotToReg ,RegToSlot,Label,FunctionReturn]
|
||||||
assert_nil msg = check_nil , msg
|
assert_nil msg = check_nil , msg
|
||||||
end
|
end
|
||||||
|
@ -17,7 +17,11 @@ module Register
|
|||||||
def test_while_assign
|
def test_while_assign
|
||||||
Parfait.object_space.get_main.add_local(:n , :Integer)
|
Parfait.object_space.get_main.add_local(:n , :Integer)
|
||||||
|
|
||||||
@input = s(:statements, s(:l_assignment, s(:name, :n), s(:int, 5)), s(:while_statement, :plus, s(:conditional, s(:name, :n)), s(:statements, s(:l_assignment, s(:name, :n), s(:operator_value, :-, s(:name, :n), s(:int, 1))))), s(:return, s(:name, :n)))
|
@input = s(:statements, s(:l_assignment, s(:local, :n), s(:int, 5)),
|
||||||
|
s(:while_statement, :plus, s(:conditional, s(:local, :n)),
|
||||||
|
s(:statements, s(:l_assignment, s(:local, :n),
|
||||||
|
s(:operator_value, :-, s(:local, :n), s(:int, 1))))),
|
||||||
|
s(:return, s(:local, :n)))
|
||||||
|
|
||||||
@expect = [Label, LoadConstant, SlotToReg, RegToSlot, Branch, Label ,
|
@expect = [Label, LoadConstant, SlotToReg, RegToSlot, Branch, Label ,
|
||||||
SlotToReg, SlotToReg, LoadConstant, OperatorInstruction, SlotToReg, RegToSlot ,
|
SlotToReg, SlotToReg, LoadConstant, OperatorInstruction, SlotToReg, RegToSlot ,
|
||||||
@ -30,7 +34,9 @@ module Register
|
|||||||
def test_while_return
|
def test_while_return
|
||||||
Parfait.object_space.get_main.add_local(:n , :Integer)
|
Parfait.object_space.get_main.add_local(:n , :Integer)
|
||||||
|
|
||||||
@input = s(:statements, s(:l_assignment, s(:name, :n), s(:int, 10)), s(:while_statement, :plus, s(:conditional, s(:operator_value, :-, s(:name, :n), s(:int, 5))), s(:statements, s(:l_assignment, s(:name, :n), s(:operator_value, :+, s(:name, :n), s(:int, 1))), s(:return, s(:name, :n)))))
|
@input = s(:statements, s(:l_assignment, s(:local, :n), s(:int, 10)), s(:while_statement, :plus, s(:conditional, s(:operator_value, :-, s(:local, :n), s(:int, 5))),
|
||||||
|
s(:statements, s(:l_assignment, s(:local, :n), s(:operator_value, :+, s(:local, :n), s(:int, 1))),
|
||||||
|
s(:return, s(:local, :n)))))
|
||||||
|
|
||||||
@expect = [Label, LoadConstant, SlotToReg, RegToSlot, Branch, Label ,
|
@expect = [Label, LoadConstant, SlotToReg, RegToSlot, Branch, Label ,
|
||||||
SlotToReg, SlotToReg, LoadConstant, OperatorInstruction, SlotToReg, RegToSlot ,
|
SlotToReg, SlotToReg, LoadConstant, OperatorInstruction, SlotToReg, RegToSlot ,
|
||||||
|
@ -9,7 +9,7 @@ class ToCodeTest < MiniTest::Test
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_field_access
|
def test_field_access
|
||||||
@statement = s(:field_access, s(:receiver, s(:name, :m)), s(:field, s(:name, :index)))
|
@statement = s(:field_access, s(:receiver, s(:ivar, :m)), s(:field, s(:ivar, :index)))
|
||||||
check "FieldAccess"
|
check "FieldAccess"
|
||||||
end
|
end
|
||||||
def test_simple_while
|
def test_simple_while
|
||||||
@ -17,15 +17,15 @@ class ToCodeTest < MiniTest::Test
|
|||||||
check "WhileStatement"
|
check "WhileStatement"
|
||||||
end
|
end
|
||||||
def test_l_assignment
|
def test_l_assignment
|
||||||
@statement = s(:l_assignment, s(:name, :i), s(:int, 0))
|
@statement = s(:l_assignment, s(:local, :i), s(:int, 0))
|
||||||
check "LocalAssignment"
|
check "LocalAssignment"
|
||||||
end
|
end
|
||||||
def test_a_assignment
|
def test_a_assignment
|
||||||
@statement = s(:a_assignment, s(:name, :i), s(:int, 0))
|
@statement = s(:a_assignment, s(:arg, :i), s(:int, 0))
|
||||||
check "ArgAssignment"
|
check "ArgAssignment"
|
||||||
end
|
end
|
||||||
def test_i_assignment
|
def test_i_assignment
|
||||||
@statement = s(:i_assignment, s(:name, :i), s(:int, 0))
|
@statement = s(:i_assignment, s(:ivar, :i), s(:int, 0))
|
||||||
check "IvarAssignment"
|
check "IvarAssignment"
|
||||||
end
|
end
|
||||||
def test_nil
|
def test_nil
|
||||||
@ -40,9 +40,13 @@ class ToCodeTest < MiniTest::Test
|
|||||||
@statement = s(:false)
|
@statement = s(:false)
|
||||||
check "FalseExpression"
|
check "FalseExpression"
|
||||||
end
|
end
|
||||||
def test_name
|
def test_known
|
||||||
@statement = s(:name, :foo)
|
@statement = s(:known, :self)
|
||||||
check "NameExpression"
|
check "KnownName"
|
||||||
|
end
|
||||||
|
def test_ivar
|
||||||
|
@statement = s(:ivar, :you)
|
||||||
|
check "InstanceName"
|
||||||
end
|
end
|
||||||
def test_class_name
|
def test_class_name
|
||||||
@statement =s(:class_name, :FooBar)
|
@statement =s(:class_name, :FooBar)
|
||||||
|
Loading…
Reference in New Issue
Block a user