only string and ast allowed as source

This commit is contained in:
Torsten Ruger 2015-10-28 21:38:23 +02:00
parent 191be8d2f6
commit bdb4a40f9c
2 changed files with 7 additions and 5 deletions

View File

@ -16,8 +16,10 @@ module Register
include Positioned
def initialize source , nekst = nil
@source = source
@next = nekst
@source = source
@next = nekst
return unless source
raise "Source must be string or ast node, not #{source.class}" unless source.is_a?(String) or source.is_a?(AST::Node)
end
attr_reader :source

View File

@ -3,9 +3,9 @@ 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)
@label = Label.new("test" , "test")
@branch = Branch.new("test" , @label)
@instruction = Instruction.new("test")
end
def test_branch_tos1
assert @branch.to_s.include?("Branch")