more and better tests
especially vool
This commit is contained in:
parent
d5625a70d7
commit
82c9f1d97f
@ -14,7 +14,7 @@ end
|
||||
|
||||
require "minitest/color"
|
||||
require "minitest/autorun"
|
||||
require "minitest/fail_fast" unless ENV["TEST_ALL"]
|
||||
#require "minitest/fail_fast" unless ENV["TEST_ALL"]
|
||||
require 'minitest/profile'
|
||||
#require "minitest/reporters"
|
||||
#Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -2,15 +2,31 @@ require_relative "helper"
|
||||
|
||||
module Vool
|
||||
class TestVoolMethod < MiniTest::Test
|
||||
include MomCompile
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
@ins = compile_first_method( "@a = 5")
|
||||
ruby_tree = Ruby::RubyCompiler.compile( as_test_main("a = 5") )
|
||||
@clazz = ruby_tree.to_vool
|
||||
end
|
||||
def method
|
||||
@clazz.body.first
|
||||
end
|
||||
|
||||
def test_setup
|
||||
|
||||
assert_equal ClassStatement , @clazz.class
|
||||
assert_equal Statements , @clazz.body.class
|
||||
assert_equal MethodStatement , method.class
|
||||
end
|
||||
def test_class
|
||||
assert_equal Parfait::Class , @clazz.create_class_object.class
|
||||
end
|
||||
def test_method
|
||||
clazz = @clazz.create_class_object
|
||||
assert_equal Parfait::VoolMethod , method.make_method(clazz).class
|
||||
end
|
||||
|
||||
#create CallableMethod
|
||||
|
||||
#create Compiler
|
||||
end
|
||||
end
|
||||
|
@ -12,9 +12,6 @@ module Risc
|
||||
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)
|
||||
@ -65,9 +62,9 @@ module Risc
|
||||
end
|
||||
def constant_setup(input)
|
||||
mom = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_mom(in_Test(input))
|
||||
assert_equal Mom::MomCompiler , mom.class
|
||||
assert_equal Mom::MomCollection , mom.class
|
||||
compiler = mom.method_compilers.first
|
||||
assert_equal MethodCompiler , compiler.class
|
||||
assert_equal Mom::MethodCompiler , compiler.class
|
||||
compiler
|
||||
end
|
||||
def test_has_method_constant
|
||||
|
@ -5,10 +5,6 @@ module RubyX
|
||||
module RubyXHelper
|
||||
def setup
|
||||
end
|
||||
def ruby_to_risc(input , options = {})
|
||||
mom = ruby_to_mom(input , options)
|
||||
mom.translate(options[:platform] || :interpreter)
|
||||
end
|
||||
def ruby_to_vool(input, options = {})
|
||||
options = RubyX.default_test_options.merge(options)
|
||||
RubyXCompiler.new(options).ruby_to_vool(input)
|
||||
|
@ -8,9 +8,10 @@ module RubyX
|
||||
def setup
|
||||
super
|
||||
code = "class Space ; def main(arg);return arg;end; end"
|
||||
@linker = ruby_to_risc(code)
|
||||
@comp = RubyXCompiler.new(load_parfait: true )
|
||||
@linker = @comp.ruby_to_risc(code,:interpreter)
|
||||
end
|
||||
def pest_to_risc
|
||||
def test_to_risc
|
||||
assert_equal Risc::Linker , @linker.class
|
||||
end
|
||||
def pest_method
|
||||
|
@ -3,6 +3,26 @@ require_relative "helper"
|
||||
|
||||
module Vool
|
||||
class TestClassStatement < MiniTest::Test
|
||||
include ScopeHelper
|
||||
def setup
|
||||
Parfait.boot!({})
|
||||
ruby_tree = Ruby::RubyCompiler.compile( as_test_main("a = 5") )
|
||||
@vool = ruby_tree.to_vool
|
||||
end
|
||||
def test_class
|
||||
assert_equal ClassStatement , @vool.class
|
||||
end
|
||||
def test_method
|
||||
assert_equal MethodStatement , @vool.body.first.class
|
||||
end
|
||||
def test_create_class
|
||||
assert_equal Parfait::Class , @vool.create_class_object.class
|
||||
end
|
||||
def test_create_class
|
||||
assert_equal :Test , @vool.create_class_object.name
|
||||
end
|
||||
end
|
||||
class TestClassStatementCompile < MiniTest::Test
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
|
29
test/vool/test_method_statement.rb
Normal file
29
test/vool/test_method_statement.rb
Normal file
@ -0,0 +1,29 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Vool
|
||||
class TestMethodStatement < MiniTest::Test
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
ruby_tree = Ruby::RubyCompiler.compile( as_test_main("a = 5") )
|
||||
@clazz = ruby_tree.to_vool
|
||||
end
|
||||
def method
|
||||
@clazz.body.first
|
||||
end
|
||||
def test_setup
|
||||
assert_equal ClassStatement , @clazz.class
|
||||
assert_equal Statements , @clazz.body.class
|
||||
assert_equal MethodStatement , method.class
|
||||
end
|
||||
def test_class
|
||||
assert_equal Parfait::Class , @clazz.create_class_object.class
|
||||
end
|
||||
def test_method
|
||||
clazz = @clazz.create_class_object
|
||||
assert_equal Parfait::VoolMethod , method.make_method(clazz).class
|
||||
end
|
||||
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user