2018-06-29 21:46:39 +02:00
|
|
|
require_relative "helper"
|
2017-04-02 11:57:05 +02:00
|
|
|
|
2018-07-19 13:46:51 +02:00
|
|
|
module Ruby
|
2019-08-15 20:30:36 +02:00
|
|
|
class TestSendNoArg < MiniTest::Test
|
2018-06-29 21:46:39 +02:00
|
|
|
include RubyTests
|
2018-07-20 09:05:11 +02:00
|
|
|
def setup
|
|
|
|
@lst = compile( "foo")
|
|
|
|
end
|
|
|
|
def test_simple_class
|
|
|
|
assert_equal SendStatement , @lst.class
|
2017-04-02 11:57:05 +02:00
|
|
|
end
|
|
|
|
def test_simple_name
|
2018-07-20 09:05:11 +02:00
|
|
|
assert_equal :foo , @lst.name
|
2017-04-02 11:57:05 +02:00
|
|
|
end
|
|
|
|
def test_simple_receiver
|
2018-07-20 09:05:11 +02:00
|
|
|
assert_equal SelfExpression , @lst.receiver.class
|
2017-04-02 11:57:05 +02:00
|
|
|
end
|
|
|
|
def test_simple_args
|
2018-07-20 09:05:11 +02:00
|
|
|
assert_equal [] , @lst.arguments
|
|
|
|
end
|
2018-09-01 14:54:25 +02:00
|
|
|
def test_tos
|
|
|
|
assert_equal "self.foo()" , @lst.to_s
|
|
|
|
end
|
2018-07-20 09:05:11 +02:00
|
|
|
end
|
2019-08-15 20:30:36 +02:00
|
|
|
class TestSendSimpleArg < MiniTest::Test
|
2018-07-20 09:05:11 +02:00
|
|
|
include RubyTests
|
|
|
|
def setup
|
|
|
|
@lst = compile( "bar(1)")
|
2017-04-02 11:57:05 +02:00
|
|
|
end
|
|
|
|
def test_one_arg
|
2018-07-20 09:05:11 +02:00
|
|
|
assert_equal SendStatement , @lst.class
|
2017-04-02 11:57:05 +02:00
|
|
|
end
|
|
|
|
def test_one_arg_name
|
2018-07-20 09:05:11 +02:00
|
|
|
assert_equal :bar , @lst.name
|
2017-04-02 11:57:05 +02:00
|
|
|
end
|
|
|
|
def test_one_arg_receiver
|
2018-07-20 09:05:11 +02:00
|
|
|
assert_equal SelfExpression , @lst.receiver.class
|
2017-04-02 11:57:05 +02:00
|
|
|
end
|
|
|
|
def test_one_arg_args
|
2018-07-20 09:05:11 +02:00
|
|
|
assert_equal 1 , @lst.arguments.first.value
|
2017-04-02 11:57:05 +02:00
|
|
|
end
|
2018-07-20 09:05:11 +02:00
|
|
|
end
|
|
|
|
class TestSendSuper < MiniTest::Test
|
|
|
|
include RubyTests
|
2017-04-02 17:42:52 +02:00
|
|
|
def test_super0_receiver
|
2018-06-29 21:46:39 +02:00
|
|
|
lst = compile( "super")
|
2018-03-15 06:54:14 +01:00
|
|
|
assert_equal SuperExpression , lst.receiver.class
|
2017-04-02 17:42:52 +02:00
|
|
|
end
|
|
|
|
def test_super0
|
2018-06-29 21:46:39 +02:00
|
|
|
lst = compile( "super")
|
2017-04-02 17:42:52 +02:00
|
|
|
assert_equal SendStatement , lst.class
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_super_receiver
|
2018-06-29 21:46:39 +02:00
|
|
|
lst = compile( "super(1)")
|
2018-03-15 06:54:14 +01:00
|
|
|
assert_equal SuperExpression , lst.receiver.class
|
2017-04-02 17:42:52 +02:00
|
|
|
end
|
|
|
|
def test_super_args
|
2018-06-29 21:46:39 +02:00
|
|
|
lst = compile( "super(1)")
|
2017-04-02 17:42:52 +02:00
|
|
|
assert_equal 1 , lst.arguments.first.value
|
|
|
|
end
|
|
|
|
def test_super_name #is nil
|
2018-06-29 21:46:39 +02:00
|
|
|
lst = compile( "super(1)")
|
2017-04-02 17:42:52 +02:00
|
|
|
assert_nil lst.name
|
|
|
|
end
|
2019-08-15 20:30:36 +02:00
|
|
|
class TestSendSendArgs < MiniTest::Test
|
|
|
|
include RubyTests
|
|
|
|
def setup
|
|
|
|
@lst = compile( "call(arg1, arg2(more))")
|
|
|
|
end
|
|
|
|
def test_one_arg
|
|
|
|
assert_equal SendStatement , @lst.class
|
|
|
|
end
|
|
|
|
def test_one_arg_name
|
|
|
|
assert_equal :call , @lst.name
|
|
|
|
end
|
|
|
|
def test_one_arg_args
|
|
|
|
assert_equal SendStatement , @lst.arguments.first.class
|
|
|
|
end
|
|
|
|
def test_one_arg_args_args
|
|
|
|
assert_equal 0 , @lst.arguments.first.arguments.length
|
|
|
|
end
|
|
|
|
def test_two_arg_args
|
|
|
|
assert_equal SendStatement , @lst.arguments[1].class
|
|
|
|
end
|
|
|
|
def test_two_arg_args_args
|
|
|
|
assert_equal SendStatement , @lst.arguments[1].arguments.first.class
|
|
|
|
assert_equal :more , @lst.arguments[1].arguments.first.name
|
|
|
|
end
|
|
|
|
end
|
2017-04-19 19:59:13 +02:00
|
|
|
end
|
2017-04-02 11:57:05 +02:00
|
|
|
end
|