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

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

Issue 376023002: Mojo: Mojom parser: Make |module| use an |identifier_wrapped|. (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
« no previous file with comments | « mojo/public/tools/bindings/pylib/mojom/parse/translate.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 23 matching lines...) Expand all
34 34
35 def testTrivialValidSource(self): 35 def testTrivialValidSource(self):
36 """Tests a trivial, but valid, .mojom source.""" 36 """Tests a trivial, but valid, .mojom source."""
37 37
38 source = """\ 38 source = """\
39 // This is a comment. 39 // This is a comment.
40 40
41 module my_module { 41 module my_module {
42 } 42 }
43 """ 43 """
44 self.assertEquals(parser.Parse(source, "my_file.mojom"), 44 expected = [('MODULE', ('IDENTIFIER', 'my_module'), None, None)]
45 [("MODULE", "my_module", None, None)]) 45 self.assertEquals(parser.Parse(source, "my_file.mojom"), expected)
46 46
47 def testSourceWithCrLfs(self): 47 def testSourceWithCrLfs(self):
48 """Tests a .mojom source with CR-LFs instead of LFs.""" 48 """Tests a .mojom source with CR-LFs instead of LFs."""
49 49
50 source = "// This is a comment.\r\n\r\nmodule my_module {\r\n}\r\n" 50 source = "// This is a comment.\r\n\r\nmodule my_module {\r\n}\r\n"
51 self.assertEquals(parser.Parse(source, "my_file.mojom"), 51 expected = [('MODULE', ('IDENTIFIER', 'my_module'), None, None)]
52 [("MODULE", "my_module", None, None)]) 52 self.assertEquals(parser.Parse(source, "my_file.mojom"), expected)
53 53
54 def testUnexpectedEOF(self): 54 def testUnexpectedEOF(self):
55 """Tests a "truncated" .mojom source.""" 55 """Tests a "truncated" .mojom source."""
56 56
57 source = """\ 57 source = """\
58 // This is a comment. 58 // This is a comment.
59 59
60 module my_module { 60 module my_module {
61 """ 61 """
62 with self.assertRaisesRegexp( 62 with self.assertRaisesRegexp(
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 134
135 struct MyStruct { 135 struct MyStruct {
136 int32 a; 136 int32 a;
137 double b; 137 double b;
138 }; 138 };
139 139
140 } // module my_module 140 } // module my_module
141 """ 141 """
142 expected = \ 142 expected = \
143 [('MODULE', 143 [('MODULE',
144 'my_module', 144 ('IDENTIFIER', 'my_module'),
145 None, 145 None,
146 [('STRUCT', 146 [('STRUCT',
147 'MyStruct', 147 'MyStruct',
148 None, 148 None,
149 [('FIELD', 'int32', 'a', ast.Ordinal(None), None), 149 [('FIELD', 'int32', 'a', ast.Ordinal(None), None),
150 ('FIELD', 'double', 'b', ast.Ordinal(None), None)])])] 150 ('FIELD', 'double', 'b', ast.Ordinal(None), None)])])]
151 self.assertEquals(parser.Parse(source, "my_file.mojom"), expected) 151 self.assertEquals(parser.Parse(source, "my_file.mojom"), expected)
152 152
153 def testSimpleStructWithoutModule(self): 153 def testSimpleStructWithoutModule(self):
154 """Tests a simple struct without an enclosing module.""" 154 """Tests a simple struct without an enclosing module."""
155 155
156 source = """\ 156 source = """\
157 struct MyStruct { 157 struct MyStruct {
158 int32 a; 158 int32 a;
159 double b; 159 double b;
160 }; 160 };
161 """ 161 """
162 expected = \ 162 expected = \
163 [('MODULE', 163 [('MODULE',
164 '', 164 None,
165 None, 165 None,
166 [('STRUCT', 166 [('STRUCT',
167 'MyStruct', 167 'MyStruct',
168 None, 168 None,
169 [('FIELD', 'int32', 'a', ast.Ordinal(None), None), 169 [('FIELD', 'int32', 'a', ast.Ordinal(None), None),
170 ('FIELD', 'double', 'b', ast.Ordinal(None), None)])])] 170 ('FIELD', 'double', 'b', ast.Ordinal(None), None)])])]
171 self.assertEquals(parser.Parse(source, "my_file.mojom"), expected) 171 self.assertEquals(parser.Parse(source, "my_file.mojom"), expected)
172 172
173 def testMissingModuleName(self): 173 def testMissingModuleName(self):
174 """Tests an (invalid) .mojom with a missing module name.""" 174 """Tests an (invalid) .mojom with a missing module name."""
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 VALUE3 = + 987, // Check that space is allowed. 212 VALUE3 = + 987, // Check that space is allowed.
213 VALUE4 = 0xAF12, 213 VALUE4 = 0xAF12,
214 VALUE5 = -0x09bcd, 214 VALUE5 = -0x09bcd,
215 VALUE6 = VALUE5, 215 VALUE6 = VALUE5,
216 VALUE7, // Leave trailing comma. 216 VALUE7, // Leave trailing comma.
217 }; 217 };
218 } // my_module 218 } // my_module
219 """ 219 """
220 expected = \ 220 expected = \
221 [('MODULE', 221 [('MODULE',
222 'my_module', 222 ('IDENTIFIER', 'my_module'),
223 None, 223 None,
224 [('ENUM', 224 [('ENUM',
225 'MyEnum1', 225 'MyEnum1',
226 [('ENUM_VALUE', 'VALUE1', None), 226 [('ENUM_VALUE', 'VALUE1', None),
227 ('ENUM_VALUE', 'VALUE2', None)]), 227 ('ENUM_VALUE', 'VALUE2', None)]),
228 ('ENUM', 228 ('ENUM',
229 'MyEnum2', 229 'MyEnum2',
230 [('ENUM_VALUE', 'VALUE1', '-1'), 230 [('ENUM_VALUE', 'VALUE1', '-1'),
231 ('ENUM_VALUE', 'VALUE2', '0'), 231 ('ENUM_VALUE', 'VALUE2', '0'),
232 ('ENUM_VALUE', 'VALUE3', '+987'), 232 ('ENUM_VALUE', 'VALUE3', '+987'),
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 274
275 struct MyStruct { 275 struct MyStruct {
276 const int8 kNumber = -1; 276 const int8 kNumber = -1;
277 int8 number@0 = kNumber; 277 int8 number@0 = kNumber;
278 }; 278 };
279 279
280 } // my_module 280 } // my_module
281 """ 281 """
282 expected = \ 282 expected = \
283 [('MODULE', 283 [('MODULE',
284 'my_module', 284 ('IDENTIFIER', 'my_module'),
285 None, 285 None,
286 [('STRUCT', 286 [('STRUCT',
287 'MyStruct', None, 287 'MyStruct', None,
288 [('CONST', 'int8', 'kNumber', '-1'), 288 [('CONST', 'int8', 'kNumber', '-1'),
289 ('FIELD', 'int8', 'number', 289 ('FIELD', 'int8', 'number',
290 ast.Ordinal(0), ('IDENTIFIER', 'kNumber'))])])] 290 ast.Ordinal(0), ('IDENTIFIER', 'kNumber'))])])]
291 self.assertEquals(parser.Parse(source, "my_file.mojom"), expected) 291 self.assertEquals(parser.Parse(source, "my_file.mojom"), expected)
292 292
293 def testNoConditionals(self): 293 def testNoConditionals(self):
294 """Tests that ?: is not allowed.""" 294 """Tests that ?: is not allowed."""
(...skipping 28 matching lines...) Expand all
323 int32 a10 @10; 323 int32 a10 @10;
324 int32 a11 @11; 324 int32 a11 @11;
325 int32 a29 @29; 325 int32 a29 @29;
326 int32 a1234567890 @1234567890; 326 int32 a1234567890 @1234567890;
327 }; 327 };
328 328
329 } // module my_module 329 } // module my_module
330 """ 330 """
331 expected = \ 331 expected = \
332 [('MODULE', 332 [('MODULE',
333 'my_module', 333 ('IDENTIFIER', 'my_module'),
334 None, 334 None,
335 [('STRUCT', 335 [('STRUCT',
336 'MyStruct', 336 'MyStruct',
337 None, 337 None,
338 [('FIELD', 'int32', 'a0', ast.Ordinal(0), None), 338 [('FIELD', 'int32', 'a0', ast.Ordinal(0), None),
339 ('FIELD', 'int32', 'a1', ast.Ordinal(1), None), 339 ('FIELD', 'int32', 'a1', ast.Ordinal(1), None),
340 ('FIELD', 'int32', 'a2', ast.Ordinal(2), None), 340 ('FIELD', 'int32', 'a2', ast.Ordinal(2), None),
341 ('FIELD', 'int32', 'a9', ast.Ordinal(9), None), 341 ('FIELD', 'int32', 'a9', ast.Ordinal(9), None),
342 ('FIELD', 'int32', 'a10', ast.Ordinal(10), None), 342 ('FIELD', 'int32', 'a10', ast.Ordinal(10), None),
343 ('FIELD', 'int32', 'a11', ast.Ordinal(11), None), 343 ('FIELD', 'int32', 'a11', ast.Ordinal(11), None),
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 module my.mod { 420 module my.mod {
421 421
422 struct MyStruct { 422 struct MyStruct {
423 int32 a; 423 int32 a;
424 }; 424 };
425 425
426 } // module my.mod 426 } // module my.mod
427 """ 427 """
428 expected = \ 428 expected = \
429 [('MODULE', 429 [('MODULE',
430 'my.mod', 430 ('IDENTIFIER', 'my.mod'),
431 None, 431 None,
432 [('STRUCT', 432 [('STRUCT',
433 'MyStruct', 433 'MyStruct',
434 None, 434 None,
435 [('FIELD', 'int32', 'a', ast.Ordinal(None), None)])])] 435 [('FIELD', 'int32', 'a', ast.Ordinal(None), None)])])]
436 self.assertEquals(parser.Parse(source, "my_file.mojom"), expected) 436 self.assertEquals(parser.Parse(source, "my_file.mojom"), expected)
437 437
438 def testValidHandleTypes(self): 438 def testValidHandleTypes(self):
439 """Tests (valid) handle types.""" 439 """Tests (valid) handle types."""
440 440
441 source = """\ 441 source = """\
442 struct MyStruct { 442 struct MyStruct {
443 handle a; 443 handle a;
444 handle<data_pipe_consumer> b; 444 handle<data_pipe_consumer> b;
445 handle <data_pipe_producer> c; 445 handle <data_pipe_producer> c;
446 handle < message_pipe > d; 446 handle < message_pipe > d;
447 handle 447 handle
448 < shared_buffer 448 < shared_buffer
449 > e; 449 > e;
450 }; 450 };
451 """ 451 """
452 expected = \ 452 expected = \
453 [('MODULE', 453 [('MODULE',
454 '', 454 None,
455 None, 455 None,
456 [('STRUCT', 456 [('STRUCT',
457 'MyStruct', 457 'MyStruct',
458 None, 458 None,
459 [('FIELD', 'handle', 'a', ast.Ordinal(None), None), 459 [('FIELD', 'handle', 'a', ast.Ordinal(None), None),
460 ('FIELD', 'handle<data_pipe_consumer>', 'b', ast.Ordinal(None), 460 ('FIELD', 'handle<data_pipe_consumer>', 'b', ast.Ordinal(None),
461 None), 461 None),
462 ('FIELD', 'handle<data_pipe_producer>', 'c', ast.Ordinal(None), 462 ('FIELD', 'handle<data_pipe_producer>', 'c', ast.Ordinal(None),
463 None), 463 None),
464 ('FIELD', 'handle<message_pipe>', 'd', ast.Ordinal(None), None), 464 ('FIELD', 'handle<message_pipe>', 'd', ast.Ordinal(None), None),
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 float a17 = .123; 506 float a17 = .123;
507 double a18 = 1.23E10; 507 double a18 = 1.23E10;
508 double a19 = 1.E-10; 508 double a19 = 1.E-10;
509 double a20 = .5E+10; 509 double a20 = .5E+10;
510 double a21 = -1.23E10; 510 double a21 = -1.23E10;
511 double a22 = +.123E10; 511 double a22 = +.123E10;
512 }; 512 };
513 """ 513 """
514 expected = \ 514 expected = \
515 [('MODULE', 515 [('MODULE',
516 '', 516 None,
517 None, 517 None,
518 [('STRUCT', 518 [('STRUCT',
519 'MyStruct', 519 'MyStruct',
520 None, 520 None,
521 [('FIELD', 'int16', 'a0', ast.Ordinal(None), '0'), 521 [('FIELD', 'int16', 'a0', ast.Ordinal(None), '0'),
522 ('FIELD', 'uint16', 'a1', ast.Ordinal(None), '0x0'), 522 ('FIELD', 'uint16', 'a1', ast.Ordinal(None), '0x0'),
523 ('FIELD', 'uint16', 'a2', ast.Ordinal(None), '0x00'), 523 ('FIELD', 'uint16', 'a2', ast.Ordinal(None), '0x00'),
524 ('FIELD', 'uint16', 'a3', ast.Ordinal(None), '0x01'), 524 ('FIELD', 'uint16', 'a3', ast.Ordinal(None), '0x01'),
525 ('FIELD', 'uint16', 'a4', ast.Ordinal(None), '0xcd'), 525 ('FIELD', 'uint16', 'a4', ast.Ordinal(None), '0xcd'),
526 ('FIELD', 'int32', 'a5' , ast.Ordinal(None), '12345'), 526 ('FIELD', 'int32', 'a5' , ast.Ordinal(None), '12345'),
(...skipping 21 matching lines...) Expand all
548 548
549 source = """\ 549 source = """\
550 struct MyStruct { 550 struct MyStruct {
551 int32[] normal_array; 551 int32[] normal_array;
552 int32[1] fixed_size_array_one_entry; 552 int32[1] fixed_size_array_one_entry;
553 int32[10] fixed_size_array_ten_entries; 553 int32[10] fixed_size_array_ten_entries;
554 }; 554 };
555 """ 555 """
556 expected = \ 556 expected = \
557 [('MODULE', 557 [('MODULE',
558 '', 558 None,
559 None, 559 None,
560 [('STRUCT', 560 [('STRUCT',
561 'MyStruct', 561 'MyStruct',
562 None, 562 None,
563 [('FIELD', 'int32[]', 'normal_array', ast.Ordinal(None), None), 563 [('FIELD', 'int32[]', 'normal_array', ast.Ordinal(None), None),
564 ('FIELD', 'int32[1]', 'fixed_size_array_one_entry', 564 ('FIELD', 'int32[1]', 'fixed_size_array_one_entry',
565 ast.Ordinal(None), None), 565 ast.Ordinal(None), None),
566 ('FIELD', 'int32[10]', 'fixed_size_array_ten_entries', 566 ('FIELD', 'int32[10]', 'fixed_size_array_ten_entries',
567 ast.Ordinal(None), None)])])] 567 ast.Ordinal(None), None)])])]
568 self.assertEquals(parser.Parse(source, "my_file.mojom"), expected) 568 self.assertEquals(parser.Parse(source, "my_file.mojom"), expected)
569 569
570 def testValidNestedArray(self): 570 def testValidNestedArray(self):
571 """Tests parsing a nested array.""" 571 """Tests parsing a nested array."""
572 572
573 source = "struct MyStruct { int32[][] nested_array; };" 573 source = "struct MyStruct { int32[][] nested_array; };"
574 expected = \ 574 expected = \
575 [('MODULE', 575 [('MODULE',
576 '', 576 None,
577 None, 577 None,
578 [('STRUCT', 578 [('STRUCT',
579 'MyStruct', 579 'MyStruct',
580 None, 580 None,
581 [('FIELD', 'int32[][]', 'nested_array', ast.Ordinal(None), 581 [('FIELD', 'int32[][]', 'nested_array', ast.Ordinal(None),
582 None)])])] 582 None)])])]
583 self.assertEquals(parser.Parse(source, "my_file.mojom"), expected) 583 self.assertEquals(parser.Parse(source, "my_file.mojom"), expected)
584 584
585 def testInvalidFixedArraySize(self): 585 def testInvalidFixedArraySize(self):
586 """Tests that invalid fixed array bounds are correctly detected.""" 586 """Tests that invalid fixed array bounds are correctly detected."""
(...skipping 30 matching lines...) Expand all
617 r"^my_file\.mojom:2: Error: Unexpected 'abcdefg':\n" 617 r"^my_file\.mojom:2: Error: Unexpected 'abcdefg':\n"
618 r" *int32\[abcdefg\] not_a_number;"): 618 r" *int32\[abcdefg\] not_a_number;"):
619 parser.Parse(source3, "my_file.mojom") 619 parser.Parse(source3, "my_file.mojom")
620 620
621 def testValidMethod(self): 621 def testValidMethod(self):
622 """Tests parsing method declarations.""" 622 """Tests parsing method declarations."""
623 623
624 source1 = "interface MyInterface { MyMethod(int32 a); };" 624 source1 = "interface MyInterface { MyMethod(int32 a); };"
625 expected1 = \ 625 expected1 = \
626 [('MODULE', 626 [('MODULE',
627 '', 627 None,
628 None, 628 None,
629 [('INTERFACE', 629 [('INTERFACE',
630 'MyInterface', 630 'MyInterface',
631 None, 631 None,
632 [('METHOD', 632 [('METHOD',
633 'MyMethod', 633 'MyMethod',
634 ast.ParameterList(ast.Parameter('int32', 'a', ast.Ordinal(None))), 634 ast.ParameterList(ast.Parameter('int32', 'a', ast.Ordinal(None))),
635 ast.Ordinal(None), 635 ast.Ordinal(None),
636 None)])])] 636 None)])])]
637 self.assertEquals(parser.Parse(source1, "my_file.mojom"), expected1) 637 self.assertEquals(parser.Parse(source1, "my_file.mojom"), expected1)
638 638
639 source2 = """\ 639 source2 = """\
640 interface MyInterface { 640 interface MyInterface {
641 MyMethod1@0(int32 a@0, int64 b@1); 641 MyMethod1@0(int32 a@0, int64 b@1);
642 MyMethod2@1() => (); 642 MyMethod2@1() => ();
643 }; 643 };
644 """ 644 """
645 expected2 = \ 645 expected2 = \
646 [('MODULE', 646 [('MODULE',
647 '', 647 None,
648 None, 648 None,
649 [('INTERFACE', 649 [('INTERFACE',
650 'MyInterface', 650 'MyInterface',
651 None, 651 None,
652 [('METHOD', 652 [('METHOD',
653 'MyMethod1', 653 'MyMethod1',
654 ast.ParameterList([ast.Parameter('int32', 'a', ast.Ordinal(0)), 654 ast.ParameterList([ast.Parameter('int32', 'a', ast.Ordinal(0)),
655 ast.Parameter('int64', 'b', ast.Ordinal(1))]), 655 ast.Parameter('int64', 'b', ast.Ordinal(1))]),
656 ast.Ordinal(0), 656 ast.Ordinal(0),
657 None), 657 None),
658 ('METHOD', 658 ('METHOD',
659 'MyMethod2', 659 'MyMethod2',
660 ast.ParameterList(), 660 ast.ParameterList(),
661 ast.Ordinal(1), 661 ast.Ordinal(1),
662 ast.ParameterList())])])] 662 ast.ParameterList())])])]
663 self.assertEquals(parser.Parse(source2, "my_file.mojom"), expected2) 663 self.assertEquals(parser.Parse(source2, "my_file.mojom"), expected2)
664 664
665 source3 = """\ 665 source3 = """\
666 interface MyInterface { 666 interface MyInterface {
667 MyMethod(string a) => (int32 a, bool b); 667 MyMethod(string a) => (int32 a, bool b);
668 }; 668 };
669 """ 669 """
670 expected3 = \ 670 expected3 = \
671 [('MODULE', 671 [('MODULE',
672 '', 672 None,
673 None, 673 None,
674 [('INTERFACE', 674 [('INTERFACE',
675 'MyInterface', 675 'MyInterface',
676 None, 676 None,
677 [('METHOD', 677 [('METHOD',
678 'MyMethod', 678 'MyMethod',
679 ast.ParameterList(ast.Parameter('string', 'a', 679 ast.ParameterList(ast.Parameter('string', 'a',
680 ast.Ordinal(None))), 680 ast.Ordinal(None))),
681 ast.Ordinal(None), 681 ast.Ordinal(None),
682 ast.ParameterList([ast.Parameter('int32', 'a', ast.Ordinal(None)), 682 ast.ParameterList([ast.Parameter('int32', 'a', ast.Ordinal(None)),
(...skipping 30 matching lines...) Expand all
713 713
714 def testValidAttributes(self): 714 def testValidAttributes(self):
715 """Tests parsing attributes (and attribute lists).""" 715 """Tests parsing attributes (and attribute lists)."""
716 716
717 # Note: We use structs because they have (optional) attribute lists. 717 # Note: We use structs because they have (optional) attribute lists.
718 718
719 # Empty attribute list. 719 # Empty attribute list.
720 source1 = "[] struct MyStruct {};" 720 source1 = "[] struct MyStruct {};"
721 expected1 = \ 721 expected1 = \
722 [('MODULE', 722 [('MODULE',
723 '', 723 None,
724 None, 724 None,
725 [('STRUCT', 725 [('STRUCT',
726 'MyStruct', 726 'MyStruct',
727 ast.AttributeList(), 727 ast.AttributeList(),
728 None)])] 728 None)])]
729 self.assertEquals(parser.Parse(source1, "my_file.mojom"), expected1) 729 self.assertEquals(parser.Parse(source1, "my_file.mojom"), expected1)
730 730
731 # One-element attribute list, with name value. 731 # One-element attribute list, with name value.
732 source2 = "[MyAttribute=MyName] struct MyStruct {};" 732 source2 = "[MyAttribute=MyName] struct MyStruct {};"
733 expected2 = \ 733 expected2 = \
734 [('MODULE', 734 [('MODULE',
735 '', 735 None,
736 None, 736 None,
737 [('STRUCT', 737 [('STRUCT',
738 'MyStruct', 738 'MyStruct',
739 ast.AttributeList(ast.Attribute("MyAttribute", "MyName")), 739 ast.AttributeList(ast.Attribute("MyAttribute", "MyName")),
740 None)])] 740 None)])]
741 self.assertEquals(parser.Parse(source2, "my_file.mojom"), expected2) 741 self.assertEquals(parser.Parse(source2, "my_file.mojom"), expected2)
742 742
743 # Two-element attribute list, with one string value and one integer value. 743 # Two-element attribute list, with one string value and one integer value.
744 source3 = "[MyAttribute1 = \"hello\", MyAttribute2 = 5] struct MyStruct {};" 744 source3 = "[MyAttribute1 = \"hello\", MyAttribute2 = 5] struct MyStruct {};"
745 expected3 = \ 745 expected3 = \
746 [('MODULE', 746 [('MODULE',
747 '', 747 None,
748 None, 748 None,
749 [('STRUCT', 749 [('STRUCT',
750 'MyStruct', 750 'MyStruct',
751 ast.AttributeList([ast.Attribute("MyAttribute1", "hello"), 751 ast.AttributeList([ast.Attribute("MyAttribute1", "hello"),
752 ast.Attribute("MyAttribute2", 5)]), 752 ast.Attribute("MyAttribute2", 5)]),
753 None)])] 753 None)])]
754 self.assertEquals(parser.Parse(source3, "my_file.mojom"), expected3) 754 self.assertEquals(parser.Parse(source3, "my_file.mojom"), expected3)
755 755
756 # TODO(vtl): Boolean attributes don't work yet. (In fact, we just |eval()| 756 # TODO(vtl): Boolean attributes don't work yet. (In fact, we just |eval()|
757 # literal (non-name) values, which is extremely dubious.) 757 # literal (non-name) values, which is extremely dubious.)
(...skipping 21 matching lines...) Expand all
779 # Missing key. 779 # Missing key.
780 source3 = "[=MyName] struct MyStruct {};" 780 source3 = "[=MyName] struct MyStruct {};"
781 with self.assertRaisesRegexp( 781 with self.assertRaisesRegexp(
782 parser.ParseError, 782 parser.ParseError,
783 r"^my_file\.mojom:1: Error: Unexpected '=':\n" 783 r"^my_file\.mojom:1: Error: Unexpected '=':\n"
784 r"\[=MyName\] struct MyStruct {};$"): 784 r"\[=MyName\] struct MyStruct {};$"):
785 parser.Parse(source3, "my_file.mojom") 785 parser.Parse(source3, "my_file.mojom")
786 786
787 if __name__ == "__main__": 787 if __name__ == "__main__":
788 unittest.main() 788 unittest.main()
OLDNEW
« no previous file with comments | « mojo/public/tools/bindings/pylib/mojom/parse/translate.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698