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
|
2018-07-20 09:05:11 +02:00
|
|
|
class TestSendFoo < 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
|
|
|
|
end
|
|
|
|
class TestSendBar < MiniTest::Test
|
|
|
|
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
|
2017-04-19 19:59:13 +02:00
|
|
|
end
|
2017-04-02 11:57:05 +02:00
|
|
|
end
|