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

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

Issue 2990383002: Emit a hint when using generic method comment syntax (issue 30356) (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 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 analyzer.test.generated.compile_time_error_code_test; 5 library analyzer.test.generated.compile_time_error_code_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analyzer/error/error.dart'; 9 import 'package:analyzer/error/error.dart';
10 import 'package:analyzer/src/error/codes.dart'; 10 import 'package:analyzer/src/error/codes.dart';
(...skipping 1626 matching lines...) Expand 10 before | Expand all | Expand 10 after
1637 class B implements A { 1637 class B implements A {
1638 B([int x = 1]) {} 1638 B([int x = 1]) {}
1639 }'''); 1639 }''');
1640 await computeAnalysisResult(source); 1640 await computeAnalysisResult(source);
1641 assertErrors(source, [ 1641 assertErrors(source, [
1642 CompileTimeErrorCode.DEFAULT_VALUE_IN_REDIRECTING_FACTORY_CONSTRUCTOR 1642 CompileTimeErrorCode.DEFAULT_VALUE_IN_REDIRECTING_FACTORY_CONSTRUCTOR
1643 ]); 1643 ]);
1644 verify([source]); 1644 verify([source]);
1645 } 1645 }
1646 1646
1647 test_deferredImportWithInvalidUri() async {
1648 Source source = addSource(r'''
1649 import '[invalid uri]' deferred as p;
1650 main() {
1651 p.loadLibrary();
1652 }''');
1653 await computeAnalysisResult(source);
1654 if (enableNewAnalysisDriver) {
1655 assertErrors(source, [CompileTimeErrorCode.URI_DOES_NOT_EXIST]);
1656 } else {
1657 assertErrors(source, [
1658 CompileTimeErrorCode.URI_DOES_NOT_EXIST,
1659 StaticWarningCode.UNDEFINED_IDENTIFIER
1660 ]);
1661 }
1662 }
1663
1647 test_duplicateConstructorName_named() async { 1664 test_duplicateConstructorName_named() async {
1648 Source source = addSource(r''' 1665 Source source = addSource(r'''
1649 class A { 1666 class A {
1650 A.a() {} 1667 A.a() {}
1651 A.a() {} 1668 A.a() {}
1652 }'''); 1669 }''');
1653 await computeAnalysisResult(source); 1670 await computeAnalysisResult(source);
1654 assertErrors(source, [ 1671 assertErrors(source, [
1655 CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_NAME, 1672 CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_NAME,
1656 CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_NAME 1673 CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR_NAME
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after
2491 // new analysis driver. 2508 // new analysis driver.
2492 expectedErrorCodes.addAll([ 2509 expectedErrorCodes.addAll([
2493 StaticWarningCode.UNDEFINED_CLASS, 2510 StaticWarningCode.UNDEFINED_CLASS,
2494 StaticWarningCode.UNDEFINED_CLASS 2511 StaticWarningCode.UNDEFINED_CLASS
2495 ]); 2512 ]);
2496 } 2513 }
2497 assertErrors(source, expectedErrorCodes); 2514 assertErrors(source, expectedErrorCodes);
2498 verify([source]); 2515 verify([source]);
2499 } 2516 }
2500 2517
2501 test_genericFunctionTypedParameter_commentSyntax() async {
2502 // Once dartbug.com/28515 is fixed, this syntax should no longer generate an
2503 // error.
2504 // TODO(paulberry): When dartbug.com/28515 is fixed, convert this into a
2505 // NonErrorResolverTest.
2506 resetWith(options: new AnalysisOptionsImpl()..strongMode = true);
2507 Source source = addSource('void g(/*=T*/ f/*<T>*/(/*=T*/ x)) {}');
2508 await computeAnalysisResult(source);
2509 var expectedErrorCodes = <ErrorCode>[
2510 CompileTimeErrorCode.GENERIC_FUNCTION_TYPED_PARAM_UNSUPPORTED
2511 ];
2512 if (enableNewAnalysisDriver) {
2513 // Due to dartbug.com/28515, some additional errors appear when using the
2514 // new analysis driver.
2515 expectedErrorCodes.addAll([
2516 StaticWarningCode.UNDEFINED_CLASS,
2517 StaticWarningCode.UNDEFINED_CLASS
2518 ]);
2519 }
2520 assertErrors(source, expectedErrorCodes);
2521 verify([source]);
2522 }
2523
2524 test_getterAndMethodWithSameName() async { 2518 test_getterAndMethodWithSameName() async {
2525 Source source = addSource(r''' 2519 Source source = addSource(r'''
2526 class A { 2520 class A {
2527 x(y) {} 2521 x(y) {}
2528 get x => 0; 2522 get x => 0;
2529 }'''); 2523 }''');
2530 await computeAnalysisResult(source); 2524 await computeAnalysisResult(source);
2531 assertErrors( 2525 assertErrors(
2532 source, [CompileTimeErrorCode.GETTER_AND_METHOD_WITH_SAME_NAME]); 2526 source, [CompileTimeErrorCode.GETTER_AND_METHOD_WITH_SAME_NAME]);
2533 verify([source]); 2527 verify([source]);
(...skipping 3407 matching lines...) Expand 10 before | Expand all | Expand 10 after
5941 test_returnInGenerator_syncStar() async { 5935 test_returnInGenerator_syncStar() async {
5942 Source source = addSource(r''' 5936 Source source = addSource(r'''
5943 f() sync* { 5937 f() sync* {
5944 return 0; 5938 return 0;
5945 }'''); 5939 }''');
5946 await computeAnalysisResult(source); 5940 await computeAnalysisResult(source);
5947 assertErrors(source, [CompileTimeErrorCode.RETURN_IN_GENERATOR]); 5941 assertErrors(source, [CompileTimeErrorCode.RETURN_IN_GENERATOR]);
5948 verify([source]); 5942 verify([source]);
5949 } 5943 }
5950 5944
5951 test_deferredImportWithInvalidUri() async {
5952 Source source = addSource(r'''
5953 import '[invalid uri]' deferred as p;
5954 main() {
5955 p.loadLibrary();
5956 }''');
5957 await computeAnalysisResult(source);
5958 if (enableNewAnalysisDriver) {
5959 assertErrors(source, [CompileTimeErrorCode.URI_DOES_NOT_EXIST]);
5960 } else {
5961 assertErrors(source, [
5962 CompileTimeErrorCode.URI_DOES_NOT_EXIST,
5963 StaticWarningCode.UNDEFINED_IDENTIFIER
5964 ]);
5965 }
5966 }
5967
5968 test_sharedDeferredPrefix() async { 5945 test_sharedDeferredPrefix() async {
5969 await resolveWithErrors(<String>[ 5946 await resolveWithErrors(<String>[
5970 r''' 5947 r'''
5971 library lib1; 5948 library lib1;
5972 f1() {}''', 5949 f1() {}''',
5973 r''' 5950 r'''
5974 library lib2; 5951 library lib2;
5975 f2() {}''', 5952 f2() {}''',
5976 r''' 5953 r'''
5977 library root; 5954 library root;
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
6622 int _x; 6599 int _x;
6623 } 6600 }
6624 '''); 6601 ''');
6625 Source source = addSource(testCode); 6602 Source source = addSource(testCode);
6626 await computeAnalysisResult(source); 6603 await computeAnalysisResult(source);
6627 assertErrors( 6604 assertErrors(
6628 source, [CompileTimeErrorCode.PRIVATE_COLLISION_IN_MIXIN_APPLICATION]); 6605 source, [CompileTimeErrorCode.PRIVATE_COLLISION_IN_MIXIN_APPLICATION]);
6629 verify([source]); 6606 verify([source]);
6630 } 6607 }
6631 } 6608 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/parser.dart ('k') | pkg/analyzer/test/generated/parser_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698