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

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

Issue 1309543011: Add support for assert statements with messages to the analyzer. Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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/non_error_resolver_test.dart
diff --git a/pkg/analyzer/test/generated/non_error_resolver_test.dart b/pkg/analyzer/test/generated/non_error_resolver_test.dart
index dedbb2a4523b6d8b4e898bf233d50e15913ac329..df6a0766db6d52f238b25020d4b003a446be4066 100644
--- a/pkg/analyzer/test/generated/non_error_resolver_test.dart
+++ b/pkg/analyzer/test/generated/non_error_resolver_test.dart
@@ -262,6 +262,70 @@ f(A a) {
verify([source]);
}
+ void test_assert_with_message_await() {
+ resetWithOptions(new AnalysisOptionsImpl()..enableAssertMessage = true);
+ Source source = addSource('''
+import 'dart:async';
+f() async {
+ assert(false, await g());
+}
+Future<String> g() => null;
+''');
+ computeLibrarySourceErrors(source);
+ assertNoErrors(source);
+ verify([source]);
+ }
+
+ void test_assert_with_message_dynamic() {
+ resetWithOptions(new AnalysisOptionsImpl()..enableAssertMessage = true);
+ Source source = addSource('''
+f() {
+ assert(false, g());
+}
+g() => null;
+''');
+ computeLibrarySourceErrors(source);
+ assertNoErrors(source);
+ verify([source]);
+ }
+
+ void test_assert_with_message_null() {
+ resetWithOptions(new AnalysisOptionsImpl()..enableAssertMessage = true);
+ Source source = addSource('''
+f() {
+ assert(false, null);
+}
+''');
+ computeLibrarySourceErrors(source);
+ assertNoErrors(source);
+ verify([source]);
+ }
+
+ void test_assert_with_message_string() {
+ resetWithOptions(new AnalysisOptionsImpl()..enableAssertMessage = true);
+ Source source = addSource('''
+f() {
+ assert(false, 'message');
+}
+''');
+ computeLibrarySourceErrors(source);
+ assertNoErrors(source);
+ verify([source]);
+ }
+
+ void test_assert_with_message_suppresses_unused_var_hint() {
+ resetWithOptions(new AnalysisOptionsImpl()..enableAssertMessage = true);
+ Source source = addSource('''
+f() {
+ String message = 'msg';
+ assert(true, message);
+}
+''');
+ computeLibrarySourceErrors(source);
+ assertNoErrors(source);
+ verify([source]);
+ }
+
void test_assignability_function_expr_rettype_from_typedef_cls() {
// In the code below, the type of (() => f()) has a return type which is
// a class, and that class is inferred from the return type of the typedef

Powered by Google App Engine
This is Rietveld 408576698