Permalink
Browse files

Pretty printing for list schemas

Change-Id: I1ff4296809359fc480d154329a70face008bdeaf
  • Loading branch information...
1 parent bffe851 commit ccce19b0ff036a0c55a5626688b756247ae570be mpage committed May 16, 2012
Showing with 12 additions and 0 deletions.
  1. +2 −0 lib/membrane/schema_parser.rb
  2. +10 −0 spec/schema_parser_spec.rb
@@ -64,6 +64,8 @@ def deparse(schema)
deparse(schema.value_schema)]
when Membrane::Schema::Enum
"enum(%s)" % [schema.elem_schemas.map { |es| deparse(es) }.join(", ")]
+ when Membrane::Schema::List
+ "[%s]" % [deparse(schema.elem_schema)]
else
schema.inspect
end
@@ -49,6 +49,16 @@
parser.deparse(enum_schema).should == "enum(String, Integer, Float)"
end
+
+ it "should deparse the element schema of a Membrane::Schema::List schema" do
+ key_schema = Membrane::Schema::Class.new(String)
+ val_schema = Membrane::Schema::Class.new(Integer)
+ item_schema = Membrane::Schema::Dictionary.new(key_schema, val_schema)
+
+ list_schema = Membrane::Schema::List.new(item_schema)
+
+ parser.deparse(list_schema).should == "[dict(String, Integer)]"
+ end
end
describe "#parse" do

0 comments on commit ccce19b

Please sign in to comment.