From 104f4c5109073770484fe39bfb5039b51bdf342f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20R=C3=BCger?= Date: Mon, 9 Sep 2019 11:48:29 +0300 Subject: [PATCH] Start on parsing parfait tests Hanging on .new currently, but there is surely more --- test/rubyx/rt_parfait/helper.rb | 2 +- test/rubyx/rt_parfait/test_object.rb | 40 ++++++++++++++++++++++++++-- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/test/rubyx/rt_parfait/helper.rb b/test/rubyx/rt_parfait/helper.rb index 9f3e9941..5ea613b4 100644 --- a/test/rubyx/rt_parfait/helper.rb +++ b/test/rubyx/rt_parfait/helper.rb @@ -8,7 +8,7 @@ class ParfaitTest def setup - @space = Parfait.object_space + @space = Object.object_space # this mapping wil have to be added to compiler end def assert(arg) return unless(arg) diff --git a/test/rubyx/rt_parfait/test_object.rb b/test/rubyx/rt_parfait/test_object.rb index f135ad2e..e7217795 100644 --- a/test/rubyx/rt_parfait/test_object.rb +++ b/test/rubyx/rt_parfait/test_object.rb @@ -4,7 +4,42 @@ module RubyX class ObjectTest < MiniTest::Test include ParfaitHelper def setup - @input = load_parfait(:object) #+ load_parfait_test(:object) + @input = load_parfait(:object) + load_parfait_test(:object) + end + + def test_load + assert @input.include? "ParfaitTest" + assert @input.include? "class Object" + end + def test_compile + compiled = Ruby::RubyCompiler.compile(@input) + assert_equal Ruby::ScopeStatement , compiled.class + assert_equal Ruby::ClassStatement , compiled.first.class + end + def test_require + compiled = Ruby::RubyCompiler.compile(@input) + assert_equal Ruby::SendStatement , compiled[1].class + assert_equal :require_relative , compiled[1].name + end + def test_test_class + compiled = Ruby::RubyCompiler.compile(@input) + assert_equal Ruby::ClassStatement , compiled[2].class + assert_equal :TestObject , compiled[2].name + end + def test_vool_object + vool = Ruby::RubyCompiler.compile(@input).to_vool + assert_equal Vool::ScopeStatement , vool.class + assert_equal Vool::ClassExpression , vool.first.class + end + def test_vool_helper + vool = Ruby::RubyCompiler.compile(@input).to_vool + assert_equal Vool::ClassExpression , vool[1].class + assert_equal :ParfaitTest , vool[1].name + end + def test_vool_test + vool = Ruby::RubyCompiler.compile(@input).to_vool + assert_equal Vool::ClassExpression , vool[2].class + assert_equal :TestObject , vool[2].name end def test_basics @@ -13,8 +48,9 @@ module RubyX end def test_run_all - @input += "class Space;def main(arg);::Parfait::Object.new;end;end" + @input += "class Space;def main(arg);'Object'.putstring;end;end" run_input + assert_equal "Object" , @interpreter.stdout end end end