mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 04:27:17 +00:00
Fix warnings in nnbd_migration.
R=brianwilkerson@google.com, paulberry@google.com Change-Id: I56fd93eec4a300ed869c0208e2b1544d18fa183b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/143242 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
parent
c57fe977f0
commit
115fb42a01
|
@ -639,7 +639,7 @@ void f(num n, int?/*?*/ i) {
|
|||
region: regions[1],
|
||||
offset: migratedContent.indexOf(' as int'),
|
||||
length: ' as int'.length,
|
||||
explanation: "Discarded a downcast that is now unnecessary",
|
||||
explanation: 'Discarded a downcast that is now unnecessary',
|
||||
kind: NullabilityFixKind.removeAs);
|
||||
assertRegion(
|
||||
region: regions[2],
|
||||
|
|
|
@ -14,6 +14,15 @@ void main() {
|
|||
|
||||
@reflectiveTest
|
||||
class UnitInfoTest {
|
||||
static bool get _areAssertsEnabled {
|
||||
try {
|
||||
assert(false);
|
||||
return false;
|
||||
} on AssertionError {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void test_hadOriginalContent_different() {
|
||||
final unitInfo = UnitInfo('/foo.dart');
|
||||
unitInfo.originalContent = 'abcd';
|
||||
|
@ -41,22 +50,15 @@ class UnitInfoTest {
|
|||
}
|
||||
|
||||
void test_hadOriginalContent_usedBeforeSet_assertsDisabled() {
|
||||
try {
|
||||
assert(false);
|
||||
} on AssertionError {
|
||||
// Asserts enabled, stop here
|
||||
return;
|
||||
}
|
||||
if (_areAssertsEnabled) return;
|
||||
|
||||
final unitInfo = UnitInfo('/foo.dart');
|
||||
expect(unitInfo.hadOriginalContent(''), false);
|
||||
}
|
||||
|
||||
void test_hadOriginalContent_usedBeforeSet_assertsEnabled() {
|
||||
try {
|
||||
assert(false);
|
||||
// asserts not enabled, stop here.
|
||||
return;
|
||||
} on AssertionError {}
|
||||
if (!_areAssertsEnabled) return;
|
||||
|
||||
final unitInfo = UnitInfo('/foo.dart');
|
||||
expect(
|
||||
() => unitInfo.hadOriginalContent(''), throwsA(isA<AssertionError>()));
|
||||
|
|
Loading…
Reference in a new issue