some more mocking worked

some didnt
This commit is contained in:
Torsten Ruger 2018-06-08 20:43:36 +03:00
parent 5815d32bde
commit 74c15d45a3
3 changed files with 40 additions and 4 deletions

View File

@ -9,6 +9,34 @@ module Risc
4
end
end
class Machine
def set_platform(plat)
@platform = plat
end
def set_translated
@translated = true
translate_methods( @platform.translator )
@cpu_init = risc_init.to_cpu(@platform.translator)
end
end
class DummyPlatform
def self.boot
machine = Risc.machine.boot
machine.set_platform( self.new )
machine
end
def translator
DummyTranslator.new
end
def padding
0
end
end
class DummyTranslator
def translate(arg)
DummyInstruction.new
end
end
class DummyInstruction < Dummy
include Util::List
def initialize(nekst = nil)
@ -19,5 +47,11 @@ module Risc
Position.get(self).trigger_inserted if Position.set?(self)
ret
end
def assemble(io)
io.write_unsigned_int_32(0)
end
def total_byte_length
4
end
end
end

View File

@ -4,11 +4,13 @@ module Risc
# tests that require a boot and test propagation
class TestCodeListenerFull < MiniTest::Test
def setup
Risc.machine.boot
#@machine = DummyPlatform.boot
@machine = Risc.machine.boot
@binary = Parfait::BinaryCode.new(1)
@method = Parfait.object_space.types.values.first.methods
@label = Risc.label("hi","ho")
@machine.translate(:arm)
#@machine.set_translated
@machine.translate(:interpreter)
@machine.position_all
end
def test_listener_after_extend

View File

@ -3,9 +3,9 @@ require_relative "helper"
module Risc
class TestInstructionListenerBig < MiniTest::Test
def setup
Risc.machine.boot
DummyPlatform.boot
@binary = Parfait::BinaryCode.new(1)
@bin_pos = CodeListener.init(@binary,0)
@bin_pos = CodeListener.init(@binary).set(0)
@instruction = DummyInstruction.new
13.times {@instruction.last.insert(DummyInstruction.new) }
@position = InstructionListener.init(@instruction , @binary)