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

Side by Side 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: Address review comments. 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library engine.non_error_resolver_test; 5 library engine.non_error_resolver_test;
6 6
7 import 'package:analyzer/src/generated/ast.dart'; 7 import 'package:analyzer/src/generated/ast.dart';
8 import 'package:analyzer/src/generated/element.dart'; 8 import 'package:analyzer/src/generated/element.dart';
9 import 'package:analyzer/src/generated/engine.dart'; 9 import 'package:analyzer/src/generated/engine.dart';
10 import 'package:analyzer/src/generated/error.dart'; 10 import 'package:analyzer/src/generated/error.dart';
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 Source source = addSource(r''' 255 Source source = addSource(r'''
256 typedef A(int p1, String p2); 256 typedef A(int p1, String p2);
257 f(A a) { 257 f(A a) {
258 a(1, '2'); 258 a(1, '2');
259 }'''); 259 }''');
260 computeLibrarySourceErrors(source); 260 computeLibrarySourceErrors(source);
261 assertNoErrors(source); 261 assertNoErrors(source);
262 verify([source]); 262 verify([source]);
263 } 263 }
264 264
265 void test_assert_with_message_await() {
266 resetWithOptions(new AnalysisOptionsImpl()..enableAssertMessage = true);
267 Source source = addSource('''
268 import 'dart:async';
269 f() async {
270 assert(false, await g());
271 }
272 Future<String> g() => null;
273 ''');
274 computeLibrarySourceErrors(source);
275 assertNoErrors(source);
276 verify([source]);
277 }
278
279 void test_assert_with_message_dynamic() {
280 resetWithOptions(new AnalysisOptionsImpl()..enableAssertMessage = true);
281 Source source = addSource('''
282 f() {
283 assert(false, g());
284 }
285 g() => null;
286 ''');
287 computeLibrarySourceErrors(source);
288 assertNoErrors(source);
289 verify([source]);
290 }
291
292 void test_assert_with_message_null() {
293 resetWithOptions(new AnalysisOptionsImpl()..enableAssertMessage = true);
294 Source source = addSource('''
295 f() {
296 assert(false, null);
297 }
298 ''');
299 computeLibrarySourceErrors(source);
300 assertNoErrors(source);
301 verify([source]);
302 }
303
304 void test_assert_with_message_string() {
305 resetWithOptions(new AnalysisOptionsImpl()..enableAssertMessage = true);
306 Source source = addSource('''
307 f() {
308 assert(false, 'message');
309 }
310 ''');
311 computeLibrarySourceErrors(source);
312 assertNoErrors(source);
313 verify([source]);
314 }
315
316 void test_assert_with_message_suppresses_unused_var_hint() {
317 resetWithOptions(new AnalysisOptionsImpl()..enableAssertMessage = true);
318 Source source = addSource('''
319 f() {
320 String message = 'msg';
321 assert(true, message);
322 }
323 ''');
324 computeLibrarySourceErrors(source);
325 assertNoErrors(source);
326 verify([source]);
327 }
328
265 void test_assignability_function_expr_rettype_from_typedef_cls() { 329 void test_assignability_function_expr_rettype_from_typedef_cls() {
266 // In the code below, the type of (() => f()) has a return type which is 330 // In the code below, the type of (() => f()) has a return type which is
267 // a class, and that class is inferred from the return type of the typedef 331 // a class, and that class is inferred from the return type of the typedef
268 // F. 332 // F.
269 Source source = addSource(''' 333 Source source = addSource('''
270 class C {} 334 class C {}
271 typedef C F(); 335 typedef C F();
272 F f; 336 F f;
273 main() { 337 main() {
274 F f2 = (() => f()); 338 F f2 = (() => f());
(...skipping 5479 matching lines...) Expand 10 before | Expand all | Expand 10 after
5754 reset(); 5818 reset();
5755 } 5819 }
5756 5820
5757 void _check_wrongNumberOfParametersForOperator1(String name) { 5821 void _check_wrongNumberOfParametersForOperator1(String name) {
5758 _check_wrongNumberOfParametersForOperator(name, "a"); 5822 _check_wrongNumberOfParametersForOperator(name, "a");
5759 } 5823 }
5760 5824
5761 CompilationUnit _getResolvedLibraryUnit(Source source) => 5825 CompilationUnit _getResolvedLibraryUnit(Source source) =>
5762 analysisContext.getResolvedCompilationUnit2(source, source); 5826 analysisContext.getResolvedCompilationUnit2(source, source);
5763 } 5827 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/generated/compile_time_error_code_test.dart ('k') | pkg/analyzer/test/generated/parser_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698