mojo/public/tools/mojom/mojom/parse/parser_unittest.py
def testValidDefaultValues(self):
    """Tests default values that are valid (to the parser)."""

    source = """\
        struct MyStruct {
          int16 a0 = 0;
          uint16 a1 = 0x0;
          uint16 a2 = 0x00;
          uint16 a3 = 0x01;
          uint16 a4 = 0xcd;
          int32 a5 = 12345;
          int64 a6 = -12345;
          int64 a7 = +12345;
          uint32 a8 = 0x12cd3;
          uint32 a9 = -0x12cD3;
          uint32 a10 = +0x12CD3;
          bool a11 = true;
          bool a12 = false;
          float a13 = 1.2345;
          float a14 = -1.2345;
          float a15 = +1.2345;
          float a16 = 123.;
          float a17 = .123;
          double a18 = 1.23E10;
          double a19 = 1.E-10;
          double a20 = .5E+10;
          double a21 = -1.23E10;
          double a22 = +.123E10;
        };
        """
    expected = ast.Mojom(None, ast.ImportList(), [
        ast.Struct(
            'MyStruct', None,
            ast.StructBody([
                ast.StructField('a0', None, None, 'int16', '0'),
                ast.StructField('a1', None, None, 'uint16', '0x0'),
                ast.StructField('a2', None, None, 'uint16', '0x00'),
                ast.StructField('a3', None, None, 'uint16', '0x01'),
                ast.StructField('a4', None, None, 'uint16', '0xcd'),
                ast.StructField('a5', None, None, 'int32', '12345'),
                ast.StructField('a6', None, None, 'int64', '-12345'),
                ast.StructField('a7', None, None, 'int64', '+12345'),
                ast.StructField('a8', None, None, 'uint32', '0x12cd3'),
                ast.StructField('a9', None, None, 'uint32', '-0x12cD3'),
                ast.StructField('a10', None, None, 'uint32', '+0x12CD3'),
                ast.StructField('a11', None, None, 'bool', 'true'),
                ast.StructField('a12', None, None, 'bool', 'false'),
                ast.StructField('a13', None, None, 'float', '1.2345'),
                ast.StructField('a14', None, None, 'float', '-1.2345'),
                ast.StructField('a15', None, None, 'float', '+1.2345'),
                ast.StructField('a16', None, None, 'float', '123.'),
                ast.StructField('a17', None, None, 'float', '.123'),
                ast.StructField('a18', None, None, 'double', '1.23E10'),
                ast.StructField('a19', None, None, 'double', '1.E-10'),
                ast.StructField('a20', None, None, 'double', '.5E+10'),
                ast.StructField('a21', None, None, 'double', '-1.23E10'),
                ast.StructField('a22', None, None, 'double', '+.123E10')
            ]))
    ])
    self.assertEquals(parser.Parse(source, "my_file.mojom"), expected)
Tests default values that are valid (to the parser).
Tests default values that are valid (to the parser).
Tests default values that are valid ( to the parser ) .
def testValidDefaultValues(self):
    source = """\
        struct MyStruct {
          int16 a0 = 0;
          uint16 a1 = 0x0;
          uint16 a2 = 0x00;
          uint16 a3 = 0x01;
          uint16 a4 = 0xcd;
          int32 a5 = 12345;
          int64 a6 = -12345;
          int64 a7 = +12345;
          uint32 a8 = 0x12cd3;
          uint32 a9 = -0x12cD3;
          uint32 a10 = +0x12CD3;
          bool a11 = true;
          bool a12 = false;
          float a13 = 1.2345;
          float a14 = -1.2345;
          float a15 = +1.2345;
          float a16 = 123.;
          float a17 = .123;
          double a18 = 1.23E10;
          double a19 = 1.E-10;
          double a20 = .5E+10;
          double a21 = -1.23E10;
          double a22 = +.123E10;
        };
        """
    expected = ast.Mojom(None, ast.ImportList(), [
        ast.Struct(
            'MyStruct', None,
            ast.StructBody([
                ast.StructField('a0', None, None, 'int16', '0'),
                ast.StructField('a1', None, None, 'uint16', '0x0'),
                ast.StructField('a2', None, None, 'uint16', '0x00'),
                ast.StructField('a3', None, None, 'uint16', '0x01'),
                ast.StructField('a4', None, None, 'uint16', '0xcd'),
                ast.StructField('a5', None, None, 'int32', '12345'),
                ast.StructField('a6', None, None, 'int64', '-12345'),
                ast.StructField('a7', None, None, 'int64', '+12345'),
                ast.StructField('a8', None, None, 'uint32', '0x12cd3'),
                ast.StructField('a9', None, None, 'uint32', '-0x12cD3'),
                ast.StructField('a10', None, None, 'uint32', '+0x12CD3'),
                ast.StructField('a11', None, None, 'bool', 'true'),
                ast.StructField('a12', None, None, 'bool', 'false'),
                ast.StructField('a13', None, None, 'float', '1.2345'),
                ast.StructField('a14', None, None, 'float', '-1.2345'),
                ast.StructField('a15', None, None, 'float', '+1.2345'),
                ast.StructField('a16', None, None, 'float', '123.'),
                ast.StructField('a17', None, None, 'float', '.123'),
                ast.StructField('a18', None, None, 'double', '1.23E10'),
                ast.StructField('a19', None, None, 'double', '1.E-10'),
                ast.StructField('a20', None, None, 'double', '.5E+10'),
                ast.StructField('a21', None, None, 'double', '-1.23E10'),
                ast.StructField('a22', None, None, 'double', '+.123E10')
            ]))
    ])
    self.assertEquals(parser.Parse(source, "my_file.mojom"), expected)
def testValidDefaultValues ( self ) : source = """\
        struct MyStruct {
          int16 a0 = 0;
          uint16 a1 = 0x0;
          uint16 a2 = 0x00;
          uint16 a3 = 0x01;
          uint16 a4 = 0xcd;
          int32 a5 = 12345;
          int64 a6 = -12345;
          int64 a7 = +12345;
          uint32 a8 = 0x12cd3;
          uint32 a9 = -0x12cD3;
          uint32 a10 = +0x12CD3;
          bool a11 = true;
          bool a12 = false;
          float a13 = 1.2345;
          float a14 = -1.2345;
          float a15 = +1.2345;
          float a16 = 123.;
          float a17 = .123;
          double a18 = 1.23E10;
          double a19 = 1.E-10;
          double a20 = .5E+10;
          double a21 = -1.23E10;
          double a22 = +.123E10;
        };
        """ expected = ast . Mojom ( None , ast . ImportList ( ) , [ ast . Struct ( 'MyStruct' , None , ast . StructBody ( [ ast . StructField ( 'a0' , None , None , 'int16' , '0' ) , ast . StructField ( 'a1' , None , None , 'uint16' , '0x0' ) , ast . StructField ( 'a2' , None , None , 'uint16' , '0x00' ) , ast . StructField ( 'a3' , None , None , 'uint16' , '0x01' ) , ast . StructField ( 'a4' , None , None , 'uint16' , '0xcd' ) , ast . StructField ( 'a5' , None , None , 'int32' , '12345' ) , ast . StructField ( 'a6' , None , None , 'int64' , '-12345' ) , ast . StructField ( 'a7' , None , None , 'int64' , '+12345' ) , ast . StructField ( 'a8' , None , None , 'uint32' , '0x12cd3' ) , ast . StructField ( 'a9' , None , None , 'uint32' , '-0x12cD3' ) , ast . StructField ( 'a10' , None , None , 'uint32' , '+0x12CD3' ) , ast . StructField ( 'a11' , None , None , 'bool' , 'true' ) , ast . StructField ( 'a12' , None , None , 'bool' , 'false' ) , ast . StructField ( 'a13' , None , None , 'float' , '1.2345' ) , ast . StructField ( 'a14' , None , None , 'float' , '-1.2345' ) , ast . StructField ( 'a15' , None , None , 'float' , '+1.2345' ) , ast . StructField ( 'a16' , None , None , 'float' , '123.' ) , ast . StructField ( 'a17' , None , None , 'float' , '.123' ) , ast . StructField ( 'a18' , None , None , 'double' , '1.23E10' ) , ast . StructField ( 'a19' , None , None , 'double' , '1.E-10' ) , ast . StructField ( 'a20' , None , None , 'double' , '.5E+10' ) , ast . StructField ( 'a21' , None , None , 'double' , '-1.23E10' ) , ast . StructField ( 'a22' , None , None , 'double' , '+.123E10' ) ] ) ) ] ) self . assertEquals ( parser . Parse ( source , "my_file.mojom" ) , expected )
Tests default values that are valid (to the parser).
Tests default values that are valid ( to the parser ) .
"""Tests default values that are valid (to the parser)."""
self