fix ruby send statement

remove ruby expression
This commit is contained in:
Torsten Ruger
2018-07-20 10:05:11 +03:00
parent 8cd9818f64
commit 7b02feae7a
6 changed files with 144 additions and 74 deletions

View File

@ -1,43 +1,44 @@
require_relative "helper"
module Ruby
class TestSend < MiniTest::Test
class TestSendFoo < MiniTest::Test
include RubyTests
def test_simple
lst = compile( "foo")
assert_equal SendStatement , lst.class
def setup
@lst = compile( "foo")
end
def test_simple_class
assert_equal SendStatement , @lst.class
end
def test_simple_name
lst = compile( "foo")
assert_equal :foo , lst.name
assert_equal :foo , @lst.name
end
def test_simple_receiver
lst = compile( "foo")
assert_equal SelfExpression , lst.receiver.class
assert_equal SelfExpression , @lst.receiver.class
end
def test_simple_args
lst = compile( "foo")
assert_equal [] , lst.arguments
assert_equal [] , @lst.arguments
end
end
class TestSendBar < MiniTest::Test
include RubyTests
def setup
@lst = compile( "bar(1)")
end
def test_one_arg
lst = compile( "bar(1)")
assert_equal SendStatement , lst.class
assert_equal SendStatement , @lst.class
end
def test_one_arg_name
lst = compile( "bar(1)")
assert_equal :bar , lst.name
assert_equal :bar , @lst.name
end
def test_one_arg_receiver
lst = compile( "bar(1)")
assert_equal SelfExpression , lst.receiver.class
assert_equal SelfExpression , @lst.receiver.class
end
def test_one_arg_args
lst = compile( "bar(1)")
assert_equal 1 , lst.arguments.first.value
assert_equal 1 , @lst.arguments.first.value
end
end
class TestSendSuper < MiniTest::Test
include RubyTests
def test_super0_receiver
lst = compile( "super")
assert_equal SuperExpression , lst.receiver.class

View File

@ -0,0 +1,98 @@
require_relative "helper"
module Ruby
class TestSendFooVool < MiniTest::Test
include RubyTests
def setup
@lst = compile( "foo").to_vool
end
def test_simple_class
assert_equal Vool::SendStatement , @lst.class
end
def test_simple_name
assert_equal :foo , @lst.name
end
def test_simple_receiver
assert_equal Vool::SelfExpression , @lst.receiver.class
end
def test_simple_args
assert_equal [] , @lst.arguments
end
end
class TestSendBarVool < MiniTest::Test
include RubyTests
def setup
@lst = compile( "bar(1)").to_vool
end
def test_class
assert_equal Vool::Statements , @lst.class
assert_equal 2 , @lst.length
end
def test_first
assert_equal Vool::LocalAssignment , @lst.first.class
end
def test_last
assert_equal Vool::SendStatement , @lst.last.class
end
def test_name
assert_equal :bar , @lst.last.name
end
def test_receiver
assert_equal Vool::SelfExpression , @lst.last.receiver.class
end
def test_args
assert @lst.last.arguments.first.name.to_s.start_with?("tmp")
end
end
class TestSendSuperVool < MiniTest::Test
include RubyTests
def test_super0_receiver
lst = compile( "super").to_vool
assert_equal Vool::SuperExpression , lst.receiver.class
end
def test_super0
lst = compile( "super").to_vool
assert_equal Vool::SendStatement , lst.class
end
end
class TestSendSuperArgsVool < MiniTest::Test
include RubyTests
def setup
@lst = compile( "super(1)").to_vool
end
def test_super_args_class
assert_equal Vool::Statements , @lst.class
assert_equal 2 , @lst.length
end
def test_super_args_first
assert_equal Vool::LocalAssignment , @lst.first.class
end
def test_super_args_last
assert_equal Vool::SendStatement , @lst.last.class
end
def test_super_receiver
assert_equal Vool::SuperExpression , @lst.last.receiver.class
end
def test_super_name #is nil
assert_nil @lst.last.name
end
end
class TestSendReceiverTypeVool < MiniTest::Test
include RubyTests
def setup
Parfait.boot!
end
def test_int_receiver
sent = compile( "5.div4").to_vool
assert_equal Parfait::Type , sent.receiver.ct_type.class
assert_equal "Integer_Type" , sent.receiver.ct_type.name
end
def test_string_receiver
sent = compile( "'5'.putstring").to_vool
assert_equal Parfait::Type , sent.receiver.ct_type.class
assert_equal "Word_Type" , sent.receiver.ct_type.name
end
end
end