Skip to content

Commit 9214e05

Browse files
authored
Convert more test files to null-safety (#1683)
1 parent 8c8edc1 commit 9214e05

8 files changed

+21
-34
lines changed

dwds/test/build/ensure_version_test.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// @dart = 2.9
6-
75
@TestOn('vm')
86
import 'dart:io';
97

dwds/test/build/min_sdk_test.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// @dart = 2.9
6-
75
@TestOn('vm')
86
@Skip('Intended to run in analyze stage on stable SDK only, see mono_pkg.yaml')
97
import 'dart:io';
@@ -19,8 +17,9 @@ void main() {
1917
sdkVersion = Version(sdkVersion.major, sdkVersion.minor, 0);
2018

2119
final sdkConstraint = VersionConstraint.compatibleWith(sdkVersion);
22-
final pubspecSdkConstraint = pubspec.environment['sdk'];
23-
expect(sdkConstraint.allowsAll(pubspecSdkConstraint), true,
20+
final pubspecSdkConstraint = pubspec.environment?['sdk'];
21+
expect(pubspecSdkConstraint, isNotNull);
22+
expect(sdkConstraint.allowsAll(pubspecSdkConstraint!), true,
2423
reason:
2524
'Min sdk constraint is outdated. Please update SDK constraint in '
2625
'pubspec to allow latest stable and backwards compatible versions.'

dwds/test/extension_backend_test.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// @dart = 2.9
6-
75
import 'dart:async';
86

97
import 'package:async/src/stream_queue.dart';
@@ -31,7 +29,7 @@ class MockSocketHandler implements SocketHandler {
3129
}
3230

3331
void main() {
34-
ExtensionBackend extensionBackend;
32+
late ExtensionBackend extensionBackend;
3533

3634
setUpAll(() async {
3735
extensionBackend =

dwds/test/metadata/class_test.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// @dart = 2.9
6-
75
import 'package:dwds/src/debugging/metadata/class.dart';
86
import 'package:test/test.dart';
97

dwds/test/objects_test.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// @dart = 2.9
6-
75
@TestOn('vm')
86
import 'package:dwds/src/utilities/objects.dart';
97
import 'package:test/test.dart';
@@ -18,16 +16,18 @@ void main() {
1816
// or from a RemoteObject.
1917
final property = Property({'name': 'prop', 'value': exampleMap});
2018
expect(property.rawValue, exampleMap);
21-
expect(property.value.objectId, '1234');
22-
expect(property.value.value, 'abcd');
19+
final value = property.value!;
20+
expect(value.objectId, '1234');
21+
expect(value.value, 'abcd');
2322
expect(property.name, 'prop');
2423
});
2524
test('from a RemoteObject', () {
2625
final remoteObject = RemoteObject({'objectId': '1234', 'value': 'abcd'});
2726
final property = Property({'name': 'prop', 'value': remoteObject});
2827
expect(property.rawValue, remoteObject);
29-
expect(property.value.objectId, '1234');
30-
expect(property.value.value, 'abcd');
28+
final value = property.value!;
29+
expect(value.objectId, '1234');
30+
expect(value.value, 'abcd');
3131
expect(property.name, 'prop');
3232
});
3333

dwds/test/readers/frontend_server_asset_reader_test.dart

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// @dart = 2.9
6-
75
import 'dart:async';
86
import 'dart:io';
97

@@ -16,10 +14,10 @@ import '../fixtures/utilities.dart';
1614
final packagesDir = p.relative('../fixtures/_test', from: p.current);
1715

1816
void main() {
19-
FrontendServerAssetReader assetReader;
20-
Directory tempFixtures;
21-
File jsonOriginal;
22-
File mapOriginal;
17+
late FrontendServerAssetReader assetReader;
18+
late Directory tempFixtures;
19+
late File jsonOriginal;
20+
late File mapOriginal;
2321

2422
Future<void> createTempFixtures() async {
2523
final fixtures = p.join('test', 'fixtures');

dwds/test/sdk_configuration_test.dart

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// @dart = 2.9
6-
75
@TestOn('vm')
86
import 'dart:io';
97

@@ -34,15 +32,15 @@ void main() {
3432
});
3533

3634
group('Non-standard configuration', () {
37-
Directory outputDir;
35+
late Directory outputDir;
3836

3937
setUp(() async {
4038
final systemTempDir = Directory.systemTemp;
4139
outputDir = systemTempDir.createTempSync('foo bar');
4240
});
4341

4442
tearDown(() async {
45-
await outputDir?.delete(recursive: true);
43+
await outputDir.delete(recursive: true);
4644
});
4745

4846
test('Can validate existing configuration layout', () async {
@@ -54,24 +52,24 @@ void main() {
5452
final librariesPath = p.join(librariesDir, 'libraries.json');
5553

5654
Directory(librariesDir).createSync(recursive: true);
57-
File(defaultSdkConfiguration.librariesPath).copySync(librariesPath);
55+
File(defaultSdkConfiguration.librariesPath!).copySync(librariesPath);
5856

5957
final summariesDir = p.join(sdkDirectory, 'summaries');
6058
final unsoundSdkSummaryPath = p.join(summariesDir, 'ddc_sdk.dill');
6159
final soundSdkSummaryPath =
6260
p.join(summariesDir, 'ddc_outline_sound.dill');
6361

6462
Directory(summariesDir).createSync(recursive: true);
65-
File(defaultSdkConfiguration.unsoundSdkSummaryPath)
63+
File(defaultSdkConfiguration.unsoundSdkSummaryPath!)
6664
.copySync(unsoundSdkSummaryPath);
67-
File(defaultSdkConfiguration.soundSdkSummaryPath)
65+
File(defaultSdkConfiguration.soundSdkSummaryPath!)
6866
.copySync(soundSdkSummaryPath);
6967

7068
final workerDir = p.join(sdkDirectory, 'snapshots');
7169
final compilerWorkerPath = p.join(workerDir, 'dartdevc.dart.snapshot');
7270

7371
Directory(workerDir).createSync(recursive: true);
74-
File(defaultSdkConfiguration.compilerWorkerPath)
72+
File(defaultSdkConfiguration.compilerWorkerPath!)
7573
.copySync(compilerWorkerPath);
7674

7775
final sdkConfiguration = SdkConfiguration(
@@ -118,7 +116,7 @@ void main() {
118116
});
119117

120118
group('SDK configuration', () {
121-
MemoryFileSystem fs;
119+
late MemoryFileSystem fs;
122120

123121
final root = '/root';
124122
final sdkDirectory = root;

dwds/test/web/batched_stream_test.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// @dart = 2.9
6-
75
@Retry(0)
86

97
import 'dart:async';

0 commit comments

Comments
 (0)