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

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

Issue 364003002: Mojo: Mojom: Disallow trailing commas in parameter lists. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 6 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import imp 5 import imp
6 import os.path 6 import os.path
7 import sys 7 import sys
8 import unittest 8 import unittest
9 9
10 # Disable lint check for finding modules: 10 # Disable lint check for finding modules:
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 'MyInterface', 636 'MyInterface',
637 None, 637 None,
638 [('METHOD', 638 [('METHOD',
639 'MyMethod', 639 'MyMethod',
640 [ast.Parameter('string', 'a', ast.Ordinal(None))], 640 [ast.Parameter('string', 'a', ast.Ordinal(None))],
641 ast.Ordinal(None), 641 ast.Ordinal(None),
642 [ast.Parameter('int32', 'a', ast.Ordinal(None)), 642 [ast.Parameter('int32', 'a', ast.Ordinal(None)),
643 ast.Parameter('bool', 'b', ast.Ordinal(None))])])])] 643 ast.Parameter('bool', 'b', ast.Ordinal(None))])])])]
644 self.assertEquals(parser.Parse(source3, "my_file.mojom"), expected3) 644 self.assertEquals(parser.Parse(source3, "my_file.mojom"), expected3)
645 645
646 def testInvalidMethods(self):
647 """Tests that invalid method declarations are correctly detected."""
648
649 # No trailing commas.
650 source1 = """\
651 interface MyInterface {
652 MyMethod(string a,);
653 };
654 """
655 with self.assertRaisesRegexp(
656 parser.ParseError,
657 r"^my_file\.mojom:2: Error: Unexpected '\)':\n"
658 r" *MyMethod\(string a,\);$"):
659 parser.Parse(source1, "my_file.mojom")
660
661 # No leading commas.
662 source2 = """\
663 interface MyInterface {
664 MyMethod(, string a);
665 };
666 """
667 with self.assertRaisesRegexp(
668 parser.ParseError,
669 r"^my_file\.mojom:2: Error: Unexpected ',':\n"
670 r" *MyMethod\(, string a\);$"):
671 parser.Parse(source2, "my_file.mojom")
672
646 if __name__ == "__main__": 673 if __name__ == "__main__":
647 unittest.main() 674 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698