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

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

Issue 1901923002: Add UNDEFINED_HIDDEN_NAME, UNDEFINED_SHOWN_NAME (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Move error generation to DeadCodeVerifier Created 4 years, 8 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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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.hint_code_test; 5 library analyzer.test.generated.hint_code_test;
6 6
7 import 'package:analyzer/src/generated/engine.dart'; 7 import 'package:analyzer/src/generated/engine.dart';
8 import 'package:analyzer/src/generated/error.dart'; 8 import 'package:analyzer/src/generated/error.dart';
9 import 'package:analyzer/src/generated/source_io.dart'; 9 import 'package:analyzer/src/generated/source_io.dart';
10 import 'package:unittest/unittest.dart'; 10 import 'package:unittest/unittest.dart';
(...skipping 1692 matching lines...) Expand 10 before | Expand all | Expand 10 after
1703 void test_typeCheck_type_not_Null() { 1703 void test_typeCheck_type_not_Null() {
1704 Source source = addSource(r''' 1704 Source source = addSource(r'''
1705 m(i) { 1705 m(i) {
1706 bool b = i is! Null; 1706 bool b = i is! Null;
1707 }'''); 1707 }''');
1708 computeLibrarySourceErrors(source); 1708 computeLibrarySourceErrors(source);
1709 assertErrors(source, [HintCode.TYPE_CHECK_IS_NOT_NULL]); 1709 assertErrors(source, [HintCode.TYPE_CHECK_IS_NOT_NULL]);
1710 verify([source]); 1710 verify([source]);
1711 } 1711 }
1712 1712
1713 void test_undefinedIdentifier_importHide() {
1714 Source source = addSource(r'''
1715 library L;
1716 import 'lib1.dart' hide a;''');
1717 addNamedSource("/lib1.dart", "library lib1;");
1718 computeLibrarySourceErrors(source);
1719 assertErrors(
1720 source,
1721 [HintCode.UNUSED_IMPORT, HintCode.UNDEFINED_HIDDEN_NAME]);
1722 verify([source]);
1723 }
1724
1725 void test_undefinedIdentifier_importShow() {
1726 Source source = addSource(r'''
1727 library L;
1728 import 'lib1.dart' show a;''');
1729 addNamedSource("/lib1.dart", "library lib1;");
1730 computeLibrarySourceErrors(source);
1731 assertErrors(
1732 source,
1733 [HintCode.UNUSED_IMPORT, HintCode.UNDEFINED_SHOWN_NAME]);
1734 verify([source]);
1735 }
1736
1737 void test_undefinedIdentifier_exportHide() {
1738 Source source = addSource(r'''
1739 library L;
1740 export 'lib1.dart' hide a;''');
1741 addNamedSource("/lib1.dart", "library lib1;");
1742 computeLibrarySourceErrors(source);
1743 assertErrors(source, [HintCode.UNDEFINED_HIDDEN_NAME]);
1744 verify([source]);
1745 }
1746
1747 void test_undefinedIdentifier_exportShow() {
1748 Source source = addSource(r'''
1749 library L;
1750 export 'lib1.dart' show a;''');
1751 addNamedSource("/lib1.dart", "library lib1;");
1752 computeLibrarySourceErrors(source);
1753 assertErrors(source, [HintCode.UNDEFINED_SHOWN_NAME]);
1754 verify([source]);
1755 }
1756
1713 void test_undefinedGetter() { 1757 void test_undefinedGetter() {
1714 Source source = addSource(r''' 1758 Source source = addSource(r'''
1715 class A {} 1759 class A {}
1716 f(var a) { 1760 f(var a) {
1717 if(a is A) { 1761 if(a is A) {
1718 return a.m; 1762 return a.m;
1719 } 1763 }
1720 }'''); 1764 }''');
1721 computeLibrarySourceErrors(source); 1765 computeLibrarySourceErrors(source);
1722 assertErrors(source, [HintCode.UNDEFINED_GETTER]); 1766 assertErrors(source, [HintCode.UNDEFINED_GETTER]);
(...skipping 1517 matching lines...) Expand 10 before | Expand all | Expand 10 after
3240 n() { 3284 n() {
3241 var a = m(), b = m(); 3285 var a = m(), b = m();
3242 } 3286 }
3243 }'''); 3287 }''');
3244 computeLibrarySourceErrors(source); 3288 computeLibrarySourceErrors(source);
3245 assertErrors( 3289 assertErrors(
3246 source, [HintCode.USE_OF_VOID_RESULT, HintCode.USE_OF_VOID_RESULT]); 3290 source, [HintCode.USE_OF_VOID_RESULT, HintCode.USE_OF_VOID_RESULT]);
3247 verify([source]); 3291 verify([source]);
3248 } 3292 }
3249 } 3293 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698