From c7978c22d4f3c2c47b5a29cc33e7c5d2874315a6 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Sat, 8 Apr 2017 17:29:53 +0300 Subject: [PATCH] improves method compiler tests --- test/vool/compilers/test_all.rb | 1 + .../test_method_compiler.rb} | 17 +++++++++++------ test/vool/test_all.rb | 1 - 3 files changed, 12 insertions(+), 7 deletions(-) rename test/vool/{test_vool_compiler.rb => compilers/test_method_compiler.rb} (64%) diff --git a/test/vool/compilers/test_all.rb b/test/vool/compilers/test_all.rb index 8e6d18db..486a32d9 100644 --- a/test/vool/compilers/test_all.rb +++ b/test/vool/compilers/test_all.rb @@ -1,3 +1,4 @@ require_relative "helper" require_relative "test_ivar_collect" require_relative "test_local_collect" +require_relative "test_method_compiler" diff --git a/test/vool/test_vool_compiler.rb b/test/vool/compilers/test_method_compiler.rb similarity index 64% rename from test/vool/test_vool_compiler.rb rename to test/vool/compilers/test_method_compiler.rb index c02ca657..6ef295e4 100644 --- a/test/vool/test_vool_compiler.rb +++ b/test/vool/compilers/test_method_compiler.rb @@ -18,26 +18,31 @@ module Vool clazz = VoolCompiler.compile in_Test("def meth; @ivar ;end") assert_equal Parfait::Class , clazz.body.clazz.class end - def test_creates_method_in_class method = create_method assert method , "No method created" + assert_equal Rubyx::RubyMethod , method.class end - - def pest_method_has_source + def test_method_has_source method = create_method - assert_equal "(ivar :@ivar)", method.source.to_s + assert_equal Vool::InstanceVariable , method.source.class end - def pest_method_has_no_args + def test_method_has_no_args method = create_method assert_equal 1 , method.args_type.instance_length end - def pest_method_has_no_locals + def test_method_has_no_locals method = create_method assert_equal 1 , method.locals_type.instance_length end + def test_method_has_one_local + VoolCompiler.compile in_Test("def meth; local = 5 ;end") + test = Parfait.object_space.get_class_by_name(:Test) + method = test.get_method(:meth) + assert_equal 2 , method.locals_type.instance_length + end end end diff --git a/test/vool/test_all.rb b/test/vool/test_all.rb index 1503fa8f..e2d8254a 100644 --- a/test/vool/test_all.rb +++ b/test/vool/test_all.rb @@ -1,4 +1,3 @@ require_relative "helper" require_relative "statements/test_all" require_relative "compilers/test_all" -require_relative "test_vool_compiler"