fix tests for NameExpression split

also necessitates giving method name without the wrapping expression
which is simpler anyway
This commit is contained in:
Torsten Ruger 2017-01-16 09:34:47 +02:00
parent 5f7ea08a43
commit 8dbbffd58e
19 changed files with 71 additions and 93 deletions

View File

@ -13,7 +13,7 @@ class HelloTest < MiniTest::Test
end
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")))))
check
end

View File

@ -13,7 +13,7 @@ module Register
end
HERE
@input = s(:statements, s(:call,
s(:name, :set_internal_byte),
:set_internal_byte ,
s(:arguments, s(:int, 1), s(:int, 104)),
s(:receiver, s(:string, "Hello"))))
super

View File

@ -21,16 +21,16 @@ module Register
end
end
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
end
# must be after boot, but before main compile, to define method
def do_clean_compile
clean_compile :Space , :itest , {:n => :Integer} ,
s(:statements, s(:if_statement, :zero, s(:condition, s(:operator_value, :-, s(:name, :n), s(:int, 12))),
s(:true_statements, s(:call, s(:name, :putstring), s(:arguments), s(:receiver, s(:string, "then")))),
s(:false_statements, s(:call, s(:name, :putstring), s(:arguments), s(:receiver, s(:string, "else"))))))
s(:statements, s(:if_statement, :zero, s(:condition, s(:operator_value, :-, s(:arg, :n), s(:int, 12))),
s(:true_statements, s(:call, :putstring , s(:arguments), s(:receiver, s(:string, "then")))),
s(:false_statements, s(:call, :putstring , s(:arguments), s(:receiver, s(:string, "else"))))))
end
def test_if
#show_ticks # get output of what is

View File

@ -12,7 +12,7 @@ module Register
end
end
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
end

View File

@ -13,7 +13,7 @@ module Register
end
HERE
@input = s(:statements, s(:call,
s(:name, :get_internal_byte),
:get_internal_byte,
s(:arguments, s(:int, 1)),
s(:receiver, s(:string, "Hello"))))
super

View File

@ -18,8 +18,8 @@ module Register
end
HERE
@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(:false_statements, s(:call, s(:name, :putstring), s(:arguments), s(:receiver, s(:string, "else"))))))
s(:true_statements, s(:call, :putstring, s(:arguments), s(:receiver, s(:string, "then")))),
s(:false_statements, s(:call, :putstring, s(:arguments), s(:receiver, s(:string, "else"))))))
super
end

View File

@ -1,7 +1,6 @@
#statements
require_relative "test_assignment"
require_relative "test_call_site"
require_relative "test_class"
require_relative "test_fields"
require_relative "test_if_statement"
require_relative "test_return_statement"

View File

@ -7,7 +7,7 @@ module Register
def test_assign_op
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 ,
LoadConstant, SlotToReg, RegToSlot, Label, FunctionReturn]
@ -15,7 +15,7 @@ module Register
end
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 = []
assert_raises{ check_nil }
end
@ -23,7 +23,7 @@ module Register
def test_assign_ivar
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 ,
RegToSlot, Label, FunctionReturn]
@ -33,7 +33,7 @@ module Register
def test_assign_local_assign
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 ,
RegToSlot, Label, FunctionReturn]
@ -42,7 +42,7 @@ module Register
def test_assign_call
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 ,
LoadConstant, SlotToReg, RegToSlot, LoadConstant, RegToSlot, RegisterTransfer ,
FunctionCall, Label, RegisterTransfer, SlotToReg, SlotToReg, SlotToReg ,
@ -52,7 +52,7 @@ module Register
def test_named_list_get
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 ,
RegToSlot, LoadConstant, SlotToReg, RegToSlot, Label, FunctionReturn]
was = check_return
@ -63,7 +63,7 @@ module Register
def test_assign_local_int
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 ,
RegToSlot, Label, FunctionReturn]
was = check_return
@ -74,14 +74,14 @@ module Register
def test_misassign_local
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]
assert_raises {check }
end
def test_assign_arg
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 ,
RegToSlot, Label, FunctionReturn]
was = check_return
@ -92,7 +92,7 @@ module Register
def test_misassign_arg
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]
assert_raises {check }
end
@ -100,7 +100,7 @@ module Register
def test_arg_get
# have to define bar externally, just because redefining main. Otherwise that would be automatic
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 ,
RegToSlot, Label, FunctionReturn]
was = check_return

View File

@ -29,7 +29,7 @@ module Register
check
end
def test_self
@input = s(:name, :self)
@input = s(:known, :self)
check
end
def test_string

View File

@ -11,31 +11,31 @@ module Register
end
def test_call_main_plain
@input = s(:call,s(:name, :main),s(:arguments))
@input = s(:call , :main ,s(:arguments))
check
end
def test_call_main_int
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
end
def test_call_main_string
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
end
def test_call_main_op
Parfait.object_space.get_main.add_local(:bar , :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
end
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
end

View File

@ -7,7 +7,7 @@ module Register
def test_call_constant_int
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 ,
SlotToReg, RegToSlot, LoadConstant, RegToSlot, RegisterTransfer, FunctionCall, Label ,
RegisterTransfer, SlotToReg, SlotToReg, LoadConstant, SlotToReg, RegToSlot, Label ,
@ -19,7 +19,7 @@ module Register
def test_call_constant_string
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 ,
SlotToReg, RegToSlot, LoadConstant, RegToSlot, RegisterTransfer, FunctionCall, Label ,
RegisterTransfer, SlotToReg, SlotToReg, LoadConstant, SlotToReg, RegToSlot, Label ,
@ -30,7 +30,7 @@ module Register
def test_call_local_int
Parfait.object_space.get_main.add_local(:testi , :Integer)
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 ,
RegToSlot, LoadConstant, RegToSlot, LoadConstant, SlotToReg, RegToSlot, LoadConstant ,
@ -43,7 +43,7 @@ module Register
Parfait.object_space.get_main.add_local(:test_l , :List)
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 ,
LoadConstant, SlotToReg, RegToSlot, LoadConstant, RegToSlot, RegisterTransfer, FunctionCall ,
Label, RegisterTransfer, SlotToReg, SlotToReg, LoadConstant, SlotToReg, RegToSlot ,
@ -52,8 +52,8 @@ module Register
end
def test_call_puts
clean_compile :Space, :putstr, {str: :Word}, s(:statements, s(:return, s(:name, :str)))
@input =s(:call, s(:name, :putstr), s(:arguments, s(:string, "Hello") ) )
clean_compile :Space, :putstr, {str: :Word}, s(:statements, s(:return, s(:arg, :str)))
@input =s(:call, :putstr , s(:arguments, s(:string, "Hello") ) )
@expect = [Label, SlotToReg, SlotToReg, RegToSlot, LoadConstant, RegToSlot ,
LoadConstant, SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot ,
LoadConstant, RegToSlot, RegisterTransfer, FunctionCall, Label, RegisterTransfer ,

View File

@ -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

View File

@ -11,13 +11,13 @@ module Register
def test_field_not_defined
@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 }
end
def test_field_not_space
@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 }
end
@ -25,7 +25,7 @@ module Register
def test_field
add_space_field(:bro,:Object)
@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
check
end

View File

@ -8,7 +8,7 @@ module Register
def test_field_named_list
Parfait.object_space.get_main.add_local( :m , :Message)
@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 ,
SlotToReg, RegToSlot, Label, FunctionReturn]
assert_nil msg = check_nil , msg
@ -18,8 +18,8 @@ module Register
Parfait.object_space.get_main.add_local( :m , :Message)
clean_compile :Space, :get_name, { :main => :Message},
s(:statements, s(:return, s(:field_access,
s(:receiver, s(:name, :main)), s(:field, s(:name, :name)))))
@input =s(:statements, s(:return, s(:call, s(:name, :get_name), s(:arguments, s(:name, :m)))))
s(:receiver, s(:arg, :main)), s(:field, s(:ivar, :name)))))
@input =s(:statements, s(:return, s(:call, :get_name, s(:arguments, s(:local, :m)))))
@expect = [Label, SlotToReg, SlotToReg, RegToSlot, LoadConstant, RegToSlot ,
LoadConstant, SlotToReg, RegToSlot, SlotToReg, SlotToReg, SlotToReg ,
@ -31,7 +31,7 @@ module Register
def test_message_field
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 ,
SlotToReg, RegToSlot, LoadConstant, SlotToReg, RegToSlot, Label ,

View File

@ -11,21 +11,21 @@ module Register
def test_local
Parfait.object_space.get_main.add_local(:bar , :Integer)
@input = s(:name, :bar)
@input = s(:local, :bar)
@output = Register::RegisterValue
check
end
def test_space
@root = :name
@input = s(:name, :space)
@input = s(:known, :space)
@output = Register::RegisterValue
check
end
def test_args
Parfait.object_space.get_main.add_argument(:bar , :Integer)
@input = s(:name, :bar)
@input = s(:arg, :bar)
@output = Register::RegisterValue
check
end

View File

@ -22,24 +22,24 @@ module Register
end
def test_local_int
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
end
def test_int_local
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
end
def test_field_int
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
end
def test_int_field
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
end
end

View File

@ -13,7 +13,7 @@ module Register
def test_return_local
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 ,
RegToSlot, Label, FunctionReturn]
assert_nil msg = check_nil , msg
@ -21,14 +21,14 @@ module Register
def test_return_local_assign
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 ,
RegToSlot, LoadConstant, SlotToReg, RegToSlot, Label, FunctionReturn]
assert_nil msg = check_nil , msg
end
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 ,
LoadConstant, SlotToReg, RegToSlot, LoadConstant, RegToSlot, RegisterTransfer ,
FunctionCall, Label, RegisterTransfer, SlotToReg, SlotToReg, RegToSlot ,
@ -38,7 +38,7 @@ module Register
def pest_return_space_length # need to add runtime first
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]
assert_nil msg = check_nil , msg
end

View File

@ -17,7 +17,11 @@ module Register
def test_while_assign
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 ,
SlotToReg, SlotToReg, LoadConstant, OperatorInstruction, SlotToReg, RegToSlot ,
@ -30,7 +34,9 @@ module Register
def test_while_return
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 ,
SlotToReg, SlotToReg, LoadConstant, OperatorInstruction, SlotToReg, RegToSlot ,

View File

@ -9,7 +9,7 @@ class ToCodeTest < MiniTest::Test
end
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"
end
def test_simple_while
@ -17,15 +17,15 @@ class ToCodeTest < MiniTest::Test
check "WhileStatement"
end
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"
end
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"
end
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"
end
def test_nil
@ -40,9 +40,13 @@ class ToCodeTest < MiniTest::Test
@statement = s(:false)
check "FalseExpression"
end
def test_name
@statement = s(:name, :foo)
check "NameExpression"
def test_known
@statement = s(:known, :self)
check "KnownName"
end
def test_ivar
@statement = s(:ivar, :you)
check "InstanceName"
end
def test_class_name
@statement =s(:class_name, :FooBar)