more and better tests

especially vool
This commit is contained in:
2019-08-08 12:18:36 +03:00
parent d5625a70d7
commit 82c9f1d97f
10 changed files with 109 additions and 53 deletions

View File

@ -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

View File

@ -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)

View File

@ -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