File: xtestenum.d

package info (click to toggle)
gcc-arm-none-eabi 15%3A14.2.rel1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,099,328 kB
  • sloc: cpp: 3,627,108; ansic: 2,571,498; ada: 834,230; f90: 235,082; makefile: 79,231; asm: 74,984; xml: 51,692; exp: 39,736; sh: 33,298; objc: 15,629; python: 15,069; fortran: 14,429; pascal: 7,003; awk: 5,070; perl: 3,106; ml: 285; lisp: 253; lex: 204; haskell: 135
file content (186 lines) | stat: -rw-r--r-- 2,203 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
/*
PERMUTE_ARGS:
RUN_OUTPUT:
---
foo
Success
---
*/

extern(C) int printf(const char*, ...);

/***********************************/

enum : float
{
    E1a,
    E1b,
    E1c
}

void test1()
{
    assert(E1a == 0.0f);
    assert(E1b == 1.0f);
    assert(E1c == 2.0f);
}

/***********************************/

enum : string
{
    E2a = "foo",
    E2b = "bar",
    E2c = "abc"
}

void test2()
{
    assert(E2a == "foo");
    assert(E2b == "bar");
    assert(E2c == "abc");
}

/***********************************/

enum E3 : string
{
    E3a = "foo",
    E3b = "bar",
    E3c = "abc"
}

void test3()
{
    printf("%.*s\n", cast(int)E3.E3a.length, E3.E3a.ptr);

    assert(E3.E3a == "foo");
    assert(E3.E3b == "bar");
    assert(E3.E3c == "abc");
}

/***********************************/

enum E4 : char
{
    Tvoid     = 'v',
    Tbool     = 'b',
}

void test4()
{
    E4 m;
}

/***********************************/

enum E5 : byte
{
    e1,
    e2
}

void test5()
{
    E5 m;
}

/***********************************/

enum : ubyte
{
    REend,
    REchar,
    REichar,
    REdchar,
    REidchar,
    REanychar,
}

void foo6(ubyte) { }
void foo6(int) { assert(0); }

void test6()
{
    foo6(REchar);
}

/***********************************/

enum
{
        foo7 = 1,
        long bar7 = 2,
        abc7,
}

enum x7 = 3;

void test7()
{
    assert(x7 == 3);
    assert(is(typeof(foo7) == int));
    assert(is(typeof(bar7) == long));
    assert(is(typeof(abc7) == long));
    assert(abc7 == 3L);
}

/***********************************/

enum E8 : real { a, b }

/***********************************/

struct S7379
{

    enum ENUM
    {
        M1,
        M2,
        M3
    }
    alias ENUM this;
}

class C7379
{
    this(S7379 test)
    {
    }

    this(string test)
    {
        this(S7379());
    }
}

/***********************************/
// https://issues.dlang.org/show_bug.cgi?id=23515

enum Easing : void function()
{
    identity1 = (){},
}

void test23515()
{
    Easing.identity1();
}

/***********************************/

int main()
{
    test1();
    test2();
    test3();
    test4();
    test5();
    test6();
    test7();
    test23515();

    printf("Success\n");
    return 0;
}