@@ -812,11 +812,6 @@ test "signed integer as enum tag" {
812
812
try expect (@intFromEnum (SignedEnum .A2 ) == 1 );
813
813
}
814
814
815
- test "int to enum with signed tag type" {
816
- const E = enum (i32 ) { a , b , c };
817
- try expect (@intToEnum (E , 0 ) == .a );
818
- }
819
-
820
815
test "enum with one member and custom tag type" {
821
816
const E = enum (u2 ) {
822
817
One ,
@@ -1202,3 +1197,18 @@ test "enum tag from a local variable" {
1202
1197
const i = @enumFromInt (S .Int (u32 ), 0 );
1203
1198
try std .testing .expect (@intFromEnum (i ) == 0 );
1204
1199
}
1200
+
1201
+ test "auto-numbered enum with signed tag type" {
1202
+ const E = enum (i32 ) { a , b };
1203
+
1204
+ try std .testing .expectEqual (@as (i32 , 0 ), @intFromEnum (E .a ));
1205
+ try std .testing .expectEqual (@as (i32 , 1 ), @intFromEnum (E .b ));
1206
+ try std .testing .expectEqual (E .a , @enumFromInt (E , 0 ));
1207
+ try std .testing .expectEqual (E .b , @enumFromInt (E , 1 ));
1208
+ try std .testing .expectEqual (E .a , @enumFromInt (E , @as (i32 , 0 )));
1209
+ try std .testing .expectEqual (E .b , @enumFromInt (E , @as (i32 , 1 )));
1210
+ try std .testing .expectEqual (E .a , @enumFromInt (E , @as (u32 , 0 )));
1211
+ try std .testing .expectEqual (E .b , @enumFromInt (E , @as (u32 , 1 )));
1212
+ try std .testing .expectEqualStrings ("a" , @tagName (E .a ));
1213
+ try std .testing .expectEqualStrings ("b" , @tagName (E .b ));
1214
+ }
0 commit comments