Skip to content
Browse files

Pretty printing for dictionary schemas

Change-Id: I34c35245c0b3ff32e8f3d18d693369d68f4051e7
  • Loading branch information...
1 parent dd651f0 commit 2cdbcd9c208d957d650d24a26072c3d5e16c5fce mpage committed May 15, 2012
Showing with 12 additions and 0 deletions.
  1. +3 −0 lib/membrane/schema_parser.rb
  2. +9 −0 spec/schema_parser_spec.rb
View
3 lib/membrane/schema_parser.rb
@@ -59,6 +59,9 @@ def deparse(schema)
"bool"
when Membrane::Schema::Class
schema.klass.inspect
+ when Membrane::Schema::Dictionary
+ "dict(%s, %s)" % [deparse(schema.key_schema),
+ deparse(schema.value_schema)]
else
schema.inspect
end
View
9 spec/schema_parser_spec.rb
@@ -31,6 +31,15 @@
parser.deparse(schema).should == klass.inspect
end
+
+ it "should deparse the k/v schemas of a Membrane::Schema::Dictionary schema" do
+ key_schema = Membrane::Schema::Class.new(String)
+ val_schema = Membrane::Schema::Class.new(Integer)
+
+ dict_schema = Membrane::Schema::Dictionary.new(key_schema, val_schema)
+
+ parser.deparse(dict_schema).should == "dict(String, Integer)"
+ end
end
describe "#parse" do

0 comments on commit 2cdbcd9

Please sign in to comment.
Something went wrong with that request. Please try again.