mojo/public/tools/mojom/mojom/generate/translate_unittest.py
def testTranslateSimpleUnions(self):
    """Makes sure that a simple union is translated correctly."""
    tree = ast.Mojom(None, ast.ImportList(), [
        ast.Union(
            "SomeUnion", None,
            ast.UnionBody([
                ast.UnionField("a", None, None, "int32"),
                ast.UnionField("b", None, None, "string")
            ]))
    ])

    translation = translate.OrderedModule(tree, "mojom_tree", [])
    self.assertEqual(1, len(translation.unions))

    union = translation.unions[0]
    self.assertTrue(isinstance(union, mojom.Union))
    self.assertEqual("SomeUnion", union.mojom_name)
    self.assertEqual(2, len(union.fields))
    self.assertEqual("a", union.fields[0].mojom_name)
    self.assertEqual(mojom.INT32.spec, union.fields[0].kind.spec)
    self.assertEqual("b", union.fields[1].mojom_name)
    self.assertEqual(mojom.STRING.spec, union.fields[1].kind.spec)
Makes sure that a simple union is translated correctly.
Makes sure that a simple union is translated correctly.
Makes sure that a simple union is translated correctly .
def testTranslateSimpleUnions(self):
    tree = ast.Mojom(None, ast.ImportList(), [
        ast.Union(
            "SomeUnion", None,
            ast.UnionBody([
                ast.UnionField("a", None, None, "int32"),
                ast.UnionField("b", None, None, "string")
            ]))
    ])
    translation = translate.OrderedModule(tree, "mojom_tree", [])
    self.assertEqual(1, len(translation.unions))
    union = translation.unions[0]
    self.assertTrue(isinstance(union, mojom.Union))
    self.assertEqual("SomeUnion", union.mojom_name)
    self.assertEqual(2, len(union.fields))
    self.assertEqual("a", union.fields[0].mojom_name)
    self.assertEqual(mojom.INT32.spec, union.fields[0].kind.spec)
    self.assertEqual("b", union.fields[1].mojom_name)
    self.assertEqual(mojom.STRING.spec, union.fields[1].kind.spec)
def testTranslateSimpleUnions ( self ) : tree = ast . Mojom ( None , ast . ImportList ( ) , [ ast . Union ( "SomeUnion" , None , ast . UnionBody ( [ ast . UnionField ( "a" , None , None , "int32" ) , ast . UnionField ( "b" , None , None , "string" ) ] ) ) ] ) translation = translate . OrderedModule ( tree , "mojom_tree" , [ ] ) self . assertEqual ( 1 , len ( translation . unions ) ) union = translation . unions [ 0 ] self . assertTrue ( isinstance ( union , mojom . Union ) ) self . assertEqual ( "SomeUnion" , union . mojom_name ) self . assertEqual ( 2 , len ( union . fields ) ) self . assertEqual ( "a" , union . fields [ 0 ] . mojom_name ) self . assertEqual ( mojom . INT32 . spec , union . fields [ 0 ] . kind . spec ) self . assertEqual ( "b" , union . fields [ 1 ] . mojom_name ) self . assertEqual ( mojom . STRING . spec , union . fields [ 1 ] . kind . spec )
Makes sure that a simple union is translated correctly.
Makes sure that a simple union is translated correctly .
"""Makes sure that a simple union is translated correctly."""
self