rubyx/test/slot_machine/test_block_statement.rb
Torsten Rüger d1f8733623 Rename Vool to Sol
Simple is really the descriptive name for the layer
Sure, it is "virtual" but that is not as important as the fact that it is simple (or simplified)
Also objct (based really) is better, since orientated implies it is a little like that, but only orientated, not really it. Sol only has objects, nothing else
Just cause i was renaming anyway
2019-10-04 00:38:47 +03:00

55 lines
1.5 KiB
Ruby

require_relative "helper"
module Sol
class TestBlockArg < MiniTest::Test
include SlotMachineCompile
def setup
@ret = compile_slot( as_main("self.main {|elem| elem = 5 } "))
end
def test_is_compiler
assert_equal SlotMachine::SlotCollection , @ret.class
end
def test_has_method
assert_equal Parfait::CallableMethod , @ret.method_compilers.get_method.class
end
def test_method_has_block
assert @ret.method_compilers.get_method.blocks , "No block created"
end
end
class TestBlockLocal < MiniTest::Test
include SlotMachineCompile
def setup
@ret = compile_slot( as_main("self.main {|elem| local = 5 } "))
@block = @ret.method_compilers.get_method.blocks
end
def test_block_arg_type
assert_equal Parfait::Type, @block.arguments_type.class
end
def test_block_arg_type_name
assert_equal 1, @block.arguments_type.variable_index(:elem)
end
def test_block_local_type
assert_equal Parfait::Type, @block.frame_type.class
end
def test_block_frame_type_name
assert_equal 1, @block.frame_type.variable_index(:local)
end
end
class TestBlockMethodArg < MiniTest::Test
include SlotMachineCompile
def setup
end
def test_method_arg_compiles
ret = compile_slot( as_main("self.main {|elem| arg = 5 } "))
assert ret
end
def test_method_local_compiles
ret = compile_slot( as_main("local = 5 ; self.main {|elem| local = 10 } "))
assert ret
end
end
end