Debian Codegraph @

gcc/testsuite/gdc.test/runnable/xtestenum.d

raw
1 /*
2 PERMUTE_ARGS:
3 RUN_OUTPUT:
4 ---
5 foo
6 Success
7 ---
8 */
9
10 extern(C) int printf(const char*, ...);
11
12 /***********************************/
13
14 enum : float
15 {
16 E1a,
17 E1b,
18 E1c
19 }
20
21 void test1()
22 {
23 assert(E1a == 0.0f);
24 assert(E1b == 1.0f);
25 assert(E1c == 2.0f);
26 }
27
28 /***********************************/
29
30 enum : string
31 {
32 E2a = "foo",
33 E2b = "bar",
34 E2c = "abc"
35 }
36
37 void test2()
38 {
39 assert(E2a == "foo");
40 assert(E2b == "bar");
41 assert(E2c == "abc");
42 }
43
44 /***********************************/
45
46 enum E3 : string
47 {
48 E3a = "foo",
49 E3b = "bar",
50 E3c = "abc"
51 }
52
53 void test3()
54 {
55 printf("%.*s\n", cast(int)E3.E3a.length, E3.E3a.ptr);
56
57 assert(E3.E3a == "foo");
58 assert(E3.E3b == "bar");
59 assert(E3.E3c == "abc");
60 }
61
62 /***********************************/
63
64 enum E4 : char
65 {
66 Tvoid = 'v',
67 Tbool = 'b',
68 }
69
70 void test4()
71 {
72 E4 m;
73 }
74
75 /***********************************/
76
77 enum E5 : byte
78 {
79 e1,
80 e2
81 }
82
83 void test5()
84 {
85 E5 m;
86 }
87
88 /***********************************/
89
90 enum : ubyte
91 {
92 REend,
93 REchar,
94 REichar,
95 REdchar,
96 REidchar,
97 REanychar,
98 }
99
100 void foo6(ubyte) { }
101 void foo6(int) { assert(0); }
102
103 void test6()
104 {
105 foo6(REchar);
106 }
107
108 /***********************************/
109
110 enum
111 {
112 foo7 = 1,
113 long bar7 = 2,
114 abc7,
115 }
116
117 enum x7 = 3;
118
119 void test7()
120 {
121 assert(x7 == 3);
122 assert(is(typeof(foo7) == int));
123 assert(is(typeof(bar7) == long));
124 assert(is(typeof(abc7) == long));
125 assert(abc7 == 3L);
126 }
127
128 /***********************************/
129
130 enum E8 : real { a, b }
131
132 /***********************************/
133
134 struct S7379
135 {
136
137 enum ENUM
138 {
139 M1,
140 M2,
141 M3
142 }
143 alias ENUM this;
144 }
145
146 class C7379
147 {
148 this(S7379 test)
149 {
150 }
151
152 this(string test)
153 {
154 this(S7379());
155 }
156 }
157
158 /***********************************/
159 // https://issues.dlang.org/show_bug.cgi?id=23515
160
161 enum Easing : void function()
162 {
163 identity1 = (){},
164 }
165
166 void test23515()
167 {
168 Easing.identity1();
169 }
170
171 /***********************************/
172
173 int main()
174 {
175 test1();
176 test2();
177 test3();
178 test4();
179 test5();
180 test6();
181 test7();
182 test23515();
183
184 printf("Success\n");
185 return 0;
186 }