mojo/public/tools/mojom/mojom/parse/parser_unittest.py
def testInvalidFixedArraySize(self):
    """Tests that invalid fixed array bounds are correctly detected."""

    source1 = """\
        struct MyStruct {
          array<int32, 0> zero_size_array;
        };
        """
    with self.assertRaisesRegexp(
        parser.ParseError,
        r"^my_file\.mojom:2: Error: Fixed array size 0 invalid:\n"
        r" *array<int32, 0> zero_size_array;$"):
      parser.Parse(source1, "my_file.mojom")

    source2 = """\
        struct MyStruct {
          array<int32, 999999999999> too_big_array;
        };
        """
    with self.assertRaisesRegexp(
        parser.ParseError,
        r"^my_file\.mojom:2: Error: Fixed array size 999999999999 invalid:\n"
        r" *array<int32, 999999999999> too_big_array;$"):
      parser.Parse(source2, "my_file.mojom")

    source3 = """\
        struct MyStruct {
          array<int32, abcdefg> not_a_number;
        };
        """
    with self.assertRaisesRegexp(
        parser.ParseError, r"^my_file\.mojom:2: Error: Unexpected 'abcdefg':\n"
        r" *array<int32, abcdefg> not_a_number;"):
      parser.Parse(source3, "my_file.mojom")
Tests that invalid fixed array bounds are correctly detected.
Tests that invalid fixed array bounds are correctly detected.
Tests that invalid fixed array bounds are correctly detected .
def testInvalidFixedArraySize(self):
    source1 = """\
        struct MyStruct {
          array<int32, 0> zero_size_array;
        };
        """
    with self.assertRaisesRegexp(
        parser.ParseError,
        r"^my_file\.mojom:2: Error: Fixed array size 0 invalid:\n"
        r" *array<int32, 0> zero_size_array;$"):
      parser.Parse(source1, "my_file.mojom")
    source2 = """\
        struct MyStruct {
          array<int32, 999999999999> too_big_array;
        };
        """
    with self.assertRaisesRegexp(
        parser.ParseError,
        r"^my_file\.mojom:2: Error: Fixed array size 999999999999 invalid:\n"
        r" *array<int32, 999999999999> too_big_array;$"):
      parser.Parse(source2, "my_file.mojom")
    source3 = """\
        struct MyStruct {
          array<int32, abcdefg> not_a_number;
        };
        """
    with self.assertRaisesRegexp(
        parser.ParseError, r"^my_file\.mojom:2: Error: Unexpected 'abcdefg':\n"
        r" *array<int32, abcdefg> not_a_number;"):
      parser.Parse(source3, "my_file.mojom")
def testInvalidFixedArraySize ( self ) : source1 = """\
        struct MyStruct {
          array<int32, 0> zero_size_array;
        };
        """ with self . assertRaisesRegexp ( parser . ParseError , r"^my_file\.mojom:2: Error: Fixed array size 0 invalid:\n" r" *array<int32, 0> zero_size_array;$" ) : parser . Parse ( source1 , "my_file.mojom" ) source2 = """\
        struct MyStruct {
          array<int32, 999999999999> too_big_array;
        };
        """ with self . assertRaisesRegexp ( parser . ParseError , r"^my_file\.mojom:2: Error: Fixed array size 999999999999 invalid:\n" r" *array<int32, 999999999999> too_big_array;$" ) : parser . Parse ( source2 , "my_file.mojom" ) source3 = """\
        struct MyStruct {
          array<int32, abcdefg> not_a_number;
        };
        """ with self . assertRaisesRegexp ( parser . ParseError , r"^my_file\.mojom:2: Error: Unexpected 'abcdefg':\n" r" *array<int32, abcdefg> not_a_number;" ) : parser . Parse ( source3 , "my_file.mojom" )
Tests that invalid fixed array bounds are correctly detected.
Tests that invalid fixed array bounds are correctly detected .
"""Tests that invalid fixed array bounds are correctly detected."""
self