2018-07-20 09:05:11 +02:00
|
|
|
require_relative "helper"
|
|
|
|
|
|
|
|
module Ruby
|
2019-10-03 23:36:49 +02:00
|
|
|
class TestSendNoArgSol < MiniTest::Test
|
2018-07-20 09:05:11 +02:00
|
|
|
include RubyTests
|
|
|
|
def setup
|
2019-10-03 23:36:49 +02:00
|
|
|
@lst = compile( "foo").to_sol
|
2018-07-20 09:05:11 +02:00
|
|
|
end
|
|
|
|
def test_simple_class
|
2019-10-03 23:36:49 +02:00
|
|
|
assert_equal Sol::SendStatement , @lst.class
|
2018-07-20 09:05:11 +02:00
|
|
|
end
|
|
|
|
def test_simple_name
|
|
|
|
assert_equal :foo , @lst.name
|
|
|
|
end
|
|
|
|
def test_simple_receiver
|
2019-10-03 23:36:49 +02:00
|
|
|
assert_equal Sol::SelfExpression , @lst.receiver.class
|
2018-07-20 09:05:11 +02:00
|
|
|
end
|
|
|
|
def test_simple_args
|
|
|
|
assert_equal [] , @lst.arguments
|
|
|
|
end
|
|
|
|
end
|
2019-10-03 23:36:49 +02:00
|
|
|
class TestSendSimpleArgSol < MiniTest::Test
|
2018-07-20 09:05:11 +02:00
|
|
|
include RubyTests
|
|
|
|
def setup
|
2019-10-03 23:36:49 +02:00
|
|
|
@lst = compile( "bar(1)").to_sol
|
2018-07-20 09:05:11 +02:00
|
|
|
end
|
|
|
|
def test_class
|
2019-10-03 23:36:49 +02:00
|
|
|
assert_equal Sol::SendStatement , @lst.class
|
2018-07-20 09:05:11 +02:00
|
|
|
end
|
|
|
|
def test_name
|
2018-07-20 12:15:16 +02:00
|
|
|
assert_equal :bar , @lst.name
|
2018-07-20 09:05:11 +02:00
|
|
|
end
|
|
|
|
def test_receiver
|
2019-10-03 23:36:49 +02:00
|
|
|
assert_equal Sol::SelfExpression , @lst.receiver.class
|
2018-07-20 09:05:11 +02:00
|
|
|
end
|
|
|
|
def test_args
|
2019-10-03 23:36:49 +02:00
|
|
|
assert_equal Sol::IntegerConstant , @lst.arguments.first.class
|
2018-07-20 09:05:11 +02:00
|
|
|
end
|
|
|
|
end
|
2019-10-03 23:36:49 +02:00
|
|
|
class TestSendSuperSol < MiniTest::Test
|
2018-07-20 09:05:11 +02:00
|
|
|
include RubyTests
|
2019-08-19 13:23:55 +02:00
|
|
|
def test_super0
|
2019-10-03 23:36:49 +02:00
|
|
|
lst = compile( "super").to_sol
|
|
|
|
assert_equal Sol::SuperStatement , lst.class
|
2018-07-20 09:05:11 +02:00
|
|
|
end
|
2019-08-19 13:23:55 +02:00
|
|
|
def test_super0_receiver
|
2019-10-03 23:36:49 +02:00
|
|
|
lst = compile( "super").to_sol
|
|
|
|
assert_equal Sol::SelfExpression , lst.receiver.class
|
2018-07-20 09:05:11 +02:00
|
|
|
end
|
|
|
|
end
|
2019-10-03 23:36:49 +02:00
|
|
|
class TestSendSuperArgsSol < MiniTest::Test
|
2018-07-20 09:05:11 +02:00
|
|
|
include RubyTests
|
|
|
|
def setup
|
2019-10-03 23:36:49 +02:00
|
|
|
@lst = compile( "super(1)").to_sol
|
2018-07-20 09:05:11 +02:00
|
|
|
end
|
2018-07-20 12:15:16 +02:00
|
|
|
def test_super_class
|
2019-10-03 23:36:49 +02:00
|
|
|
assert_equal Sol::SuperStatement , @lst.class
|
2018-07-20 09:05:11 +02:00
|
|
|
end
|
|
|
|
def test_super_receiver
|
2019-10-03 23:36:49 +02:00
|
|
|
assert_equal Sol::SelfExpression , @lst.receiver.class
|
2018-07-20 09:05:11 +02:00
|
|
|
end
|
2019-08-19 13:23:55 +02:00
|
|
|
def test_super_name
|
2019-08-19 17:48:13 +02:00
|
|
|
assert_equal :super, @lst.name
|
2018-07-20 09:05:11 +02:00
|
|
|
end
|
|
|
|
end
|
2019-10-03 23:36:49 +02:00
|
|
|
class TestSendReceiverTypeSol < MiniTest::Test
|
2018-07-20 09:05:11 +02:00
|
|
|
include RubyTests
|
|
|
|
|
|
|
|
def setup
|
2019-02-08 22:03:23 +01:00
|
|
|
Parfait.boot!(Parfait.default_test_options)
|
2018-07-20 09:05:11 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_int_receiver
|
2019-10-03 23:36:49 +02:00
|
|
|
sent = compile( "5.div4").to_sol
|
2018-07-20 09:05:11 +02:00
|
|
|
assert_equal Parfait::Type , sent.receiver.ct_type.class
|
|
|
|
assert_equal "Integer_Type" , sent.receiver.ct_type.name
|
|
|
|
end
|
|
|
|
def test_string_receiver
|
2019-10-03 23:36:49 +02:00
|
|
|
sent = compile( "'5'.putstring").to_sol
|
2018-07-20 09:05:11 +02:00
|
|
|
assert_equal Parfait::Type , sent.receiver.ct_type.class
|
|
|
|
assert_equal "Word_Type" , sent.receiver.ct_type.name
|
|
|
|
end
|
|
|
|
end
|
2019-08-16 17:42:57 +02:00
|
|
|
class TestSendReceiver < MiniTest::Test
|
|
|
|
include RubyTests
|
|
|
|
def setup
|
2019-10-03 23:36:49 +02:00
|
|
|
@lst = compile( "call.once.more").to_sol
|
2019-08-16 17:42:57 +02:00
|
|
|
end
|
|
|
|
def test_class
|
2019-10-03 23:36:49 +02:00
|
|
|
assert_equal Sol::Statements , @lst.class
|
2019-08-16 17:42:57 +02:00
|
|
|
end
|
|
|
|
def test_one
|
2019-10-03 23:36:49 +02:00
|
|
|
assert_equal Sol::LocalAssignment , @lst.first.class
|
2019-08-16 17:42:57 +02:00
|
|
|
end
|
|
|
|
def test_one_name
|
|
|
|
assert @lst[0].name.to_s.start_with?("tmp_")
|
|
|
|
end
|
|
|
|
def test_one_value
|
|
|
|
assert_equal :call , @lst[0].value.name
|
|
|
|
end
|
|
|
|
def test_two_name
|
|
|
|
assert @lst[1].name.to_s.start_with?("tmp_")
|
|
|
|
end
|
|
|
|
def test_two_value
|
|
|
|
assert_equal :once , @lst[1].value.name
|
|
|
|
end
|
|
|
|
def test_three_class
|
2019-10-03 23:36:49 +02:00
|
|
|
assert_equal Sol::SendStatement, @lst[2].class
|
2019-08-16 17:42:57 +02:00
|
|
|
end
|
|
|
|
def test_three_name
|
|
|
|
assert_equal :more , @lst[2].name
|
|
|
|
end
|
|
|
|
def test_three_self
|
|
|
|
assert @lst[2].receiver.name.to_s.start_with?("tmp_")
|
|
|
|
end
|
|
|
|
end
|
2018-07-20 09:05:11 +02:00
|
|
|
end
|