actually using volotile attributes and outputting sof in test. very readable
This commit is contained in:
parent
a594b716bc
commit
81f8f0f3a2
@ -1,7 +1,7 @@
|
||||
module Sof
|
||||
class Volotile
|
||||
@@mapping = {
|
||||
Virtual::MethodDefinition => []
|
||||
Virtual::MethodDefinition => [:current]
|
||||
}
|
||||
def self.attributes clazz
|
||||
@@mapping[clazz] || []
|
||||
|
@ -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 )
|
||||
|
@ -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
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user