From 81ecb88b631a9c1e677852a33ad916238dee0ef2 Mon Sep 17 00:00:00 2001 From: Ilya Yanok Date: Thu, 11 Apr 2024 05:55:48 -0700 Subject: [PATCH] Fix one README example that were broken by https://github.com/dart-lang/mockito/commit/1dcd8225e9014b17ba256d7fa1d056f339189630 Also sync the executable version of it with the README. Fixes https://github.com/dart-lang/mockito/issues/744 PiperOrigin-RevId: 623800048 --- README.md | 6 ++++-- example/example.dart | 7 +++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0189d40c..a9fdfac6 100644 --- a/README.md +++ b/README.md @@ -170,7 +170,10 @@ In most cases, both plain arguments and argument matchers can be passed into mock methods: ```dart -// You can use plain arguments themselves +// You can use `any` +when(cat.eatFood(any)).thenReturn(false); + +// ... or plain arguments themselves when(cat.eatFood("fish")).thenReturn(true); // ... including collections @@ -178,7 +181,6 @@ when(cat.walk(["roof","tree"])).thenReturn(2); // ... or matchers when(cat.eatFood(argThat(startsWith("dry")))).thenReturn(false); -when(cat.eatFood(any)).thenReturn(false); // ... or mix arguments with matchers when(cat.eatFood(argThat(startsWith("dry")), hungry: true)).thenReturn(true); diff --git a/example/example.dart b/example/example.dart index 1439ed2e..56270cd2 100644 --- a/example/example.dart +++ b/example/example.dart @@ -88,8 +88,11 @@ void main() { }); test('Argument matchers', () { - // You can use plain arguments themselves - when(cat.eatFood('fish')).thenReturn(true); + // You can use `any` + when(cat.eatFood(any)).thenReturn(false); + + // ... or plain arguments themselves + when(cat.eatFood("fish")).thenReturn(true); // ... including collections when(cat.walk(['roof', 'tree'])).thenReturn(2);