Skip to content

Commit

Permalink
#2559. Add tests for enum with empty list of values (#3066)
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrekhov authored Feb 5, 2025
1 parent d923012 commit dd7fa9c
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 4 deletions.
16 changes: 12 additions & 4 deletions Language/Enums/syntax_t02.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,24 @@
/// enumType:
/// metadata enum id ‘{’ id [‘, ’ id]* [‘, ’] ‘}’
/// ;
///
/// @description Checks that it is compile-time error if enum does not declare
/// any member
/// any member.
/// @author [email protected]
enum E1 {}
// ^^
// [analyzer] unspecified
// [cfe] unspecified

enum E {}
// ^
enum E2 {
// ^^
// [analyzer] unspecified
// [cfe] unspecified
;
}

main() {
E e;
print(E1);
print(E2);
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
/// @description Checks that it is a syntax error if an enum augmentation
/// contains no any values.
/// @author [email protected]
/// @issue 56883
// SharedOptions=--enable-experiment=macros

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// @assertion New enum values may be defined in an augmenting enum, and they
/// will be appended to the current values of the declaration in augmentation
/// application order.
///
/// @description Checks that it is a syntax error if an enum augmentation
/// contains an empty list of values.
/// @author [email protected]
/// @issue 56883
// SharedOptions=--enable-experiment=macros

enum E1 {
e0;
}

augment enum E1 {
;
//^
// [analyzer] unspecified
// [cfe] unspecified
}

enum E2 {
e0;
}

augment enum E2 {
;
//^
// [analyzer] unspecified
// [cfe] unspecified
void foo() {}
}

main() {
print(E1);
print(E2);
}

0 comments on commit dd7fa9c

Please sign in to comment.