Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Unified Diff: pkg/analyzer/test/generated/compile_time_error_code_test.dart

Issue 2483213010: Validate that the expressions in an assert in the initializer list of a const constructor are all p… (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/generated/resolver.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/generated/compile_time_error_code_test.dart
diff --git a/pkg/analyzer/test/generated/compile_time_error_code_test.dart b/pkg/analyzer/test/generated/compile_time_error_code_test.dart
index 35dea2a8f20c4e1499ea673ddb3160f3c3c53184..4b4bf3d125a90c1d87ea0a0a6e63b1a0248873c5 100644
--- a/pkg/analyzer/test/generated/compile_time_error_code_test.dart
+++ b/pkg/analyzer/test/generated/compile_time_error_code_test.dart
@@ -4596,6 +4596,32 @@ f() {
]);
}
+ void test_nonConstValueInInitializer_assert_condition() {
+ resetWithOptions(new AnalysisOptionsImpl()..enableAssertInitializer = true);
+ Source source = addSource(r'''
+class A {
+ const A(int i) : assert(i.isNegative);
+}''');
+ computeLibrarySourceErrors(source);
+ assertErrors(
+ source, [CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER]);
+ verify([source]);
+ }
+
+ void test_nonConstValueInInitializer_assert_message() {
+ resetWithOptions(new AnalysisOptionsImpl()
+ ..enableAssertInitializer = true
+ ..enableAssertMessage = true);
+ Source source = addSource(r'''
+class A {
+ const A(int i) : assert(i < 0, 'isNegative = ${i.isNegative}');
+}''');
+ computeLibrarySourceErrors(source);
+ assertErrors(
+ source, [CompileTimeErrorCode.NON_CONSTANT_VALUE_IN_INITIALIZER]);
+ verify([source]);
+ }
+
void test_nonConstValueInInitializer_binary_notBool_left() {
Source source = addSource(r'''
class A {
« no previous file with comments | « pkg/analyzer/lib/src/generated/resolver.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698