only string and ast allowed as source
This commit is contained in:
parent
191be8d2f6
commit
bdb4a40f9c
@ -16,8 +16,10 @@ module Register
|
|||||||
include Positioned
|
include Positioned
|
||||||
|
|
||||||
def initialize source , nekst = nil
|
def initialize source , nekst = nil
|
||||||
@source = source
|
@source = source
|
||||||
@next = nekst
|
@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
|
end
|
||||||
attr_reader :source
|
attr_reader :source
|
||||||
|
|
||||||
|
@ -3,9 +3,9 @@ require_relative "../helper"
|
|||||||
module Register
|
module Register
|
||||||
class TestInstructions < MiniTest::Test
|
class TestInstructions < MiniTest::Test
|
||||||
def setup
|
def setup
|
||||||
@label = Label.new(nil , "test")
|
@label = Label.new("test" , "test")
|
||||||
@branch = Branch.new(nil , @label)
|
@branch = Branch.new("test" , @label)
|
||||||
@instruction = Instruction.new(nil)
|
@instruction = Instruction.new("test")
|
||||||
end
|
end
|
||||||
def test_branch_tos1
|
def test_branch_tos1
|
||||||
assert @branch.to_s.include?("Branch")
|
assert @branch.to_s.include?("Branch")
|
||||||
|
Loading…
Reference in New Issue
Block a user