2019-08-13 18:32:17 +02:00
|
|
|
require_relative "helper"
|
2019-08-06 17:33:27 +02:00
|
|
|
|
|
|
|
module Mom
|
2019-08-22 21:56:44 +02:00
|
|
|
class TestBlockCompiler1 < MiniTest::Test
|
2019-08-13 18:32:17 +02:00
|
|
|
include ScopeHelper
|
2019-08-06 17:33:27 +02:00
|
|
|
|
|
|
|
def setup
|
2019-09-12 12:10:31 +02:00
|
|
|
code = as_main_block("return 5" , "a = 1")
|
2019-08-13 18:32:17 +02:00
|
|
|
@risc = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_risc(code)
|
2019-08-06 17:33:27 +02:00
|
|
|
end
|
|
|
|
|
2019-08-22 21:56:44 +02:00
|
|
|
def test_collection
|
|
|
|
assert_equal Risc::RiscCollection, @risc.class
|
|
|
|
end
|
|
|
|
def test_main_compiler
|
|
|
|
assert_equal :main , @risc.method_compilers.first.callable.name
|
|
|
|
end
|
|
|
|
def test_main_block_compiler
|
|
|
|
assert_equal :main , @risc.method_compilers.first.block_compilers.first.in_method.name
|
|
|
|
assert_equal :main_block , @risc.method_compilers.first.block_compilers.first.callable.name
|
|
|
|
end
|
|
|
|
end
|
|
|
|
class TestBlockCompiler2 < MiniTest::Test
|
|
|
|
include ScopeHelper
|
|
|
|
|
|
|
|
def setup
|
2019-09-12 12:10:31 +02:00
|
|
|
code = as_main_block("return arg" , "arg = 1")
|
2019-08-22 21:56:44 +02:00
|
|
|
@risc = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_risc(code)
|
|
|
|
end
|
|
|
|
|
2019-08-13 18:32:17 +02:00
|
|
|
def test_collection
|
|
|
|
assert_equal Risc::RiscCollection, @risc.class
|
2019-08-06 17:33:27 +02:00
|
|
|
end
|
2019-08-13 18:32:17 +02:00
|
|
|
def test_main_compiler
|
|
|
|
assert_equal :main , @risc.method_compilers.first.callable.name
|
2019-08-06 17:33:27 +02:00
|
|
|
end
|
2019-08-13 18:32:17 +02:00
|
|
|
def test_main_block_compiler
|
|
|
|
assert_equal :main , @risc.method_compilers.first.block_compilers.first.in_method.name
|
|
|
|
assert_equal :main_block , @risc.method_compilers.first.block_compilers.first.callable.name
|
2019-08-06 17:33:27 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|