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

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

Issue 3003363002: Report compile time errors when assert initializers fail. (Closed)
Patch Set: Created 3 years, 4 months 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
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 5158c9070561ecbc4d13a94a87a9597667ed963d..e8cc06876c80d9cac982fa4da7585cdc3dc2ed5c 100644
--- a/pkg/analyzer/test/generated/compile_time_error_code_test.dart
+++ b/pkg/analyzer/test/generated/compile_time_error_code_test.dart
@@ -1120,6 +1120,35 @@ const C = a.m;''');
verify([source]);
}
+ test_constEvalThrowsException_assertInitializer_false() async {
+ resetWith(
+ options: new AnalysisOptionsImpl()..enableAssertInitializer = true);
+ Source source = addSource(r'''
+class A {
+ const A(int p) : assert(p != 0);
+}
+const a = const A(0);
+''');
+ await computeAnalysisResult(source);
+ assertErrors(source, [CompileTimeErrorCode.CONST_EVAL_THROWS_ASSERT_FALSE]);
+ verify([source]);
+ }
+
+ test_constEvalThrowsException_assertInitializer_notBool() async {
+ resetWith(
+ options: new AnalysisOptionsImpl()..enableAssertInitializer = true);
+ Source source = addSource(r'''
+class A<T> {
+ const A(T p) : assert(p);
+}
+const a = const A(0);
+''');
+ await computeAnalysisResult(source);
+ assertErrors(
+ source, [CompileTimeErrorCode.CONST_EVAL_THROWS_ASSERT_NOT_BOOL]);
+ verify([source]);
+ }
+
test_constEvalThrowsException_binaryMinus_null() async {
await _check_constEvalThrowsException_binary_null("null - 5", false);
await _check_constEvalThrowsException_binary_null("5 - null", true);
« no previous file with comments | « pkg/analyzer/lib/src/generated/resolver.dart ('k') | pkg/analyzer/test/generated/non_error_resolver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698