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

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

Issue 1644683002: A missing enum case in a switch is a warning, not a compile-time error. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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 'package:analyzer/src/generated/error.dart'; 7 import 'package:analyzer/src/generated/error.dart';
8 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode; 8 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode;
9 import 'package:analyzer/src/generated/source_io.dart'; 9 import 'package:analyzer/src/generated/source_io.dart';
10 10
(...skipping 3529 matching lines...) Expand 10 before | Expand all | Expand 10 after
3540 class A { 3540 class A {
3541 get x => 0; 3541 get x => 0;
3542 x(y) {} 3542 x(y) {}
3543 }'''); 3543 }''');
3544 computeLibrarySourceErrors(source); 3544 computeLibrarySourceErrors(source);
3545 assertErrors( 3545 assertErrors(
3546 source, [CompileTimeErrorCode.METHOD_AND_GETTER_WITH_SAME_NAME]); 3546 source, [CompileTimeErrorCode.METHOD_AND_GETTER_WITH_SAME_NAME]);
3547 verify([source]); 3547 verify([source]);
3548 } 3548 }
3549 3549
3550 void test_missingEnumConstantInSwitch() {
3551 Source source = addSource(r'''
3552 enum E { ONE, TWO, THREE, FOUR }
3553 bool odd(E e) {
3554 switch (e) {
3555 case E.ONE:
3556 case E.THREE: return true;
3557 }
3558 return false;
3559 }''');
3560 computeLibrarySourceErrors(source);
3561 assertErrors(source, [
3562 CompileTimeErrorCode.MISSING_ENUM_CONSTANT_IN_SWITCH,
3563 CompileTimeErrorCode.MISSING_ENUM_CONSTANT_IN_SWITCH
3564 ]);
3565 verify([source]);
3566 }
3567
3568 void test_mixinDeclaresConstructor_classDeclaration() { 3550 void test_mixinDeclaresConstructor_classDeclaration() {
3569 Source source = addSource(r''' 3551 Source source = addSource(r'''
3570 class A { 3552 class A {
3571 A() {} 3553 A() {}
3572 } 3554 }
3573 class B extends Object with A {}'''); 3555 class B extends Object with A {}''');
3574 computeLibrarySourceErrors(source); 3556 computeLibrarySourceErrors(source);
3575 assertErrors(source, [CompileTimeErrorCode.MIXIN_DECLARES_CONSTRUCTOR]); 3557 assertErrors(source, [CompileTimeErrorCode.MIXIN_DECLARES_CONSTRUCTOR]);
3576 verify([source]); 3558 verify([source]);
3577 } 3559 }
(...skipping 2707 matching lines...) Expand 10 before | Expand all | Expand 10 after
6285 source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR]); 6267 source, [CompileTimeErrorCode.WRONG_NUMBER_OF_PARAMETERS_FOR_OPERATOR]);
6286 verify([source]); 6268 verify([source]);
6287 reset(); 6269 reset();
6288 } 6270 }
6289 6271
6290 void _check_wrongNumberOfParametersForOperator1(String name) { 6272 void _check_wrongNumberOfParametersForOperator1(String name) {
6291 _check_wrongNumberOfParametersForOperator(name, ""); 6273 _check_wrongNumberOfParametersForOperator(name, "");
6292 _check_wrongNumberOfParametersForOperator(name, "a, b"); 6274 _check_wrongNumberOfParametersForOperator(name, "a, b");
6293 } 6275 }
6294 } 6276 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/error_verifier.dart ('k') | pkg/analyzer/test/generated/static_warning_code_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698