some cc driven cleanup

bit anoying that the builtin engine is used
Even it is not as well configurable as preferred reek.
Still, found one minor bug
This commit is contained in:
2019-10-02 17:42:24 +03:00
parent 48e18ac9cd
commit fd8a3e9cc5
9 changed files with 42 additions and 15 deletions

View File

@ -19,5 +19,24 @@ module Parfait
def test_type
assert_equal ::Parfait::Type , @object.get_internal_word( 0 ).class
end
def test_type_length
assert_equal 1 , Object.type_length
end
def test_set_type
type = @object.type
assert @object.set_type(type)
assert @object.type = type
end
def test_has_type
assert @object.has_type?
end
def test_set_inst
type = @object.type
assert @object.set_instance_variable(:type , type)
assert_equal type , @object.type
end
def test_names
assert_equal "[:type]" , @object.instance_variables.to_s
end
end
end

View File

@ -39,7 +39,7 @@ module Ruby
end
def test_to_s
lst = compile( double_if )
assert_equal "if(false); true;else; false;end" , lst.to_s.gsub("\n",";")
assert_tos "if(false);true;else;false;end" , lst
end
end
end

View File

@ -12,13 +12,18 @@ module Ruby
end
def test_true
assert_equal Vool::LocalAssignment , @lst.if_true.class
assert @lst.has_true?
end
def test_false
assert_equal Vool::LocalAssignment , @lst.if_false.class
assert @lst.has_false?
end
def test_condition
assert_equal Vool::TrueConstant , @lst.condition.class
end
def test_to_s
assert_tos "if (true);a = 1;else;a = 2;end" , @lst
end
end
class TestIfStatementVoolHoisted < MiniTest::Test
include RubyTests

View File

@ -1,5 +1,8 @@
module Minitest
module Assertions
def assert_tos string , object
assert_equal string , object.to_s.gsub("\n",";").gsub(/\s+/," ").gsub("; ",";")
end
def assert_slot_to_reg( slot , array = nil, index = nil , register = nil)
assert_equal Risc::SlotToReg , slot.class
assert_equal( array , slot.array.symbol , "wrong source register") if array

View File

@ -25,6 +25,9 @@ module Vool
def test_class_instance
assert_equal :a , @vool.to_parfait.instance_type.names[1]
end
def test_to_s
assert_tos "class Test < Object;def main(arg);@a = 5;return @a;end;end" , @vool
end
end
class TestClassStatementTypeCreation < MiniTest::Test
include ScopeHelper