Skip to content

Commit

Permalink
Pretty printing for enum schemas
Browse files Browse the repository at this point in the history
Change-Id: I06e02f66d0a9415f2b35cedc1aab3ac52eb07c3f
  • Loading branch information
mpage committed May 16, 2012
1 parent 2cdbcd9 commit bffe851
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/membrane/schema_parser.rb
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions spec/schema_parser_spec.rb
Expand Up @@ -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
Expand Down

0 comments on commit bffe851

Please sign in to comment.