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 2fa172fb60c8248ae26d1ac6b0ca27b5ec9583f3..abfb8779547ea87d4e653a1bdff507a419e06c57 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 |
@@ -672,16 +672,47 @@ class ParserTest(unittest.TestCase): |
r" *int32\[999999999999\] too_big_array;$"): |
parser.Parse(source2, "my_file.mojom") |
- source3 = """\ |
- struct MyStruct { |
- int32[abcdefg] not_a_number; |
- }; |
- """ |
- with self.assertRaisesRegexp( |
- parser.ParseError, |
- r"^my_file\.mojom:2: Error: Unexpected 'abcdefg':\n" |
- r" *int32\[abcdefg\] not_a_number;"): |
- parser.Parse(source3, "my_file.mojom") |
+ def testValidAssociativeArrays(self): |
+ """Tests that we can parse valid associative array structures.""" |
+ |
+ source1 = "struct MyStruct { uint8[string] data; };" |
+ expected1 = ast.Mojom( |
+ None, |
+ ast.ImportList(), |
+ [ast.Struct( |
+ 'MyStruct', |
+ None, |
+ ast.StructBody( |
+ [ast.StructField('data', None, 'uint8{string}', None)]))]) |
+ self.assertEquals(parser.Parse(source1, "my_file.mojom"), expected1) |
+ |
+ source2 = "interface MyInterface { MyMethod(uint8[string] a); };" |
+ expected2 = ast.Mojom( |
+ None, |
+ ast.ImportList(), |
+ [ast.Interface( |
+ 'MyInterface', |
+ None, |
+ ast.InterfaceBody( |
+ ast.Method( |
+ 'MyMethod', |
+ None, |
+ ast.ParameterList( |
+ ast.Parameter('a', None, 'uint8{string}')), |
+ None)))]) |
+ self.assertEquals(parser.Parse(source2, "my_file.mojom"), expected2) |
+ |
+ source3 = "struct MyStruct { uint8[string][] data; };" |
+ expected3 = ast.Mojom( |
+ None, |
+ ast.ImportList(), |
+ [ast.Struct( |
+ 'MyStruct', |
+ None, |
+ ast.StructBody( |
+ [ast.StructField('data', None, 'uint8{string}[]', None)]))]) |
+ self.assertEquals(parser.Parse(source3, "my_file.mojom"), expected3) |
+ |
def testValidMethod(self): |
"""Tests parsing method declarations.""" |