generate mains test methods according to file name
This commit is contained in:
28
test/mains/test_interpreted.rb
Normal file
28
test/mains/test_interpreted.rb
Normal file
@ -0,0 +1,28 @@
|
||||
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
|
||||
run_main(input)
|
||||
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
|
Reference in New Issue
Block a user