mojo/public/tools/mojom/mojom/parse/parser_unittest.py
def testInvalidOrdinals(self):
    """Tests that (lexically) invalid ordinals are correctly detected."""

    source1 = """\
        module my_module;

        struct MyStruct {
          int32 a_missing@;
        };
        """
    with self.assertRaisesRegexp(
        lexer.LexError, r"^my_file\.mojom:4: Error: Missing ordinal value$"):
      parser.Parse(source1, "my_file.mojom")

    source2 = """\
        module my_module;

        struct MyStruct {
          int32 a_octal@01;
        };
        """
    with self.assertRaisesRegexp(
        lexer.LexError, r"^my_file\.mojom:4: Error: "
        r"Octal and hexadecimal ordinal values not allowed$"):
      parser.Parse(source2, "my_file.mojom")

    source3 = """\
        module my_module; struct MyStruct { int32 a_invalid_octal@08; };
        """
    with self.assertRaisesRegexp(
        lexer.LexError, r"^my_file\.mojom:1: Error: "
        r"Octal and hexadecimal ordinal values not allowed$"):
      parser.Parse(source3, "my_file.mojom")

    source4 = "module my_module; struct MyStruct { int32 a_hex@0x1aB9; };"
    with self.assertRaisesRegexp(
        lexer.LexError, r"^my_file\.mojom:1: Error: "
        r"Octal and hexadecimal ordinal values not allowed$"):
      parser.Parse(source4, "my_file.mojom")

    source5 = "module my_module; struct MyStruct { int32 a_hex@0X0; };"
    with self.assertRaisesRegexp(
        lexer.LexError, r"^my_file\.mojom:1: Error: "
        r"Octal and hexadecimal ordinal values not allowed$"):
      parser.Parse(source5, "my_file.mojom")

    source6 = """\
        struct MyStruct {
          int32 a_too_big@999999999999;
        };
        """
    with self.assertRaisesRegexp(
        parser.ParseError, r"^my_file\.mojom:2: Error: "
        r"Ordinal value 999999999999 too large:\n"
        r" *int32 a_too_big@999999999999;$"):
      parser.Parse(source6, "my_file.mojom")
Tests that (lexically) invalid ordinals are correctly detected.
Tests that (lexically) invalid ordinals are correctly detected.
Tests that ( lexically ) invalid ordinals are correctly detected .
def testInvalidOrdinals(self):
    source1 = """\
        module my_module;
        struct MyStruct {
          int32 a_missing@;
        };
        """
    with self.assertRaisesRegexp(
        lexer.LexError, r"^my_file\.mojom:4: Error: Missing ordinal value$"):
      parser.Parse(source1, "my_file.mojom")
    source2 = """\
        module my_module;
        struct MyStruct {
          int32 a_octal@01;
        };
        """
    with self.assertRaisesRegexp(
        lexer.LexError, r"^my_file\.mojom:4: Error: "
        r"Octal and hexadecimal ordinal values not allowed$"):
      parser.Parse(source2, "my_file.mojom")
    source3 = """\
        module my_module; struct MyStruct { int32 a_invalid_octal@08; };
        """
    with self.assertRaisesRegexp(
        lexer.LexError, r"^my_file\.mojom:1: Error: "
        r"Octal and hexadecimal ordinal values not allowed$"):
      parser.Parse(source3, "my_file.mojom")
    source4 = "module my_module; struct MyStruct { int32 a_hex@0x1aB9; };"
    with self.assertRaisesRegexp(
        lexer.LexError, r"^my_file\.mojom:1: Error: "
        r"Octal and hexadecimal ordinal values not allowed$"):
      parser.Parse(source4, "my_file.mojom")
    source5 = "module my_module; struct MyStruct { int32 a_hex@0X0; };"
    with self.assertRaisesRegexp(
        lexer.LexError, r"^my_file\.mojom:1: Error: "
        r"Octal and hexadecimal ordinal values not allowed$"):
      parser.Parse(source5, "my_file.mojom")
    source6 = """\
        struct MyStruct {
          int32 a_too_big@999999999999;
        };
        """
    with self.assertRaisesRegexp(
        parser.ParseError, r"^my_file\.mojom:2: Error: "
        r"Ordinal value 999999999999 too large:\n"
        r" *int32 a_too_big@999999999999;$"):
      parser.Parse(source6, "my_file.mojom")
def testInvalidOrdinals ( self ) : source1 = """\
        module my_module;

        struct MyStruct {
          int32 a_missing@;
        };
        """ with self . assertRaisesRegexp ( lexer . LexError , r"^my_file\.mojom:4: Error: Missing ordinal value$" ) : parser . Parse ( source1 , "my_file.mojom" ) source2 = """\
        module my_module;

        struct MyStruct {
          int32 a_octal@01;
        };
        """ with self . assertRaisesRegexp ( lexer . LexError , r"^my_file\.mojom:4: Error: " r"Octal and hexadecimal ordinal values not allowed$" ) : parser . Parse ( source2 , "my_file.mojom" ) source3 = """\
        module my_module; struct MyStruct { int32 a_invalid_octal@08; };
        """ with self . assertRaisesRegexp ( lexer . LexError , r"^my_file\.mojom:1: Error: " r"Octal and hexadecimal ordinal values not allowed$" ) : parser . Parse ( source3 , "my_file.mojom" ) source4 = "module my_module; struct MyStruct { int32 a_hex@0x1aB9; };" with self . assertRaisesRegexp ( lexer . LexError , r"^my_file\.mojom:1: Error: " r"Octal and hexadecimal ordinal values not allowed$" ) : parser . Parse ( source4 , "my_file.mojom" ) source5 = "module my_module; struct MyStruct { int32 a_hex@0X0; };" with self . assertRaisesRegexp ( lexer . LexError , r"^my_file\.mojom:1: Error: " r"Octal and hexadecimal ordinal values not allowed$" ) : parser . Parse ( source5 , "my_file.mojom" ) source6 = """\
        struct MyStruct {
          int32 a_too_big@999999999999;
        };
        """ with self . assertRaisesRegexp ( parser . ParseError , r"^my_file\.mojom:2: Error: " r"Ordinal value 999999999999 too large:\n" r" *int32 a_too_big@999999999999;$" ) : parser . Parse ( source6 , "my_file.mojom" )
Tests that (lexically) invalid ordinals are correctly detected.
Tests that ( lexically ) invalid ordinals are correctly detected .
"""Tests that (lexically) invalid ordinals are correctly detected."""
self