lots of stuff to move to linked lists
and remove the blocks more position stuff coming, but the list part should be ok
This commit is contained in:
@ -2,3 +2,4 @@
|
||||
require_relative "test_compat"
|
||||
require_relative "test_padding"
|
||||
require_relative "test_positioning"
|
||||
require_relative "test_instructions"
|
||||
|
46
test/register/test_instructions.rb
Normal file
46
test/register/test_instructions.rb
Normal file
@ -0,0 +1,46 @@
|
||||
require_relative "../helper"
|
||||
|
||||
module Register
|
||||
class TestInstructions < MiniTest::Test
|
||||
def setup
|
||||
@label = Label.new(nil , "test")
|
||||
@branch = Branch.new(nil , @label)
|
||||
@instruction = Instruction.new(nil)
|
||||
end
|
||||
def test_last_empty
|
||||
assert_equal @instruction, @instruction.last
|
||||
end
|
||||
def test_last_not_empty
|
||||
@instruction.set_next @branch
|
||||
assert_equal @branch, @instruction.last
|
||||
end
|
||||
def test_append_empty
|
||||
@instruction.append @branch
|
||||
assert_equal @branch, @instruction.last
|
||||
end
|
||||
def test_insert
|
||||
@instruction.insert @branch
|
||||
assert_equal @branch, @instruction.last
|
||||
end
|
||||
def test_append_not_empty
|
||||
@instruction.append @branch
|
||||
@instruction.append @label
|
||||
assert_equal @label, @instruction.last
|
||||
end
|
||||
def test_next1
|
||||
assert_equal nil , @instruction.next
|
||||
end
|
||||
def test_next2
|
||||
@instruction.set_next @label
|
||||
assert_equal @label , @instruction.next
|
||||
assert_equal nil , @instruction.next(2)
|
||||
end
|
||||
def test_replace
|
||||
@instruction.append @branch
|
||||
@instruction.replace_next @label
|
||||
assert_equal @label, @instruction.last
|
||||
assert_equal @label, @instruction.next
|
||||
assert_equal 2 , @instruction.length , @instruction.to_ac
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user