short hash, inline like for array. with curly braces off course
This commit is contained in:
parent
6343e644b4
commit
fc9615a649
@ -22,7 +22,15 @@ module Sof
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
def short_out(io,level)
|
def short_out(io,level)
|
||||||
long_out(io,level)
|
io.write("{")
|
||||||
|
children.each_with_index do |child , i|
|
||||||
|
key , val = child
|
||||||
|
key.out(io , level + 1)
|
||||||
|
io.write " => "
|
||||||
|
val.out(io , level + 1)
|
||||||
|
io.write ", " unless (i+1) == children.length
|
||||||
|
end
|
||||||
|
io.write("}")
|
||||||
end
|
end
|
||||||
def long_out io , level
|
def long_out io , level
|
||||||
indent = " " * level
|
indent = " " * level
|
||||||
|
@ -60,7 +60,7 @@ 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 })
|
||||||
check "-:one => 1\n-:tru => true"
|
check "{:one => 1, :tru => true}"
|
||||||
end
|
end
|
||||||
def test_hash_object
|
def test_hash_object
|
||||||
@out = Sof::Writer.write({ one: 1 , two: ObjectWithAttributes.new })
|
@out = Sof::Writer.write({ one: 1 , two: ObjectWithAttributes.new })
|
||||||
@ -68,7 +68,7 @@ class BasicSof < MiniTest::Test
|
|||||||
end
|
end
|
||||||
def test_array_hash
|
def test_array_hash
|
||||||
@out = Sof::Writer.write([true, 1 , { one: 1 , tru: true }])
|
@out = Sof::Writer.write([true, 1 , { one: 1 , tru: true }])
|
||||||
check "-true\n-1\n--:one => 1\n -:tru => true"
|
check "-true\n-1\n-{:one => 1, :tru => true}"
|
||||||
end
|
end
|
||||||
def test_hash_array
|
def test_hash_array
|
||||||
@out = Sof::Writer.write({ one: [1 , ObjectWithAttributes.new] , two: true })
|
@out = Sof::Writer.write({ one: [1 , ObjectWithAttributes.new] , two: true })
|
||||||
|
Loading…
Reference in New Issue
Block a user