bit of renaming and a string test
This commit is contained in:
@ -1,17 +0,0 @@
|
||||
require_relative '../helper'
|
||||
require "risc/interpreter"
|
||||
require "parser/ruby22"
|
||||
|
||||
module Rubyx
|
||||
module RubyxTests
|
||||
include CompilerHelper
|
||||
include Risc::InterpreterHelpers
|
||||
subs = ObjectSpace.each_object(Class).select { |klass| klass < Risc::Instruction }
|
||||
subs.each do |clazz|
|
||||
name = clazz.to_s
|
||||
next if name.include?("Arm")
|
||||
scoped = name.split("::").last
|
||||
module_eval "#{scoped} = #{name}"
|
||||
end
|
||||
end
|
||||
end
|
@ -1,45 +0,0 @@
|
||||
require_relative 'helper'
|
||||
|
||||
module Rubyx
|
||||
class TestRubyHello #< MiniTest::Test
|
||||
include RubyxTests
|
||||
Branch = Risc::Branch
|
||||
Label = Risc::Label
|
||||
|
||||
def setup
|
||||
@string_input = as_main '"Hello there".putstring'
|
||||
Risc.machine.boot
|
||||
# do_clean_compile
|
||||
RubyxCompiler.compile @string_input
|
||||
Risc::Collector.collect_space
|
||||
@interpreter = Risc::Interpreter.new
|
||||
@interpreter.start Risc.machine.init
|
||||
end
|
||||
|
||||
def test_chain
|
||||
#show_ticks
|
||||
check_chain [Branch, Label, LoadConstant, SlotToReg, RegToSlot,
|
||||
LoadConstant, RegToSlot, FunctionCall, Label, LoadConstant,
|
||||
SlotToReg, RegToSlot, SlotToReg, LoadConstant, RegToSlot,
|
||||
LoadConstant, RegToSlot, LoadConstant, SlotToReg, RegToSlot,
|
||||
LoadConstant, RegToSlot, Transfer, FunctionCall, Label,
|
||||
LoadConstant, SlotToReg, RegToSlot, SlotToReg, SlotToReg,
|
||||
Transfer, Syscall, Transfer, Transfer, RegToSlot,
|
||||
Label, FunctionReturn, Transfer, SlotToReg, SlotToReg,
|
||||
Label, FunctionReturn, Transfer, Syscall, NilClass]
|
||||
end
|
||||
|
||||
def test_overflow
|
||||
instruction = ticks( 24 )
|
||||
assert_equal Risc::FunctionCall , instruction.class
|
||||
assert_equal :putstring , instruction.method.name
|
||||
end
|
||||
|
||||
def test_ruby_hello
|
||||
done = ticks(45)
|
||||
assert_equal NilClass , done.class
|
||||
assert_equal "Hello there" , @interpreter.stdout
|
||||
end
|
||||
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user