2018-04-26 11:31:37 +02:00
|
|
|
require_relative "helper"
|
2015-10-27 17:08:40 +01:00
|
|
|
|
2017-04-14 10:13:47 +02:00
|
|
|
module Parfait
|
2018-04-26 11:31:37 +02:00
|
|
|
class TestMessage < ParfaitTest
|
2015-10-27 17:08:40 +01:00
|
|
|
|
2017-04-14 10:13:47 +02:00
|
|
|
def setup
|
2018-04-26 11:31:37 +02:00
|
|
|
super
|
2018-09-01 10:24:16 +02:00
|
|
|
@mess = @space.get_next_for(:Message)
|
2017-04-14 10:13:47 +02:00
|
|
|
end
|
2019-08-22 16:54:17 +02:00
|
|
|
def test_args_start
|
|
|
|
assert_equal 8 , Message.args_start_at
|
|
|
|
end
|
2019-08-23 09:21:22 +02:00
|
|
|
def test_locals_start
|
|
|
|
assert_equal 15 , Message.locals_start_at
|
|
|
|
end
|
2017-04-14 10:13:47 +02:00
|
|
|
def test_length
|
2019-08-23 09:21:22 +02:00
|
|
|
assert_equal 31 , @mess.get_type.instance_length , @mess.get_type.inspect
|
2017-04-14 10:13:47 +02:00
|
|
|
end
|
|
|
|
def test_attribute_set
|
2018-08-11 18:17:20 +02:00
|
|
|
@mess.set_receiver( 55 ) # 55 is not parfait, hance not actually allowed
|
2017-04-14 10:13:47 +02:00
|
|
|
assert_equal 55 , @mess.receiver
|
|
|
|
end
|
2019-08-23 09:21:22 +02:00
|
|
|
def test_indexed_arg
|
2019-08-22 16:54:17 +02:00
|
|
|
assert_equal 8 , @mess.get_type.variable_index(:arguments_given)
|
|
|
|
assert_equal 9 , @mess.get_type.variable_index(:arg1)
|
|
|
|
assert_equal 13 , @mess.get_type.variable_index(:arg5)
|
2017-04-14 10:13:47 +02:00
|
|
|
end
|
2019-08-23 09:21:22 +02:00
|
|
|
def test_indexed_local
|
|
|
|
assert_equal 15 , @mess.get_type.variable_index(:locals_used)
|
|
|
|
assert_equal 16 , @mess.get_type.variable_index(:local1)
|
|
|
|
assert_equal 30 , @mess.get_type.variable_index(:local15)
|
|
|
|
end
|
2017-04-14 10:13:47 +02:00
|
|
|
def test_next_message
|
|
|
|
assert_equal Message , @mess.next_message.class
|
|
|
|
end
|
|
|
|
def test_locals
|
2019-08-23 09:21:22 +02:00
|
|
|
assert_equal Integer , @mess.locals_used.class
|
2017-04-14 10:13:47 +02:00
|
|
|
end
|
|
|
|
def test_arguments
|
2019-08-22 16:54:17 +02:00
|
|
|
assert_equal Integer , @mess.arguments_given.class
|
2017-04-14 10:13:47 +02:00
|
|
|
end
|
|
|
|
def test_return_address
|
|
|
|
assert_nil @mess.return_address
|
|
|
|
end
|
|
|
|
def test_return_value
|
|
|
|
assert_nil @mess.return_value
|
|
|
|
end
|
|
|
|
def test_caller
|
|
|
|
assert_nil @mess.caller
|
|
|
|
end
|
2018-07-22 21:29:32 +02:00
|
|
|
def test_method
|
|
|
|
assert_nil @mess.method
|
2017-04-14 10:13:47 +02:00
|
|
|
end
|
2016-12-29 17:45:32 +01:00
|
|
|
end
|
2015-10-27 17:08:40 +01:00
|
|
|
end
|