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:
parent
48e18ac9cd
commit
fd8a3e9cc5
@ -1,5 +1,10 @@
|
||||
---
|
||||
engines:
|
||||
checks:
|
||||
method-count:
|
||||
enabled: false
|
||||
method-lines:
|
||||
enabled: false
|
||||
bundler-audit:
|
||||
enabled: true
|
||||
duplication:
|
||||
|
@ -38,9 +38,9 @@ module Ruby
|
||||
|
||||
def to_s(depth = 0)
|
||||
parts = "if(#{@condition})\n"
|
||||
parts += " #{@if_true.to_s(depth + 1)}\n" if(@if_true)
|
||||
parts += " #{@if_true.to_s(1)}\n" if(@if_true)
|
||||
parts += "else\n" if(@if_false)
|
||||
parts += " #{@if_false.to_s(depth + 1)}\n" if(@if_false)
|
||||
parts += " #{@if_false.to_s(1)}\n" if(@if_false)
|
||||
parts += "end\n"
|
||||
at_depth(depth , parts )
|
||||
end
|
||||
|
@ -16,16 +16,8 @@ module Vool
|
||||
def initialize( name , supe , body)
|
||||
@name = name
|
||||
@super_class_name = supe || :Object
|
||||
case body
|
||||
when MethodExpression
|
||||
@body = Statements.new([body])
|
||||
when Statements
|
||||
@body = body
|
||||
when nil
|
||||
@body = Statements.new([])
|
||||
else
|
||||
raise "what body #{body}"
|
||||
end
|
||||
raise "what body #{body}" unless body.is_a?(Statements)
|
||||
@body = body
|
||||
end
|
||||
|
||||
# This creates the Parfait class.
|
||||
|
@ -52,8 +52,8 @@ module Vool
|
||||
def to_s(depth = 0)
|
||||
parts = "if (#{@condition.to_s(0)})\n"
|
||||
parts += " #{@if_true}\n" if @if_true
|
||||
parts += "else\n" if(@false)
|
||||
parts += " #{@if_false}\n" if(@false)
|
||||
parts += "else\n" if(@if_false)
|
||||
parts += " #{@if_false}\n" if(@if_false)
|
||||
parts += "end\n"
|
||||
at_depth(depth , parts )
|
||||
end
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user