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