test31
auto test31 =
q{--- test31
// test enums
//enum i32 e2; // manifest constant, invalid, need initializer
enum e3 = 3; // manifest constant
enum i32 e4 = 4; // manifest constant
enum { e5 = 5 } // anon type
enum : i32 { e6 = 6 } // anon type
enum e1; // type
enum e7 : i32 { e7 = 7 } // type
enum e8 : i32; // type, body omitted
enum e9 { e9 = 9 } // type
@extern(module, "host")
void print_num(i64 val);
e9 ret_enum(){ return e9.e9; }
void accept_enum(e9 e){print_num(e);}
void run() {
print_num(e3);
print_num(e4);
print_num(e5);
print_num(e6);
// enum implicitly casts to base
print_num(e7.e7);
print_num(e9.e9);
accept_enum(e9.e9);
// explicit cast of int to enum
accept_enum(cast(e9)42);
// makes sure that e9.e9 is of type e9 and that e9 is implicitly castable to i32
print_num(ret_enum());
}
};
tests passing
functionsvariables