This commit is contained in:
Torsten Ruger 2015-10-25 12:10:56 +02:00
parent 0921073025
commit 7a690cd38d
2 changed files with 15 additions and 1 deletions

View File

@ -10,7 +10,7 @@ module Register
attr_reader :label
def to_s
"#{self.class.name}: #{label.name}"
"#{self.class.name}: #{label ? label.name : ''}"
end
alias :inspect :to_s

View File

@ -7,6 +7,20 @@ module Register
@branch = Branch.new(nil , @label)
@instruction = Instruction.new(nil)
end
def test_branch_tos1
assert @branch.to_s.include?("Branch")
assert @branch.to_s.include?("test")
end
def test_branch_tos2
branch = Branch.new(nil ,nil)
assert branch.to_s.include?("Branch")
end
def test_label_tos1
assert @label.to_s.include?("Label")
end
def test_label_tos2
assert Label.new(nil,nil).to_s.include?("Label")
end
def test_last_empty
assert_equal @instruction, @instruction.last
end