some renames before main fixes commences
This commit is contained in:
@ -7,7 +7,7 @@ module Risc
|
||||
def setup
|
||||
super
|
||||
@input = as_block("return 5")
|
||||
@mom = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_mom(as_test_main)
|
||||
@mom = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_mom(as_main)
|
||||
end
|
||||
def main_risc
|
||||
@mom.to_risc.method_compilers.find{|c| c.callable.name == :main }
|
||||
|
@ -22,13 +22,13 @@ module Risc
|
||||
def as_block( block_input , method_input = "main_local = 5")
|
||||
"#{method_input} ; self.main{|val| #{block_input}}"
|
||||
end
|
||||
def as_test_main
|
||||
"class Test; #{@class_input if @class_input};def main(arg);#{@input};end;end"
|
||||
def as_main
|
||||
"class Space; #{@class_input if @class_input};def main(arg);#{@input};end;end"
|
||||
end
|
||||
def to_target
|
||||
assert @expect , "No output given"
|
||||
compiler = RubyX::RubyXCompiler.new(RubyX.default_test_options)
|
||||
vool = compiler.ruby_to_vool(as_test_main)
|
||||
vool = compiler.ruby_to_vool(as_main)
|
||||
compiler.to_target(:interpreter)
|
||||
end
|
||||
def produce_main
|
||||
|
@ -5,7 +5,7 @@ module Mom
|
||||
class BootTest < MiniTest::Test
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
Builtin.compiler_for( Parfait.object_space.get_class.instance_type , Space , :main)
|
||||
MomCollection.compiler_for( Parfait.object_space.get_class.instance_type , Parfait::Space , :main)
|
||||
end
|
||||
def get_int_compiler(name)
|
||||
obj_type = Parfait.object_space.get_type_by_class_name(:Integer)
|
||||
|
@ -5,7 +5,7 @@ module Mom
|
||||
include ScopeHelper
|
||||
|
||||
def setup
|
||||
code = as_test_main_block("return 5" , "a = 1")
|
||||
code = as_main_block("return 5" , "a = 1")
|
||||
@risc = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_risc(code)
|
||||
end
|
||||
|
||||
@ -24,7 +24,7 @@ module Mom
|
||||
include ScopeHelper
|
||||
|
||||
def setup
|
||||
code = as_test_main_block("return arg" , "arg = 1")
|
||||
code = as_main_block("return arg" , "arg = 1")
|
||||
@risc = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_risc(code)
|
||||
end
|
||||
|
||||
|
@ -6,7 +6,7 @@ module Vool
|
||||
include MomCompile
|
||||
|
||||
def setup
|
||||
@ret = compile_mom( as_test_main("self.main {|elem| elem = 5 } "))
|
||||
@ret = compile_mom( as_main("self.main {|elem| elem = 5 } "))
|
||||
end
|
||||
def test_is_compiler
|
||||
assert_equal Mom::MomCollection , @ret.class
|
||||
@ -21,7 +21,7 @@ module Vool
|
||||
class TestBlockLocal < MiniTest::Test
|
||||
include MomCompile
|
||||
def setup
|
||||
@ret = compile_mom( as_test_main("self.main {|elem| local = 5 } "))
|
||||
@ret = compile_mom( as_main("self.main {|elem| local = 5 } "))
|
||||
@block = @ret.method_compilers.first.get_method.blocks
|
||||
end
|
||||
def test_block_arg_type
|
||||
@ -43,11 +43,11 @@ module Vool
|
||||
def setup
|
||||
end
|
||||
def test_method_arg_compiles
|
||||
ret = compile_mom( as_test_main("self.main {|elem| arg = 5 } "))
|
||||
ret = compile_mom( as_main("self.main {|elem| arg = 5 } "))
|
||||
assert ret
|
||||
end
|
||||
def test_method_local_compiles
|
||||
ret = compile_mom( as_test_main("local = 5 ; self.main {|elem| local = 10 } "))
|
||||
ret = compile_mom( as_main("local = 5 ; self.main {|elem| local = 10 } "))
|
||||
assert ret
|
||||
end
|
||||
end
|
||||
|
@ -1,23 +0,0 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Mom
|
||||
class TestBuiltinFunction < MiniTest::Test
|
||||
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
@functions = Builtin.boot_functions({})
|
||||
end
|
||||
def test_has_boot_function
|
||||
assert @functions
|
||||
end
|
||||
def test_boot_function_type
|
||||
assert_equal Array, @functions.class
|
||||
end
|
||||
def test_boot_function_length
|
||||
assert_equal 21, @functions.length
|
||||
end
|
||||
def test_boot_function_first
|
||||
assert_equal Mom::MethodCompiler, @functions.first.class
|
||||
end
|
||||
end
|
||||
end
|
@ -6,7 +6,7 @@ module Vool
|
||||
include MomCompile
|
||||
|
||||
def setup
|
||||
@ret = compile_mom( as_test_main("return 1"))
|
||||
@ret = compile_mom( as_main("return 1"))
|
||||
end
|
||||
|
||||
def test_return_class
|
||||
|
@ -12,13 +12,13 @@ module Mom
|
||||
assert_equal MomCollection , @comp.class
|
||||
end
|
||||
def test_compilers
|
||||
assert_equal 23 , @comp.compilers.length
|
||||
assert_equal 2 , @comp.compilers.length
|
||||
end
|
||||
def test_boot_compilers
|
||||
assert_equal 22 , @comp.boot_compilers.length
|
||||
def test_init_compiler
|
||||
assert_equal Mom::MethodCompiler , @comp.init_compiler.class
|
||||
end
|
||||
def test_compilers_bare
|
||||
assert_equal 22 , MomCollection.new.compilers.length
|
||||
assert_equal 1 , MomCollection.new.compilers.length
|
||||
end
|
||||
def test_append_class
|
||||
assert_equal MomCollection, (@comp.append @comp).class
|
||||
@ -31,7 +31,7 @@ module Mom
|
||||
include MomCompile
|
||||
|
||||
def setup
|
||||
@comp = compile_mom( "class Test ; def main(); return 'Hi'; end; end;")
|
||||
@comp = compile_mom( "class Space ; def main(); return 'Hi'; end; end;")
|
||||
@collection = @comp.to_risc()
|
||||
end
|
||||
def compiler
|
||||
@ -42,7 +42,7 @@ module Mom
|
||||
end
|
||||
def test_has_risc_compiler
|
||||
assert_equal Risc::MethodCompiler, compiler.class
|
||||
assert_equal 23, @collection.method_compilers.length
|
||||
assert_equal 2, @collection.method_compilers.length
|
||||
end
|
||||
def test_has_risc_instructions
|
||||
assert_equal Risc::Label, compiler.risc_instructions.class
|
||||
|
Reference in New Issue
Block a user