fix mom tests

and always have a list inside a class
This commit is contained in:
Torsten Ruger
2018-06-29 23:29:10 +03:00
parent 5b87133df2
commit 8d7a2fe4d6
8 changed files with 42 additions and 32 deletions

View File

@ -38,19 +38,20 @@ module Risc
def test_creates_method_statement_in_class
clazz = RubyX::RubyXCompiler.ruby_to_vool in_Test("def meth; @ivar = 5 ;end")
assert_equal Vool::MethodStatement , clazz.body.class
assert_equal Vool::Statements , clazz.body.class
assert_equal Vool::MethodStatement , clazz.body.first.class
end
def test_method_statement_has_class
vool = RubyX::RubyXCompiler.ruby_to_vool in_Test("def meth; @ivar = 5;end")
clazz = vool.to_mom(nil)
assert vool.body.clazz
assert vool.body.first.clazz
end
def test_parfait_class_creation
vool = RubyX::RubyXCompiler.ruby_to_vool in_Test("def meth; @ivar = 5;end")
clazz = vool.to_mom(nil)
assert_equal Parfait::Class , vool.body.clazz.class
assert_equal Parfait::Class , vool.body.first.clazz.class
end
def test_typed_method_instance_type

View File

@ -8,6 +8,9 @@ module RubyX
def ruby_to_vool(input)
RubyXCompiler.ruby_to_vool(input)
end
def ruby_to_mom(input)
RubyXCompiler.ruby_to_mom(input)
end
def compile_in_test input
vool = ruby_to_vool in_Test(input)
vool.to_mom(nil)

View File

@ -22,7 +22,7 @@ module Vool
end
def test_compile_class_body
assert_nil @lst.body
assert @lst.body.empty?
end
end
@ -31,13 +31,13 @@ module Vool
include RubyTests
def test_compile_one_method
lst = compile( in_Test("@ivar = 4") )
assert_equal IvarAssignment , lst.body.class
lst = compile( as_test_main("@ivar = 4") )
assert_equal IvarAssignment , lst.body.first.body.class
end
def test_compile_two_methods
lst = compile( in_Test("false; true;") )
assert_equal ScopeStatement , lst.body.class
assert_equal TrueConstant , lst.body.statements[1].class
def test_compile_two_stats
lst = compile( as_test_main("false; true;") )
assert_equal ScopeStatement , lst.body.first.body.class
assert_equal TrueConstant , lst.body.first.body.statements[1].class
end
end

View File

@ -24,7 +24,8 @@ module RubyX
def test_class_body_is_scope
clazz = ruby_to_vool in_Test("def meth; @ivar = 5 ;end")
assert_equal Vool::MethodStatement , clazz.body.class
assert_equal Vool::Statements , clazz.body.class
assert_equal Vool::MethodStatement , clazz.body.first.class
end
def test_space_is_unchanged_by_compile

View File

@ -1,34 +1,24 @@
require_relative "../helper"
require_relative "helper"
module RubyX
class TestVoolCompiler < MiniTest::Test
include ScopeHelper
def setup
Risc.machine.boot
end
def ruby_to_vool(input)
RubyXCompiler.ruby_to_vool(input)
end
include RubyXHelper
def test_creates_class_without_deriviation
vool = ruby_to_vool "class Testing ; end"
vool.to_mom(nil)
ruby_to_mom "class Testing ; end"
clazz = Parfait.object_space.get_class_by_name(:Testing)
assert clazz , "No classes created"
assert_equal :Object , clazz.super_class_name
end
def test_creates_class_deriviation
vool = ruby_to_vool "class Testing ; end"
mom = vool.to_mom(nil)
assert_equal Vool::ClassStatement , vool.class
#assert mom , "No classes created"
mom = ruby_to_mom "class Testing ; end"
assert mom , "No classes created"
end
def test_creates_class_with_deriviation
vool = ruby_to_vool "class Test2 < List ;end"
vool.to_mom(nil)
ruby_to_mom "class Test2 < List ;end"
clazz = Parfait.object_space.get_class_by_name(:Test2)
assert clazz, "No classes created"
assert_equal :List , clazz.super_class_name