2015-11-07 12:18:08 +02:00
|
|
|
require_relative "helper"
|
2015-10-14 13:48:21 +03:00
|
|
|
|
2017-01-19 09:02:29 +02:00
|
|
|
module Risc
|
2015-10-14 15:17:33 +03:00
|
|
|
class TestCall < MiniTest::Test
|
2015-11-07 12:18:08 +02:00
|
|
|
include ExpressionHelper
|
2016-12-10 15:26:25 +02:00
|
|
|
include AST::Sexp
|
2015-10-14 13:48:21 +03:00
|
|
|
|
|
|
|
def setup
|
2017-01-19 09:02:29 +02:00
|
|
|
Risc.machine.boot
|
|
|
|
@output = Risc::RiscValue
|
2015-10-14 13:48:21 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_call_main_plain
|
2017-01-16 09:34:47 +02:00
|
|
|
@input = s(:call , :main ,s(:arguments))
|
2015-10-14 13:48:21 +03:00
|
|
|
check
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_call_main_int
|
2016-12-30 14:10:49 +02:00
|
|
|
Parfait.object_space.get_main.add_argument(:blar , :Integer)
|
2017-01-16 09:34:47 +02:00
|
|
|
@input =s(:call, :main ,s(:arguments , s(:int, 1)))
|
2015-10-14 16:16:03 +03:00
|
|
|
check
|
|
|
|
end
|
|
|
|
|
2015-10-14 13:48:21 +03:00
|
|
|
def test_call_main_string
|
2016-12-30 14:10:49 +02:00
|
|
|
Parfait.object_space.get_main.add_argument(:blar , :Word)
|
2017-01-16 09:34:47 +02:00
|
|
|
@input =s(:call, :main ,s(:arguments , s(:string, "1") ))
|
2015-10-14 13:48:21 +03:00
|
|
|
check
|
|
|
|
end
|
|
|
|
|
2015-10-14 21:34:18 +03:00
|
|
|
def test_call_main_op
|
2016-12-30 14:10:49 +02:00
|
|
|
Parfait.object_space.get_main.add_local(:bar , :Integer)
|
|
|
|
Parfait.object_space.get_main.add_argument(:blar , :Integer)
|
2017-01-16 09:34:47 +02:00
|
|
|
@input =s(:call, :main ,s(:arguments , s(:local, :bar) ))
|
2015-10-14 13:48:21 +03:00
|
|
|
check
|
|
|
|
end
|
2015-10-14 16:16:03 +03:00
|
|
|
|
|
|
|
def test_call_string_put
|
2017-08-29 18:38:51 +03:00
|
|
|
@input = s(:call, :putstring,s(:arguments),s(:receiver,s(:string, "Hello Raisa, I am rubyx")))
|
2015-10-14 16:16:03 +03:00
|
|
|
check
|
|
|
|
end
|
|
|
|
|
2015-10-14 13:48:21 +03:00
|
|
|
end
|
|
|
|
end
|