rubyx/test/slot_machine/test_callable_compiler.rb

32 lines
737 B
Ruby
Raw Normal View History

2019-07-22 14:21:16 +02:00
require_relative "helper"
module SlotMachine
# need to derive, to overwrite source_name
2019-08-08 11:18:36 +02:00
class FakeCallableCompiler < CallableCompiler
def source_name
"luke"
end
end
class TestCallableCompiler < MiniTest::Test
2019-07-22 14:21:16 +02:00
def setup
@compiler = FakeCallableCompiler.new(Risc::FakeCallable.new)
2019-07-22 14:21:16 +02:00
end
2019-08-08 11:18:36 +02:00
def test_ok
assert @compiler
2019-07-22 14:21:16 +02:00
end
2019-08-08 11:18:36 +02:00
def test_current
assert @compiler.current
2019-07-22 14:21:16 +02:00
end
2019-08-08 11:18:36 +02:00
def test_current_label
assert_equal Label , @compiler.current.class
assert_equal @compiler.source_name , @compiler.current.name
2019-07-22 14:21:16 +02:00
end
def test_slot
assert @compiler.slot_instructions
2019-07-22 14:21:16 +02:00
end
2019-08-08 11:18:36 +02:00
def test_const
assert_equal Array , @compiler.constants.class
2019-07-22 14:21:16 +02:00
end
end
end