Unverified Commit 20fe2f88 authored by Jenn Magder's avatar Jenn Magder Committed by GitHub

Prefer tear offs to lambdas in test expects (#61196)

parent ed9a705e
...@@ -47,7 +47,7 @@ void main() { ...@@ -47,7 +47,7 @@ void main() {
'wobble': 'womble', 'wobble': 'womble',
}, },
); );
expect(() => fingerprinter.buildFingerprint(), throwsA(anything)); expect(fingerprinter.buildFingerprint, throwsA(anything));
}, overrides: contextOverrides); }, overrides: contextOverrides);
testUsingContext('creates fingerprint with specified properties and files', () { testUsingContext('creates fingerprint with specified properties and files', () {
......
...@@ -482,8 +482,8 @@ void main() { ...@@ -482,8 +482,8 @@ void main() {
expect(lines[1], equals('')); expect(lines[1], equals(''));
// Verify that stopping or canceling multiple times throws. // Verify that stopping or canceling multiple times throws.
expect(() { ansiStatus.cancel(); }, throwsAssertionError); expect(ansiStatus.cancel, throwsAssertionError);
expect(() { ansiStatus.stop(); }, throwsAssertionError); expect(ansiStatus.stop, throwsAssertionError);
done = true; done = true;
}); });
expect(done, isTrue); expect(done, isTrue);
......
...@@ -122,7 +122,7 @@ void main() { ...@@ -122,7 +122,7 @@ void main() {
await fileCache.diffFileList(<File>[file]); await fileCache.diffFileList(<File>[file]);
expect(() => fileCache.persist(), returnsNormally); expect(fileCache.persist, returnsNormally);
}); });
testWithoutContext('FileStore handles hashing missing files', () async { testWithoutContext('FileStore handles hashing missing files', () async {
......
...@@ -48,7 +48,7 @@ void main() { ...@@ -48,7 +48,7 @@ void main() {
}); });
test('should throw when locking is not acquired', () { test('should throw when locking is not acquired', () {
expect(() => Cache.checkLockAcquired(), throwsStateError); expect(Cache.checkLockAcquired, throwsStateError);
}); });
test('should not throw when locking is disabled', () { test('should not throw when locking is disabled', () {
...@@ -547,7 +547,7 @@ void main() { ...@@ -547,7 +547,7 @@ void main() {
final MockCache mockCache = MockCache(); final MockCache mockCache = MockCache();
final FontSubsetArtifacts artifacts = FontSubsetArtifacts(mockCache); final FontSubsetArtifacts artifacts = FontSubsetArtifacts(mockCache);
when(mockCache.includeAllPlatforms).thenReturn(false); when(mockCache.includeAllPlatforms).thenReturn(false);
expect(() => artifacts.getBinaryDirs(), throwsToolExit(message: 'Unsupported operating system: ${globals.platform.operatingSystem}')); expect(artifacts.getBinaryDirs, throwsToolExit(message: 'Unsupported operating system: ${globals.platform.operatingSystem}'));
}, overrides: <Type, Generator> { }, overrides: <Type, Generator> {
Platform: () => FakePlatform(operatingSystem: 'fuchsia'), Platform: () => FakePlatform(operatingSystem: 'fuchsia'),
}); });
......
...@@ -164,7 +164,7 @@ keep this 2 ...@@ -164,7 +164,7 @@ keep this 2
mockUsage, mockUsage,
); );
expect(() =>iosProjectMigration.migrate(), throwsToolExit(message: 'Your Xcode project requires migration')); expect(iosProjectMigration.migrate, throwsToolExit(message: 'Your Xcode project requires migration'));
verify(mockUsage.sendEvent('ios-migration', 'remove-frameworks', label: 'failure', value: null)); verify(mockUsage.sendEvent('ios-migration', 'remove-frameworks', label: 'failure', value: null));
}); });
...@@ -182,7 +182,7 @@ keep this 2 ...@@ -182,7 +182,7 @@ keep this 2
mockXcode, mockXcode,
mockUsage, mockUsage,
); );
expect(() =>iosProjectMigration.migrate(), throwsToolExit(message: 'Your Xcode project requires migration')); expect(iosProjectMigration.migrate, throwsToolExit(message: 'Your Xcode project requires migration'));
verify(mockUsage.sendEvent('ios-migration', 'remove-frameworks', label: 'failure', value: null)); verify(mockUsage.sendEvent('ios-migration', 'remove-frameworks', label: 'failure', value: null));
}); });
...@@ -198,7 +198,7 @@ keep this 2 ...@@ -198,7 +198,7 @@ keep this 2
mockXcode, mockXcode,
mockUsage, mockUsage,
); );
expect(() =>iosProjectMigration.migrate(), throwsToolExit(message: 'Your Xcode project requires migration')); expect(iosProjectMigration.migrate, throwsToolExit(message: 'Your Xcode project requires migration'));
verify(mockUsage.sendEvent('ios-migration', 'remove-frameworks', label: 'failure', value: null)); verify(mockUsage.sendEvent('ios-migration', 'remove-frameworks', label: 'failure', value: null));
}); });
...@@ -235,7 +235,7 @@ keep this 2 ...@@ -235,7 +235,7 @@ keep this 2
mockXcode, mockXcode,
mockUsage, mockUsage,
); );
expect(() =>iosProjectMigration.migrate(), throwsToolExit(message: 'Your Xcode project requires migration')); expect(iosProjectMigration.migrate, throwsToolExit(message: 'Your Xcode project requires migration'));
verify(mockUsage.sendEvent('ios-migration', 'remove-frameworks', label: 'failure', value: null)); verify(mockUsage.sendEvent('ios-migration', 'remove-frameworks', label: 'failure', value: null));
}); });
...@@ -253,7 +253,7 @@ keep this 2 ...@@ -253,7 +253,7 @@ keep this 2
mockXcode, mockXcode,
mockUsage, mockUsage,
); );
expect(() =>iosProjectMigration.migrate(), throwsToolExit(message: 'Your Xcode project requires migration')); expect(iosProjectMigration.migrate, throwsToolExit(message: 'Your Xcode project requires migration'));
verify(mockUsage.sendEvent('ios-migration', 'remove-frameworks', label: 'failure', value: null)); verify(mockUsage.sendEvent('ios-migration', 'remove-frameworks', label: 'failure', value: null));
}); });
}); });
......
...@@ -474,7 +474,7 @@ Information about project "Runner": ...@@ -474,7 +474,7 @@ Information about project "Runner":
); );
expect( expect(
() => defaultInfo.reportFlavorNotFoundAndExit(), defaultInfo.reportFlavorNotFoundAndExit,
throwsToolExit( throwsToolExit(
message: 'The Xcode project does not define custom schemes. You cannot use the --flavor option.' message: 'The Xcode project does not define custom schemes. You cannot use the --flavor option.'
), ),
...@@ -490,7 +490,7 @@ Information about project "Runner": ...@@ -490,7 +490,7 @@ Information about project "Runner":
); );
expect( expect(
() => info.reportFlavorNotFoundAndExit(), info.reportFlavorNotFoundAndExit,
throwsToolExit( throwsToolExit(
message: 'You must specify a --flavor option to select one of the available schemes.' message: 'You must specify a --flavor option to select one of the available schemes.'
), ),
......
...@@ -135,7 +135,7 @@ void main() { ...@@ -135,7 +135,7 @@ void main() {
); );
final MDnsObservatoryDiscovery portDiscovery = MDnsObservatoryDiscovery(mdnsClient: client); final MDnsObservatoryDiscovery portDiscovery = MDnsObservatoryDiscovery(mdnsClient: client);
expect(() => portDiscovery.query(), throwsToolExit()); expect(portDiscovery.query, throwsToolExit());
}); });
testUsingContext('Multiple ports available, with appId', () async { testUsingContext('Multiple ports available, with appId', () async {
......
...@@ -24,7 +24,7 @@ void main() { ...@@ -24,7 +24,7 @@ void main() {
flutterUsage: usage, flutterUsage: usage,
); );
expect(() => doctorResultEvent.send(), returnsNormally); expect(doctorResultEvent.send, returnsNormally);
verify(usage.sendEvent('doctor-result', any, label: anyNamed('label'))).called(3); verify(usage.sendEvent('doctor-result', any, label: anyNamed('label'))).called(3);
}); });
...@@ -46,7 +46,7 @@ void main() { ...@@ -46,7 +46,7 @@ void main() {
flutterUsage: usage, flutterUsage: usage,
); );
expect(() => doctorResultEvent.send(), returnsNormally); expect(doctorResultEvent.send, returnsNormally);
verify(usage.sendEvent('doctor-result', any, label: anyNamed('label'))).called(1); verify(usage.sendEvent('doctor-result', any, label: anyNamed('label'))).called(1);
}); });
......
...@@ -875,7 +875,7 @@ void main() { ...@@ -875,7 +875,7 @@ void main() {
testUsingContext('ResidentRunner does support CanvasKit', () => testbed.run(() async { testUsingContext('ResidentRunner does support CanvasKit', () => testbed.run(() async {
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[]); fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[]);
expect(() => residentRunner.toggleCanvaskit(), expect(residentRunner.toggleCanvaskit,
throwsA(isA<Exception>())); throwsA(isA<Exception>()));
})); }));
......
...@@ -1560,7 +1560,7 @@ void main() { ...@@ -1560,7 +1560,7 @@ void main() {
when(mockWebDevFS.connect(any)) when(mockWebDevFS.connect(any))
.thenThrow(const WebSocketException()); .thenThrow(const WebSocketException());
await expectLater(() => residentWebRunner.run(), throwsToolExit()); await expectLater(residentWebRunner.run, throwsToolExit());
expect(fakeVmServiceHost.hasRemainingExpectations, false); expect(fakeVmServiceHost.hasRemainingExpectations, false);
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
FileSystem: () => fileSystem, FileSystem: () => fileSystem,
...@@ -1577,7 +1577,7 @@ void main() { ...@@ -1577,7 +1577,7 @@ void main() {
when(mockWebDevFS.connect(any)) when(mockWebDevFS.connect(any))
.thenThrow(AppConnectionException('')); .thenThrow(AppConnectionException(''));
await expectLater(() => residentWebRunner.run(), throwsToolExit()); await expectLater(residentWebRunner.run, throwsToolExit());
expect(fakeVmServiceHost.hasRemainingExpectations, false); expect(fakeVmServiceHost.hasRemainingExpectations, false);
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
FileSystem: () => fileSystem, FileSystem: () => fileSystem,
...@@ -1594,7 +1594,7 @@ void main() { ...@@ -1594,7 +1594,7 @@ void main() {
when(mockWebDevFS.connect(any)) when(mockWebDevFS.connect(any))
.thenThrow(ChromeDebugException(<String, dynamic>{})); .thenThrow(ChromeDebugException(<String, dynamic>{}));
await expectLater(() => residentWebRunner.run(), throwsToolExit()); await expectLater(residentWebRunner.run, throwsToolExit());
expect(fakeVmServiceHost.hasRemainingExpectations, false); expect(fakeVmServiceHost.hasRemainingExpectations, false);
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
FileSystem: () => fileSystem, FileSystem: () => fileSystem,
...@@ -1609,7 +1609,7 @@ void main() { ...@@ -1609,7 +1609,7 @@ void main() {
_setupMocks(); _setupMocks();
when(mockWebDevFS.connect(any)).thenThrow(Exception()); when(mockWebDevFS.connect(any)).thenThrow(Exception());
await expectLater(() => residentWebRunner.run(), throwsException); await expectLater(residentWebRunner.run, throwsException);
expect(fakeVmServiceHost.hasRemainingExpectations, false); expect(fakeVmServiceHost.hasRemainingExpectations, false);
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
FileSystem: () => fileSystem, FileSystem: () => fileSystem,
...@@ -1628,7 +1628,7 @@ void main() { ...@@ -1628,7 +1628,7 @@ void main() {
when(mockWebDevFS.connect(any)).thenThrow(StateError('')); when(mockWebDevFS.connect(any)).thenThrow(StateError(''));
await expectLater(() => residentWebRunner.run(), throwsStateError); await expectLater(residentWebRunner.run, throwsStateError);
verify(mockStatus.stop()).called(1); verify(mockStatus.stop()).called(1);
expect(fakeVmServiceHost.hasRemainingExpectations, false); expect(fakeVmServiceHost.hasRemainingExpectations, false);
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment