rubyx/test/mains/test_interpreted.rb
Torsten Rüger 12b29285d7 Lots of preloading for tests
so many relied (implicitly( on some builtin function
after all can't do much in ruby without calling
Now all those dependencies are explicit
Small risc changes come because the macro version has a return label and unreachable label
2019-09-13 14:07:12 +03:00

31 lines
919 B
Ruby

require_relative 'helper'
module Mains
class TestInterpreted < MiniTest::Test
include Risc::Ticker
def setup;end
# runnable_methods is called by minitest to determine which tests to run
def self.runnable_methods
all = Dir["test/mains/source/*.rb"]
tests =[]
all.each do |file_name|
fullname = file_name.split("/").last.split(".").first
name , stdout , exit_code = fullname.split("_")
method_name = "test_#{name}"
tests << method_name
input = File.read(file_name)
self.send(:define_method, method_name ) do
@preload = "all"
ticks = run_input(input)
#puts "Ticks for #{method_name}=#{ticks}"
assert_equal stdout , @interpreter.stdout , "Wrong stdout #{name}"
assert_equal exit_code , get_return.to_s , "Wrong exit code #{name}"
end
end
tests
end
end
end