2019-08-08 11:19:27 +02:00
|
|
|
require_relative "helper"
|
|
|
|
module Risc
|
|
|
|
class FakeCallableCompiler < CallableCompiler
|
2019-08-10 11:42:47 +02:00
|
|
|
def initialize(a,c)
|
|
|
|
super(a,c)
|
2019-08-08 11:19:27 +02:00
|
|
|
end
|
|
|
|
def source_name
|
|
|
|
"luke"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
class TestCallableCompiler < MiniTest::Test
|
2020-02-27 10:57:18 +01:00
|
|
|
def setup
|
|
|
|
Parfait.boot!({})
|
2020-02-28 11:54:17 +01:00
|
|
|
@compiler = Risc.test_compiler
|
2020-02-27 10:57:18 +01:00
|
|
|
end
|
|
|
|
def test_ok
|
|
|
|
assert @compiler
|
|
|
|
end
|
|
|
|
def test_current
|
|
|
|
assert @compiler.current
|
|
|
|
end
|
|
|
|
def test_current_label
|
|
|
|
assert_equal Label , @compiler.current.class
|
2020-02-28 11:54:17 +01:00
|
|
|
assert_equal "start_label" , @compiler.current.name
|
2020-02-27 10:57:18 +01:00
|
|
|
end
|
|
|
|
def test_slot
|
|
|
|
assert @compiler.risc_instructions
|
|
|
|
end
|
|
|
|
def test_const
|
|
|
|
assert_equal Array , @compiler.constants.class
|
|
|
|
end
|
|
|
|
def test_use_reg
|
|
|
|
@compiler.use_reg(:Type)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
class TestFakeCallableCompiler < MiniTest::Test
|
2019-08-08 11:19:27 +02:00
|
|
|
def setup
|
|
|
|
Parfait.boot!({})
|
2019-10-03 19:55:41 +02:00
|
|
|
label = SlotMachine::Label.new("hi","ho")
|
2019-08-10 11:42:47 +02:00
|
|
|
@compiler = FakeCallableCompiler.new(FakeCallable.new , label)
|
2019-08-08 11:19:27 +02:00
|
|
|
end
|
|
|
|
def test_ok
|
|
|
|
assert @compiler
|
|
|
|
end
|
|
|
|
def test_current
|
|
|
|
assert @compiler.current
|
|
|
|
end
|
|
|
|
def test_current_label
|
|
|
|
assert_equal Label , @compiler.current.class
|
|
|
|
assert_equal "ho" , @compiler.current.name
|
|
|
|
end
|
2019-10-03 19:55:41 +02:00
|
|
|
def test_slot
|
2019-08-08 11:19:27 +02:00
|
|
|
assert @compiler.risc_instructions
|
|
|
|
end
|
|
|
|
def test_const
|
|
|
|
assert_equal Array , @compiler.constants.class
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|