Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Pretty printer for tuples

Change-Id: If37835e20dfa875e98e7c399764a00979b135b79
  • Loading branch information...
commit 67b98a56d647378a37c0b818fa8eeb38f6b7608b 1 parent 8af7296
mpage authored
Showing with 12 additions and 0 deletions.
  1. +2 −0  lib/membrane/schema_parser.rb
  2. +10 −0 spec/schema_parser_spec.rb
View
2  lib/membrane/schema_parser.rb
@@ -72,6 +72,8 @@ def deparse(schema)
deparse_record(schema)
when Membrane::Schema::Regexp
schema.regexp.inspect
+ when Membrane::Schema::Tuple
+ "tuple(%s)" % [schema.elem_schemas.map { |es| deparse(es) }.join(", ")]
else
schema.inspect
end
View
10 spec/schema_parser_spec.rb
@@ -89,6 +89,16 @@
schema.regexp.should_receive(:inspect)
parser.deparse(schema)
end
+
+ it "should deparse the element schemas of a Membrane::Schema::Tuple schema" do
+ schemas = [String, Integer].map { |c| Membrane::Schema::Class.new(c) }
+ schemas << Membrane::Schema::Value.new("test")
+
+ enum_schema = Membrane::Schema::Tuple.new(*schemas)
+
+ parser.deparse(enum_schema).should == 'tuple(String, Integer, "test")'
+ end
+
end
describe "#parse" do
Please sign in to comment.
Something went wrong with that request. Please try again.