working up
This commit is contained in:
parent
0a7814a07b
commit
b0a54cb8c2
@ -37,7 +37,7 @@ module Sof
|
|||||||
output( io , val)
|
output( io , val)
|
||||||
io.write(" ,") unless i == (attributes.length - 1)
|
io.write(" ,") unless i == (attributes.length - 1)
|
||||||
end
|
end
|
||||||
io.puts ")"
|
io.write ")"
|
||||||
attributes.each_with_index do |a , i|
|
attributes.each_with_index do |a , i|
|
||||||
val = get_value(object , a)
|
val = get_value(object , a)
|
||||||
next if is_value?(val)
|
next if is_value?(val)
|
||||||
|
15
test/sof.rb
15
test/sof.rb
@ -1,4 +1,5 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
require "yaml"
|
||||||
|
|
||||||
class ObjectWithAttributes
|
class ObjectWithAttributes
|
||||||
def initialize
|
def initialize
|
||||||
@ -19,7 +20,7 @@ class BasicSof < MiniTest::Test
|
|||||||
end
|
end
|
||||||
def test_object
|
def test_object
|
||||||
out = Sof::Writer.write(ObjectWithAttributes.new)
|
out = Sof::Writer.write(ObjectWithAttributes.new)
|
||||||
assert_equal "#{OBJECT_STRING}\n" , out
|
assert_equal "#{OBJECT_STRING}" , out
|
||||||
end
|
end
|
||||||
def test_simple_array
|
def test_simple_array
|
||||||
out = Sof::Writer.write([true, 1234])
|
out = Sof::Writer.write([true, 1234])
|
||||||
@ -27,7 +28,7 @@ class BasicSof < MiniTest::Test
|
|||||||
end
|
end
|
||||||
def test_array_object
|
def test_array_object
|
||||||
out = Sof::Writer.write([true, 1234 , ObjectWithAttributes.new])
|
out = Sof::Writer.write([true, 1234 , ObjectWithAttributes.new])
|
||||||
assert_equal "-true\n-1234\n-#{OBJECT_STRING}\n\n" , out
|
assert_equal "-true\n-1234\n-#{OBJECT_STRING}\n" , out
|
||||||
end
|
end
|
||||||
def test_array_array
|
def test_array_array
|
||||||
out = Sof::Writer.write([true, 1 , [true , 12 ]])
|
out = Sof::Writer.write([true, 1 , [true , 12 ]])
|
||||||
@ -39,7 +40,7 @@ class BasicSof < MiniTest::Test
|
|||||||
end
|
end
|
||||||
def test_array_array_object
|
def test_array_array_object
|
||||||
out = Sof::Writer.write([true, 1 , [true , 12 , ObjectWithAttributes.new]])
|
out = Sof::Writer.write([true, 1 , [true , 12 , ObjectWithAttributes.new]])
|
||||||
assert_equal "-true\n-1\n--true\n -12\n -#{OBJECT_STRING}\n\n\n" , out
|
assert_equal "-true\n-1\n--true\n -12\n -#{OBJECT_STRING}\n\n" , out
|
||||||
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 })
|
||||||
@ -47,7 +48,13 @@ class BasicSof < MiniTest::Test
|
|||||||
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 })
|
||||||
puts out
|
assert_equal "-:one 1\n-:two #{OBJECT_STRING}\n" , out
|
||||||
|
end
|
||||||
|
def test_hash_array
|
||||||
|
out = Sof::Writer.write({ one: [1 , ObjectWithAttributes.new] , two: true })
|
||||||
|
puts "\n#{out}"
|
||||||
|
s = { :one => [1 , ObjectWithAttributes.new] , :two => true }.to_yaml
|
||||||
|
puts s
|
||||||
assert_equal "-:one 1\n-:two #{OBJECT_STRING}\n\n" , out
|
assert_equal "-:one 1\n-:two #{OBJECT_STRING}\n\n" , out
|
||||||
end
|
end
|
||||||
end
|
end
|
Loading…
Reference in New Issue
Block a user