2019-08-12 12:16:15 +02:00
|
|
|
require_relative "helper"
|
|
|
|
|
2019-10-03 19:55:41 +02:00
|
|
|
module SlotMachine
|
2019-08-12 12:16:15 +02:00
|
|
|
module Builtin
|
|
|
|
class TestWordPutRisc < BootTest
|
|
|
|
def setup
|
2019-09-13 09:41:13 +02:00
|
|
|
@method = get_compiler("Word",:put)
|
|
|
|
end
|
2019-10-03 19:55:41 +02:00
|
|
|
def test_slot_length
|
2019-09-13 09:41:13 +02:00
|
|
|
assert_equal :putstring , @method.callable.name
|
2019-10-03 19:55:41 +02:00
|
|
|
assert_equal 7 , @method.slot_instructions.length
|
2019-08-12 12:16:15 +02:00
|
|
|
end
|
|
|
|
def test_compile
|
|
|
|
assert_equal Risc::MethodCompiler , @method.to_risc.class
|
|
|
|
end
|
|
|
|
def test_risc_length
|
2019-09-13 09:41:13 +02:00
|
|
|
assert_equal 44 , @method.to_risc.risc_instructions.length
|
2019-08-12 12:16:15 +02:00
|
|
|
end
|
2020-03-06 17:09:56 +01:00
|
|
|
def test_allocate
|
|
|
|
assert_allocate
|
|
|
|
end
|
|
|
|
def test_all
|
|
|
|
assert_reg_to_slot risc(23) , :r1 , :r0 , 5
|
|
|
|
assert_slot_to_reg risc(24),:r0 , 2 , :r1
|
|
|
|
assert_slot_to_reg risc(25),:r1 , 1 , :r2
|
|
|
|
assert_transfer risc(26) , :r0 , :r8
|
|
|
|
assert_equal Risc::Syscall, risc(27).class
|
|
|
|
assert_transfer risc(28) , :r0 , :r3
|
|
|
|
assert_transfer risc(29) , :r8 , :r0
|
|
|
|
assert_slot_to_reg risc(30),:r0 , 5 , :r4
|
|
|
|
assert_reg_to_slot risc(31) , :r3 , :r4 , 2
|
|
|
|
assert_slot_to_reg risc(32),:r0 , 5 , :r2
|
|
|
|
assert_reg_to_slot risc(33) , :r2 , :r0 , 5
|
|
|
|
assert_branch risc(34) , "return_label"
|
|
|
|
assert_label risc(35) , "return_label"
|
|
|
|
end
|
|
|
|
def test_return
|
|
|
|
assert_return(35)
|
|
|
|
end
|
2019-08-12 12:16:15 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|