From 81f8f0f3a27130971a90ede557df7c43e566702a Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Mon, 18 Aug 2014 17:16:18 +0300 Subject: [PATCH] actually using volotile attributes and outputting sof in test. very readable --- lib/sof/volotile.rb | 2 +- lib/sof/writer.rb | 2 +- test/sof.rb | 4 ++-- test/virtual/virtual_helper.rb | 4 +++- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/sof/volotile.rb b/lib/sof/volotile.rb index 406851fb..f685276f 100644 --- a/lib/sof/volotile.rb +++ b/lib/sof/volotile.rb @@ -1,7 +1,7 @@ module Sof class Volotile @@mapping = { - Virtual::MethodDefinition => [] + Virtual::MethodDefinition => [:current] } def self.attributes clazz @@mapping[clazz] || [] diff --git a/lib/sof/writer.rb b/lib/sof/writer.rb index b27bf845..7a31ee3a 100644 --- a/lib/sof/writer.rb +++ b/lib/sof/writer.rb @@ -38,7 +38,7 @@ module Sof hash end immediate , extended = atts.partition {|a,val| val.is_a?(SimpleNode) } - head += immediate.collect {|a,val| "#{a}: #{val.data}"}.join(", ") + ")" + head += immediate.collect {|a,val| "#{a.to_sof()} => #{val.data}"}.join(", ") + ")" node = ObjectNode.new(head , ref) extended.each do |a , val| node.add( to_sof_node(a,level + 1) , val ) diff --git a/test/sof.rb b/test/sof.rb index e1caa64a..fe9fcde4 100644 --- a/test/sof.rb +++ b/test/sof.rb @@ -8,7 +8,7 @@ class ObjectWithAttributes end attr_accessor :extra end -OBJECT_STRING = "ObjectWithAttributes(name: 'some name', number: 1234)" +OBJECT_STRING = "ObjectWithAttributes(:name => 'some name', :number => 1234)" class BasicSof < MiniTest::Test def check should @@ -84,6 +84,6 @@ class BasicSof < MiniTest::Test object = ObjectWithAttributes.new object.extra = object @out = Sof::Writer.write(object) - check "&1 ObjectWithAttributes(name: 'some name', number: 1234, extra: *1)" + check "&1 ObjectWithAttributes(:name => 'some name', :number => 1234, :extra => *1)" end end \ No newline at end of file diff --git a/test/virtual/virtual_helper.rb b/test/virtual/virtual_helper.rb index 08a31487..46f4e204 100644 --- a/test/virtual/virtual_helper.rb +++ b/test/virtual/virtual_helper.rb @@ -11,7 +11,9 @@ module VirtualHelper machine = Virtual::Machine.boot expressions = machine.compile_main @string_input should = YAML.load(@output.gsub("RETURN_MARKER" , "\n")) - assert_equal should , expressions , expressions.to_yaml.gsub("\n" , "RETURN_MARKER") + "\n" + Sof::Members.write(expressions) + assert_equal should , expressions , expressions.to_yaml.gsub("\n" , "RETURN_MARKER") + "\n" + Sof::Writer.write(expressions) + puts "" + puts Sof::Writer.write(expressions) end end