OLD | NEW |
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.static_warning_code_test; | 5 library analyzer.test.generated.static_warning_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:test_reflective_loader/test_reflective_loader.dart'; |
10 import 'package:unittest/unittest.dart'; | 11 import 'package:unittest/unittest.dart'; |
11 | 12 |
12 import '../reflective_tests.dart'; | |
13 import '../utils.dart'; | 13 import '../utils.dart'; |
14 import 'resolver_test_case.dart'; | 14 import 'resolver_test_case.dart'; |
15 | 15 |
16 main() { | 16 main() { |
17 initializeTestEnvironment(); | 17 initializeTestEnvironment(); |
18 runReflectiveTests(StaticWarningCodeTest); | 18 defineReflectiveTests(StaticWarningCodeTest); |
19 } | 19 } |
20 | 20 |
21 @reflectiveTest | 21 @reflectiveTest |
22 class StaticWarningCodeTest extends ResolverTestCase { | 22 class StaticWarningCodeTest extends ResolverTestCase { |
23 void fail_argumentTypeNotAssignable_tearOff_required() { | 23 void fail_argumentTypeNotAssignable_tearOff_required() { |
24 Source source = addSource(r''' | 24 Source source = addSource(r''' |
25 class C { | 25 class C { |
26 Object/*=T*/ f/*<T>*/(Object/*=T*/ x) => x; | 26 Object/*=T*/ f/*<T>*/(Object/*=T*/ x) => x; |
27 } | 27 } |
28 g(C c) { | 28 g(C c) { |
(...skipping 3491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3520 computeLibrarySourceErrors(source); | 3520 computeLibrarySourceErrors(source); |
3521 assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]); | 3521 assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]); |
3522 } | 3522 } |
3523 | 3523 |
3524 void test_undefinedIdentifier_function() { | 3524 void test_undefinedIdentifier_function() { |
3525 Source source = addSource("int a() => b;"); | 3525 Source source = addSource("int a() => b;"); |
3526 computeLibrarySourceErrors(source); | 3526 computeLibrarySourceErrors(source); |
3527 assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]); | 3527 assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]); |
3528 } | 3528 } |
3529 | 3529 |
3530 void test_undefinedIdentifierAwait_function() { | |
3531 Source source = addSource("void a() { await; }"); | |
3532 computeLibrarySourceErrors(source); | |
3533 assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER_AWAIT]); | |
3534 } | |
3535 | |
3536 void test_undefinedIdentifier_importCore_withShow() { | 3530 void test_undefinedIdentifier_importCore_withShow() { |
3537 Source source = addSource(r''' | 3531 Source source = addSource(r''' |
3538 import 'dart:core' show List; | 3532 import 'dart:core' show List; |
3539 main() { | 3533 main() { |
3540 List; | 3534 List; |
3541 String; | 3535 String; |
3542 }'''); | 3536 }'''); |
3543 computeLibrarySourceErrors(source); | 3537 computeLibrarySourceErrors(source); |
3544 assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]); | 3538 assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]); |
3545 } | 3539 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3587 import 'lib.dart'; | 3581 import 'lib.dart'; |
3588 class B extends A { | 3582 class B extends A { |
3589 test() { | 3583 test() { |
3590 _foo = 42; | 3584 _foo = 42; |
3591 } | 3585 } |
3592 }'''); | 3586 }'''); |
3593 computeLibrarySourceErrors(source); | 3587 computeLibrarySourceErrors(source); |
3594 assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]); | 3588 assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER]); |
3595 } | 3589 } |
3596 | 3590 |
| 3591 void test_undefinedIdentifierAwait_function() { |
| 3592 Source source = addSource("void a() { await; }"); |
| 3593 computeLibrarySourceErrors(source); |
| 3594 assertErrors(source, [StaticWarningCode.UNDEFINED_IDENTIFIER_AWAIT]); |
| 3595 } |
| 3596 |
3597 void test_undefinedNamedParameter() { | 3597 void test_undefinedNamedParameter() { |
3598 Source source = addSource(r''' | 3598 Source source = addSource(r''' |
3599 f({a, b}) {} | 3599 f({a, b}) {} |
3600 main() { | 3600 main() { |
3601 f(c: 1); | 3601 f(c: 1); |
3602 }'''); | 3602 }'''); |
3603 computeLibrarySourceErrors(source); | 3603 computeLibrarySourceErrors(source); |
3604 assertErrors(source, [StaticWarningCode.UNDEFINED_NAMED_PARAMETER]); | 3604 assertErrors(source, [StaticWarningCode.UNDEFINED_NAMED_PARAMETER]); |
3605 // no verify(), 'c' is not resolved | 3605 // no verify(), 'c' is not resolved |
3606 } | 3606 } |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3680 | 3680 |
3681 void test_voidReturnForGetter() { | 3681 void test_voidReturnForGetter() { |
3682 Source source = addSource(r''' | 3682 Source source = addSource(r''' |
3683 class S { | 3683 class S { |
3684 void get value {} | 3684 void get value {} |
3685 }'''); | 3685 }'''); |
3686 computeLibrarySourceErrors(source); | 3686 computeLibrarySourceErrors(source); |
3687 assertErrors(source, [StaticWarningCode.VOID_RETURN_FOR_GETTER]); | 3687 assertErrors(source, [StaticWarningCode.VOID_RETURN_FOR_GETTER]); |
3688 } | 3688 } |
3689 } | 3689 } |
OLD | NEW |