Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(987)

Unified Diff: mojo/public/tools/bindings/pylib/mojom_tests/parse/parser_unittest.py

Issue 295773002: Mojo: Mojom: Make specialized handle types (e.g., message_pipe) not keywords. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review comments Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/public/tools/bindings/pylib/mojom_tests/parse/lexer_unittest.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/tools/bindings/pylib/mojom_tests/parse/parser_unittest.py
diff --git a/mojo/public/tools/bindings/pylib/mojom_tests/parse/parser_unittest.py b/mojo/public/tools/bindings/pylib/mojom_tests/parse/parser_unittest.py
index 99a41e2fcaba22d2d016b9bd1b5a989dedc2fe4d..5ef995b1d7499c63b72e162ed8385562ad87f009 100644
--- a/mojo/public/tools/bindings/pylib/mojom_tests/parse/parser_unittest.py
+++ b/mojo/public/tools/bindings/pylib/mojom_tests/parse/parser_unittest.py
@@ -311,7 +311,7 @@ struct MyStruct {
parser.Parse(source6, "my_file.mojom")
def testNestedNamespace(self):
- """Tests nested namespaces work."""
+ """Tests that "nested" namespaces work."""
source = """\
module my.mod {
@@ -331,6 +331,47 @@ struct MyStruct {
[('FIELD', 'int32', 'a', ast.Ordinal(None), None)])])]
self.assertEquals(parser.Parse(source, "my_file.mojom"), expected)
+ def testValidHandleTypes(self):
+ """Tests (valid) handle types."""
+ source = """\
+struct MyStruct {
+ handle a;
+ handle<data_pipe_consumer> b;
+ handle <data_pipe_producer> c;
+ handle < message_pipe > d;
+ handle
+ < shared_buffer
+ > e;
+};
+"""
+ expected = \
+[('MODULE',
+ '',
+ None,
+ [('STRUCT',
+ 'MyStruct',
+ None,
+ [('FIELD', 'handle', 'a', ast.Ordinal(None), None),
+ ('FIELD', 'handle<data_pipe_consumer>', 'b', ast.Ordinal(None), None),
+ ('FIELD', 'handle<data_pipe_producer>', 'c', ast.Ordinal(None), None),
+ ('FIELD', 'handle<message_pipe>', 'd', ast.Ordinal(None), None),
+ ('FIELD', 'handle<shared_buffer>', 'e', ast.Ordinal(None), None)])])]
+ self.assertEquals(parser.Parse(source, "my_file.mojom"), expected)
+
+ def testInvalidHandleType(self):
+ """Tests an invalid (unknown) handle type."""
+ source = """\
+struct MyStruct {
+ handle<wtf_is_this> foo;
+};
+"""
+ with self.assertRaisesRegexp(
+ parser.ParseError,
+ r"^my_file\.mojom:2: Error: "
+ r"Invalid handle type 'wtf_is_this':\n"
+ r" handle<wtf_is_this> foo;$"):
+ parser.Parse(source, "my_file.mojom")
+
if __name__ == "__main__":
unittest.main()
« no previous file with comments | « mojo/public/tools/bindings/pylib/mojom_tests/parse/lexer_unittest.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698