| 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 e4e92b8e03b2f3881a3797662c6cbc152cc49d36..71ab32b62e66a35ec123fff96892b22f8b584704 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
|
| @@ -643,5 +643,32 @@ class ParserTest(unittest.TestCase):
|
| ast.Parameter('bool', 'b', ast.Ordinal(None))])])])]
|
| self.assertEquals(parser.Parse(source3, "my_file.mojom"), expected3)
|
|
|
| + def testInvalidMethods(self):
|
| + """Tests that invalid method declarations are correctly detected."""
|
| +
|
| + # No trailing commas.
|
| + source1 = """\
|
| + interface MyInterface {
|
| + MyMethod(string a,);
|
| + };
|
| + """
|
| + with self.assertRaisesRegexp(
|
| + parser.ParseError,
|
| + r"^my_file\.mojom:2: Error: Unexpected '\)':\n"
|
| + r" *MyMethod\(string a,\);$"):
|
| + parser.Parse(source1, "my_file.mojom")
|
| +
|
| + # No leading commas.
|
| + source2 = """\
|
| + interface MyInterface {
|
| + MyMethod(, string a);
|
| + };
|
| + """
|
| + with self.assertRaisesRegexp(
|
| + parser.ParseError,
|
| + r"^my_file\.mojom:2: Error: Unexpected ',':\n"
|
| + r" *MyMethod\(, string a\);$"):
|
| + parser.Parse(source2, "my_file.mojom")
|
| +
|
| if __name__ == "__main__":
|
| unittest.main()
|
|
|