From c4f89441e231b0314c4e1693a9df9f145556df72 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Sun, 27 Sep 2015 11:27:30 +0300 Subject: [PATCH] cleaning --- lib/bosl/compiler/compound_expressions.rb | 6 +++--- lib/bosl/compiler/field_def.rb | 1 + test/compiler/code_checker.rb | 16 ++++++++++++++++ test/compiler/test_methods.rb | 18 +++--------------- 4 files changed, 23 insertions(+), 18 deletions(-) create mode 100644 test/compiler/code_checker.rb diff --git a/lib/bosl/compiler/compound_expressions.rb b/lib/bosl/compiler/compound_expressions.rb index 2b45a60b..c7c4051c 100644 --- a/lib/bosl/compiler/compound_expressions.rb +++ b/lib/bosl/compiler/compound_expressions.rb @@ -3,14 +3,14 @@ module Bosl # attr_reader :values def on_array expession, context -# to.do + raise "not implemented" end # attr_reader :key , :value def on_association context -# to.do + raise "not implemented" end def on_hash context -# to.do + raise "not implemented" end end end diff --git a/lib/bosl/compiler/field_def.rb b/lib/bosl/compiler/field_def.rb index b523d5fd..8b8848b8 100644 --- a/lib/bosl/compiler/field_def.rb +++ b/lib/bosl/compiler/field_def.rb @@ -2,6 +2,7 @@ module Bosl Compiler.class_eval do def on_field_def expression +# puts expression.inspect type , name , value = *expression name = name index = method.ensure_local( name ) diff --git a/test/compiler/code_checker.rb b/test/compiler/code_checker.rb new file mode 100644 index 00000000..297b669f --- /dev/null +++ b/test/compiler/code_checker.rb @@ -0,0 +1,16 @@ +module CodeChecker + def check + Virtual.machine.boot.compile_main @string_input + produced = Virtual.machine.space.get_main.source + assert @output , "No output given" + assert_equal @output.length , produced.blocks.length , "Block length" + produced.blocks.each_with_index do |b,i| + codes = @output[i] + assert codes , "No codes for block #{i}" + assert_equal b.codes.length , codes.length , "Code length for block #{i}" + b.codes.each_with_index do |c , ii | + assert_equal codes[ii] , c.class , "Block #{i} , code #{ii}" + end + end + end +end diff --git a/test/compiler/test_methods.rb b/test/compiler/test_methods.rb index ba0de77c..d4aa2235 100644 --- a/test/compiler/test_methods.rb +++ b/test/compiler/test_methods.rb @@ -1,21 +1,9 @@ require_relative "compiler_helper" +require_relative "code_checker" + module Virtual class TestMethods < MiniTest::Test - - def check - Virtual.machine.boot.compile_main @string_input - produced = Virtual.machine.space.get_main.source - assert @output , "No output given" - assert_equal @output.length , produced.blocks.length , "Block length" - produced.blocks.each_with_index do |b,i| - codes = @output[i] - assert codes , "No codes for block #{i}" - assert_equal b.codes.length , codes.length , "Code length for block #{i}" - b.codes.each_with_index do |c , ii | - assert_equal codes[ii] , c.class , "Block #{i} , code #{ii}" - end - end - end + include CodeChecker def test_module @string_input = <