Permalink
Browse files

Pretty printing for enum schemas

Change-Id: I06e02f66d0a9415f2b35cedc1aab3ac52eb07c3f
  • Loading branch information...
1 parent 2cdbcd9 commit bffe8512f85c4732eeb98379a32de56501f01d98 mpage committed May 16, 2012
Showing with 11 additions and 0 deletions.
  1. +2 −0 lib/membrane/schema_parser.rb
  2. +9 −0 spec/schema_parser_spec.rb
@@ -62,6 +62,8 @@ def deparse(schema)
when Membrane::Schema::Dictionary
"dict(%s, %s)" % [deparse(schema.key_schema),
deparse(schema.value_schema)]
+ when Membrane::Schema::Enum
+ "enum(%s)" % [schema.elem_schemas.map { |es| deparse(es) }.join(", ")]
else
schema.inspect
end
@@ -40,6 +40,15 @@
parser.deparse(dict_schema).should == "dict(String, Integer)"
end
+
+ it "should deparse the element schemas of a Membrane::Schema::Enum schema" do
+ schemas =
+ [String, Integer, Float].map { |c| Membrane::Schema::Class.new(c) }
+
+ enum_schema = Membrane::Schema::Enum.new(*schemas)
+
+ parser.deparse(enum_schema).should == "enum(String, Integer, Float)"
+ end
end
describe "#parse" do

0 comments on commit bffe851

Please sign in to comment.