diff --git a/test/mom/builtin/helper.rb b/test/mom/builtin/helper.rb index 21f9128c..3c123684 100644 --- a/test/mom/builtin/helper.rb +++ b/test/mom/builtin/helper.rb @@ -5,10 +5,24 @@ module Mom class BootTest < MiniTest::Test def setup Parfait.boot!(Parfait.default_test_options) - @functions = Builtin.boot_functions + Builtin.compiler_for( Parfait.object_space.get_class.instance_type , Space , :main) end - def get_compiler( name ) - @functions.each.find{|meth| meth.callable.name == name} + def get_int_compiler(name) + obj_type = Parfait.object_space.get_type_by_class_name(:Integer) + Builtin.compiler_for( obj_type , Integer , name) + end + def get_operator_compiler(name) + obj_type = Parfait.object_space.get_type_by_class_name(:Integer) + Builtin.operator_compiler( obj_type , name) + end + + def get_object_compiler(name) + obj_type = Parfait.object_space.get_type_by_class_name(:Object) + Builtin.compiler_for( obj_type , Object , name) + end + def get_word_compiler(name) + obj_type = Parfait.object_space.get_type_by_class_name(:Word) + Builtin.compiler_for( obj_type , Word , name) end end end diff --git a/test/mom/builtin/test_comparison.rb b/test/mom/builtin/test_comparison.rb index 2259705d..d5b2a1da 100644 --- a/test/mom/builtin/test_comparison.rb +++ b/test/mom/builtin/test_comparison.rb @@ -5,19 +5,7 @@ module Mom class TestIntComp1Risc < BootTest def setup super - @method = get_compiler(:<) - end - def test_compile - assert_equal Risc::MethodCompiler , @method.to_risc.class - end - def test_risc_length - assert_equal 28 , @method.to_risc.risc_instructions.length - end - end - class TestIntComp2Risc < BootTest - def setup - super - @method = get_compiler(:>=) + @method = get_int_compiler(:<) end def test_compile assert_equal Risc::MethodCompiler , @method.to_risc.class @@ -26,5 +14,17 @@ module Mom assert_equal 27 , @method.to_risc.risc_instructions.length end end + class TestIntComp2Risc < BootTest + def setup + super + @method = get_int_compiler(:>=) + end + def test_compile + assert_equal Risc::MethodCompiler , @method.to_risc.class + end + def test_risc_length + assert_equal 26 , @method.to_risc.risc_instructions.length + end + end end end diff --git a/test/mom/builtin/test_div10.rb b/test/mom/builtin/test_div10.rb index 3958fd21..45dbffa3 100644 --- a/test/mom/builtin/test_div10.rb +++ b/test/mom/builtin/test_div10.rb @@ -5,7 +5,7 @@ module Mom class TestIntDiv10Risc < BootTest def setup super - @method = get_compiler(:div10) + @method = get_int_compiler(:div10) end def test_compile assert_equal Risc::MethodCompiler , @method.to_risc.class diff --git a/test/mom/builtin/test_div4.rb b/test/mom/builtin/test_div4.rb index e143322f..4c9f3be8 100644 --- a/test/mom/builtin/test_div4.rb +++ b/test/mom/builtin/test_div4.rb @@ -5,7 +5,7 @@ module Mom class TestIntDiv4Risc < BootTest def setup super - @method = get_compiler(:div4) + @method = get_int_compiler(:div4) end def test_compile assert_equal Risc::MethodCompiler , @method.to_risc.class diff --git a/test/mom/builtin/test_exit.rb b/test/mom/builtin/test_exit.rb index 612341f2..6a9661a7 100644 --- a/test/mom/builtin/test_exit.rb +++ b/test/mom/builtin/test_exit.rb @@ -5,7 +5,7 @@ module Mom class TestObjectExitRisc < BootTest def setup super - @method = get_compiler(:exit) + @method = get_object_compiler(:exit) end def test_compile assert_equal Risc::MethodCompiler , @method.to_risc.class diff --git a/test/mom/builtin/test_get_internal_byte.rb b/test/mom/builtin/test_get_internal_byte.rb index 756a33ea..841f184f 100644 --- a/test/mom/builtin/test_get_internal_byte.rb +++ b/test/mom/builtin/test_get_internal_byte.rb @@ -5,13 +5,13 @@ module Mom class TestWordGetRisc < BootTest def setup super - @method = get_compiler(:get_internal_byte) + @method = get_word_compiler(:get_internal_byte) end def test_compile assert_equal Risc::MethodCompiler , @method.to_risc.class end def test_risc_length - assert_equal 48 , @method.to_risc.risc_instructions.length + assert_equal 47 , @method.to_risc.risc_instructions.length end end end diff --git a/test/mom/builtin/test_get_internal_word.rb b/test/mom/builtin/test_get_internal_word.rb index 756a33ea..2976a5f9 100644 --- a/test/mom/builtin/test_get_internal_word.rb +++ b/test/mom/builtin/test_get_internal_word.rb @@ -5,13 +5,13 @@ module Mom class TestWordGetRisc < BootTest def setup super - @method = get_compiler(:get_internal_byte) + @method = get_object_compiler(:get_internal_word) end def test_compile assert_equal Risc::MethodCompiler , @method.to_risc.class end def test_risc_length - assert_equal 48 , @method.to_risc.risc_instructions.length + assert_equal 19 , @method.to_risc.risc_instructions.length end end end diff --git a/test/mom/builtin/test_init.rb b/test/mom/builtin/test_init.rb index ead6f662..c7830b31 100644 --- a/test/mom/builtin/test_init.rb +++ b/test/mom/builtin/test_init.rb @@ -5,7 +5,7 @@ module Mom class TestObjectInitRisc < BootTest def setup super - @method = get_compiler(:__init__) + @method = get_object_compiler(:__init__) end def test_compile assert_equal Risc::MethodCompiler , @method.to_risc.class diff --git a/test/mom/builtin/test_integer.rb b/test/mom/builtin/test_integer.rb index c8f384b5..56fb0229 100644 --- a/test/mom/builtin/test_integer.rb +++ b/test/mom/builtin/test_integer.rb @@ -5,7 +5,7 @@ module Mom class TestIntDiv4 < BootTest def setup super - @method = get_compiler(:div4) + @method = get_int_compiler(:div4) end def test_has_get_internal assert_equal Mom::MethodCompiler , @method.class @@ -17,7 +17,7 @@ module Mom class TestIntDiv10 < BootTest def setup super - @method = get_compiler(:div10) + @method = get_int_compiler(:div10) end def test_has_get_internal assert_equal Mom::MethodCompiler , @method.class @@ -29,7 +29,7 @@ module Mom class TestIntComp1 < BootTest def setup super - @method = get_compiler(:<) + @method = get_int_compiler(:<) end def test_has_get_internal assert_equal Mom::MethodCompiler , @method.class @@ -41,7 +41,7 @@ module Mom class TestIntComp2 < BootTest def setup super - @method = get_compiler(:>=) + @method = get_int_compiler(:>=) end def test_has_get_internal assert_equal Mom::MethodCompiler , @method.class @@ -56,7 +56,7 @@ module Mom end def each_method &block Risc.operators.each do |name| - method = get_compiler(name) + method = get_operator_compiler(name) block.yield(method) end end diff --git a/test/mom/builtin/test_method_missing.rb b/test/mom/builtin/test_method_missing.rb index 70008e4f..c6ebe8d4 100644 --- a/test/mom/builtin/test_method_missing.rb +++ b/test/mom/builtin/test_method_missing.rb @@ -5,7 +5,7 @@ module Mom class TestObjectMissingRisc < BootTest def setup super - @method = get_compiler(:method_missing) + @method = get_object_compiler(:_method_missing) end def test_compile assert_equal Risc::MethodCompiler , @method.to_risc.class diff --git a/test/mom/builtin/test_object.rb b/test/mom/builtin/test_object.rb index 55d13906..c41b5663 100644 --- a/test/mom/builtin/test_object.rb +++ b/test/mom/builtin/test_object.rb @@ -5,7 +5,7 @@ module Mom class TestObjectGet < BootTest def setup super - @method = get_compiler(:get_internal_word) + @method = get_object_compiler(:get_internal_word) end def test_has_get_internal assert_equal Mom::MethodCompiler , @method.class @@ -17,7 +17,7 @@ module Mom class TestObjectSet < BootTest def setup super - @method = get_compiler(:set_internal_word) + @method = get_object_compiler(:set_internal_word) end def test_has_get_internal assert_equal Mom::MethodCompiler , @method.class @@ -29,7 +29,7 @@ module Mom class TestObjectMissing < BootTest def setup super - @method = get_compiler(:method_missing) + @method = get_object_compiler(:_method_missing) end def test_has_get_internal assert_equal Mom::MethodCompiler , @method.class @@ -41,7 +41,7 @@ module Mom class TestObjectExit < BootTest def setup super - @method = get_compiler(:exit) + @method = get_object_compiler(:exit) end def test_has_get_internal assert_equal Mom::MethodCompiler , @method.class @@ -53,7 +53,7 @@ module Mom class TestObjectInit < BootTest def setup super - @method = get_compiler(:__init__) + @method = get_object_compiler(:__init__) end def test_has_get_internal assert_equal Mom::MethodCompiler , @method.class diff --git a/test/mom/builtin/test_operator.rb b/test/mom/builtin/test_operator.rb index 83f7e0c6..5500fb93 100644 --- a/test/mom/builtin/test_operator.rb +++ b/test/mom/builtin/test_operator.rb @@ -8,7 +8,7 @@ module Mom end def each_method &block Risc.operators.each do |name| - method = get_compiler(name) + method = get_operator_compiler(name) block.yield(method) end end @@ -19,7 +19,7 @@ module Mom end def test_risc_length each_method do |method| - assert_equal 49 , method.to_risc.risc_instructions.length + assert_equal 48 , method.to_risc.risc_instructions.length end end end diff --git a/test/mom/builtin/test_putstring.rb b/test/mom/builtin/test_putstring.rb index 59f2a80f..4d3ad40a 100644 --- a/test/mom/builtin/test_putstring.rb +++ b/test/mom/builtin/test_putstring.rb @@ -5,7 +5,7 @@ module Mom class TestWordPutRisc < BootTest def setup super - @method = get_compiler(:putstring) + @method = get_word_compiler(:putstring) end def test_compile assert_equal Risc::MethodCompiler , @method.to_risc.class diff --git a/test/mom/builtin/test_set_internal_byte.rb b/test/mom/builtin/test_set_internal_byte.rb index 57eb50d2..43ada438 100644 --- a/test/mom/builtin/test_set_internal_byte.rb +++ b/test/mom/builtin/test_set_internal_byte.rb @@ -5,13 +5,13 @@ module Mom class TestWordSetRisc < BootTest def setup super - @method = get_compiler(:set_internal_byte) + @method = get_word_compiler(:set_internal_byte) end def test_compile assert_equal Risc::MethodCompiler , @method.to_risc.class end def test_risc_length - assert_equal 22 , @method.to_risc.risc_instructions.length + assert_equal 21 , @method.to_risc.risc_instructions.length end end end diff --git a/test/mom/builtin/test_set_internal_word.rb b/test/mom/builtin/test_set_internal_word.rb index 57eb50d2..d9b3e9ae 100644 --- a/test/mom/builtin/test_set_internal_word.rb +++ b/test/mom/builtin/test_set_internal_word.rb @@ -5,13 +5,13 @@ module Mom class TestWordSetRisc < BootTest def setup super - @method = get_compiler(:set_internal_byte) + @method = get_object_compiler(:set_internal_word) end def test_compile assert_equal Risc::MethodCompiler , @method.to_risc.class end def test_risc_length - assert_equal 22 , @method.to_risc.risc_instructions.length + assert_equal 20 , @method.to_risc.risc_instructions.length end end end diff --git a/test/mom/builtin/test_word.rb b/test/mom/builtin/test_word.rb index 6f32d960..00e7e75c 100644 --- a/test/mom/builtin/test_word.rb +++ b/test/mom/builtin/test_word.rb @@ -5,7 +5,7 @@ module Mom class TestWordPut < BootTest def setup super - @method = get_compiler(:putstring) + @method = get_word_compiler(:putstring) end def test_has_get_internal assert_equal Mom::MethodCompiler , @method.class @@ -17,7 +17,7 @@ module Mom class TestWordGet < BootTest def setup super - @method = get_compiler(:get_internal_byte) + @method = get_word_compiler(:get_internal_byte) end def test_has_get_internal assert_equal Mom::MethodCompiler , @method.class @@ -29,7 +29,7 @@ module Mom class TestWordSet < BootTest def setup super - @method = get_compiler(:set_internal_byte) + @method = get_word_compiler(:set_internal_byte) end def test_has_get_internal assert_equal Mom::MethodCompiler , @method.class