1/* Copyright (c) 2013 The Chromium Authors. All rights reserved.
2   Use of this source code is governed by a BSD-style license that can be
3  found in the LICENSE file. */
4
5/* Test Enum productions
6
7Run with --test to generate an AST and verify that all comments accurately
8reflect the state of the Nodes.
9
10BUILD Type(Name)
11This comment signals that a node of type <Type> is created with the
12name <Name>.
13
14ERROR Error String
15This comment signals that a error of <Error String> is generated.  The error
16is not assigned to a node, but are expected in order.
17
18PROP Key=Value
19This comment signals that a property has been set on the Node such that
20<Key> = <Value>.
21
22TREE
23Type(Name)
24  Type(Name)
25  Type(Name)
26    Type(Name)
27    ...
28This comment signals that a tree of nodes matching the BUILD comment
29symatics should exist.  This is an exact match.
30*/
31
32/* TREE
33 *Enum(MealType1)
34 *  EnumItem(rice)
35 *  EnumItem(noodles)
36 *  EnumItem(other)
37*/
38enum MealType1 {
39  /* BUILD EnumItem (rice) */
40  rice,
41  /* BUILD EnumItem (noodles) */
42  noodles,
43  /* BUILD EnumItem(other) */
44  other
45};
46
47/* BUILD Error(Enum missing name.) */
48/* ERROR Enum missing name. */
49enum {
50  rice,
51  noodles,
52  other,
53};
54
55/* TREE
56 *Enum(MealType2)
57 *  EnumItem(rice)
58 *  EnumItem(noodles)
59 *  EnumItem(other)
60*/
61enum MealType2 {
62  /* BUILD EnumItem(rice) */
63  rice,
64  /* BUILD EnumItem(noodles) */
65  noodles = 1,
66  /* BUILD EnumItem(other) */
67  other
68};
69
70/* BUILD Error(Unexpected identifier "noodles" after identifier "rice".) */
71/* ERROR Unexpected identifier "noodles" after identifier "rice". */
72enum MissingComma {
73  rice
74  noodles,
75  other
76};
77
78/* BUILD Error(Trailing comma in block.) */
79/* ERROR Trailing comma in block. */
80enum TrailingComma {
81  rice,
82  noodles,
83  other,
84};
85
86/* BUILD Error(Unexpected "," after ",".) */
87/* ERROR Unexpected "," after ",". */
88enum ExtraComma {
89  rice,
90  noodles,
91  ,other,
92};
93
94/* BUILD Error(Unexpected keyword "interface" after "{".) */
95/* ERROR Unexpected keyword "interface" after "{". */
96enum ExtraComma {
97  interface,
98  noodles,
99  ,other,
100};
101
102/* BUILD Error(Unexpected string "somename" after "{".) */
103/* ERROR Unexpected string "somename" after "{". */
104enum ExtraComma {
105  "somename",
106  noodles,
107  other,
108};
109
110/* BUILD Enum(MealType3) */
111enum MealType3 {
112  /* BUILD EnumItem(rice) */
113  rice = 1 << 1,
114  /* BUILD EnumItem(noodles) */
115  noodles = 0x1 << 0x2,
116  /* BUILD EnumItem(other) */
117  other = 012 << 777
118};
119
120/* BUILD Enum(MealType4) */
121enum MealType4 {
122  /* BUILD EnumItem(rice) */
123  rice = true,
124  /* BUILD EnumItem(noodles) */
125  noodles = false
126};
127