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

Side by Side Diff: pkg/analyzer/test/generated/non_error_resolver_test.dart

Issue 1239513005: Switch on null-aware operators by default in analyzer. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 5 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 2354 matching lines...) Expand 10 before | Expand all | Expand 10 after
2365 void test_invalidAssignment_defaultValue_optional() { 2365 void test_invalidAssignment_defaultValue_optional() {
2366 Source source = addSource(r''' 2366 Source source = addSource(r'''
2367 f([String x = '0']) { 2367 f([String x = '0']) {
2368 }'''); 2368 }''');
2369 computeLibrarySourceErrors(source); 2369 computeLibrarySourceErrors(source);
2370 assertNoErrors(source); 2370 assertNoErrors(source);
2371 verify([source]); 2371 verify([source]);
2372 } 2372 }
2373 2373
2374 void test_invalidAssignment_ifNullAssignment_compatibleType() { 2374 void test_invalidAssignment_ifNullAssignment_compatibleType() {
2375 AnalysisOptionsImpl options = new AnalysisOptionsImpl();
2376 options.enableNullAwareOperators = true;
2377 resetWithOptions(options);
2378 Source source = addSource(''' 2375 Source source = addSource('''
2379 void f(int i) { 2376 void f(int i) {
2380 num n; 2377 num n;
2381 n ??= i; 2378 n ??= i;
2382 } 2379 }
2383 '''); 2380 ''');
2384 computeLibrarySourceErrors(source); 2381 computeLibrarySourceErrors(source);
2385 assertNoErrors(source); 2382 assertNoErrors(source);
2386 verify([source]); 2383 verify([source]);
2387 } 2384 }
2388 2385
2389 void test_invalidAssignment_ifNullAssignment_sameType() { 2386 void test_invalidAssignment_ifNullAssignment_sameType() {
2390 AnalysisOptionsImpl options = new AnalysisOptionsImpl();
2391 options.enableNullAwareOperators = true;
2392 resetWithOptions(options);
2393 Source source = addSource(''' 2387 Source source = addSource('''
2394 void f(int i) { 2388 void f(int i) {
2395 int j; 2389 int j;
2396 j ??= i; 2390 j ??= i;
2397 } 2391 }
2398 '''); 2392 ''');
2399 computeLibrarySourceErrors(source); 2393 computeLibrarySourceErrors(source);
2400 assertNoErrors(source); 2394 assertNoErrors(source);
2401 verify([source]); 2395 verify([source]);
2402 } 2396 }
(...skipping 2601 matching lines...) Expand 10 before | Expand all | Expand 10 after
5004 Bar.ctor() : super.ctor(); 4998 Bar.ctor() : super.ctor();
5005 }'''); 4999 }''');
5006 computeLibrarySourceErrors(source); 5000 computeLibrarySourceErrors(source);
5007 assertNoErrors(source); 5001 assertNoErrors(source);
5008 verify([source]); 5002 verify([source]);
5009 } 5003 }
5010 5004
5011 void test_undefinedGetter_typeLiteral_conditionalAccess() { 5005 void test_undefinedGetter_typeLiteral_conditionalAccess() {
5012 // When applied to a type literal, the conditional access operator '?.' can 5006 // When applied to a type literal, the conditional access operator '?.' can
5013 // be used to access instance getters of Type. 5007 // be used to access instance getters of Type.
5014 AnalysisOptionsImpl options = new AnalysisOptionsImpl();
5015 options.enableNullAwareOperators = true;
5016 resetWithOptions(options);
5017 Source source = addSource(''' 5008 Source source = addSource('''
5018 class A {} 5009 class A {}
5019 f() => A?.hashCode; 5010 f() => A?.hashCode;
5020 '''); 5011 ''');
5021 computeLibrarySourceErrors(source); 5012 computeLibrarySourceErrors(source);
5022 assertNoErrors(source); 5013 assertNoErrors(source);
5023 verify([source]); 5014 verify([source]);
5024 } 5015 }
5025 5016
5026 void test_undefinedGetter_typeSubstitution() { 5017 void test_undefinedGetter_typeSubstitution() {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
5094 (() => null)(); 5085 (() => null)();
5095 }'''); 5086 }''');
5096 computeLibrarySourceErrors(source); 5087 computeLibrarySourceErrors(source);
5097 assertNoErrors(source); 5088 assertNoErrors(source);
5098 // A call to verify(source) fails as '(() => null)()' isn't resolved. 5089 // A call to verify(source) fails as '(() => null)()' isn't resolved.
5099 } 5090 }
5100 5091
5101 void test_undefinedMethod_typeLiteral_conditionalAccess() { 5092 void test_undefinedMethod_typeLiteral_conditionalAccess() {
5102 // When applied to a type literal, the conditional access operator '?.' can 5093 // When applied to a type literal, the conditional access operator '?.' can
5103 // be used to access instance methods of Type. 5094 // be used to access instance methods of Type.
5104 AnalysisOptionsImpl options = new AnalysisOptionsImpl();
5105 options.enableNullAwareOperators = true;
5106 resetWithOptions(options);
5107 Source source = addSource(''' 5095 Source source = addSource('''
5108 class A {} 5096 class A {}
5109 f() => A?.toString(); 5097 f() => A?.toString();
5110 '''); 5098 ''');
5111 computeLibrarySourceErrors(source); 5099 computeLibrarySourceErrors(source);
5112 assertNoErrors(source); 5100 assertNoErrors(source);
5113 verify([source]); 5101 verify([source]);
5114 } 5102 }
5115 5103
5116 void test_undefinedOperator_index() { 5104 void test_undefinedOperator_index() {
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
5530 reset(); 5518 reset();
5531 } 5519 }
5532 5520
5533 void _check_wrongNumberOfParametersForOperator1(String name) { 5521 void _check_wrongNumberOfParametersForOperator1(String name) {
5534 _check_wrongNumberOfParametersForOperator(name, "a"); 5522 _check_wrongNumberOfParametersForOperator(name, "a");
5535 } 5523 }
5536 5524
5537 CompilationUnit _getResolvedLibraryUnit(Source source) => 5525 CompilationUnit _getResolvedLibraryUnit(Source source) =>
5538 analysisContext.getResolvedCompilationUnit2(source, source); 5526 analysisContext.getResolvedCompilationUnit2(source, source);
5539 } 5527 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/generated/engine_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