add hash with object
This commit is contained in:
parent
16261f96b0
commit
0a7814a07b
@ -31,6 +31,12 @@ module Sof
|
|||||||
add(a , level + 1)
|
add(a , level + 1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if( object.is_a? Hash )
|
||||||
|
object.each do |a,b|
|
||||||
|
add(a , level + 1)
|
||||||
|
add(b , level + 1)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -43,7 +43,11 @@ class BasicSof < MiniTest::Test
|
|||||||
end
|
end
|
||||||
def test_simple_hash
|
def test_simple_hash
|
||||||
out = Sof::Writer.write({ one: 1 , tru: true })
|
out = Sof::Writer.write({ one: 1 , tru: true })
|
||||||
puts out
|
|
||||||
assert_equal "-:one 1\n-:tru true\n" , out
|
assert_equal "-:one 1\n-:tru true\n" , out
|
||||||
end
|
end
|
||||||
|
def test_hash_object
|
||||||
|
out = Sof::Writer.write({ one: 1 , two: ObjectWithAttributes.new })
|
||||||
|
puts out
|
||||||
|
assert_equal "-:one 1\n-:two #{OBJECT_STRING}\n\n" , out
|
||||||
|
end
|
||||||
end
|
end
|
Loading…
Reference in New Issue
Block a user