fix level bug that became obvous with recursion

This commit is contained in:
Torsten Ruger
2014-08-18 13:33:40 +03:00
parent ad4aaaff8a
commit 338c669a00
3 changed files with 15 additions and 8 deletions

View File

@ -6,10 +6,7 @@ class ObjectWithAttributes
@name = "some name"
@number = 1234
end
def extra_array
@extra = [:sym , 123]
self
end
attr_accessor :extra
end
OBJECT_STRING = "ObjectWithAttributes(name: 'some name', number: 1234)"
@ -32,7 +29,9 @@ class BasicSof < MiniTest::Test
check "#{OBJECT_STRING}"
end
def test_object_extra_array
@out = Sof::Writer.write(ObjectWithAttributes.new.extra_array)
object = ObjectWithAttributes.new
object.extra = [:sym , 123]
@out = Sof::Writer.write(object)
check "#{OBJECT_STRING}\n :extra -:sym\n -123"
end
def test_simple_array
@ -81,4 +80,10 @@ class BasicSof < MiniTest::Test
@out = Sof::Writer.write(ar)
check "-true\n-1\n-*1"
end
def test_object_recursive
ar = [true, 1 ]
ar << ar
@out = Sof::Writer.write(ar)
check "-true\n-1\n-*1"
end
end