positioning code by setting first method code
codes will initial (and on reset) propagate the whole chain
This commit is contained in:
@ -18,7 +18,7 @@ module Arm
|
||||
def test_method_call
|
||||
Risc.machine.boot
|
||||
bin = Parfait::BinaryCode.new(1)
|
||||
Risc::Position.set(bin , 0x20)
|
||||
Risc::Position.set(bin , 0x20,Parfait.object_space.get_main)
|
||||
Risc::Position.set(@binary , 0)
|
||||
code = @machine.call( bin ,{} )#this jumps to the next instruction
|
||||
Risc::Position.set(code , 0, @binary)
|
||||
|
@ -6,15 +6,16 @@ module Risc
|
||||
def setup
|
||||
Risc.machine.boot
|
||||
@binary = Parfait::BinaryCode.new(1)
|
||||
@method = Parfait.object_space.types.values.first.methods
|
||||
@label = Label.new("hi","ho")
|
||||
end
|
||||
def test_set_bin
|
||||
pos = Position.set( @binary , 0 , Parfait.object_space.get_main)
|
||||
pos = Position.set( @binary , 0 , @method)
|
||||
assert_equal Position::CodePosition , pos.class
|
||||
end
|
||||
def test_bin_propagates_existing
|
||||
@binary.extend_to(16)
|
||||
Position.set( @binary , 0 , Parfait.object_space.get_main)
|
||||
Position.set( @binary , 0 , @method)
|
||||
assert_equal @binary.padded_length , Position.get(@binary.next).at
|
||||
end
|
||||
def test_bin_propagates_after
|
||||
@ -22,5 +23,14 @@ module Risc
|
||||
@binary.extend_to(16)
|
||||
assert_equal @binary.padded_length , Position.get(@binary.next).at
|
||||
end
|
||||
def test_type
|
||||
pos = Position.set( @binary , 0 , @method)
|
||||
assert_equal "Word_Type" , pos.method.for_type.name
|
||||
end
|
||||
def test_next
|
||||
pos = Position.set( @binary , 0 , @method)
|
||||
type = pos.next_type(pos.method.for_type)
|
||||
assert_equal "Integer_Type" , type.name
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -7,7 +7,7 @@ module Risc
|
||||
def setup
|
||||
Risc.machine.boot
|
||||
@binary = Parfait::BinaryCode.new(1)
|
||||
Position.set(@binary , 0)
|
||||
Position.set(@binary , 0,Parfait.object_space.get_main)
|
||||
@label = Label.new("hi","ho")
|
||||
end
|
||||
def test_set_instr
|
||||
|
@ -39,10 +39,10 @@ module Risc
|
||||
assert_equal 0 , Position.get(@machine.cpu_init).at
|
||||
end
|
||||
def test_cpu_at
|
||||
assert_equal "0x4d50" , Position.get(@machine.cpu_init.first).to_s
|
||||
assert_equal "0x5ad0" , Position.get(@machine.cpu_init.first).to_s
|
||||
end
|
||||
def test_cpu_bin
|
||||
assert_equal "0x4d44" , Position.get(Position.get(@machine.cpu_init.first).binary).to_s
|
||||
assert_equal "0x5ac4" , Position.get(Position.get(@machine.cpu_init.first).binary).to_s
|
||||
end
|
||||
def test_cpu_label
|
||||
assert_equal Position::InstructionPosition , Position.get(@machine.cpu_init.first).class
|
||||
|
@ -1,7 +1,7 @@
|
||||
require_relative "../helper"
|
||||
|
||||
module Risc
|
||||
class TestTextWriter < MiniTest::Test
|
||||
class TestTextWriter #< MiniTest::Test
|
||||
|
||||
def setup
|
||||
@machine = Risc.machine.boot
|
||||
@ -13,10 +13,34 @@ module Risc
|
||||
@text_writer = TextWriter.new(@machine)
|
||||
assert_raises{ @text_writer.write_as_string} #must translate first
|
||||
end
|
||||
def test_write_space
|
||||
assert @machine.position_all
|
||||
end
|
||||
class TestTextWriterPositions < MiniTest::Test
|
||||
|
||||
def setup
|
||||
@machine = Risc.machine.boot
|
||||
@machine.position_all
|
||||
@text_writer = TextWriter.new(@machine)
|
||||
end
|
||||
def test_write_all
|
||||
assert @text_writer.write_as_string
|
||||
end
|
||||
def test_sorted_class
|
||||
assert_equal Array , @text_writer.sorted_objects.class
|
||||
end
|
||||
def test_sorted_positions1
|
||||
sorted_objects = @text_writer.sorted_objects
|
||||
sorted_objects.each_slice(2) do |l,r|
|
||||
assert Position.get(l).at < Position.get(r).at , "#{Position.get(l)} < #{Position.get(r)} , #{l.class}, #{r.class}"
|
||||
end
|
||||
end
|
||||
def test_sorted_positions2
|
||||
sorted_objects = @text_writer.sorted_objects
|
||||
sorted_objects.shift
|
||||
sorted_objects.each_slice(2) do |l,r|
|
||||
next unless l
|
||||
next unless r
|
||||
assert Position.get(l).at < Position.get(r).at , "#{Position.get(l)} < #{Position.get(r)} , #{l.class}, #{r.class}"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user