fix to_s
This commit is contained in:
parent
0921073025
commit
7a690cd38d
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user