From f359e789828ad09e97d0a97235e7051155314c58 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Sat, 10 Dec 2016 18:09:51 +0200 Subject: [PATCH] adjust test helper to current s-exp situation also refrain from hacking the compiler by using the constructor --- test/typed/expressions/helper.rb | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/test/typed/expressions/helper.rb b/test/typed/expressions/helper.rb index 22152ce0..3afba423 100644 --- a/test/typed/expressions/helper.rb +++ b/test/typed/expressions/helper.rb @@ -1,33 +1,20 @@ require_relative '../helper' -Typed::Compiler.class_eval do - def set_main main - @clazz = Register.machine.space.get_class_by_name :Object - @method = main - @current = main.instructions.next - end -end - module ExpressionHelper - def set_main compiler - compiler.set_main Register.machine.space.get_main - end def check - machine = Register.machine - machine.boot unless machine.booted - compiler = Typed::Compiler.new - set_main(compiler) + Register.machine.boot unless Register.machine.booted + compiler = Typed::Compiler.new Register.machine.space.get_main code = Typed.ast_to_code @input produced = compiler.process( code ) assert @output , "No output given" - assert_equal produced.class , @output , "Wrong class" + assert_equal produced.class , @output , "Wrong class" produced end # test hack to in place change object type - def add_object_field(name,type) - class_type = Register.machine.space.get_class_by_name(:Object).instance_type + def add_space_field(name,type) + class_type = Register.machine.space.get_class_by_name(:Space).instance_type class_type.send(:private_add_instance_variable, name , type) end end