Issue #477: tests for Constant-2019-update added.
diff --git a/LanguageFeatures/Constant-update-2018/ShortCircuitOperators_A01_t10.dart b/LanguageFeatures/Constant-update-2018/ShortCircuitOperators_A01_t10.dart
index c3e3fac..a1d32f0 100644
--- a/LanguageFeatures/Constant-update-2018/ShortCircuitOperators_A01_t10.dart
+++ b/LanguageFeatures/Constant-update-2018/ShortCircuitOperators_A01_t10.dart
@@ -19,7 +19,7 @@
dynamic nonConst;
const int i = 5;
-bool b = true;
+bool bb = true;
class MyClass1 {
final bool b;
@@ -35,7 +35,7 @@
// [analyzer] unspecified
// [cfe] unspecified
- const bool a2 = false && b;
+ const bool a2 = false && bb;
// ^
// [analyzer] unspecified
// [cfe] unspecified
diff --git a/LanguageFeatures/Constant-update-2018/ShortCircuitOperators_A02_t02.dart b/LanguageFeatures/Constant-update-2018/ShortCircuitOperators_A02_t02.dart
index 201f298..f0aaf02 100644
--- a/LanguageFeatures/Constant-update-2018/ShortCircuitOperators_A02_t02.dart
+++ b/LanguageFeatures/Constant-update-2018/ShortCircuitOperators_A02_t02.dart
@@ -10,7 +10,6 @@
* @description Checks that [||] throws error if the first operand of [||]
* operation is [false] and the second one is not valid in the constant
* expression.
- * @compile-error
* @author iarkh@unipro.ru
*/
// SharedOptions=--enable-experiment=constant-update-2018
@@ -22,4 +21,7 @@
main() {
const inst = MyClass();
+// ^^^^^^^^^
+// [analyzer] unspecified
+// [cfe] unspecified
}
diff --git a/LanguageFeatures/Constant-update-2018/ShortCircuitOperators_A02_t03.dart b/LanguageFeatures/Constant-update-2018/ShortCircuitOperators_A02_t03.dart
index 23031ef..aed9e28 100644
--- a/LanguageFeatures/Constant-update-2018/ShortCircuitOperators_A02_t03.dart
+++ b/LanguageFeatures/Constant-update-2018/ShortCircuitOperators_A02_t03.dart
@@ -7,10 +7,9 @@
* @assertion Likewise the [||] operator only evaluates its second operand if
* the first evaluates to [false], and the second operand must be a potentially
* constant expression.
- * @description Checks that [||] throws error if the first operand of [&&]
+ * @description Checks that [||] throws error if the first operand of [||]
* operation is [false] and the second one is not valid in the constant
* expression.
- * @compile-error
* @author iarkh@unipro.ru
*/
// SharedOptions=--enable-experiment=constant-update-2018
@@ -19,4 +18,8 @@
main() {
const bool a1 = (i < 0) || ((null as String).length > 14);
+// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+// [analyzer] unspecified
+// [cfe] unspecified
+
}
diff --git a/LanguageFeatures/Constant-update-2018/ShortCircuitOperators_A02_t04.dart b/LanguageFeatures/Constant-update-2018/ShortCircuitOperators_A02_t04.dart
index b769470..21e5f0d 100644
--- a/LanguageFeatures/Constant-update-2018/ShortCircuitOperators_A02_t04.dart
+++ b/LanguageFeatures/Constant-update-2018/ShortCircuitOperators_A02_t04.dart
@@ -7,14 +7,19 @@
* @assertion Likewise the [||] operator only evaluates its second operand if
* the first evaluates to [false], and the second operand must be a potentially
* constant expression.
- * @description Checks that [||] throws error if the first operand of [&&]
+ * @description Checks that [||] throws error if the first operand of [||]
* operation is [false] and the second one is not valid in the constant
* expression.
- * @compile-error
* @author iarkh@unipro.ru
*/
// SharedOptions=--enable-experiment=constant-update-2018
+const dynamic nil = null;
+
main() {
- const bool a2 = false || ((null as String).length > 14);
+ const bool a = false || nil;
+// ^^^^^^^^^^^^
+// [analyzer] unspecified
+// [cfe] unspecified
+
}
diff --git a/LanguageFeatures/Constant-update-2018/ShortCircuitOperators_A02_t05.dart b/LanguageFeatures/Constant-update-2018/ShortCircuitOperators_A02_t05.dart
index 9130681..7c639fe 100644
--- a/LanguageFeatures/Constant-update-2018/ShortCircuitOperators_A02_t05.dart
+++ b/LanguageFeatures/Constant-update-2018/ShortCircuitOperators_A02_t05.dart
@@ -9,14 +9,26 @@
* constant expression.
* @description Checks that compile error is thrown if the first [||] operand is
* [true] and the second one is not [bool] in the constant expression.
- * @compile-error
* @author iarkh@unipro.ru
*/
// SharedOptions=--enable-experiment=constant-update-2018
-class MyClass {
+const String str = "12345";
+
+class MyClass1 {
final bool b;
- const MyClass() : b = true || (null as String).length;
+ const MyClass1() : b = true || (null as String).length;
+// ^^^^^^^^^^^^^^^^^^^^^^^
+// [analyzer] unspecified
+// [cfe] unspecified
+}
+
+class MyClass2 {
+ final bool b;
+ const MyClass2() : b = true || str;
+// ^^^
+// [analyzer] unspecified
+// [cfe] unspecified
}
main() {
diff --git a/LanguageFeatures/Constant-update-2018/ShortCircuitOperators_A02_t06.dart b/LanguageFeatures/Constant-update-2018/ShortCircuitOperators_A02_t06.dart
index 1f216c7..bd1ee7b 100644
--- a/LanguageFeatures/Constant-update-2018/ShortCircuitOperators_A02_t06.dart
+++ b/LanguageFeatures/Constant-update-2018/ShortCircuitOperators_A02_t06.dart
@@ -9,7 +9,6 @@
* constant expression.
* @description Checks that compile error is thrown if the first [||] operand is
* [true] and the second one is not [bool] in the constant expression.
- * @compile-error
* @author iarkh@unipro.ru
*/
// SharedOptions=--enable-experiment=constant-update-2018
@@ -18,4 +17,7 @@
main() {
const bool a1 = (i > 0) || (null as String).length;
+// ^^^^^^^^^^^^^^^^^^^^^^^
+// [analyzer] unspecified
+// [cfe] unspecified
}
diff --git a/LanguageFeatures/Constant-update-2018/ShortCircuitOperators_A02_t07.dart b/LanguageFeatures/Constant-update-2018/ShortCircuitOperators_A02_t07.dart
index 4c02d42..8576ecf 100644
--- a/LanguageFeatures/Constant-update-2018/ShortCircuitOperators_A02_t07.dart
+++ b/LanguageFeatures/Constant-update-2018/ShortCircuitOperators_A02_t07.dart
@@ -9,11 +9,22 @@
* constant expression.
* @description Checks that compile error is thrown if the first [||] operand is
* [true] and the second one is not [bool] in the constant expression.
- * @compile-error
* @author iarkh@unipro.ru
*/
// SharedOptions=--enable-experiment=constant-update-2018
+const int i = 0;
+const String d = "";
+
main() {
- const bool a2 = true || (null as String).length;
+ const bool a1 = true || (null as String).length;
+// ^^^^^^^^^^^^^^^^^^^^^^^
+// [analyzer] unspecified
+// [cfe] unspecified
+
+ const bool a2 = (i == 0) || d;
+// ^
+// [analyzer] unspecified
+// [cfe] unspecified
+
}
diff --git a/LanguageFeatures/Constant-update-2018/ShortCircuitOperators_A02_t11.dart b/LanguageFeatures/Constant-update-2018/ShortCircuitOperators_A02_t11.dart
new file mode 100644
index 0000000..13d327d
--- /dev/null
+++ b/LanguageFeatures/Constant-update-2018/ShortCircuitOperators_A02_t11.dart
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2019, 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 Likewise the [||] operator only evaluates its second operand if
+ * the first evaluates to [false], and the second operand must be a potentially
+ * constant expression.
+ * @description Checks that [||] throws a compile error if the first operand in
+ * the constant expression [||] is [true] and the second one is not a constant.
+ * @author iarkh@unipro.ru
+ */
+// SharedOptions=--enable-experiment=constant-update-2018
+
+dynamic nonConst;
+const int i = 5;
+bool bb = true;
+
+class MyClass {
+ final bool b;
+ const MyClass() : b = true || nonConst;
+// ^^^^^^^^
+// [analyzer] unspecified
+// [cfe] unspecified
+}
+
+main() {
+ const bool a1 = (i > 0) || bb;
+// ^^
+// [analyzer] unspecified
+// [cfe] unspecified
+
+ const bool a2 = true || nonConst;
+// ^^^^^^^^
+// [analyzer] unspecified
+// [cfe] unspecified
+
+ const bool a3 = true || i < nonConst;
+// ^^^^^^^^
+// [analyzer] unspecified
+// [cfe] unspecified
+
+}
diff --git a/LanguageFeatures/Constant-update-2018/ShortCircuitOperators_A02_t12.dart b/LanguageFeatures/Constant-update-2018/ShortCircuitOperators_A02_t12.dart
new file mode 100644
index 0000000..69fc052
--- /dev/null
+++ b/LanguageFeatures/Constant-update-2018/ShortCircuitOperators_A02_t12.dart
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2019, 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 Likewise the [||] operator only evaluates its second operand if
+ * the first evaluates to [false], and the second operand must be a potentially
+ * constant expression.
+ * @description Checks that [||] throws error if the first operand of [||]
+ * operation is [false] and the second one is not a constant expression.
+ * @author iarkh@unipro.ru
+ */
+// SharedOptions=--enable-experiment=constant-update-2018
+
+const int i = 25;
+bool b = false;
+dynamic d;
+int j = 4;
+
+main() {
+ const bool a1 = false || b;
+// ^^^^^^^^^^
+// [analyzer] unspecified
+// [cfe] unspecified
+
+ const bool a2 = (i < 0) || b;
+// ^^^^^^^^^^^^
+// [analyzer] unspecified
+// [cfe] unspecified
+
+ const bool a3 = false || d < 11;
+// ^^^^^^^^^^^^^^^
+// [analyzer] unspecified
+// [cfe] unspecified
+
+ const bool a4 = (i == 2) || (j == 4);
+// ^^^^^^^^^^^^^^^^^^^^
+// [analyzer] unspecified
+// [cfe] unspecified
+
+}
diff --git a/LanguageFeatures/Constant-update-2018/ShortCircuitOperators_A02_t13.dart b/LanguageFeatures/Constant-update-2018/ShortCircuitOperators_A02_t13.dart
new file mode 100644
index 0000000..37c77d7
--- /dev/null
+++ b/LanguageFeatures/Constant-update-2018/ShortCircuitOperators_A02_t13.dart
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2019, 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 Likewise the [||] operator only evaluates its second operand if
+ * the first evaluates to [false], and the second operand must be a potentially
+ * constant expression.
+ * @description Checks that compile error is thrown if constant constructor
+ * argument is not a constant itself.
+ * @author iarkh@unipro.ru
+ */
+// SharedOptions=--enable-experiment=constant-update-2018
+
+int i = 0;
+
+dynamic str;
+
+dynamic a = 1;
+
+class MyClass {
+ final bool b;
+ const MyClass(Object o) : b = true || ((o as int) > 25);
+}
+
+main() {
+ const MyClass c1 = MyClass(i);
+// ^
+// [analyzer] unspecified
+// [cfe] unspecified
+
+ const MyClass c2 = MyClass(str);
+// ^^^
+// [analyzer] unspecified
+// [cfe] unspecified
+
+ const MyClass c3 = MyClass(a);
+// ^
+// [analyzer] unspecified
+// [cfe] unspecified
+
+}