#1258. Enhanced Enums semantics tests added
diff --git a/LanguageFeatures/Enhanced-Enum/semantics_A03_t01.dart b/LanguageFeatures/Enhanced-Enum/semantics_A03_t01.dart
index 4b123b1..6544172 100644
--- a/LanguageFeatures/Enhanced-Enum/semantics_A03_t01.dart
+++ b/LanguageFeatures/Enhanced-Enum/semantics_A03_t01.dart
@@ -44,9 +44,9 @@
main() {
Expect.equals(1, E.e1.mixedInMethod1());
- Expect.equals(2, E.e1.mixedInMethod2());
+ Expect.equals(1, E.e1.mixedInMethod2());
Expect.equals(1, E.e2.mixedInMethod1());
- Expect.equals(3, E.e2.mixedInMethod2());
+ Expect.equals(2, E.e2.mixedInMethod2());
Expect.equals(1, E.e3.mixedInMethod1());
- Expect.equals(4, E.e3.mixedInMethod2());
+ Expect.equals(3, E.e3.mixedInMethod2());
}
diff --git a/LanguageFeatures/Enhanced-Enum/semantics_A03_t02.dart b/LanguageFeatures/Enhanced-Enum/semantics_A03_t02.dart
index 43665e5..e14492c 100644
--- a/LanguageFeatures/Enhanced-Enum/semantics_A03_t02.dart
+++ b/LanguageFeatures/Enhanced-Enum/semantics_A03_t02.dart
@@ -53,9 +53,9 @@
main() {
Expect.equals(1, E.e1.val1);
- Expect.equals(2, E.e1.val2);
+ Expect.equals(1, E.e1.val2);
Expect.equals(2, E.e2.val1);
- Expect.equals(4, E.e2.val2);
+ Expect.equals(3, E.e2.val2);
Expect.equals(3, E.e3.val1);
- Expect.equals(6, E.e3.val2);
+ Expect.equals(5, E.e3.val2);
}
diff --git a/LanguageFeatures/Enhanced-Enum/semantics_A05_t02.dart b/LanguageFeatures/Enhanced-Enum/semantics_A05_t02.dart
new file mode 100644
index 0000000..8831751
--- /dev/null
+++ b/LanguageFeatures/Enhanced-Enum/semantics_A05_t02.dart
@@ -0,0 +1,49 @@
+// Copyright (c) 2022, 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 The semantics of such an enum declaration, E, is defined as
+/// introducing a (semantic) class, C, just like a similar class declaration.
+/// ...
+/// Default constructor: If no generative constructors were declared, and no
+/// unnamed factory constructor was added, a default generative constructor is
+/// added:
+///
+/// const Name();
+/// (This differs from the default constructor of a normal class declaration by
+/// being constant.)
+///
+/// @description Check that if a generative constructors was declared then a
+/// default generative constructor is not added
+/// @author sgrekhov@unipro.ru
+
+// SharedOptions=--enable-experiment=enhanced-enums
+
+enum E1 {
+ e1,
+//^^
+// [analyzer] unspecified
+// [cfe] unspecified
+ e2;
+//^^
+// [analyzer] unspecified
+// [cfe] unspecified
+
+ E1.n(int i) {}
+}
+
+enum E2 {
+ e1(),
+//^^
+// [analyzer] unspecified
+// [cfe] unspecified
+ e2.n(1),
+ e3.n(1);
+
+ E2.n(int i) {}
+}
+
+main() {
+ print(E1.e1);
+ print(E2.e1);
+}
diff --git a/LanguageFeatures/Enhanced-Enum/semantics_A05_t03.dart b/LanguageFeatures/Enhanced-Enum/semantics_A05_t03.dart
new file mode 100644
index 0000000..7bcfb22
--- /dev/null
+++ b/LanguageFeatures/Enhanced-Enum/semantics_A05_t03.dart
@@ -0,0 +1,51 @@
+// Copyright (c) 2022, 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 The semantics of such an enum declaration, E, is defined as
+/// introducing a (semantic) class, C, just like a similar class declaration.
+/// ...
+/// Default constructor: If no generative constructors were declared, and no
+/// unnamed factory constructor was added, a default generative constructor is
+/// added:
+///
+/// const Name();
+/// (This differs from the default constructor of a normal class declaration by
+/// being constant.)
+///
+/// @description Check that if unnamed factory constructor was declared then a
+/// default generative constructor is not added
+/// @author sgrekhov@unipro.ru
+
+// SharedOptions=--enable-experiment=enhanced-enums
+
+enum E1 {
+ e1,
+//^^
+// [analyzer] unspecified
+// [cfe] unspecified
+ e2;
+//^^
+// [analyzer] unspecified
+// [cfe] unspecified
+
+ factory E1(int i) => E1.values[i];
+}
+
+enum E2 {
+ e1(),
+//^^
+// [analyzer] unspecified
+// [cfe] unspecified
+ e2(0);
+//^^
+// [analyzer] unspecified
+// [cfe] unspecified
+
+ factory E2(int i) => E2.values[i];
+}
+
+main() {
+ print(E1.e1);
+ print(E2.e1);
+}