2018-06-29 21:46:39 +02:00
|
|
|
require_relative "helper"
|
2017-04-02 11:57:05 +02:00
|
|
|
|
|
|
|
module Vool
|
|
|
|
class TestSend < MiniTest::Test
|
2018-06-29 21:46:39 +02:00
|
|
|
include RubyTests
|
2017-04-02 11:57:05 +02:00
|
|
|
|
|
|
|
def test_simple
|
2018-06-29 21:46:39 +02:00
|
|
|
lst = compile( "foo")
|
2017-04-02 11:57:05 +02:00
|
|
|
assert_equal SendStatement , lst.class
|
|
|
|
end
|
|
|
|
def test_simple_name
|
2018-06-29 21:46:39 +02:00
|
|
|
lst = compile( "foo")
|
2017-04-02 11:57:05 +02:00
|
|
|
assert_equal :foo , lst.name
|
|
|
|
end
|
|
|
|
def test_simple_receiver
|
2018-06-29 21:46:39 +02:00
|
|
|
lst = compile( "foo")
|
2018-03-15 06:54:14 +01:00
|
|
|
assert_equal SelfExpression , lst.receiver.class
|
2017-04-02 11:57:05 +02:00
|
|
|
end
|
|
|
|
def test_simple_args
|
2018-06-29 21:46:39 +02:00
|
|
|
lst = compile( "foo")
|
2017-04-02 11:57:05 +02:00
|
|
|
assert_equal [] , lst.arguments
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_one_arg
|
2018-06-29 21:46:39 +02:00
|
|
|
lst = compile( "bar(1)")
|
2017-04-02 11:57:05 +02:00
|
|
|
assert_equal SendStatement , lst.class
|
|
|
|
end
|
|
|
|
def test_one_arg_name
|
2018-06-29 21:46:39 +02:00
|
|
|
lst = compile( "bar(1)")
|
2017-04-02 11:57:05 +02:00
|
|
|
assert_equal :bar , lst.name
|
|
|
|
end
|
|
|
|
def test_one_arg_receiver
|
2018-06-29 21:46:39 +02:00
|
|
|
lst = compile( "bar(1)")
|
2018-03-15 06:54:14 +01:00
|
|
|
assert_equal SelfExpression , lst.receiver.class
|
2017-04-02 11:57:05 +02:00
|
|
|
end
|
|
|
|
def test_one_arg_args
|
2018-06-29 21:46:39 +02:00
|
|
|
lst = compile( "bar(1)")
|
2017-04-02 11:57:05 +02:00
|
|
|
assert_equal 1 , lst.arguments.first.value
|
|
|
|
end
|
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
|
|
|
|
class TestSendReceiverType < MiniTest::Test
|
2018-06-29 21:56:49 +02:00
|
|
|
include RubyTests
|
2017-04-19 19:59:13 +02:00
|
|
|
|
|
|
|
def setup
|
2018-07-01 13:12:42 +02:00
|
|
|
Parfait.boot!
|
2017-04-19 19:59:13 +02:00
|
|
|
end
|
2017-04-02 17:42:52 +02:00
|
|
|
|
2017-04-19 19:59:13 +02:00
|
|
|
def test_int_receiver
|
2018-06-29 21:46:39 +02:00
|
|
|
sent = compile( "5.div4")
|
2017-04-19 19:59:13 +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
|
2018-06-29 21:46:39 +02:00
|
|
|
sent = compile( "'5'.putstring")
|
2017-04-19 19:59:13 +02:00
|
|
|
assert_equal Parfait::Type , sent.receiver.ct_type.class
|
|
|
|
assert_equal "Word_Type" , sent.receiver.ct_type.name
|
|
|
|
end
|
2017-04-02 11:57:05 +02:00
|
|
|
end
|
|
|
|
end
|