-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
linter: Move tests for 3 lint rules:
* no_default_cases tests * overridden_fields * unnecessary_lambdas Change-Id: Ib84fca717b6ef8badae2ebe41bc42dfa34fb8407 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392160 Reviewed-by: Phil Quitslund <[email protected]> Commit-Queue: Phil Quitslund <[email protected]> Auto-Submit: Samuel Rawlins <[email protected]>
- Loading branch information
Showing
7 changed files
with
210 additions
and
232 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
import 'package:test_reflective_loader/test_reflective_loader.dart'; | ||
|
||
import '../rule_test_support.dart'; | ||
|
||
main() { | ||
defineReflectiveSuite(() { | ||
defineReflectiveTests(NoDefaultCasesTest); | ||
}); | ||
} | ||
|
||
@reflectiveTest | ||
class NoDefaultCasesTest extends LintRuleTest { | ||
@override | ||
String get lintRule => 'no_default_cases'; | ||
|
||
test_enumLikeType() async { | ||
await assertDiagnostics(r''' | ||
class C { | ||
final int i; | ||
const C._(this.i); | ||
static const a = C._(1); | ||
static const b = C._(2); | ||
static const c = C._(3); | ||
} | ||
void f(C c) { | ||
switch (c) { | ||
case C.a : | ||
print('a'); | ||
break; | ||
default: | ||
print('default'); | ||
} | ||
} | ||
''', [ | ||
lint(210, 32), | ||
]); | ||
} | ||
|
||
test_enumType() async { | ||
await assertDiagnostics(r''' | ||
void f(E e) { | ||
switch(e) { | ||
case E.a : | ||
print('a'); | ||
break; | ||
default: | ||
print('default'); | ||
} | ||
} | ||
enum E { | ||
a, b, c; | ||
} | ||
''', [ | ||
lint(78, 32), | ||
]); | ||
} | ||
|
||
test_intType() async { | ||
await assertNoDiagnostics(r''' | ||
void f(int i) { | ||
switch (i) { | ||
case 1 : | ||
print('1'); | ||
break; | ||
default: | ||
print('default'); | ||
} | ||
} | ||
'''); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.