diff --git a/test/helper.rb b/test/helper.rb index 86116324..2e886af7 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -14,7 +14,7 @@ end require "minitest/color" require "minitest/autorun" -require "minitest/fail_fast" unless ENV["TEST_ALL"] +#require "minitest/fail_fast" unless ENV["TEST_ALL"] require 'minitest/profile' #require "minitest/reporters" #Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new diff --git a/test/mom/test_callable_compiler.rb b/test/mom/test_callable_compiler.rb index aefb6d84..5652295e 100644 --- a/test/mom/test_callable_compiler.rb +++ b/test/mom/test_callable_compiler.rb @@ -1,40 +1,32 @@ require_relative "helper" - +class FakeCallable +end module Mom + class FakeCallableCompiler < CallableCompiler + def source_name + "luke" + end + end class TestCallableCompiler < MiniTest::Test - include MomCompile def setup - Parfait.boot!(Parfait.default_test_options) - @comp = compile_mom( "class Test ; def main(); return 'Hi'; end; end;") + @compiler = FakeCallableCompiler.new(FakeCallable.new) end - - def test_class - assert_equal MomCompiler , @comp.class + def test_ok + assert @compiler end - def test_compilers - assert_equal 23 , @comp.compilers.length + def test_current + assert @compiler.current end - def test_boot_compilers - assert_equal 22 , @comp.boot_compilers.length + def test_current_label + assert_equal Label , @compiler.current.class + assert_equal @compiler.source_name , @compiler.current.name end - def test_compilers_bare - assert_equal 22 , MomCompiler.new.compilers.length + def test_mom + assert @compiler.mom_instructions end - def test_returns_constants - assert_equal Array , @comp.constants.class - end - def test_has_constant - assert_equal "Hi" , @comp.constants[1].to_string - end - def test_has_translate - assert @comp.translate(:interpreter) - end - def test_append_class - assert_equal MomCompiler, (@comp.append @comp).class - end - def test_append_length - assert_equal 2 , @comp.append(@comp).method_compilers.length + def test_const + assert_equal Array , @compiler.constants.class end end end diff --git a/test/mom/test_method_compiler.rb b/test/mom/test_method_compiler.rb index 7c668332..5db946e6 100644 --- a/test/mom/test_method_compiler.rb +++ b/test/mom/test_method_compiler.rb @@ -12,9 +12,6 @@ module Mom vool.to_mom(nil) vool end - def in_test_mom(str) - FIXMERubyX::RubyXCompiler.new(in_Test(str)).ruby_to_mom() - end def create_method(body = "@ivar = 5") in_test_vool("def meth; #{body};end") test = Parfait.object_space.get_class_by_name(:Test) diff --git a/test/mom/test_mom_collection.rb b/test/mom/test_mom_collection.rb index ae6ac0e5..5bfa814a 100644 --- a/test/mom/test_mom_collection.rb +++ b/test/mom/test_mom_collection.rb @@ -27,13 +27,6 @@ module Mom def test_has_constant_before assert_equal [] , @comp.constants end - def test_has_constant_after -#needs translating -# assert_equal "Hi" , @comp.constants[0].to_string - end - def test_has_translate -# assert @comp.translate(:interpreter) - end def test_append_class assert_equal MomCollection, (@comp.append @comp).class end @@ -41,4 +34,19 @@ module Mom assert_equal 2 , @comp.append(@comp).method_compilers.length end end + class TestMomCollectionToRisc < MiniTest::Test + include MomCompile + + def setup + Parfait.boot!(Parfait.default_test_options) + @comp = compile_mom( "class Test ; def main(); return 'Hi'; end; end;") + @collection = @comp.to_risc() + end + def test_has_to_risc + assert_equal Risc::RiscCollection, @collection.class + end + def test_has_risc_compiler + assert_equal Risc::RiscCollection, @collection.method_compilers.first + end + end end diff --git a/test/parfait/test_vool_method.rb b/test/parfait/test_vool_method.rb index c0314bf6..30a3e8ea 100644 --- a/test/parfait/test_vool_method.rb +++ b/test/parfait/test_vool_method.rb @@ -2,15 +2,31 @@ require_relative "helper" module Vool class TestVoolMethod < MiniTest::Test - include MomCompile + include VoolCompile def setup Parfait.boot!(Parfait.default_test_options) - @ins = compile_first_method( "@a = 5") + ruby_tree = Ruby::RubyCompiler.compile( as_test_main("a = 5") ) + @clazz = ruby_tree.to_vool + end + def method + @clazz.body.first end - def test_setup - + assert_equal ClassStatement , @clazz.class + assert_equal Statements , @clazz.body.class + assert_equal MethodStatement , method.class end + def test_class + assert_equal Parfait::Class , @clazz.create_class_object.class + end + def test_method + clazz = @clazz.create_class_object + assert_equal Parfait::VoolMethod , method.make_method(clazz).class + end + + #create CallableMethod + + #create Compiler end end diff --git a/test/risc/test_method_compiler.rb b/test/risc/test_method_compiler.rb index b791ecb2..1ef918bd 100644 --- a/test/risc/test_method_compiler.rb +++ b/test/risc/test_method_compiler.rb @@ -12,9 +12,6 @@ module Risc vool.to_mom(nil) vool end - def in_test_mom(str) - FIXMERubyX::RubyXCompiler.new(in_Test(str)).ruby_to_mom() - end def create_method(body = "@ivar = 5") in_test_vool("def meth; #{body};end") test = Parfait.object_space.get_class_by_name(:Test) @@ -65,9 +62,9 @@ module Risc end def constant_setup(input) mom = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_mom(in_Test(input)) - assert_equal Mom::MomCompiler , mom.class + assert_equal Mom::MomCollection , mom.class compiler = mom.method_compilers.first - assert_equal MethodCompiler , compiler.class + assert_equal Mom::MethodCompiler , compiler.class compiler end def test_has_method_constant diff --git a/test/rubyx/helper.rb b/test/rubyx/helper.rb index d6f7a191..ae58aa8b 100644 --- a/test/rubyx/helper.rb +++ b/test/rubyx/helper.rb @@ -5,10 +5,6 @@ module RubyX module RubyXHelper def setup end - def ruby_to_risc(input , options = {}) - mom = ruby_to_mom(input , options) - mom.translate(options[:platform] || :interpreter) - end def ruby_to_vool(input, options = {}) options = RubyX.default_test_options.merge(options) RubyXCompiler.new(options).ruby_to_vool(input) diff --git a/test/rubyx/test_rubyx_compiler2.rb b/test/rubyx/test_rubyx_compiler2.rb index 6646acac..0a7af514 100644 --- a/test/rubyx/test_rubyx_compiler2.rb +++ b/test/rubyx/test_rubyx_compiler2.rb @@ -8,9 +8,10 @@ module RubyX def setup super code = "class Space ; def main(arg);return arg;end; end" - @linker = ruby_to_risc(code) + @comp = RubyXCompiler.new(load_parfait: true ) + @linker = @comp.ruby_to_risc(code,:interpreter) end - def pest_to_risc + def test_to_risc assert_equal Risc::Linker , @linker.class end def pest_method diff --git a/test/vool/test_class_statement.rb b/test/vool/test_class_statement.rb index 38abbbdf..4f67616f 100644 --- a/test/vool/test_class_statement.rb +++ b/test/vool/test_class_statement.rb @@ -3,6 +3,26 @@ require_relative "helper" module Vool class TestClassStatement < MiniTest::Test + include ScopeHelper + def setup + Parfait.boot!({}) + ruby_tree = Ruby::RubyCompiler.compile( as_test_main("a = 5") ) + @vool = ruby_tree.to_vool + end + def test_class + assert_equal ClassStatement , @vool.class + end + def test_method + assert_equal MethodStatement , @vool.body.first.class + end + def test_create_class + assert_equal Parfait::Class , @vool.create_class_object.class + end + def test_create_class + assert_equal :Test , @vool.create_class_object.name + end + end + class TestClassStatementCompile < MiniTest::Test include VoolCompile def setup diff --git a/test/vool/test_method_statement.rb b/test/vool/test_method_statement.rb new file mode 100644 index 00000000..dcbf7813 --- /dev/null +++ b/test/vool/test_method_statement.rb @@ -0,0 +1,29 @@ +require_relative "helper" + +module Vool + class TestMethodStatement < MiniTest::Test + include VoolCompile + + def setup + Parfait.boot!(Parfait.default_test_options) + ruby_tree = Ruby::RubyCompiler.compile( as_test_main("a = 5") ) + @clazz = ruby_tree.to_vool + end + def method + @clazz.body.first + end + def test_setup + assert_equal ClassStatement , @clazz.class + assert_equal Statements , @clazz.body.class + assert_equal MethodStatement , method.class + end + def test_class + assert_equal Parfait::Class , @clazz.create_class_object.class + end + def test_method + clazz = @clazz.create_class_object + assert_equal Parfait::VoolMethod , method.make_method(clazz).class + end + + end +end