diff --git a/lib/melon/type_collector.rb b/lib/melon/compiler/type_collector.rb similarity index 100% rename from lib/melon/type_collector.rb rename to lib/melon/compiler/type_collector.rb diff --git a/test/melon/compiler/test_all.rb b/test/melon/compiler/test_all.rb index d62ab71f..068f85b3 100644 --- a/test/melon/compiler/test_all.rb +++ b/test/melon/compiler/test_all.rb @@ -1,2 +1,2 @@ -require_relative "test_class" -require_relative "test_collector" +require_relative "test_type_collector" +require_relative "test_method_collector" diff --git a/test/melon/compiler/test_clollector.rb b/test/melon/compiler/test_clollector.rb deleted file mode 100644 index 54beed95..00000000 --- a/test/melon/compiler/test_clollector.rb +++ /dev/null @@ -1,29 +0,0 @@ -require_relative "helper" - -module Melon - class TestCollector < MiniTest::Test - - def setup - Register.machine.boot unless Register.machine.booted - end - - def test_ivar_name - Compiler.compile "class TestIvar < Object ; def meth; @ivar;end; end" - itest = Parfait::Space.object_space.get_class_by_name(:TestIvar) - assert itest.instance_type.instance_names.include?(:ivar) , itest.instance_type.instance_names.inspect - end - - def test_ivar_assign - Compiler.compile "class TestIvar2 < Object ; def meth; @ivar = 5 ;end; end" - itest = Parfait::Space.object_space.get_class_by_name(:TestIvar2) - assert itest.instance_type.instance_names.include?(:ivar) , itest.instance_type.instance_names.inspect - end - - def test_ivar_operator_assign - Compiler.compile "class TestIvar3 < Object ; def meth; @ivar += 5 ;end; end" - itest = Parfait::Space.object_space.get_class_by_name(:TestIvar3) - assert itest.instance_type.instance_names.include?(:ivar) , itest.instance_type.instance_names.inspect - end - - end -end diff --git a/test/melon/compiler/test_type_collector.rb b/test/melon/compiler/test_type_collector.rb new file mode 100644 index 00000000..09600864 --- /dev/null +++ b/test/melon/compiler/test_type_collector.rb @@ -0,0 +1,37 @@ +require_relative "helper" + +module Melon + class TestTypeCollector < MiniTest::Test + + def setup + Register.machine.boot unless Register.machine.booted + end + + def parse_collect( input ) + ast = Parser::Ruby22.parse input + TypeCollector.new.collect(ast) + end + + def test_ivar_name + hash = parse_collect "def meth; @ivar;end" + assert hash[:ivar] , hash + end + + def test_ivar_assign + hash = parse_collect "def meth; @ivar = 5;end" + assert hash[:ivar] , hash + end + + def test_ivar_operator_assign + hash = parse_collect "def meth; @ivar += 5;end" + assert hash[:ivar] , hash + end + + def test_compile_class + Compiler.compile "class TestIvar < Object ; def meth; @ivar;end; end" + itest = Parfait::Space.object_space.get_class_by_name(:TestIvar) + assert itest.instance_type.instance_names.include?(:ivar) , itest.instance_type.instance_names.inspect + end + + end +end diff --git a/test/melon/test_all.rb b/test/melon/test_all.rb index 089b4bd3..29831cb9 100644 --- a/test/melon/test_all.rb +++ b/test/melon/test_all.rb @@ -1 +1,2 @@ require_relative "compiler/test_all" +require_relative "test_compiler" diff --git a/test/melon/compiler/test_class.rb b/test/melon/test_compiler.rb similarity index 100% rename from test/melon/compiler/test_class.rb rename to test/melon/test_compiler.rb