small shuffle of test helpers, also guard helpers

This commit is contained in:
Torsten Ruger 2016-12-17 00:15:27 +02:00
parent f8cefcde3c
commit ece017fa86
4 changed files with 17 additions and 6 deletions

View File

@ -4,6 +4,7 @@
guard :minitest do guard :minitest do
# with Minitest::Unit # with Minitest::Unit
watch(%r{^test/(.*)\/?test_(.*)\.rb$}) watch(%r{^test/(.*)\/?test_(.*)\.rb$})
watch(%r{^test/(.*/)?helper.rb$}) { |m| "test/#{m[1]}test_all.rb" }
watch(%r{^lib/(.*/)?([^/]+)\.rb$}) { |m| "test/#{m[1]}test_#{m[2]}.rb" } watch(%r{^lib/(.*/)?([^/]+)\.rb$}) { |m| "test/#{m[1]}test_#{m[2]}.rb" }
watch(%r{^test/test_helper\.rb$}) { 'test' } watch(%r{^test/test_helper\.rb$}) { 'test' }

View File

@ -19,6 +19,14 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'test'))
require 'salama' require 'salama'
module Compiling
def clean_compile(clazz_name , method_name , args , statements)
compiler = Typed::Compiler.new.create_method(clazz_name,method_name,args ).init_method
compiler.process( Typed.ast_to_code( statements ) )
end
end
class Ignored class Ignored
def == other def == other
return false unless other.class == self.class return false unless other.class == self.class

View File

@ -1,4 +1,4 @@
require_relative "../../helper" require_relative "../helper"
require "register/interpreter" require "register/interpreter"
module Ticker module Ticker
@ -6,12 +6,17 @@ module Ticker
def setup def setup
machine = Register.machine.boot machine = Register.machine.boot
do_clean_compile
Typed.compile( @input ) Typed.compile( @input )
machine.collect machine.collect
@interpreter = Register::Interpreter.new @interpreter = Register::Interpreter.new
@interpreter.start Register.machine.init @interpreter.start Register.machine.init
end end
# must be after boot, but before main compile, to define method
def do_clean_compile
end
def check_chain should def check_chain should
should.each_with_index do |name , index| should.each_with_index do |name , index|
got = ticks(1) got = ticks(1)

View File

@ -3,19 +3,16 @@ require_relative '../helper'
module Statements module Statements
include AST::Sexp include AST::Sexp
include Compiling
def setup def setup
Register.machine.boot # force boot to reset main Register.machine.boot # force boot to reset main
end end
def clean_compile(clazz_name , method_name , args , statements)
compiler = Typed::Compiler.new.create_method(clazz_name,method_name,args ).init_method
compiler.process( Typed.ast_to_code( statements ) )
end
def check def check
assert @expect , "No output given" assert @expect , "No output given"
compiler = Typed::Compiler.new Register.machine.space.get_main compiler = Typed::Compiler.new
produced = compiler.process( Typed.ast_to_code( @input) ) produced = compiler.process( Typed.ast_to_code( @input) )
produced = Register.machine.space.get_main.instructions produced = Register.machine.space.get_main.instructions
compare_instructions produced , @expect compare_instructions produced , @expect