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
|
module Sof
|
||||||
class Volotile
|
class Volotile
|
||||||
@@mapping = {
|
@@mapping = {
|
||||||
Virtual::MethodDefinition => []
|
Virtual::MethodDefinition => [:current]
|
||||||
}
|
}
|
||||||
def self.attributes clazz
|
def self.attributes clazz
|
||||||
@@mapping[clazz] || []
|
@@mapping[clazz] || []
|
||||||
|
@ -38,7 +38,7 @@ module Sof
|
|||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
immediate , extended = atts.partition {|a,val| val.is_a?(SimpleNode) }
|
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)
|
node = ObjectNode.new(head , ref)
|
||||||
extended.each do |a , val|
|
extended.each do |a , val|
|
||||||
node.add( to_sof_node(a,level + 1) , val )
|
node.add( to_sof_node(a,level + 1) , val )
|
||||||
|
@ -8,7 +8,7 @@ class ObjectWithAttributes
|
|||||||
end
|
end
|
||||||
attr_accessor :extra
|
attr_accessor :extra
|
||||||
end
|
end
|
||||||
OBJECT_STRING = "ObjectWithAttributes(name: 'some name', number: 1234)"
|
OBJECT_STRING = "ObjectWithAttributes(:name => 'some name', :number => 1234)"
|
||||||
|
|
||||||
class BasicSof < MiniTest::Test
|
class BasicSof < MiniTest::Test
|
||||||
def check should
|
def check should
|
||||||
@ -84,6 +84,6 @@ class BasicSof < MiniTest::Test
|
|||||||
object = ObjectWithAttributes.new
|
object = ObjectWithAttributes.new
|
||||||
object.extra = object
|
object.extra = object
|
||||||
@out = Sof::Writer.write(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
|
||||||
end
|
end
|
@ -11,7 +11,9 @@ module VirtualHelper
|
|||||||
machine = Virtual::Machine.boot
|
machine = Virtual::Machine.boot
|
||||||
expressions = machine.compile_main @string_input
|
expressions = machine.compile_main @string_input
|
||||||
should = YAML.load(@output.gsub("RETURN_MARKER" , "\n"))
|
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user