Issue #1244: Utils functions updated according to the Effective Dart Guide, relative tests updated accordingly.
diff --git a/Language/Libraries_and_Scripts/Scripts/top_level_main_t01.dart b/Language/Libraries_and_Scripts/Scripts/top_level_main_t01.dart
index fc26d1f..6387547 100644
--- a/Language/Libraries_and_Scripts/Scripts/top_level_main_t01.dart
+++ b/Language/Libraries_and_Scripts/Scripts/top_level_main_t01.dart
@@ -16,7 +16,7 @@
run_main() async {
String executable = Platform.resolvedExecutable;
String eScript = Platform.script.toString().replaceAll(".dart", "_lib.dart");
- if (isAOT) {
+ if (isAot) {
// This is the case of AOT configuration
executable = executable.replaceRange(
executable.lastIndexOf(Platform.pathSeparator) + 1, null, "dart");
diff --git a/Language/Libraries_and_Scripts/Scripts/top_level_main_t06.dart b/Language/Libraries_and_Scripts/Scripts/top_level_main_t06.dart
index 689e9c2..486c6cb 100644
--- a/Language/Libraries_and_Scripts/Scripts/top_level_main_t06.dart
+++ b/Language/Libraries_and_Scripts/Scripts/top_level_main_t06.dart
@@ -16,7 +16,7 @@
run_main() async {
String executable = Platform.resolvedExecutable;
String eScript = Platform.script.toString().replaceAll(".dart", "_lib.dart");
- if (isAOT) {
+ if (isAot) {
// This is the case of AOT configuration
executable = executable.replaceRange(
executable.lastIndexOf(Platform.pathSeparator) + 1, null, "dart");
diff --git a/LanguageFeatures/nnbd/overriding/override_checking_A06_t001.dart b/LanguageFeatures/nnbd/overriding/override_checking_A06_t001.dart
index d7026e7..ad35ce6 100644
--- a/LanguageFeatures/nnbd/overriding/override_checking_A06_t001.dart
+++ b/LanguageFeatures/nnbd/overriding/override_checking_A06_t001.dart
@@ -18,8 +18,8 @@
import "../../../Utils/expect.dart";
-class B extends CHECK_TOP_MERGE<Object> {}
-class C extends CHECK_TOP_MERGE<Object> {}
+class B extends CheckTopMerge<Object> {}
+class C extends CheckTopMerge<Object> {}
class D extends B implements C {}
diff --git a/LanguageFeatures/nnbd/overriding/override_checking_A06_t002.dart b/LanguageFeatures/nnbd/overriding/override_checking_A06_t002.dart
index ae55ab6..638a491 100644
--- a/LanguageFeatures/nnbd/overriding/override_checking_A06_t002.dart
+++ b/LanguageFeatures/nnbd/overriding/override_checking_A06_t002.dart
@@ -18,8 +18,8 @@
import "../../../Utils/expect.dart";
-class B extends CHECK_TOP_MERGE<Object?> {}
-class C extends CHECK_TOP_MERGE<Object?> {}
+class B extends CheckTopMerge<Object?> {}
+class C extends CheckTopMerge<Object?> {}
class D extends B implements C {}
diff --git a/LanguageFeatures/nnbd/overriding/override_checking_A06_t010.dart b/LanguageFeatures/nnbd/overriding/override_checking_A06_t010.dart
index d4c37a0..3bff62c 100644
--- a/LanguageFeatures/nnbd/overriding/override_checking_A06_t010.dart
+++ b/LanguageFeatures/nnbd/overriding/override_checking_A06_t010.dart
@@ -19,8 +19,8 @@
import "../../../Utils/expect.dart";
-class B extends CHECK_TOP_MERGE<Object?> {}
-class C extends CHECK_TOP_MERGE<dynamic> {}
+class B extends CheckTopMerge<Object?> {}
+class C extends CheckTopMerge<dynamic> {}
class D1 extends B implements C {}
class D2 extends C implements B {}
diff --git a/LanguageFeatures/nnbd/overriding/override_checking_A06_t011.dart b/LanguageFeatures/nnbd/overriding/override_checking_A06_t011.dart
index 9343dde..cf5974d 100644
--- a/LanguageFeatures/nnbd/overriding/override_checking_A06_t011.dart
+++ b/LanguageFeatures/nnbd/overriding/override_checking_A06_t011.dart
@@ -19,8 +19,8 @@
import "../../../Utils/expect.dart";
-class B extends CHECK_TOP_MERGE<Object?> {}
-class C extends CHECK_TOP_MERGE<void > {}
+class B extends CheckTopMerge<Object?> {}
+class C extends CheckTopMerge<void > {}
class D1 extends B implements C {}
class D2 extends C implements B {}
diff --git a/LanguageFeatures/nnbd/overriding/override_checking_A06_t015.dart b/LanguageFeatures/nnbd/overriding/override_checking_A06_t015.dart
index 1408b32..d4841d6 100644
--- a/LanguageFeatures/nnbd/overriding/override_checking_A06_t015.dart
+++ b/LanguageFeatures/nnbd/overriding/override_checking_A06_t015.dart
@@ -19,8 +19,8 @@
import "../../../Utils/expect.dart";
-class B extends CHECK_TOP_MERGE<int> {}
-class C extends CHECK_TOP_MERGE<int> {}
+class B extends CheckTopMerge<int> {}
+class C extends CheckTopMerge<int> {}
class D extends B implements C {}
diff --git a/LanguageFeatures/nnbd/overriding/override_checking_A06_t017.dart b/LanguageFeatures/nnbd/overriding/override_checking_A06_t017.dart
index 22b25b4..0e6da6a 100644
--- a/LanguageFeatures/nnbd/overriding/override_checking_A06_t017.dart
+++ b/LanguageFeatures/nnbd/overriding/override_checking_A06_t017.dart
@@ -18,8 +18,8 @@
import "../../../Utils/expect.dart";
-class B extends CHECK_TOP_MERGE<int?> {}
-class C extends CHECK_TOP_MERGE<int?> {}
+class B extends CheckTopMerge<int?> {}
+class C extends CheckTopMerge<int?> {}
class D extends B implements C {}
diff --git a/LanguageFeatures/nnbd/overriding/override_checking_A06_t036.dart b/LanguageFeatures/nnbd/overriding/override_checking_A06_t036.dart
index 9ce2e01..a8e796d 100644
--- a/LanguageFeatures/nnbd/overriding/override_checking_A06_t036.dart
+++ b/LanguageFeatures/nnbd/overriding/override_checking_A06_t036.dart
@@ -18,8 +18,8 @@
import "../../../Utils/expect.dart";
-class B extends CHECK_TOP_MERGE<Function?> {}
-class C extends CHECK_TOP_MERGE<Function?> {}
+class B extends CheckTopMerge<Function?> {}
+class C extends CheckTopMerge<Function?> {}
class D extends B implements C {}
diff --git a/LanguageFeatures/nnbd/overriding/override_checking_A06_t037.dart b/LanguageFeatures/nnbd/overriding/override_checking_A06_t037.dart
index b48318b..857f400 100644
--- a/LanguageFeatures/nnbd/overriding/override_checking_A06_t037.dart
+++ b/LanguageFeatures/nnbd/overriding/override_checking_A06_t037.dart
@@ -18,8 +18,8 @@
import "../../../Utils/expect.dart";
-class B extends CHECK_TOP_MERGE<Function> {}
-class C extends CHECK_TOP_MERGE<Function> {}
+class B extends CheckTopMerge<Function> {}
+class C extends CheckTopMerge<Function> {}
class D extends B implements C {}
diff --git a/LanguageFeatures/nnbd/overriding/override_checking_A06_t039.dart b/LanguageFeatures/nnbd/overriding/override_checking_A06_t039.dart
index d8392de..562900b 100644
--- a/LanguageFeatures/nnbd/overriding/override_checking_A06_t039.dart
+++ b/LanguageFeatures/nnbd/overriding/override_checking_A06_t039.dart
@@ -18,8 +18,8 @@
import "../../../Utils/expect.dart";
-class B extends CHECK_TOP_MERGE<dynamic> {}
-class C extends CHECK_TOP_MERGE<dynamic> {}
+class B extends CheckTopMerge<dynamic> {}
+class C extends CheckTopMerge<dynamic> {}
class D extends B implements C {}
diff --git a/LanguageFeatures/nnbd/overriding/override_checking_A06_t042.dart b/LanguageFeatures/nnbd/overriding/override_checking_A06_t042.dart
index dd27e51..303f0d5 100644
--- a/LanguageFeatures/nnbd/overriding/override_checking_A06_t042.dart
+++ b/LanguageFeatures/nnbd/overriding/override_checking_A06_t042.dart
@@ -19,8 +19,8 @@
import "../../../Utils/expect.dart";
-class B extends CHECK_TOP_MERGE<dynamic> {}
-class C extends CHECK_TOP_MERGE<void > {}
+class B extends CheckTopMerge<dynamic> {}
+class C extends CheckTopMerge<void > {}
class D1 extends B implements C {}
class D2 extends C implements B {}
diff --git a/LanguageFeatures/nnbd/overriding/override_checking_A06_t048.dart b/LanguageFeatures/nnbd/overriding/override_checking_A06_t048.dart
index 7f031df..4a57595 100644
--- a/LanguageFeatures/nnbd/overriding/override_checking_A06_t048.dart
+++ b/LanguageFeatures/nnbd/overriding/override_checking_A06_t048.dart
@@ -18,8 +18,8 @@
import "../../../Utils/expect.dart";
-class B extends CHECK_TOP_MERGE<void> {}
-class C extends CHECK_TOP_MERGE<void> {}
+class B extends CheckTopMerge<void> {}
+class C extends CheckTopMerge<void> {}
class D extends B implements C {}
diff --git a/LanguageFeatures/nnbd/overriding/override_checking_A06_t057.dart b/LanguageFeatures/nnbd/overriding/override_checking_A06_t057.dart
index fd27fe1..174695e 100644
--- a/LanguageFeatures/nnbd/overriding/override_checking_A06_t057.dart
+++ b/LanguageFeatures/nnbd/overriding/override_checking_A06_t057.dart
@@ -18,8 +18,8 @@
import "../../../Utils/expect.dart";
-class B extends CHECK_TOP_MERGE<Null> {}
-class C extends CHECK_TOP_MERGE<Null> {}
+class B extends CheckTopMerge<Null> {}
+class C extends CheckTopMerge<Null> {}
class D extends B implements C {}
diff --git a/LanguageFeatures/nnbd/overriding/override_checking_A06_t062.dart b/LanguageFeatures/nnbd/overriding/override_checking_A06_t062.dart
index 4d34639..716f543 100644
--- a/LanguageFeatures/nnbd/overriding/override_checking_A06_t062.dart
+++ b/LanguageFeatures/nnbd/overriding/override_checking_A06_t062.dart
@@ -19,8 +19,8 @@
import "dart:async";
import "../../../Utils/expect.dart";
-class B extends CHECK_TOP_MERGE<FutureOr> {}
-class C extends CHECK_TOP_MERGE<FutureOr> {}
+class B extends CheckTopMerge<FutureOr> {}
+class C extends CheckTopMerge<FutureOr> {}
class D extends B implements C {}
diff --git a/LanguageFeatures/nnbd/overriding/override_checking_A06_t064.dart b/LanguageFeatures/nnbd/overriding/override_checking_A06_t064.dart
index 7e0f327..2dece33 100644
--- a/LanguageFeatures/nnbd/overriding/override_checking_A06_t064.dart
+++ b/LanguageFeatures/nnbd/overriding/override_checking_A06_t064.dart
@@ -20,8 +20,8 @@
import "dart:async";
import "../../../Utils/expect.dart";
-class B extends CHECK_TOP_MERGE<FutureOr> {}
-class C extends CHECK_TOP_MERGE<Object? > {}
+class B extends CheckTopMerge<FutureOr> {}
+class C extends CheckTopMerge<Object? > {}
class D1 extends C implements B {}
class D2 extends B implements C {}
diff --git a/LanguageFeatures/nnbd/overriding/override_checking_A06_t067.dart b/LanguageFeatures/nnbd/overriding/override_checking_A06_t067.dart
index 2d029a6..b61bde7 100644
--- a/LanguageFeatures/nnbd/overriding/override_checking_A06_t067.dart
+++ b/LanguageFeatures/nnbd/overriding/override_checking_A06_t067.dart
@@ -20,8 +20,8 @@
import "dart:async";
import "../../../Utils/expect.dart";
-class B extends CHECK_TOP_MERGE<FutureOr> {}
-class C extends CHECK_TOP_MERGE<dynamic > {}
+class B extends CheckTopMerge<FutureOr> {}
+class C extends CheckTopMerge<dynamic > {}
class D1 extends C implements B {}
class D2 extends B implements C {}
diff --git a/LanguageFeatures/nnbd/overriding/override_checking_A06_t068.dart b/LanguageFeatures/nnbd/overriding/override_checking_A06_t068.dart
index dbc600c..eb62f83 100644
--- a/LanguageFeatures/nnbd/overriding/override_checking_A06_t068.dart
+++ b/LanguageFeatures/nnbd/overriding/override_checking_A06_t068.dart
@@ -20,8 +20,8 @@
import "dart:async";
import "../../../Utils/expect.dart";
-class B extends CHECK_TOP_MERGE<FutureOr> {}
-class C extends CHECK_TOP_MERGE<void > {}
+class B extends CheckTopMerge<FutureOr> {}
+class C extends CheckTopMerge<void > {}
class D1 extends C implements B {}
class D2 extends B implements C {}
diff --git a/LanguageFeatures/nnbd/overriding/override_checking_A06_t075.dart b/LanguageFeatures/nnbd/overriding/override_checking_A06_t075.dart
index b33b47a..7059362 100644
--- a/LanguageFeatures/nnbd/overriding/override_checking_A06_t075.dart
+++ b/LanguageFeatures/nnbd/overriding/override_checking_A06_t075.dart
@@ -19,8 +19,8 @@
import "dart:async";
import "../../../Utils/expect.dart";
-class B extends CHECK_TOP_MERGE<FutureOr<int>> {}
-class C extends CHECK_TOP_MERGE<FutureOr<int>> {}
+class B extends CheckTopMerge<FutureOr<int>> {}
+class C extends CheckTopMerge<FutureOr<int>> {}
class D extends B implements C {}
diff --git a/LanguageFeatures/nnbd/overriding/override_checking_A06_t076.dart b/LanguageFeatures/nnbd/overriding/override_checking_A06_t076.dart
index bfe3615..6729c07 100644
--- a/LanguageFeatures/nnbd/overriding/override_checking_A06_t076.dart
+++ b/LanguageFeatures/nnbd/overriding/override_checking_A06_t076.dart
@@ -19,8 +19,8 @@
import "dart:async";
import "../../../Utils/expect.dart";
-class B extends CHECK_TOP_MERGE<FutureOr<int?>> {}
-class C extends CHECK_TOP_MERGE<FutureOr<int?>> {}
+class B extends CheckTopMerge<FutureOr<int?>> {}
+class C extends CheckTopMerge<FutureOr<int?>> {}
class D extends B implements C {}
diff --git a/LanguageFeatures/nnbd/overriding/override_checking_A06_t077.dart b/LanguageFeatures/nnbd/overriding/override_checking_A06_t077.dart
index 9f76fcf..ed09133 100644
--- a/LanguageFeatures/nnbd/overriding/override_checking_A06_t077.dart
+++ b/LanguageFeatures/nnbd/overriding/override_checking_A06_t077.dart
@@ -19,8 +19,8 @@
import "dart:async";
import "../../../Utils/expect.dart";
-class B extends CHECK_TOP_MERGE<FutureOr<FutureOr>> {}
-class C extends CHECK_TOP_MERGE<FutureOr<FutureOr>> {}
+class B extends CheckTopMerge<FutureOr<FutureOr>> {}
+class C extends CheckTopMerge<FutureOr<FutureOr>> {}
class D extends B implements C {}
diff --git a/LanguageFeatures/nnbd/overriding/override_checking_A06_t089.dart b/LanguageFeatures/nnbd/overriding/override_checking_A06_t089.dart
index cf77e9e..42aabc3 100644
--- a/LanguageFeatures/nnbd/overriding/override_checking_A06_t089.dart
+++ b/LanguageFeatures/nnbd/overriding/override_checking_A06_t089.dart
@@ -20,8 +20,8 @@
import "dart:async";
import "../../../Utils/expect.dart";
-class B extends CHECK_TOP_MERGE<FutureOr<FutureOr>> {}
-class C extends CHECK_TOP_MERGE<dynamic> {}
+class B extends CheckTopMerge<FutureOr<FutureOr>> {}
+class C extends CheckTopMerge<dynamic> {}
class D1 extends B implements C {}
class D2 extends C implements B {}
diff --git a/LanguageFeatures/nnbd/overriding/override_checking_A06_t092.dart b/LanguageFeatures/nnbd/overriding/override_checking_A06_t092.dart
index 10299ff..6468f3c 100644
--- a/LanguageFeatures/nnbd/overriding/override_checking_A06_t092.dart
+++ b/LanguageFeatures/nnbd/overriding/override_checking_A06_t092.dart
@@ -20,8 +20,8 @@
import "dart:async";
import "../../../Utils/expect.dart";
-class B extends CHECK_TOP_MERGE<FutureOr<FutureOr>> {}
-class C extends CHECK_TOP_MERGE<void> {}
+class B extends CheckTopMerge<FutureOr<FutureOr>> {}
+class C extends CheckTopMerge<void> {}
class D1 extends B implements C {}
class D2 extends C implements B {}
diff --git a/LanguageFeatures/nnbd/overriding/override_checking_A06_t097.dart b/LanguageFeatures/nnbd/overriding/override_checking_A06_t097.dart
index 2f29c34..23dff9a 100644
--- a/LanguageFeatures/nnbd/overriding/override_checking_A06_t097.dart
+++ b/LanguageFeatures/nnbd/overriding/override_checking_A06_t097.dart
@@ -18,8 +18,8 @@
import "../../../Utils/expect.dart";
-class B extends CHECK_TOP_MERGE<Function?> {}
-class C extends CHECK_TOP_MERGE<Function?> {}
+class B extends CheckTopMerge<Function?> {}
+class C extends CheckTopMerge<Function?> {}
class D extends B implements C {}
diff --git a/LanguageFeatures/nnbd/overriding/override_checking_A06_t102.dart b/LanguageFeatures/nnbd/overriding/override_checking_A06_t102.dart
index 7afd60a..6835d28 100644
--- a/LanguageFeatures/nnbd/overriding/override_checking_A06_t102.dart
+++ b/LanguageFeatures/nnbd/overriding/override_checking_A06_t102.dart
@@ -20,8 +20,8 @@
import "dart:async";
import "../../../Utils/expect.dart";
-class B extends CHECK_TOP_MERGE<FutureOr> {}
-class C extends CHECK_TOP_MERGE<FutureOr<FutureOr>> {}
+class B extends CheckTopMerge<FutureOr> {}
+class C extends CheckTopMerge<FutureOr<FutureOr>> {}
class D1 extends B implements C {}
class D2 extends C implements B {}
diff --git a/LanguageFeatures/nnbd/overriding/override_checking_A06_t119.dart b/LanguageFeatures/nnbd/overriding/override_checking_A06_t119.dart
index 3a927c0..9a79e70 100644
--- a/LanguageFeatures/nnbd/overriding/override_checking_A06_t119.dart
+++ b/LanguageFeatures/nnbd/overriding/override_checking_A06_t119.dart
@@ -19,8 +19,8 @@
import "../../../Utils/expect.dart";
-class B extends CHECK_TOP_MERGE<Never> {}
-class C extends CHECK_TOP_MERGE<Never> {}
+class B extends CheckTopMerge<Never> {}
+class C extends CheckTopMerge<Never> {}
class D extends B implements C {}
diff --git a/LibTest/async/Future/Future.delayed_A01_t01.dart b/LibTest/async/Future/Future.delayed_A01_t01.dart
index c886ea7..d181ab3 100644
--- a/LibTest/async/Future/Future.delayed_A01_t01.dart
+++ b/LibTest/async/Future/Future.delayed_A01_t01.dart
@@ -16,7 +16,7 @@
void check(delay, value) {
asyncStart();
- new Future.delayed(durationMs(delay), () => value)
+ new Future.delayed(durationInMilliseconds(delay), () => value)
.then((v) {
Expect.equals(value, v);
asyncEnd();
diff --git a/LibTest/async/Future/Future.delayed_A01_t02.dart b/LibTest/async/Future/Future.delayed_A01_t02.dart
index 25403a8..b04cc90 100644
--- a/LibTest/async/Future/Future.delayed_A01_t02.dart
+++ b/LibTest/async/Future/Future.delayed_A01_t02.dart
@@ -15,7 +15,7 @@
import "../../../Utils/expect.dart";
check(delayms, value) {
- Duration delay = durationMs(delayms);
+ Duration delay = durationInMilliseconds(delayms);
Stopwatch sw = new Stopwatch();
asyncStart();
sw.start();
diff --git a/LibTest/async/Future/Future.delayed_A03_t01.dart b/LibTest/async/Future/Future.delayed_A03_t01.dart
index 1de092a..0e8bdf8 100644
--- a/LibTest/async/Future/Future.delayed_A03_t01.dart
+++ b/LibTest/async/Future/Future.delayed_A03_t01.dart
@@ -14,7 +14,7 @@
check(delay, value) {
asyncStart();
- new Future.delayed(durationMs(delay), () {throw value;})
+ new Future.delayed(durationInMilliseconds(delay), () {throw value;})
.then(
(v) {
Expect.fail("Created future should complete with error");
diff --git a/LibTest/async/Future/any_A01_t05.dart b/LibTest/async/Future/any_A01_t05.dart
index 5e9acab..87f1892 100644
--- a/LibTest/async/Future/any_A01_t05.dart
+++ b/LibTest/async/Future/any_A01_t05.dart
@@ -30,5 +30,5 @@
asyncEnd();
});
asyncStart();
- new Timer(durationMs(200), () => completers[3].complete("value"));
+ new Timer(durationInMilliseconds(200), () => completers[3].complete("value"));
}
diff --git a/LibTest/async/Future/doWhile_A05_t01.dart b/LibTest/async/Future/doWhile_A05_t01.dart
index abde38f..7ad0a48 100644
--- a/LibTest/async/Future/doWhile_A05_t01.dart
+++ b/LibTest/async/Future/doWhile_A05_t01.dart
@@ -21,7 +21,7 @@
FutureOr<bool> f() {
num++;
- return new Future.delayed(durationMs(100), () => (num < N));
+ return new Future.delayed(durationInMilliseconds(100), () => (num < N));
}
asyncStart();
diff --git a/LibTest/async/Future/forEach_A01_t03.dart b/LibTest/async/Future/forEach_A01_t03.dart
index f159e46..97c805f 100644
--- a/LibTest/async/Future/forEach_A01_t03.dart
+++ b/LibTest/async/Future/forEach_A01_t03.dart
@@ -18,7 +18,7 @@
dynamic f(element) {
log.add(element);
- return new Future.delayed(durationMs(100));
+ return new Future.delayed(durationInMilliseconds(100));
}
asyncStart();
diff --git a/LibTest/async/Future/wait_A01_t01.dart b/LibTest/async/Future/wait_A01_t01.dart
index b972c1e..66f10d9 100644
--- a/LibTest/async/Future/wait_A01_t01.dart
+++ b/LibTest/async/Future/wait_A01_t01.dart
@@ -31,7 +31,7 @@
int i = 0;
new Timer.periodic(
- durationMs(50),
+ durationInMilliseconds(50),
(Timer t){
Expect.isFalse(futureCompleted);
completers[i].complete(i);
diff --git a/LibTest/async/Stream/Stream.fromFutures_all_t02.dart b/LibTest/async/Stream/Stream.fromFutures_all_t02.dart
index 6a9e3ee..7a2cf26 100644
--- a/LibTest/async/Stream/Stream.fromFutures_all_t02.dart
+++ b/LibTest/async/Stream/Stream.fromFutures_all_t02.dart
@@ -16,7 +16,7 @@
import "dart:async";
import "allTests_A02.lib.dart";
-Stream<T> create<T>(Iterable<T> data, {bool isError(T x)?, T? defVal}) {
+Stream<T> create<T>(Iterable<T> data, {bool isError(T x)?, T? defaultValue}) {
return new Stream.fromFutures(data.map((T x) {
return new Future.value(x).catchError((_) {}).then((_) {
if (isError != null && isError(x)) {
diff --git a/LibTest/async/Stream/Stream.fromIterable_A02_t01.dart b/LibTest/async/Stream/Stream.fromIterable_A02_t01.dart
index 2c57428..26a8577 100644
--- a/LibTest/async/Stream/Stream.fromIterable_A02_t01.dart
+++ b/LibTest/async/Stream/Stream.fromIterable_A02_t01.dart
@@ -33,7 +33,7 @@
}, onError: (error) {
events.add(error);
// wait some time for additional (wrong) events
- new Future.delayed(durationMs(500), () {
+ new Future.delayed(durationInMilliseconds(500), () {
Expect.listEquals([0, 1, 2, 3, 4, 5, "done"], events);
asyncEnd();
});
diff --git a/LibTest/async/Stream/Stream.periodic_A01_t01.dart b/LibTest/async/Stream/Stream.periodic_A01_t01.dart
index aa09e32..d83ce15 100644
--- a/LibTest/async/Stream/Stream.periodic_A01_t01.dart
+++ b/LibTest/async/Stream/Stream.periodic_A01_t01.dart
@@ -14,7 +14,7 @@
import "../../../Utils/expect.dart";
void check(int periodMs) {
- Duration period = durationMs(periodMs);
+ Duration period = durationInMilliseconds(periodMs);
const int maxCount = 5;
int count = 0;
diff --git a/LibTest/async/Stream/Stream.periodic_A02_t01.dart b/LibTest/async/Stream/Stream.periodic_A02_t01.dart
index de64c84..c3e1e89 100644
--- a/LibTest/async/Stream/Stream.periodic_A02_t01.dart
+++ b/LibTest/async/Stream/Stream.periodic_A02_t01.dart
@@ -13,7 +13,7 @@
void check(int periodMs) {
Stream s = new Stream<int>.periodic(
- durationMs(periodMs), (computationCount) => computationCount * periodMs);
+ durationInMilliseconds(periodMs), (computationCount) => computationCount * periodMs);
int count = 0;
asyncStart();
StreamSubscription<int>? subs;
diff --git a/LibTest/async/Stream/Stream.periodic_A03_t01.dart b/LibTest/async/Stream/Stream.periodic_A03_t01.dart
index 5b4e351..b469b2e 100644
--- a/LibTest/async/Stream/Stream.periodic_A03_t01.dart
+++ b/LibTest/async/Stream/Stream.periodic_A03_t01.dart
@@ -17,7 +17,7 @@
void check(int periodMs) {
String id = "s$periodMs";
- Duration period = durationMs(periodMs);
+ Duration period = durationInMilliseconds(periodMs);
StreamSubscription<int>? subs;
int count = 0;
asyncStart();
diff --git a/LibTest/async/Stream/Stream.periodic_all_t02.dart b/LibTest/async/Stream/Stream.periodic_all_t02.dart
index 3ae85e2..e7f9f37 100644
--- a/LibTest/async/Stream/Stream.periodic_all_t02.dart
+++ b/LibTest/async/Stream/Stream.periodic_all_t02.dart
@@ -12,7 +12,8 @@
import "dart:async";
import "allTests_A02.lib.dart" as all;
-Stream<T> create<T>(Iterable<T> data, {bool isError(T x)?, required T defVal}) {
+Stream<T> create<T>(
+ Iterable<T> data, {bool isError(T x)?, required T defaultValue}) {
int count = data.length;
Iterator<T> iterator = data.iterator;
return new Stream<T>.periodic(
@@ -26,7 +27,7 @@
}
return x;
}
- return defVal;
+ return defaultValue;
}
).takeWhile((_) => count >= 0);
}
diff --git a/LibTest/async/Stream/any_A02_t01.test.dart b/LibTest/async/Stream/any_A02_t01.test.dart
index abe5eb6..3326369 100644
--- a/LibTest/async/Stream/any_A02_t01.test.dart
+++ b/LibTest/async/Stream/any_A02_t01.test.dart
@@ -19,10 +19,12 @@
void test(CreateStreamWithErrorsFunction create) {
Object error = new Error();
- check(create([error], isError: (_) => true, defVal: new Object()), error);
+ check(create([error],
+ isError: (_) => true, defaultValue: new Object()), error);
error = new Exception();
- check(create([error], isError: (_) => true, defVal: new Object()), error);
+ check(create([error],
+ isError: (_) => true, defaultValue: new Object()), error);
- check(create<int>([1, 2, 3], isError: (x) => x.isOdd, defVal: 42), 1);
+ check(create<int>([1, 2, 3], isError: (x) => x.isOdd, defaultValue: 42), 1);
}
diff --git a/LibTest/async/Stream/asBroadcastStream_A04_t03.test.dart b/LibTest/async/Stream/asBroadcastStream_A04_t03.test.dart
index 1f0b10b..f0f290f 100644
--- a/LibTest/async/Stream/asBroadcastStream_A04_t03.test.dart
+++ b/LibTest/async/Stream/asBroadcastStream_A04_t03.test.dart
@@ -79,5 +79,5 @@
}
}
- timer = new Timer.periodic(durationMs(10), addSubscribersIfNeeded);
+ timer = Timer.periodic(durationInMilliseconds(10), addSubscribersIfNeeded);
}
diff --git a/LibTest/async/Stream/asBroadcastStream_A05_t02.test.dart b/LibTest/async/Stream/asBroadcastStream_A05_t02.test.dart
index c54fcc9..fc11030 100644
--- a/LibTest/async/Stream/asBroadcastStream_A05_t02.test.dart
+++ b/LibTest/async/Stream/asBroadcastStream_A05_t02.test.dart
@@ -16,11 +16,13 @@
import "allTests_A02.lib.dart" as StreamTests;
void test(CreateStreamWithErrorsFunction create) {
- Stream s = create([], isError:(_) => false, defVal: new Object());
+ Stream s = create([], isError:(_) => false, defaultValue: Object());
if (!s.isBroadcast) {
StreamTests.test(
- <T>(Iterable<T> data, {bool isError(T x)?, required T defVal}) {
- return create<T>(data, isError: isError, defVal: defVal).asBroadcastStream();
+ <T>(Iterable<T> data, { bool isError(T x)?, required T defaultValue }) {
+ return create<T>(data,
+ isError: isError,
+ defaultValue: defaultValue).asBroadcastStream();
}
);
}
diff --git a/LibTest/async/Stream/asyncMap_A01_t04.test.dart b/LibTest/async/Stream/asyncMap_A01_t04.test.dart
index 5902a38..551034b 100644
--- a/LibTest/async/Stream/asyncMap_A01_t04.test.dart
+++ b/LibTest/async/Stream/asyncMap_A01_t04.test.dart
@@ -21,7 +21,8 @@
void check<T>(Stream<T> stream, List<T> expected) {
AsyncExpect.data(
expected,
- stream.asyncMap((e) => new Future.delayed(durationMs(50), () => e))
+ stream.asyncMap((e) =>
+ new Future.delayed(durationInMilliseconds(50), () => e))
);
}
diff --git a/LibTest/async/Stream/asyncMap_A03_t01.test.dart b/LibTest/async/Stream/asyncMap_A03_t01.test.dart
index f8d5b47..3eb9c7c 100644
--- a/LibTest/async/Stream/asyncMap_A03_t01.test.dart
+++ b/LibTest/async/Stream/asyncMap_A03_t01.test.dart
@@ -23,9 +23,11 @@
import "../../../Utils/expect.dart";
void test(CreateStreamWithErrorsFunction create) {
- Stream stream = create(["a", "b", "c"], isError: (e) => true, defVal: "");
+ Stream stream = create(
+ ["a", "b", "c"], isError: (e) => true, defaultValue: "");
AsyncExpect.events([], ["a", "b", "c"], stream.asyncMap((e) => e));
- stream = create([1, 2, 3, 4, 5], isError:(e) => e.isEven, defVal: -1);
+ stream = create(
+ [1, 2, 3, 4, 5], isError:(e) => e.isEven, defaultValue: -1);
AsyncExpect.events([1, 3, 5], [2, 4], stream.asyncMap((e) => e));
}
diff --git a/LibTest/async/Stream/asyncMap_A03_t03.test.dart b/LibTest/async/Stream/asyncMap_A03_t03.test.dart
index 3495a7b..8a7f18e 100644
--- a/LibTest/async/Stream/asyncMap_A03_t03.test.dart
+++ b/LibTest/async/Stream/asyncMap_A03_t03.test.dart
@@ -14,8 +14,8 @@
/// ...
/// Error and done events are passed through unchanged to the returned stream.
///
-/// @description Checks that if future returned by [convert] completes
-/// with an error, then this error is passed to returned stream.
+/// @description Checks that if future returned by [convert] completes with an
+/// error, then this error is passed to returned stream.
/// @author a.semenov@unipro.ru
library asyncMap_A03_t03;
@@ -24,14 +24,16 @@
void test(CreateStreamFunction create) {
Stream<String> stream1 = create(["a", "b", "c"]);
- AsyncExpect.events([], ["a", "b", "c"], stream1.asyncMap((e) => new Future.error(e)));
+ AsyncExpect.events([],
+ ["a", "b", "c"], stream1.asyncMap((e) => new Future.error(e)));
Stream<int> stream2 = create([1, 2, 3, 4, 5]);
AsyncExpect.events(
[1, 3, 5],
[2, 4],
stream2.asyncMap(
- (int e) => new Future.delayed(durationMs(50), () => e.isOdd ? e : throw e)
+ (int e) => new Future.delayed(
+ durationInMilliseconds(50), () => e.isOdd ? e : throw e)
)
);
}
diff --git a/LibTest/async/Stream/contains_A03_t01.test.dart b/LibTest/async/Stream/contains_A03_t01.test.dart
index 43072fe..81f58a3 100644
--- a/LibTest/async/Stream/contains_A03_t01.test.dart
+++ b/LibTest/async/Stream/contains_A03_t01.test.dart
@@ -14,6 +14,6 @@
void test(CreateStreamWithErrorsFunction create) {
Error error = new Error();
- Stream s = create([error], isError: (e) => true, defVal: new Object());
+ Stream s = create([error], isError: (e) => true, defaultValue: new Object());
AsyncExpect.error(error, s.contains(1));
}
diff --git a/LibTest/async/Stream/contains_A03_t02.test.dart b/LibTest/async/Stream/contains_A03_t02.test.dart
index ac8ff55..c192bbe 100644
--- a/LibTest/async/Stream/contains_A03_t02.test.dart
+++ b/LibTest/async/Stream/contains_A03_t02.test.dart
@@ -14,6 +14,7 @@
void test(CreateStreamWithErrorsFunction create) {
Error error = new Error();
- Stream s = create([1, error], isError: (e) => e is Error, defVal: new Object());
+ Stream s = create(
+ [1, error], isError: (e) => e is Error, defaultValue: Object());
AsyncExpect.value(true, s.contains(1));
}
diff --git a/LibTest/async/Stream/contains_A03_t03.test.dart b/LibTest/async/Stream/contains_A03_t03.test.dart
index 9e84624..791ccfe 100644
--- a/LibTest/async/Stream/contains_A03_t03.test.dart
+++ b/LibTest/async/Stream/contains_A03_t03.test.dart
@@ -14,6 +14,7 @@
void test(CreateStreamWithErrorsFunction create) {
Error error = new Error();
- Stream s = create([1, 2, error, 3, 4], isError: (e) => e is Error, defVal: new Object());
+ Stream s = create(
+ [1, 2, error, 3, 4], isError: (e) => e is Error, defaultValue: Object());
AsyncExpect.error(error, s.contains(4));
}
diff --git a/LibTest/async/Stream/distinct_A04_t01.test.dart b/LibTest/async/Stream/distinct_A04_t01.test.dart
index 4e83c4c..beec758 100644
--- a/LibTest/async/Stream/distinct_A04_t01.test.dart
+++ b/LibTest/async/Stream/distinct_A04_t01.test.dart
@@ -3,12 +3,12 @@
// BSD-style license that can be found in the LICENSE file.
/// @assertion Stream<T> distinct([bool equals(T previous, T next)])
-/// Skips data events if they are equal to the previous data event.
-/// The returned stream provides the same events as this stream, except that it
+/// Skips data events if they are equal to the previous data event.
+/// The returned stream provides the same events as this stream, except that it
/// never provides two consecutive data events that are equal.
-/// @description Checks that errors in original stream are copied to the returned
-/// stream. [equals] is omitted.
-/// @issue #29627
+/// @description Checks that errors in original stream are copied to the
+/// returned stream. [equals] is omitted.
+/// @issue 29627
/// @author a.semenov@unipro.ru
library distinct_A04_t01;
@@ -21,12 +21,16 @@
}
void test(CreateStreamWithErrorsFunction create) {
- check(create([], defVal: 0), [], []);
- check<int>(create([1, 2, 2, 3], isError: (e) => e.isEven, defVal: 42), [1, 3], [2, 2]);
+ check(create([], defaultValue: 0), [], []);
+ check<int>(create([1, 2, 2, 3], isError: (e) => e.isEven, defaultValue: 42),
+ [1, 3], [2, 2]);
check<int>(
- create([1, 1, 2, 2, 3, 3], isError: (e) => e.isEven, defVal: 42), [1, 3], [2, 2]);
+ create([1, 1, 2, 2, 3, 3], isError: (e) => e.isEven, defaultValue: 42),
+ [1, 3], [2, 2]);
check<int>(
- create([1, 1, 2, 2, 3, 3], isError: (e) => e.isOdd, defVal: 42), [2], [1, 1, 3, 3]);
+ create([1, 1, 2, 2, 3, 3], isError: (e) => e.isOdd, defaultValue: 42),
+ [2], [1, 1, 3, 3]);
check<int?>(
- create([1, 2, null, null], isError: (e) => e is num, defVal: 42), [null], [1, 2]);
+ create([1, 2, null, null], isError: (e) => e is num, defaultValue: 42),
+ [null], [1, 2]);
}
diff --git a/LibTest/async/Stream/distinct_A04_t02.test.dart b/LibTest/async/Stream/distinct_A04_t02.test.dart
index b27e42c..dcb8404 100644
--- a/LibTest/async/Stream/distinct_A04_t02.test.dart
+++ b/LibTest/async/Stream/distinct_A04_t02.test.dart
@@ -22,12 +22,16 @@
}
void test(CreateStreamWithErrorsFunction create) {
- check(create([], defVal: 0), [], []);
- check<int>(create([1, 2, 2, 3], isError: (e) => e.isEven, defVal: 42), [1, 3], [2, 2]);
+ check(create([], defaultValue: 0), [], []);
+ check<int>(create([1, 2, 2, 3], isError: (e) => e.isEven, defaultValue: 42),
+ [1, 3], [2, 2]);
check<int>(
- create([1, 1, 2, 2, 3, 3], isError: (e) => e.isEven, defVal: 42), [1, 3], [2, 2]);
+ create([1, 1, 2, 2, 3, 3], isError: (e) => e.isEven, defaultValue: 42),
+ [1, 3], [2, 2]);
check<int>(
- create([1, 1, 2, 2, 3, 3], isError: (e) => e.isOdd, defVal: 42), [2], [1, 1, 3, 3]);
+ create([1, 1, 2, 2, 3, 3], isError: (e) => e.isOdd, defaultValue: 42),
+ [2], [1, 1, 3, 3]);
check<int?>(
- create([1, 2, null, null], isError: (e) => e is num, defVal: 42), [null], [1, 2]);
+ create([1, 2, null, null], isError: (e) => e is num, defaultValue: 42),
+ [null], [1, 2]);
}
diff --git a/LibTest/async/Stream/drain_A01_t01.test.dart b/LibTest/async/Stream/drain_A01_t01.test.dart
index b453468..f4c4e0c 100644
--- a/LibTest/async/Stream/drain_A01_t01.test.dart
+++ b/LibTest/async/Stream/drain_A01_t01.test.dart
@@ -3,13 +3,13 @@
// BSD-style license that can be found in the LICENSE file.
/// @assertion Future drain([futureValue])
-/// Discards all data on the stream, but signals when it's done or an error
+/// Discards all data on the stream, but signals when it's done or an error
/// occurred.
-/// When subscribing using drain, cancelOnError will be true.
+/// When subscribing using drain, cancelOnError will be true.
/// This means that the future will complete with the first error on the stream
/// and then cancel the subscription.
-/// @description Checks that the future will complete with the first error
-/// on the stream.
+/// @description Checks that the future will complete with the first error on
+/// the stream.
/// @author kaigorodov
library drain_A01_t01;
@@ -18,6 +18,7 @@
import "../../../Utils/expect.dart";
void test(CreateStreamWithErrorsFunction create) {
- Stream<int> s = create([1, 2, 3, 4, 5], isError: (e) => true, defVal: 42);
+ Stream<int> s = create([1, 2, 3, 4, 5], isError: (e) => true,
+ defaultValue: 42);
AsyncExpect.error(1, s.drain());
}
diff --git a/LibTest/async/Stream/elementAt_A02_t01.test.dart b/LibTest/async/Stream/elementAt_A02_t01.test.dart
index b5245e1..ee444f6 100644
--- a/LibTest/async/Stream/elementAt_A02_t01.test.dart
+++ b/LibTest/async/Stream/elementAt_A02_t01.test.dart
@@ -17,7 +17,7 @@
void test(CreateStreamWithErrorsFunction create) {
for (int k = 0; k < 10; k++) {
Iterable<int> i = new Iterable<int>.generate(10, (int x) => x);
- Stream<int> s = create(i, isError: (e) => e == k, defVal: 42);
+ Stream<int> s = create(i, isError: (e) => e == k, defaultValue: 42);
AsyncExpect.error(k, s.elementAt(k));
}
}
diff --git a/LibTest/async/Stream/every_A02_t01.test.dart b/LibTest/async/Stream/every_A02_t01.test.dart
index 1a65e26..74da912 100644
--- a/LibTest/async/Stream/every_A02_t01.test.dart
+++ b/LibTest/async/Stream/every_A02_t01.test.dart
@@ -19,15 +19,11 @@
void test(CreateStreamWithErrorsFunction create) {
Object error = new ArgumentError(1);
- check(create([error], isError: (e) => true, defVal: new Object()), error);
- check(
- create([1, 2, error, 3, 4],
- isError: (e) => e is ArgumentError, defVal: new Object()),
- error);
+ check(create([error], isError: (e) => true, defaultValue: Object()), error);
+ check(create([1, 2, error, 3, 4], isError: (e) => e is ArgumentError,
+ defaultValue: Object()), error);
error = new StateError("");
- check(create([error], isError: (e) => true, defVal: new Object()), error);
- check(
- create([1, 2, error, 3, 4],
- isError: (e) => e is StateError, defVal: new Object()),
- error);
+ check(create([error], isError: (e) => true, defaultValue: Object()), error);
+ check(create([1, 2, error, 3, 4], isError: (e) => e is StateError,
+ defaultValue: Object()), error);
}
diff --git a/LibTest/async/Stream/firstWhere_A03_t01.test.dart b/LibTest/async/Stream/firstWhere_A03_t01.test.dart
index fea52ba..329d9c7 100644
--- a/LibTest/async/Stream/firstWhere_A03_t01.test.dart
+++ b/LibTest/async/Stream/firstWhere_A03_t01.test.dart
@@ -7,15 +7,15 @@
///
/// Finds the first element of this stream matching test.
///
-/// Returns a future that is completed with the first element of this stream that
-/// test returns true for.
+/// Returns a future that is completed with the first element of this stream
+/// that test returns true for.
///
-/// If no such element is found before this stream is done, and a orElse function
-/// is provided, the result of calling orElse becomes the value of the future. If
-/// orElse throws, the returned future is completed with that error.
+/// If no such element is found before this stream is done, and a orElse
+/// function is provided, the result of calling orElse becomes the value of the
+/// future. If orElse throws, the returned future is completed with that error.
///
-/// If this stream emits an error before the first matching element, the returned
-/// future is completed with that error, and processing stops.
+/// If this stream emits an error before the first matching element, the
+/// returned future is completed with that error, and processing stops.
///
/// Stops listening to the stream after the first matching element or error has
/// been received.
@@ -38,6 +38,6 @@
import "../../../Utils/expect.dart";
void test(CreateStreamWithErrorsFunction create) {
- Stream s = create([1, 2, 3, 4, 5], isError: (x) => x == 4, defVal: 42);
+ Stream s = create([1, 2, 3, 4, 5], isError: (x) => x == 4, defaultValue: 42);
AsyncExpect.error(4, s.firstWhere((v) => v == 5));
}
diff --git a/LibTest/async/Stream/first_A03_t01.test.dart b/LibTest/async/Stream/first_A03_t01.test.dart
index 65c27c4..2aac7c8 100644
--- a/LibTest/async/Stream/first_A03_t01.test.dart
+++ b/LibTest/async/Stream/first_A03_t01.test.dart
@@ -3,10 +3,10 @@
// BSD-style license that can be found in the LICENSE file.
/// @assertion Future<T> first
-/// If an error event occurs before the first data event, the resulting
-/// future is completed with that error.
-/// @description Checks that if error event occurs before the first data
-/// event, the future completes with that error.
+/// If an error event occurs before the first data event, the resulting future
+/// is completed with that error.
+/// @description Checks that if error event occurs before the first data event,
+/// the future completes with that error.
/// @author ilya
library first_A03_t01;
@@ -15,6 +15,6 @@
import "../../../Utils/expect.dart";
void test(CreateStreamWithErrorsFunction create) {
- Stream s = create([1, 2, 3], isError: (_) => true, defVal: 42);
+ Stream s = create([1, 2, 3], isError: (_) => true, defaultValue: 42);
AsyncExpect.error(1, s.first);
}
diff --git a/LibTest/async/Stream/forEach_A02_t01.test.dart b/LibTest/async/Stream/forEach_A02_t01.test.dart
index 44c4187..e04f400 100644
--- a/LibTest/async/Stream/forEach_A02_t01.test.dart
+++ b/LibTest/async/Stream/forEach_A02_t01.test.dart
@@ -5,8 +5,8 @@
/// @assertion Future forEach(void action(T element))
/// Completes the future with an error if the stream has an error event, or if
/// action throws.
-/// @description Checks that the future is completed with error if the stream has
-/// an error event.
+/// @description Checks that the future is completed with error if the stream
+/// has an error event.
/// @author kaigorodov
library forEach_A02_t01;
@@ -19,12 +19,14 @@
}
void test(CreateStreamWithErrorsFunction create) {
- check(create([1, 2, 3, 4], isError: (v) => v == 4, defVal: 42), 4);
+ check(create([1, 2, 3, 4], isError: (v) => v == 4, defaultValue: 42), 4);
List list = [];
check(
- create([null, "2", -3, 4.0, list], isError: (v) => v == list, defVal: 42),
+ create([null, "2", -3, 4.0, list], isError: (v) => v == list,
+ defaultValue: 42),
list);
check(
- create([null, "2", -3, 4.0, list], isError: (v) => v == 4.0, defVal: 42),
+ create([null, "2", -3, 4.0, list], isError: (v) => v == 4.0,
+ defaultValue: 42),
4.0);
}
diff --git a/LibTest/async/Stream/handleError_A01_t01.test.dart b/LibTest/async/Stream/handleError_A01_t01.test.dart
index 5ae4d26..53aa23c 100644
--- a/LibTest/async/Stream/handleError_A01_t01.test.dart
+++ b/LibTest/async/Stream/handleError_A01_t01.test.dart
@@ -6,7 +6,8 @@
/// Creates a wrapper Stream that intercepts some errors from this stream.
/// If this stream sends an error that matches test, then it is intercepted by
/// the onError function.
-/// An asynchronous error e is matched by a test function if test(e) returns true.
+/// An asynchronous error e is matched by a test function if test(e) returns
+/// true.
/// @description Checks that an error e intercepted by [onError] function
/// if test(e) returns true.
/// @author a.semenov@unipro.ru
@@ -36,14 +37,15 @@
}
void test(CreateStreamWithErrorsFunction create) {
- check(create([], defVal: 42), (x) => true, [], [], []);
- check(create([], isError: (x) => true, defVal: 42), (x) => true, [], [], []);
- check(create([1, 2, 3, 4, 5], isError: (x) => true, defVal: 42),
+ check(create([], defaultValue: 42), (x) => true, [], [], []);
+ check(create([], isError: (x) => true, defaultValue: 42),
+ (x) => true, [], [], []);
+ check(create([1, 2, 3, 4, 5], isError: (x) => true, defaultValue: 42),
(x) => x.isEven, [], [2, 4], [1, 3, 5]);
check(
create(["a", 1, "b", 2, "c", 3, "d", 4, "e", 5, "f"],
- isError: (x) => x is int, defVal: 42),
+ isError: (x) => x is int, defaultValue: 42),
(x) => (x is int && x.isEven), // test function
["a", "b", "c", "d", "e", "f"], // expected data
[2, 4], // intercepted errors
diff --git a/LibTest/async/Stream/handleError_A02_t01.test.dart b/LibTest/async/Stream/handleError_A02_t01.test.dart
index 6cced50..fa8c0e4 100644
--- a/LibTest/async/Stream/handleError_A02_t01.test.dart
+++ b/LibTest/async/Stream/handleError_A02_t01.test.dart
@@ -30,14 +30,14 @@
}
void test(CreateStreamWithErrorsFunction create) {
- check(create([], defVal: 42), [], []);
- check(create([], isError: (x) => true, defVal: 42), [], []);
+ check(create([], defaultValue: 42), [], []);
+ check(create([], isError: (x) => true, defaultValue: 42), [], []);
- check(create([1, 2, 3, 4], defVal: 42), [1, 2, 3, 4], []);
- check(
- create([1, 2, 3, 4], isError: (x) => true, defVal: 42), [], [1, 2, 3, 4]);
- check(create([1, 2, 3, 4], isError: (x) => x.isEven, defVal: 42), [1, 3],
- [2, 4]);
- check(create([null, "2", -3, 4.0, []], isError: (x) => x is num, defVal: 42),
- [null, "2", []], [-3, 4.0]);
+ check(create([1, 2, 3, 4], defaultValue: 42), [1, 2, 3, 4], []);
+ check(create([1, 2, 3, 4], isError: (x) => true, defaultValue: 42),
+ [], [1, 2, 3, 4]);
+ check(create([1, 2, 3, 4], isError: (x) => x.isEven, defaultValue: 42),
+ [1, 3], [2, 4]);
+ check(create([null, "2", -3, 4.0, []], isError: (x) => x is num,
+ defaultValue: 42), [null, "2", []], [-3, 4.0]);
}
diff --git a/LibTest/async/Stream/handleError_A03_t01.test.dart b/LibTest/async/Stream/handleError_A03_t01.test.dart
index 5c47211..d60fcbc 100644
--- a/LibTest/async/Stream/handleError_A03_t01.test.dart
+++ b/LibTest/async/Stream/handleError_A03_t01.test.dart
@@ -14,7 +14,8 @@
import "dart:async";
import "../../../Utils/expect.dart";
-void check(Stream s, void onError(error), List data, List intercepted, List expected) {
+void check(
+ Stream s, void onError(error), List data, List intercepted, List expected) {
List actualIntercepted = [];
List actualErrors = [];
List actualData = [];
@@ -41,28 +42,23 @@
}
void test(CreateStreamWithErrorsFunction create) {
- check(create([], defVal: 42), (e) => throw e, [], [], []);
- check(create([], isError:(x) => true, defVal: 42), (e) => throw e, [], [], []);
+ check(create([], defaultValue: 42), (e) => throw e, [], [], []);
+ check(create([], isError:(x) => true, defaultValue: 42),
+ (e) => throw e, [], [], []);
- check(create([1, 2, 3, 4, 5], isError: (x) => true, defVal: 42),
+ check(create([1, 2, 3, 4, 5], isError: (x) => true, defaultValue: 42),
(x) => throw x, [], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5]);
- check(
- create(
- ["a", 1, "b", 2, "c", 3, "d", 4, "e", 5, "f"],
- isError: (x) => x is num, defVal: 42
- ),
+ check(create(["a", 1, "b", 2, "c", 3, "d", 4, "e", 5, "f"],
+ isError: (x) => x is num, defaultValue: 42),
(x) { if (x.isEven) { throw x; }}, // onError function
["a", "b", "c", "d", "e", "f"], // expected data
[1, 2, 3, 4, 5], // intercepted errors
[2,4] // rethrown errors
);
- check(
- create(
- ["a", 1, "b", 2, "c", 3, "d", 4, "e", 5, "f"],
- isError: (x) => x is num, defVal: 42
- ),
+ check(create(["a", 1, "b", 2, "c", 3, "d", 4, "e", 5, "f"],
+ isError: (x) => x is num, defaultValue: 42),
(x) { if (x.isEven) { throw x + 10; }}, // onError function
["a", "b", "c", "d", "e", "f"], // expected data
[1, 2, 3, 4, 5], // intercepted errors
diff --git a/LibTest/async/Stream/handleError_A05_t01.test.dart b/LibTest/async/Stream/handleError_A05_t01.test.dart
index d1226e6..5339799 100644
--- a/LibTest/async/Stream/handleError_A05_t01.test.dart
+++ b/LibTest/async/Stream/handleError_A05_t01.test.dart
@@ -21,7 +21,7 @@
List errors = [];
List traces = [];
asyncStart();
- Stream s = create([1, 2, 3, 4, 5], isError: (x) => true, defVal: 42);
+ Stream s = create([1, 2, 3, 4, 5], isError: (x) => true, defaultValue: 42);
s.handleError((error, stackTrace) {
errors.add(error);
traces.add(stackTrace);
diff --git a/LibTest/async/Stream/handleError_A07_t01.test.dart b/LibTest/async/Stream/handleError_A07_t01.test.dart
index 8e68646..27f110a 100644
--- a/LibTest/async/Stream/handleError_A07_t01.test.dart
+++ b/LibTest/async/Stream/handleError_A07_t01.test.dart
@@ -3,7 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
/// @assertion Stream<T> handleError(Function onError, {bool test(error)})
-/// If a broadcast stream is listened to more than once, each subscription will
+/// If a broadcast stream is listened to more than once, each subscription will
/// individually perform the test and handle the error.
/// @description Checks that [test] and [onError] are called once per listener
/// per error.
@@ -15,8 +15,8 @@
import "../../../Utils/expect.dart";
void test(CreateStreamWithErrorsFunction create) {
- Stream s =
- create(["a", 1, "b", 2, "c", 3], isError: (x) => x is num, defVal: 42);
+ Stream s = create(["a", 1, "b", 2, "c", 3], isError: (x) => x is num,
+ defaultValue: 42);
Map onErrorCalls = new Map();
Map testCalls = new Map();
asyncStart();
diff --git a/LibTest/async/Stream/isEmpty_A03_t01.test.dart b/LibTest/async/Stream/isEmpty_A03_t01.test.dart
index cc65592..6886069 100644
--- a/LibTest/async/Stream/isEmpty_A03_t01.test.dart
+++ b/LibTest/async/Stream/isEmpty_A03_t01.test.dart
@@ -7,14 +7,16 @@
/// error.
/// @description Checks that returned future is completed with the first error,
/// that appears in the stream
-/// @issue #29730
+/// @issue 29730
/// @author a.semenov@unipro.ru
library isEmpty_A03_t01;
import "../../../Utils/expect.dart";
void test(CreateStreamWithErrorsFunction create) {
- AsyncExpect.value(true, create([], defVal: 42).isEmpty);
- AsyncExpect.error(1, create([1, 2, 3, null], isError:(x) => x==1, defVal: 42).isEmpty);
- AsyncExpect.value(false, create([1, 2, 3, null], isError:(x) => x==3, defVal: 42).isEmpty);
+ AsyncExpect.value(true, create([], defaultValue: 42).isEmpty);
+ AsyncExpect.error(1,
+ create([1, 2, 3, null], isError:(x) => x==1, defaultValue: 42).isEmpty);
+ AsyncExpect.value(false,
+ create([1, 2, 3, null], isError:(x) => x==3, defaultValue: 42).isEmpty);
}
diff --git a/LibTest/async/Stream/join_A02_t01.test.dart b/LibTest/async/Stream/join_A02_t01.test.dart
index d73abab..1973da8 100644
--- a/LibTest/async/Stream/join_A02_t01.test.dart
+++ b/LibTest/async/Stream/join_A02_t01.test.dart
@@ -16,7 +16,8 @@
void test(CreateStreamWithErrorsFunction create) {
Error error = new Error();
- Stream s = create([1, 2, error, 4, 5], isError: (e) => e is Error, defVal: 42);
+ Stream s = create([1, 2, error, 4, 5], isError: (e) => e is Error,
+ defaultValue: 42);
AsyncExpect.error(error, s.join());
}
diff --git a/LibTest/async/Stream/lastWhere_A01_t02.test.dart b/LibTest/async/Stream/lastWhere_A01_t02.test.dart
index da767a1..a877839 100644
--- a/LibTest/async/Stream/lastWhere_A01_t02.test.dart
+++ b/LibTest/async/Stream/lastWhere_A01_t02.test.dart
@@ -26,7 +26,10 @@
void check<T>(Stream<T> s, bool test(T element), T expected) {
bool orElseCalled = false;
asyncStart();
- s.lastWhere(test, orElse:() {orElseCalled = true;})
+ s.lastWhere(test, orElse:() {
+ orElseCalled = true;
+ return null as T;
+ })
.then((T actual){
Expect.equals(expected, actual);
Expect.isFalse(orElseCalled);
@@ -36,8 +39,8 @@
void test(CreateStreamFunction create) {
check(create<int>([1, 2, 3]), (int element) => true, 3);
- check(create<int>([1, 2, 3]), (int element) => element != null, 3);
- check(create<int>([1, 2, 3, null]), (int element) => element == null, null);
+ check(create<int?>([1, 2, 3]), (int? element) => element != null, 3);
+ check(create<int?>([1, 2, 3, null]), (int? element) => element == null, null);
check(create<int>([1, 2, 3]), (int element) => element > 0, 3);
check(create<int>(new Iterable<int>.generate(10, (int index) => index * 5)),
(int element) => element != 30, 45);
diff --git a/LibTest/async/Stream/lastWhere_A03_t01.test.dart b/LibTest/async/Stream/lastWhere_A03_t01.test.dart
index 65b274d..bbb3e93 100644
--- a/LibTest/async/Stream/lastWhere_A03_t01.test.dart
+++ b/LibTest/async/Stream/lastWhere_A03_t01.test.dart
@@ -30,10 +30,10 @@
}
void test(CreateStreamWithErrorsFunction create) {
- check<int>(
- create([1, 2, 3], isError: (e) => true, defVal: 42), (x) => x > 0, 1);
- check<int>(
- create([1, 2, 3], isError: (e) => e == 3, defVal: 42), (x) => x > 0, 3);
- check<int>(create([-1, 1, -2, 2, 3], isError: (e) => e == 3, defVal: 42),
+ check<int>(create([1, 2, 3], isError: (e) => true, defaultValue: 42),
+ (x) => x > 0, 1);
+ check<int>(create([1, 2, 3], isError: (e) => e == 3, defaultValue: 42),
+ (x) => x > 0, 3);
+ check<int>(create([-1, 1, -2, 2, 3], isError: (e) => e == 3, defaultValue: 42),
(x) => x < 0, 3);
}
diff --git a/LibTest/async/Stream/last_A03_t01.test.dart b/LibTest/async/Stream/last_A03_t01.test.dart
index 808dc7f..53c0adf 100644
--- a/LibTest/async/Stream/last_A03_t01.test.dart
+++ b/LibTest/async/Stream/last_A03_t01.test.dart
@@ -5,8 +5,8 @@
/// @assertion Future<T> last
/// If an error event occurs before the first data event, the resulting future
/// is completed with that error.
-/// @description Checks that if error event occurs before the first data
-/// event, the future completes with that error.
+/// @description Checks that if error event occurs before the first data event,
+/// the future completes with that error.
/// @author ilya
/// @author a.semenov@unipro.ru
@@ -17,14 +17,12 @@
Error error = new Error();
AsyncExpect.error(
error,
- create([1, 2, error, 4, 5], isError: (e) => e is Error, defVal: 42).last
- );
+ create(
+ [1, 2, error, 4, 5], isError: (e) => e is Error, defaultValue: 42).last);
AsyncExpect.error(
error,
- create([error, 4, 5], isError: (e) => e is Error, defVal: 42).last
- );
+ create([error, 4, 5], isError: (e) => e is Error, defaultValue: 42).last);
AsyncExpect.error(
error,
- create([1, 2, error], isError: (e) => e is Error, defVal: 42).last
- );
+ create([1, 2, error], isError: (e) => e is Error, defaultValue: 42).last);
}
diff --git a/LibTest/async/Stream/length_A02_t01.test.dart b/LibTest/async/Stream/length_A02_t01.test.dart
index 1f6931c..3612715 100644
--- a/LibTest/async/Stream/length_A02_t01.test.dart
+++ b/LibTest/async/Stream/length_A02_t01.test.dart
@@ -3,8 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
/// @assertion Future<int> length
-/// If the stream contains an error, the returned future is completed with
-/// that error, and processing stops.
+/// If the stream contains an error, the returned future is completed with that
+/// error, and processing stops.
/// @description Checks that If the stream contains an error, the returned
/// future is completed with that error, and processing stops
/// @author a.semenov@unipro.ru
@@ -14,11 +14,11 @@
import "../../../Utils/expect.dart";
void test(CreateStreamWithErrorsFunction create) {
- AsyncExpect.error(1, create([1], isError: (_) => true, defVal: 42).length);
AsyncExpect.error(
- 3, create([1, 2, 3, null], isError: (e) => e == 3, defVal: 42).length);
- AsyncExpect.error(
- 12,
+ 1, create([1], isError: (_) => true, defaultValue: 42).length);
+ AsyncExpect.error(3,
+ create([1, 2, 3, null], isError: (e) => e == 3, defaultValue: 42).length);
+ AsyncExpect.error(12,
create<int>(new Iterable.generate(10, (int i) => i * 2),
- isError: (e) => e > 10, defVal: 42).length);
+ isError: (e) => e > 10, defaultValue: 42).length);
}
diff --git a/LibTest/async/Stream/listen_A03_t01.test.dart b/LibTest/async/Stream/listen_A03_t01.test.dart
index 8f10fc7..a5781a2 100644
--- a/LibTest/async/Stream/listen_A03_t01.test.dart
+++ b/LibTest/async/Stream/listen_A03_t01.test.dart
@@ -6,8 +6,8 @@
/// {Function onError, void onDone(), bool cancelOnError})
/// On errors from this stream, the onError handler is given a object describing
/// the error.
-/// @description Checks that the onError handler is given an object describing the
-/// error.
+/// @description Checks that the onError handler is given an object describing
+/// the error.
/// @author kaigorodov
library listen_A03_t01;
@@ -31,13 +31,14 @@
}
void test(CreateStreamWithErrorsFunction create) {
- check(create([], defVal: 42), [], []);
- check(create([1, 2, 3, 4], isError: (x) => false, defVal: 42), [1, 2, 3, 4],
- []);
- check(
- create([1, 2, 3, 4], isError: (x) => true, defVal: 42), [], [1, 2, 3, 4]);
- check<int>(create([1, 2, 3, 4], isError: (x) => x.isOdd, defVal: 42), [2, 4],
- [1, 3]);
- check(create([null, "2", -3, 4.0, []], isError: (x) => x is num, defVal: 42),
+ check(create([], defaultValue: 42), [], []);
+ check(create([1, 2, 3, 4], isError: (x) => false, defaultValue: 42),
+ [1, 2, 3, 4], []);
+ check(create([1, 2, 3, 4], isError: (x) => true, defaultValue: 42),
+ [], [1, 2, 3, 4]);
+ check<int>(create([1, 2, 3, 4], isError: (x) => x.isOdd, defaultValue: 42),
+ [2, 4], [1, 3]);
+ check(create(
+ [null, "2", -3, 4.0, []], isError: (x) => x is num, defaultValue: 42),
[null, "2", []], [-3, 4.0]);
}
diff --git a/LibTest/async/Stream/listen_A04_t01.test.dart b/LibTest/async/Stream/listen_A04_t01.test.dart
index 8770241..c539c3c 100644
--- a/LibTest/async/Stream/listen_A04_t01.test.dart
+++ b/LibTest/async/Stream/listen_A04_t01.test.dart
@@ -8,7 +8,7 @@
/// reported. The default is false.
/// @description Checks that if cancelOnError is true, the subscription is ended
/// when the first error is reported.
-/// @issue #25967
+/// @issue 25967
/// @author kaigorodov
/// @author a.semenov@unipro.ru
@@ -27,7 +27,7 @@
onError: (Object error) {
errorSink.add(error);
// wait for possible additional error
- new Future.delayed(durationMs(500), (){
+ new Future.delayed(durationInMilliseconds(500), (){
Expect.listEquals(data, dataSink);
Expect.listEquals(errors, errorSink);
asyncEnd();
@@ -44,14 +44,15 @@
}
void test(CreateStreamWithErrorsFunction create) {
- check(create([], defVal: 42), [], []);
- check(create([1, 2, 3, 4], isError:(x) => false, defVal: 42), [1, 2, 3, 4], []);
- check(create([1, 2, 3, 4], isError:(x) => true, defVal: 42), [], [1]);
- check<int>(create([1, 2, 3, 4], isError:(x) => x.isOdd, defVal: 42), [], [1]);
- check<int>(create([1, 2, 3, 4], isError:(x) => x.isEven, defVal: 42), [1], [2]);
- check(
- create([null, "2", -3, 4.0, []], isError:(x) => x is num, defVal: 42),
- [null, "2"],
- [-3]
- );
+ check(create([], defaultValue: 42), [], []);
+ check(create([1, 2, 3, 4], isError:(x) => false, defaultValue: 42),
+ [1, 2, 3, 4], []);
+ check(create([1, 2, 3, 4], isError:(x) => true, defaultValue: 42), [], [1]);
+ check<int>(create([1, 2, 3, 4], isError:(x) => x.isOdd, defaultValue: 42),
+ [], [1]);
+ check<int>(create([1, 2, 3, 4], isError:(x) => x.isEven, defaultValue: 42),
+ [1], [2]);
+ check(create(
+ [null, "2", -3, 4.0, []], isError:(x) => x is num, defaultValue: 42),
+ [null, "2"], [-3]);
}
diff --git a/LibTest/async/Stream/map_A03_t01.test.dart b/LibTest/async/Stream/map_A03_t01.test.dart
index 2950fa0..112e576 100644
--- a/LibTest/async/Stream/map_A03_t01.test.dart
+++ b/LibTest/async/Stream/map_A03_t01.test.dart
@@ -4,7 +4,6 @@
/// @assertion Stream<S> map<S>(S convert(T event))
/// Error and done events are passed through unchanged to the returned stream.
-///
/// @description Checks that each error of this stream is passed to returned
/// stream.
/// @author a.semenov@unipro.ru
@@ -14,9 +13,9 @@
import "../../../Utils/expect.dart";
void test(CreateStreamWithErrorsFunction create) {
- Stream stream = create(["a", "b", "c"], isError:(e) => true, defVal: "");
+ Stream stream = create(["a", "b", "c"], isError:(e) => true, defaultValue: "");
AsyncExpect.events([], ["a", "b", "c"], stream.map((e) => e));
- stream = create([1, 2, 3, 4, 5], isError:(e) => e.isEven, defVal: 42);
+ stream = create([1, 2, 3, 4, 5], isError:(e) => e.isEven, defaultValue: 42);
AsyncExpect.events([1, 3, 5], [2, 4], stream.map((e) => e));
}
diff --git a/LibTest/async/Stream/pipe_A01_t02.test.dart b/LibTest/async/Stream/pipe_A01_t02.test.dart
index df1949b..6508516 100644
--- a/LibTest/async/Stream/pipe_A01_t02.test.dart
+++ b/LibTest/async/Stream/pipe_A01_t02.test.dart
@@ -41,7 +41,8 @@
}
);
- Stream<int> s = create([1, 2, 3, 4, 5], isError:(x) => x.isEven, defVal: 42);
+ Stream<int> s =
+ create([1, 2, 3, 4, 5], isError:(x) => x.isEven, defaultValue: 42);
asyncStart();
s.pipe(c).then((x) {
diff --git a/LibTest/async/Stream/reduce_A03_t01.test.dart b/LibTest/async/Stream/reduce_A03_t01.test.dart
index e522607..8693ddc 100644
--- a/LibTest/async/Stream/reduce_A03_t01.test.dart
+++ b/LibTest/async/Stream/reduce_A03_t01.test.dart
@@ -18,10 +18,10 @@
}
void test(CreateStreamWithErrorsFunction create) {
- check(create([1, 2, 3, 4, 5], isError: (_) => true, defVal: 42),
+ check(create([1, 2, 3, 4, 5], isError: (_) => true, defaultValue: 42),
(int p, int e) => p + e, 1);
- check<int>(create([1, 2, 3, 4, 5], isError: (x) => x.isEven, defVal: 42),
+ check<int>(create([1, 2, 3, 4, 5], isError: (x) => x.isEven, defaultValue: 42),
(int p, int e) => p * e, 2);
- check(create([1, 2, 3, 4, 5], isError: (x) => x == 5, defVal: 42),
+ check(create([1, 2, 3, 4, 5], isError: (x) => x == 5, defaultValue: 42),
(int p, int e) => p + e, 5);
}
diff --git a/LibTest/async/Stream/single_A03_t01.test.dart b/LibTest/async/Stream/single_A03_t01.test.dart
index 689a9d2..5055fde 100644
--- a/LibTest/async/Stream/single_A03_t01.test.dart
+++ b/LibTest/async/Stream/single_A03_t01.test.dart
@@ -15,8 +15,12 @@
import "../../../Utils/expect.dart";
void test(CreateStreamWithErrorsFunction create) {
- AsyncExpect.error(1, create([1, 2, 3], isError: (_) => true, defVal: 42).single);
- AsyncExpect.error(1, create([1, 2, 3], isError: (x) => x == 1, defVal: 42).single);
- AsyncExpect.error(2, create([1, 2], isError: (x) => x == 2, defVal: 42).single);
- AsyncExpect.error(2, create([1, 2, 3], isError: (x) => x == 2, defVal: 42).single);
+ AsyncExpect.error(
+ 1, create([1, 2, 3], isError: (_) => true, defaultValue: 42).single);
+ AsyncExpect.error(
+ 1, create([1, 2, 3], isError: (x) => x == 1, defaultValue: 42).single);
+ AsyncExpect.error(
+ 2, create([1, 2], isError: (x) => x == 2, defaultValue: 42).single);
+ AsyncExpect.error(
+ 2, create([1, 2, 3], isError: (x) => x == 2, defaultValue: 42).single);
}
diff --git a/LibTest/async/Stream/skipWhile_A02_t01.test.dart b/LibTest/async/Stream/skipWhile_A02_t01.test.dart
index 937784f..f565343 100644
--- a/LibTest/async/Stream/skipWhile_A02_t01.test.dart
+++ b/LibTest/async/Stream/skipWhile_A02_t01.test.dart
@@ -22,14 +22,15 @@
}
void test(CreateStreamWithErrorsFunction create) {
- check(create([1, 2, 3], isError: (_) => true, defVal: 42), (_) => false, [],
- [1, 2, 3]);
- check<int>(create<int>([1, 2, 3, 4, 5], isError: (x) => x.isOdd, defVal: 42),
- (x) => x < 4, [4], [1, 3, 5]);
- check(create<int>([1, 2, 3, 4, 5], isError: (x) => x.isOdd, defVal: 42),
+ check(create([1, 2, 3], isError: (_) => true, defaultValue: 42), (_) => false,
+ [], [1, 2, 3]);
+ check<int>(
+ create<int>([1, 2, 3, 4, 5], isError: (x) => x.isOdd, defaultValue: 42),
+ (x) => x < 4, [4], [1, 3, 5]);
+ check(create<int>([1, 2, 3, 4, 5], isError: (x) => x.isOdd, defaultValue: 42),
(x) => x == 1, [2, 4], [1, 3, 5]);
- check(create<int>([1, 2, 3, 4, 5], isError: (x) => x.isEven, defVal: 42),
+ check(create<int>([1, 2, 3, 4, 5], isError: (x) => x.isEven, defaultValue: 42),
(x) => x == 1, [3, 5], [2, 4]);
- check(create<int>([1, 2, 3, 4, 5], isError: (x) => x < 5, defVal: 42),
+ check(create<int>([1, 2, 3, 4, 5], isError: (x) => x < 5, defaultValue: 42),
(x) => x == 5, [], [1, 2, 3, 4]);
}
diff --git a/LibTest/async/Stream/skip_A03_t01.test.dart b/LibTest/async/Stream/skip_A03_t01.test.dart
index 04a6752..56e3b82 100644
--- a/LibTest/async/Stream/skip_A03_t01.test.dart
+++ b/LibTest/async/Stream/skip_A03_t01.test.dart
@@ -8,8 +8,8 @@
/// if listened to at the same time, except that the first [count]
/// data events are not emitted.
/// The returned stream is done when this stream is.
-/// If this stream emits fewer than [count] data events
-/// before being done, the returned stream emits no data events.
+/// If this stream emits fewer than [count] data events before being done, the
+/// returned stream emits no data events.
/// @description Checks that errors in the input stream are propagated to the
/// returned stream.
/// @author a.semenov@unipro.ru
@@ -20,25 +20,19 @@
void test(CreateStreamWithErrorsFunction create) {
AsyncExpect.events([], [1, 2, 3],
- create([1, 2, 3], isError: (_) => true, defVal: 42).skip(0));
+ create([1, 2, 3], isError: (_) => true, defaultValue: 42).skip(0));
AsyncExpect.events([], [1, 2, 3],
- create([1, 2, 3], isError: (_) => true, defVal: 42).skip(1));
+ create([1, 2, 3], isError: (_) => true, defaultValue: 42).skip(1));
AsyncExpect.events([], [1, 2, 3],
- create([1, 2, 3], isError: (_) => true, defVal: 42).skip(10));
+ create([1, 2, 3], isError: (_) => true, defaultValue: 42).skip(10));
- AsyncExpect.events(
- [],
- [1, 3, 5],
- create<int>([1, 2, 3, 4, 5], isError: (x) => x.isOdd, defVal: 42)
+ AsyncExpect.events([], [1, 3, 5],
+ create<int>([1, 2, 3, 4, 5], isError: (x) => x.isOdd, defaultValue: 42)
.skip(10));
- AsyncExpect.events(
- [3, 5],
- [2, 4],
- create<int>([1, 2, 3, 4, 5], isError: (x) => x.isEven, defVal: 42)
+ AsyncExpect.events([3, 5], [2, 4],
+ create<int>([1, 2, 3, 4, 5], isError: (x) => x.isEven, defaultValue: 42)
.skip(1));
- AsyncExpect.events(
- [5],
- [2, 4],
- create<int>([1, 2, 3, 4, 5], isError: (x) => x.isEven, defVal: 42)
+ AsyncExpect.events([5], [2, 4],
+ create<int>([1, 2, 3, 4, 5], isError: (x) => x.isEven, defaultValue: 42)
.skip(2));
}
diff --git a/LibTest/async/Stream/takeWhile_A01_t02.test.dart b/LibTest/async/Stream/takeWhile_A01_t02.test.dart
index 7fe861a..896692a 100644
--- a/LibTest/async/Stream/takeWhile_A01_t02.test.dart
+++ b/LibTest/async/Stream/takeWhile_A01_t02.test.dart
@@ -6,8 +6,8 @@
/// Forwards data events while test is successful.
/// The returned stream provides the same events as this stream as long as test
/// returns true for the event data.
-/// The stream is done when either this stream is done, or when this stream first
-/// provides a value that test doesn't accept.
+/// The stream is done when either this stream is done, or when this stream
+/// first provides a value that test doesn't accept.
/// @description Checks that all error events (which occur before the returned
/// stream is done) are submitted to the returned stream.
/// Checks that the resulting stream ends with a done event.
@@ -24,24 +24,30 @@
}
void test(CreateStreamWithErrorsFunction create) {
- check(create([1, 2, 3], isError: (_) => true, defVal: 42), (x) => false, [], [1, 2, 3]);
- check(create([1, 2, 3], isError: (_) => true, defVal: 42), (x) => true, [], [1, 2, 3]);
+ check(create([1, 2, 3], isError: (_) => true, defaultValue: 42), (x) => false,
+ [], [1, 2, 3]);
+ check(create([1, 2, 3], isError: (_) => true, defaultValue: 42), (x) => true,
+ [], [1, 2, 3]);
- check(create<int>([1, 2, 3, 4, 5], isError: (x) => x.isOdd, defVal: 42), (x) => false, [],
- [1]);
- check<int>(create<int>([1, 2, 3, 4, 5], isError: (x) => x.isOdd, defVal: 42),
+ check(create<int>([1, 2, 3, 4, 5], isError: (x) => x.isOdd, defaultValue: 42),
+ (x) => false, [], [1]);
+ check<int>(
+ create<int>([1, 2, 3, 4, 5], isError: (x) => x.isOdd, defaultValue: 42),
(x) => x < 4, [2], [1, 3]);
- check(create<int>([1, 2, 3, 4, 5], isError: (x) => x.isEven, defVal: 42), (x) => false,
- [], []);
- check<int>(create<int>([1, 2, 3, 4, 5], isError: (x) => x.isEven, defVal: 42),
+ check(create<int>([1, 2, 3, 4, 5], isError: (x) => x.isEven, defaultValue: 42),
+ (x) => false, [], []);
+ check<int>(
+ create<int>([1, 2, 3, 4, 5], isError: (x) => x.isEven, defaultValue: 42),
(x) => x < 4, [1, 3], [2, 4]);
- check(create<int>([1, 2, 3, 4, 5], isError: (x) => x < 4, defVal: 42), (x) => true,
- [4, 5], [1, 2, 3]);
- check(create<int>([1, 2, 3, 4, 5], isError: (x) => x < 4, defVal: 42), (x) => false, [],
- [1, 2, 3]);
- check<int>(create<int>([1, 2, 3, 4, 5], isError: (x) => x < 4, defVal: 42), (x) => x > 2,
- [4, 5], [1, 2, 3]);
- check<int>(create<int>([1, 2, 3, 4, 5], isError: (x) => x > 2, defVal: 42), (x) => x < 3,
- [1, 2], [3, 4, 5]);
+ check(create<int>([1, 2, 3, 4, 5], isError: (x) => x < 4, defaultValue: 42),
+ (x) => true, [4, 5], [1, 2, 3]);
+ check(create<int>([1, 2, 3, 4, 5], isError: (x) => x < 4, defaultValue: 42),
+ (x) => false, [], [1, 2, 3]);
+ check<int>(
+ create<int>([1, 2, 3, 4, 5], isError: (x) => x < 4, defaultValue: 42),
+ (x) => x > 2, [4, 5], [1, 2, 3]);
+ check<int>(
+ create<int>([1, 2, 3, 4, 5], isError: (x) => x > 2, defaultValue: 42),
+ (x) => x < 3, [1, 2], [3, 4, 5]);
}
diff --git a/LibTest/async/Stream/take_A01_t02.test.dart b/LibTest/async/Stream/take_A01_t02.test.dart
index 0b45544..16d7a48 100644
--- a/LibTest/async/Stream/take_A01_t02.test.dart
+++ b/LibTest/async/Stream/take_A01_t02.test.dart
@@ -4,10 +4,10 @@
/// @assertion Stream<T> take(int count)
/// Provides at most the first n values of this stream.
-/// Forwards the first n data events of this stream, and all error events,
-/// to the returned stream, and ends with a done event.
-/// If this stream produces fewer than count values before it's done,
-/// so will the returned stream.
+/// Forwards the first n data events of this stream, and all error events, to
+/// the returned stream, and ends with a done event.
+/// If this stream produces fewer than count values before it's done, so will
+/// the returned stream.
/// @description Checks that all error events (which are before first n data
/// events) are submitted to the returned stream. Checks that the resulting
/// stream ends with a done event.
@@ -18,23 +18,29 @@
import "dart:async";
import "../../../Utils/expect.dart";
-void check<T>(
+void check<T>(
Stream<T> s, int count, List<T> expectedData, List expectedErrors) {
AsyncExpect.events(expectedData, expectedErrors, s.take(count));
}
void test(CreateStreamWithErrorsFunction create) {
- check(create([1, 2, 3], isError: (_) => true, defVal: 42), 0, [], []);
- check(create([1, 2, 3], isError: (_) => true, defVal: 42), 1, [], [1, 2, 3]);
- check(create([1, 2, 3], isError: (_) => true, defVal: 42), 10, [], [1, 2, 3]);
+ check(create([1, 2, 3], isError: (_) => true, defaultValue: 42), 0, [], []);
+ check(create([1, 2, 3], isError: (_) => true, defaultValue: 42),
+ 1, [], [1, 2, 3]);
+ check(create([1, 2, 3], isError: (_) => true, defaultValue: 42),
+ 10, [], [1, 2, 3]);
- check(create<int>([1, 2, 3, 4, 5], isError: (x) => x.isOdd, defVal: 42), 10, [2, 4],
- [1, 3, 5]);
- check(
- create<int>([1, 2, 3, 4, 5], isError: (x) => x.isOdd, defVal: 42), 2, [2, 4], [1, 3]);
- check(create<int>([1, 2, 3, 4, 5], isError: (x) => x.isEven, defVal: 42), 1, [1], []);
- check(create<int>([1, 2, 3, 4, 5], isError: (x) => x.isEven, defVal: 42), 2, [1, 3], [2]);
+ check(create<int>([1, 2, 3, 4, 5], isError: (x) => x.isOdd, defaultValue: 42),
+ 10, [2, 4], [1, 3, 5]);
+ check(create<int>([1, 2, 3, 4, 5], isError: (x) => x.isOdd, defaultValue: 42),
+ 2, [2, 4], [1, 3]);
+ check(create<int>([1, 2, 3, 4, 5], isError: (x) => x.isEven, defaultValue: 42),
+ 1, [1], []);
+ check(create<int>([1, 2, 3, 4, 5], isError: (x) => x.isEven, defaultValue: 42),
+ 2, [1, 3], [2]);
- check(create<int>([1, 2, 3, 4, 5], isError: (x) => x < 4, defVal: 42), 1, [4], [1, 2, 3]);
- check(create<int>([1, 2, 3, 4, 5], isError: (x) => x > 2, defVal: 42), 2, [1, 2], []);
+ check(create<int>([1, 2, 3, 4, 5], isError: (x) => x < 4, defaultValue: 42),
+ 1, [4], [1, 2, 3]);
+ check(create<int>([1, 2, 3, 4, 5], isError: (x) => x > 2, defaultValue: 42),
+ 2, [1, 2], []);
}
diff --git a/LibTest/async/Stream/timeout_A01_t02.test.dart b/LibTest/async/Stream/timeout_A01_t02.test.dart
index e335514..91fc53b 100644
--- a/LibTest/async/Stream/timeout_A01_t02.test.dart
+++ b/LibTest/async/Stream/timeout_A01_t02.test.dart
@@ -22,10 +22,10 @@
}
void test(CreateStreamWithErrorsFunction create) {
- check(create<int>([1, 2, 3, 4, 5], isError: (x) => true, defVal: 42), [],
- [1, 2, 3, 4, 5]);
- check(create<int>([1, 2, 3, 4, 5], isError: (x) => x.isEven, defVal: 42),
+ check(create<int>([1, 2, 3, 4, 5], isError: (x) => true, defaultValue: 42),
+ [], [1, 2, 3, 4, 5]);
+ check(create<int>([1, 2, 3, 4, 5], isError: (x) => x.isEven, defaultValue: 42),
[1, 3, 5], [2, 4]);
- check(create<int>([1, 2, 3, 4, 5], isError: (x) => x.isOdd, defVal: 42),
+ check(create<int>([1, 2, 3, 4, 5], isError: (x) => x.isOdd, defaultValue: 42),
[2, 4], [1, 3, 5]);
}
diff --git a/LibTest/async/Stream/timeout_A02_t01.test.dart b/LibTest/async/Stream/timeout_A02_t01.test.dart
index 6708c9c..06170b8 100644
--- a/LibTest/async/Stream/timeout_A02_t01.test.dart
+++ b/LibTest/async/Stream/timeout_A02_t01.test.dart
@@ -21,9 +21,9 @@
void test(CreateStreamFunction create) {
int count = 0;
Stream s1 = create(["a", "b", "c"]);
- Stream s2 = s1.asyncMap((x) => new Future.delayed(durationMs(100), () => x));
+ Stream s2 = s1.asyncMap((x) => new Future.delayed(durationInMilliseconds(100), () => x));
Stream s3 = s2.timeout(
- durationMs(10),
+ durationInMilliseconds(10),
onTimeout: (EventSink sink) => sink.add(count++)
);
AsyncExpect.data([0, "a", 1, "b", 2, "c"], s3);
diff --git a/LibTest/async/Stream/timeout_A02_t02.test.dart b/LibTest/async/Stream/timeout_A02_t02.test.dart
index 5c1fe6e..22a1752 100644
--- a/LibTest/async/Stream/timeout_A02_t02.test.dart
+++ b/LibTest/async/Stream/timeout_A02_t02.test.dart
@@ -22,7 +22,7 @@
// delay for 100 ms and throw error if element starts with '!'
Stream s2 = s.asyncMap(
(x) => new Future.delayed(
- durationMs(100),
+ durationInMilliseconds(100),
() {
if (x is String && x.startsWith("!")){
throw x;
@@ -32,7 +32,7 @@
)
);
Stream s3 = s2.timeout(
- durationMs(10),
+ durationInMilliseconds(10),
onTimeout: (EventSink sink) => sink.add(count++)
);
List actualEvents = [];
diff --git a/LibTest/async/Stream/timeout_A03_t01.test.dart b/LibTest/async/Stream/timeout_A03_t01.test.dart
index a35dcff..182fa85 100644
--- a/LibTest/async/Stream/timeout_A03_t01.test.dart
+++ b/LibTest/async/Stream/timeout_A03_t01.test.dart
@@ -20,8 +20,8 @@
void test(CreateStreamFunction create) {
int count = 0;
Stream s1 = create(["a", "b", "c"]);
- Stream s2 = s1.asyncMap((x) => new Future.delayed(durationMs(100), () => x));
- Stream s3 = s2.timeout(durationMs(10));
+ Stream s2 = s1.asyncMap((x) => new Future.delayed(durationInMilliseconds(100), () => x));
+ Stream s3 = s2.timeout(durationInMilliseconds(10));
List actual = [];
asyncStart();
s3.listen(
diff --git a/LibTest/async/Stream/timeout_A03_t02.test.dart b/LibTest/async/Stream/timeout_A03_t02.test.dart
index 180b9e9..e344982 100644
--- a/LibTest/async/Stream/timeout_A03_t02.test.dart
+++ b/LibTest/async/Stream/timeout_A03_t02.test.dart
@@ -23,7 +23,7 @@
// delay for 100 ms and throw error if element starts with '!'
Stream s2 = s.asyncMap(
(x) => new Future.delayed(
- durationMs(100),
+ durationInMilliseconds(100),
() {
if (x is String && x.startsWith("!")){
throw x;
@@ -32,7 +32,7 @@
}
)
);
- Stream s3 = s2.timeout(durationMs(10));
+ Stream s3 = s2.timeout(durationInMilliseconds(10));
List actualEvents = [];
asyncStart();
s3.listen(
diff --git a/LibTest/async/Stream/timeout_A05_t01.test.dart b/LibTest/async/Stream/timeout_A05_t01.test.dart
index 8bd2215..0d11deb 100644
--- a/LibTest/async/Stream/timeout_A05_t01.test.dart
+++ b/LibTest/async/Stream/timeout_A05_t01.test.dart
@@ -14,10 +14,10 @@
import "../../../Utils/expect.dart";
void check<T>(Stream<T> s, T timeoutValue) {
- Expect.equals(s.isBroadcast, s.timeout(durationMs(10)).isBroadcast);
+ Expect.equals(s.isBroadcast, s.timeout(durationInMilliseconds(10)).isBroadcast);
Expect.equals(s.isBroadcast,
s.timeout(
- durationMs(10),
+ durationInMilliseconds(10),
onTimeout:(EventSink<T> sink) => sink.add(timeoutValue)
).isBroadcast
);
diff --git a/LibTest/async/Stream/transform_A01_t01.test.dart b/LibTest/async/Stream/transform_A01_t01.test.dart
index 1aebc61..c6938dd 100644
--- a/LibTest/async/Stream/transform_A01_t01.test.dart
+++ b/LibTest/async/Stream/transform_A01_t01.test.dart
@@ -30,16 +30,17 @@
}
void test(CreateStreamWithErrorsFunction create) {
- check(create([1, 2, 3, 4, 5], defVal: 42), passThrough, [1, 2, 3, 4, 5], []);
- check(create<int>([1, 2, 3, 4, 5], isError: (x) => x.isOdd, defVal: 42), passThrough,
- [2, 4], [1, 3, 5]);
- check(create([1, 2, 3, 4, 5], isError: (x) => true, defVal: 42), passThrough, [],
- [1, 2, 3, 4, 5]);
+ check(create([1, 2, 3, 4, 5], defaultValue: 42),
+ passThrough, [1, 2, 3, 4, 5], []);
+ check(create<int>([1, 2, 3, 4, 5], isError: (x) => x.isOdd, defaultValue: 42),
+ passThrough, [2, 4], [1, 3, 5]);
+ check(create([1, 2, 3, 4, 5], isError: (x) => true, defaultValue: 42),
+ passThrough, [], [1, 2, 3, 4, 5]);
- check(create([1, 2, 3, 4, 5], defVal: 42), doubleDataNegateError,
+ check(create([1, 2, 3, 4, 5], defaultValue: 42), doubleDataNegateError,
[1, 1, 2, 2, 3, 3, 4, 4, 5, 5], []);
- check(create<int>([1, 2, 3, 4, 5], isError: (x) => x.isOdd, defVal: 42),
+ check(create<int>([1, 2, 3, 4, 5], isError: (x) => x.isOdd, defaultValue: 42),
doubleDataNegateError, [2, 2, 4, 4], [-1, -3, -5]);
- check(create([1, 2, 3, 4, 5], isError: (x) => true, defVal: 42), doubleDataNegateError,
- [], [-1, -2, -3, -4, -5]);
+ check(create([1, 2, 3, 4, 5], isError: (x) => true, defaultValue: 42),
+ doubleDataNegateError, [], [-1, -2, -3, -4, -5]);
}
diff --git a/LibTest/async/Stream/where_A01_t02.test.dart b/LibTest/async/Stream/where_A01_t02.test.dart
index 8db640e..0f0ed2f 100644
--- a/LibTest/async/Stream/where_A01_t02.test.dart
+++ b/LibTest/async/Stream/where_A01_t02.test.dart
@@ -21,14 +21,16 @@
}
void test(CreateStreamWithErrorsFunction create) {
- check(create([1, 2, 3, 4, 5], isError: (x) => true, defVal: 42), (e) => true,
- [], [1, 2, 3, 4, 5]);
- check(create<int>([1, 2, 3, 4, 5], isError: (x) => x.isEven, defVal: 42),
+ check(create([1, 2, 3, 4, 5], isError: (x) => true, defaultValue: 42),
+ (e) => true, [], [1, 2, 3, 4, 5]);
+ check(create<int>([1, 2, 3, 4, 5], isError: (x) => x.isEven, defaultValue: 42),
(e) => true, [1, 3, 5], [2, 4]);
- check<int>(create<int>([1, 2, 3, 4, 5], isError: (x) => x.isEven, defVal: 42),
+ check<int>(
+ create<int>([1, 2, 3, 4, 5], isError: (x) => x.isEven, defaultValue: 42),
(e) => e > 1, [3, 5], [2, 4]);
- check(create<int>([1, 2, 3, 4, 5], isError: (x) => x.isEven, defVal: 42),
+ check(create<int>([1, 2, 3, 4, 5], isError: (x) => x.isEven, defaultValue: 42),
(e) => false, [], [2, 4]);
- check<int>(create<int>([1, 2, 3, 4, 5], isError: (x) => x.isEven, defVal: 42),
+ check<int>(
+ create<int>([1, 2, 3, 4, 5], isError: (x) => x.isEven, defaultValue: 42),
(e) => throw e, [], [1, 2, 3, 4, 5]);
}
diff --git a/LibTest/async/StreamController/StreamController.broadcast_A07_t03.dart b/LibTest/async/StreamController/StreamController.broadcast_A07_t03.dart
index 58b9dcb..dafd54b 100644
--- a/LibTest/async/StreamController/StreamController.broadcast_A07_t03.dart
+++ b/LibTest/async/StreamController/StreamController.broadcast_A07_t03.dart
@@ -32,7 +32,7 @@
);
int i = 0, k = 0;
- new Timer.periodic(durationMs(100), (Timer timer) {
+ new Timer.periodic(durationInMilliseconds(100), (Timer timer) {
new Future.value(subscriptions[i].cancel()).then(
(_) {
Expect.equals((++k < 5) ? 0 : 1, onCancelCallCount);
diff --git a/LibTest/async/StreamController/StreamController.broadcast_A08_t02.dart b/LibTest/async/StreamController/StreamController.broadcast_A08_t02.dart
index 6b89444..24346c1 100644
--- a/LibTest/async/StreamController/StreamController.broadcast_A08_t02.dart
+++ b/LibTest/async/StreamController/StreamController.broadcast_A08_t02.dart
@@ -21,7 +21,7 @@
Future unsubscribe(List<StreamSubscription> subscriptions, int count) {
count--;
- return new Future.delayed(durationMs(50), () => subscriptions[count].cancel())
+ return new Future.delayed(durationInMilliseconds(50), () => subscriptions[count].cancel())
.then((_) {
if (count > 0) {
return unsubscribe(subscriptions, count);
diff --git a/LibTest/async/StreamController/StreamController.broadcast_Stream_all_A01_t02.dart b/LibTest/async/StreamController/StreamController.broadcast_Stream_all_A01_t02.dart
index 1589bfb..6bdf08c 100644
--- a/LibTest/async/StreamController/StreamController.broadcast_Stream_all_A01_t02.dart
+++ b/LibTest/async/StreamController/StreamController.broadcast_Stream_all_A01_t02.dart
@@ -18,7 +18,8 @@
import "dart:async";
import "../Stream/allTests_A02.lib.dart";
-Stream<T> create<T>(Iterable<T> data, {bool isError(T element)?, T? defVal}) {
+Stream<T> create<T>(
+ Iterable<T> data, {bool isError(T element)?, T? defaultValue}) {
StreamController<T>? sc;
sc = new StreamController<T>.broadcast(
onListen:() {
diff --git a/LibTest/async/StreamController/StreamController.broadcast_Stream_all_A02_t02.dart b/LibTest/async/StreamController/StreamController.broadcast_Stream_all_A02_t02.dart
index f4fc9b2..1598dcd 100644
--- a/LibTest/async/StreamController/StreamController.broadcast_Stream_all_A02_t02.dart
+++ b/LibTest/async/StreamController/StreamController.broadcast_Stream_all_A02_t02.dart
@@ -18,7 +18,8 @@
import "dart:async";
import "../Stream/allTests_A02.lib.dart";
-Stream<T> create<T>(Iterable<T> data, {bool isError(T element)?, T? defVal}) {
+Stream<T> create<T>(
+ Iterable<T> data, {bool isError(T element)?, T? defaultValue}) {
StreamController<T>? sc;
sc = new StreamController<T>.broadcast(
sync: true,
diff --git a/LibTest/async/StreamController/StreamController_A07_t01.dart b/LibTest/async/StreamController/StreamController_A07_t01.dart
index 406ac2d..7b8ffab 100644
--- a/LibTest/async/StreamController/StreamController_A07_t01.dart
+++ b/LibTest/async/StreamController/StreamController_A07_t01.dart
@@ -19,7 +19,7 @@
bool onCancelFutureComplete = false;
StreamController controller = new StreamController(
onCancel: () => new Future.delayed(
- durationMs(100),
+ durationInMilliseconds(100),
() {
onCancelFutureComplete = true;
}
diff --git a/LibTest/async/StreamController/stream_all_A01_t02.dart b/LibTest/async/StreamController/stream_all_A01_t02.dart
index bfedd63..14d415a 100644
--- a/LibTest/async/StreamController/stream_all_A01_t02.dart
+++ b/LibTest/async/StreamController/stream_all_A01_t02.dart
@@ -10,7 +10,8 @@
import "dart:async";
import "../Stream/allTests_A02.lib.dart";
-Stream<T> create<T>(Iterable<T> data, {bool isError(T element)?, T? defVal}) {
+Stream<T> create<T>(
+ Iterable<T> data, {bool isError(T element)?, T? defaultValue}) {
StreamController<T> sc = new StreamController<T>();
for (T e in data) {
if (isError != null && isError(e)) {
diff --git a/LibTest/async/StreamController/stream_all_A02_t02.dart b/LibTest/async/StreamController/stream_all_A02_t02.dart
index 33f9989..ab2025e 100644
--- a/LibTest/async/StreamController/stream_all_A02_t02.dart
+++ b/LibTest/async/StreamController/stream_all_A02_t02.dart
@@ -10,7 +10,7 @@
import "dart:async";
import "../Stream/allTests_A02.lib.dart";
-Stream<T> create<T>(Iterable<T> data, {bool isError(T element)?, T? defVal}) {
+Stream<T> create<T>(Iterable<T> data, {bool isError(T element)?, T? defaultValue}) {
StreamController<T>? sc;
sc = new StreamController<T>(
sync: true,
diff --git a/LibTest/async/Timer/Timer.periodic_A01_t01.dart b/LibTest/async/Timer/Timer.periodic_A01_t01.dart
index 1de955a..40bc43e 100644
--- a/LibTest/async/Timer/Timer.periodic_A01_t01.dart
+++ b/LibTest/async/Timer/Timer.periodic_A01_t01.dart
@@ -15,7 +15,7 @@
main() {
int times = 10;
int count = 0;
- Duration delay = durationMs(20);
+ Duration delay = durationInMilliseconds(20);
Stopwatch sw = new Stopwatch();
sw.start();
diff --git a/LibTest/async/Timer/Timer.periodic_A02_t01.dart b/LibTest/async/Timer/Timer.periodic_A02_t01.dart
index 810ba71..a25a3f3 100644
--- a/LibTest/async/Timer/Timer.periodic_A02_t01.dart
+++ b/LibTest/async/Timer/Timer.periodic_A02_t01.dart
@@ -14,7 +14,7 @@
int times = 5;
int count = 0;
asyncStart();
- new Timer.periodic(durationMs(delay), (Timer timer) {
+ new Timer.periodic(durationInMilliseconds(delay), (Timer timer) {
count++;
if (count == times) {
timer.cancel();
diff --git a/LibTest/async/Timer/Timer_A01_t01.dart b/LibTest/async/Timer/Timer_A01_t01.dart
index 4ba357b..2f7eff8 100644
--- a/LibTest/async/Timer/Timer_A01_t01.dart
+++ b/LibTest/async/Timer/Timer_A01_t01.dart
@@ -12,7 +12,7 @@
import "../../../Utils/expect.dart";
check(int delayms) {
- Duration delay = durationMs(delayms);
+ Duration delay = durationInMilliseconds(delayms);
Stopwatch sw = new Stopwatch();
sw.start();
diff --git a/LibTest/async/Timer/Timer_A02_t01.dart b/LibTest/async/Timer/Timer_A02_t01.dart
index 3b52f22..920e010 100644
--- a/LibTest/async/Timer/Timer_A02_t01.dart
+++ b/LibTest/async/Timer/Timer_A02_t01.dart
@@ -14,7 +14,7 @@
bool seen = false;
asyncStart();
- new Timer(durationMs(delayms), () {
+ new Timer(durationInMilliseconds(delayms), () {
Expect.isFalse(seen);
seen = true;
asyncEnd();
diff --git a/LibTest/async/Timer/cancel_A01_t01.dart b/LibTest/async/Timer/cancel_A01_t01.dart
index 1b5ae44..b2f863c 100644
--- a/LibTest/async/Timer/cancel_A01_t01.dart
+++ b/LibTest/async/Timer/cancel_A01_t01.dart
@@ -14,14 +14,14 @@
int delay = 20;
int count = 0;
- Timer timer = new Timer.periodic(durationMs(delay), (Timer t) {
+ Timer timer = new Timer.periodic(durationInMilliseconds(delay), (Timer t) {
count++;
}
);
timer.cancel();
asyncStart();
- new Timer(durationMs(delay * 3), () {
+ new Timer(durationInMilliseconds(delay * 3), () {
Expect.equals(count, 0);
asyncEnd();
});
diff --git a/LibTest/async/Timer/cancel_A01_t02.dart b/LibTest/async/Timer/cancel_A01_t02.dart
index fe69d42..908c7ac 100644
--- a/LibTest/async/Timer/cancel_A01_t02.dart
+++ b/LibTest/async/Timer/cancel_A01_t02.dart
@@ -14,14 +14,14 @@
int delay = 20;
int count = 0;
- Timer timer = new Timer(durationMs(delay), () {
+ Timer timer = new Timer(durationInMilliseconds(delay), () {
count++;
}
);
timer.cancel();
asyncStart();
- new Timer(durationMs(delay * 3), () {
+ new Timer(durationInMilliseconds(delay * 3), () {
Expect.equals(count, 0);
asyncEnd();
});
diff --git a/LibTest/async/Timer/isActive_A01_t01.dart b/LibTest/async/Timer/isActive_A01_t01.dart
index a1d0853..8993628 100644
--- a/LibTest/async/Timer/isActive_A01_t01.dart
+++ b/LibTest/async/Timer/isActive_A01_t01.dart
@@ -17,7 +17,7 @@
check(int delayms) {
asyncStart();
Timer? t;
- t = new Timer(durationMs(delayms), () {
+ t = new Timer(durationInMilliseconds(delayms), () {
Expect.isFalse(t!.isActive);
asyncEnd();
});
diff --git a/LibTest/async/Timer/isActive_A01_t02.dart b/LibTest/async/Timer/isActive_A01_t02.dart
index a50030e..776a79a 100644
--- a/LibTest/async/Timer/isActive_A01_t02.dart
+++ b/LibTest/async/Timer/isActive_A01_t02.dart
@@ -19,7 +19,7 @@
int count = 0;
asyncStart();
- Timer t = new Timer.periodic(durationMs(delay), (Timer timer) {
+ Timer t = new Timer.periodic(durationInMilliseconds(delay), (Timer timer) {
count++;
Expect.isTrue(timer.isActive);
if (count == times) {
diff --git a/LibTest/async/Timer/run_A01_t01.dart b/LibTest/async/Timer/run_A01_t01.dart
index 88309e9..07dbb59 100644
--- a/LibTest/async/Timer/run_A01_t01.dart
+++ b/LibTest/async/Timer/run_A01_t01.dart
@@ -19,7 +19,7 @@
count++;
});
- new Timer(durationMs(100), () {
+ new Timer(durationInMilliseconds(100), () {
Expect.equals(1, count);
asyncEnd();
});
diff --git a/LibTest/core/ArgumentError/ArgumentError.notNull_A01_t02.dart b/LibTest/core/ArgumentError/ArgumentError.notNull_A01_t02.dart
index e706468..20261c2 100644
--- a/LibTest/core/ArgumentError/ArgumentError.notNull_A01_t02.dart
+++ b/LibTest/core/ArgumentError/ArgumentError.notNull_A01_t02.dart
@@ -12,6 +12,6 @@
main() {
ArgumentError err = new ArgumentError.notNull();
- Expect.isNull(null, err.name);
+ Expect.isNull(null, err.name ?? 'unnamed error');
Expect.equals("Must not be null", err.message);
}
diff --git a/LibTest/core/Stopwatch/elapsedMicroseconds_A01_t01.dart b/LibTest/core/Stopwatch/elapsedMicroseconds_A01_t01.dart
index 9ead733..d796277 100644
--- a/LibTest/core/Stopwatch/elapsedMicroseconds_A01_t01.dart
+++ b/LibTest/core/Stopwatch/elapsedMicroseconds_A01_t01.dart
@@ -12,7 +12,7 @@
import "dart:async";
import "../../../Utils/expect.dart";
-Duration delay = durationMs(10);
+Duration delay = durationInMilliseconds(10);
Stopwatch sw = new Stopwatch();
int count = 5;
diff --git a/LibTest/core/Stopwatch/elapsedMilliseconds_A01_t01.dart b/LibTest/core/Stopwatch/elapsedMilliseconds_A01_t01.dart
index ec74786..be2564c 100644
--- a/LibTest/core/Stopwatch/elapsedMilliseconds_A01_t01.dart
+++ b/LibTest/core/Stopwatch/elapsedMilliseconds_A01_t01.dart
@@ -12,7 +12,7 @@
import "dart:async";
import "../../../Utils/expect.dart";
-Duration delay = durationMs(10);
+Duration delay = durationInMilliseconds(10);
Stopwatch sw = new Stopwatch();
int count = 5;
diff --git a/LibTest/core/Stopwatch/elapsedTicks_A01_t01.dart b/LibTest/core/Stopwatch/elapsedTicks_A01_t01.dart
index e97c232..b464a66 100644
--- a/LibTest/core/Stopwatch/elapsedTicks_A01_t01.dart
+++ b/LibTest/core/Stopwatch/elapsedTicks_A01_t01.dart
@@ -16,7 +16,7 @@
import "dart:async";
import "../../../Utils/expect.dart";
-Duration delay = durationMs(10);
+Duration delay = durationInMilliseconds(10);
Stopwatch sw = new Stopwatch();
int count = 5;
int e0 = 0;
diff --git a/LibTest/core/Stopwatch/elapsedTicks_A01_t02.dart b/LibTest/core/Stopwatch/elapsedTicks_A01_t02.dart
index 4dea05a..f3fe0fa 100644
--- a/LibTest/core/Stopwatch/elapsedTicks_A01_t02.dart
+++ b/LibTest/core/Stopwatch/elapsedTicks_A01_t02.dart
@@ -16,7 +16,7 @@
import "dart:async";
import "../../../Utils/expect.dart";
-Duration delay = durationMs(10);
+Duration delay = durationInMilliseconds(10);
Stopwatch sw = new Stopwatch();
int count = 5;
int e0 = 0;
diff --git a/LibTest/core/Stopwatch/elapsedTicks_A01_t03.dart b/LibTest/core/Stopwatch/elapsedTicks_A01_t03.dart
index 2fcaab9..fde04ba 100644
--- a/LibTest/core/Stopwatch/elapsedTicks_A01_t03.dart
+++ b/LibTest/core/Stopwatch/elapsedTicks_A01_t03.dart
@@ -16,7 +16,7 @@
import "dart:async";
import "../../../Utils/expect.dart";
-Duration delay = durationMs(10);
+Duration delay = durationInMilliseconds(10);
Stopwatch sw = new Stopwatch();
int count = 5;
diff --git a/LibTest/core/Stopwatch/elapsed_A01_t01.dart b/LibTest/core/Stopwatch/elapsed_A01_t01.dart
index 4f573e4..c3915f9 100644
--- a/LibTest/core/Stopwatch/elapsed_A01_t01.dart
+++ b/LibTest/core/Stopwatch/elapsed_A01_t01.dart
@@ -11,7 +11,7 @@
import "dart:async";
import "../../../Utils/expect.dart";
-Duration delay = durationMs(50);
+Duration delay = durationInMilliseconds(50);
Stopwatch sw = new Stopwatch();
Duration e0 = new Duration();
diff --git a/LibTest/core/Stopwatch/elapsed_A01_t02.dart b/LibTest/core/Stopwatch/elapsed_A01_t02.dart
index 5185455..681718a 100644
--- a/LibTest/core/Stopwatch/elapsed_A01_t02.dart
+++ b/LibTest/core/Stopwatch/elapsed_A01_t02.dart
@@ -11,7 +11,7 @@
import "dart:async";
import "../../../Utils/expect.dart";
-Duration delay = durationMs(50);
+Duration delay = durationInMilliseconds(50);
Stopwatch sw = new Stopwatch();
Duration e0 = new Duration();
diff --git a/LibTest/core/Stopwatch/elapsed_A01_t03.dart b/LibTest/core/Stopwatch/elapsed_A01_t03.dart
index 5dbebe8..314f345 100644
--- a/LibTest/core/Stopwatch/elapsed_A01_t03.dart
+++ b/LibTest/core/Stopwatch/elapsed_A01_t03.dart
@@ -11,7 +11,7 @@
import "dart:async";
import "../../../Utils/expect.dart";
-Duration delay = durationMs(50);
+Duration delay = durationInMilliseconds(50);
Stopwatch sw = new Stopwatch();
main() {
diff --git a/LibTest/core/Stopwatch/isRunning_A01_t01.dart b/LibTest/core/Stopwatch/isRunning_A01_t01.dart
index 4e9ebb1..1ff3a92 100644
--- a/LibTest/core/Stopwatch/isRunning_A01_t01.dart
+++ b/LibTest/core/Stopwatch/isRunning_A01_t01.dart
@@ -11,7 +11,7 @@
import "dart:async";
import "../../../Utils/expect.dart";
-Duration delay = durationMs(20);
+Duration delay = durationInMilliseconds(20);
Stopwatch sw = new Stopwatch();
main() {
diff --git a/LibTest/core/Stopwatch/reset_A01_t01.dart b/LibTest/core/Stopwatch/reset_A01_t01.dart
index e62fbb4..50249e8 100644
--- a/LibTest/core/Stopwatch/reset_A01_t01.dart
+++ b/LibTest/core/Stopwatch/reset_A01_t01.dart
@@ -11,7 +11,7 @@
import "dart:async";
import "../../../Utils/expect.dart";
-Duration delay = durationMs(50);
+Duration delay = durationInMilliseconds(50);
Stopwatch sw = new Stopwatch();
int e0 = 0;
diff --git a/LibTest/core/Stopwatch/start_A01_t01.dart b/LibTest/core/Stopwatch/start_A01_t01.dart
index 168930d..c084a33 100644
--- a/LibTest/core/Stopwatch/start_A01_t01.dart
+++ b/LibTest/core/Stopwatch/start_A01_t01.dart
@@ -15,7 +15,7 @@
import "dart:async";
import "../../../Utils/expect.dart";
-Duration delay = durationMs(50);
+Duration delay = durationInMilliseconds(50);
Stopwatch sw = new Stopwatch();
int e0 = 0;
diff --git a/LibTest/core/Stopwatch/start_A01_t02.dart b/LibTest/core/Stopwatch/start_A01_t02.dart
index 4c144d1..8f98c32 100644
--- a/LibTest/core/Stopwatch/start_A01_t02.dart
+++ b/LibTest/core/Stopwatch/start_A01_t02.dart
@@ -15,7 +15,7 @@
import "dart:async";
import "../../../Utils/expect.dart";
-Duration delay = durationMs(50);
+Duration delay = durationInMilliseconds(50);
Stopwatch sw = new Stopwatch();
int e0 = 0;
diff --git a/LibTest/core/Stopwatch/start_A01_t03.dart b/LibTest/core/Stopwatch/start_A01_t03.dart
index 63aedba..4396a25 100644
--- a/LibTest/core/Stopwatch/start_A01_t03.dart
+++ b/LibTest/core/Stopwatch/start_A01_t03.dart
@@ -15,7 +15,7 @@
import "dart:async";
import "../../../Utils/expect.dart";
-Duration delay = durationMs(50);
+Duration delay = durationInMilliseconds(50);
Stopwatch sw = new Stopwatch();
int e0 = 0;
diff --git a/LibTest/core/Stopwatch/stop_A01_t01.dart b/LibTest/core/Stopwatch/stop_A01_t01.dart
index dfa7291..f328623 100644
--- a/LibTest/core/Stopwatch/stop_A01_t01.dart
+++ b/LibTest/core/Stopwatch/stop_A01_t01.dart
@@ -13,7 +13,7 @@
import "dart:async";
import "../../../Utils/expect.dart";
-Duration delay = durationMs(10);
+Duration delay = durationInMilliseconds(10);
Stopwatch sw = new Stopwatch();
int count = 5;
int ticks = -1;
diff --git a/LibTest/io/RawDatagramSocket/timeout_A06_t01.dart b/LibTest/io/RawDatagramSocket/timeout_A06_t01.dart
index fd91a43..609373a 100644
--- a/LibTest/io/RawDatagramSocket/timeout_A06_t01.dart
+++ b/LibTest/io/RawDatagramSocket/timeout_A06_t01.dart
@@ -51,7 +51,7 @@
});
Stream bcs = receiver.asBroadcastStream();
- Stream s = bcs.timeout(durationMs(1));
+ Stream s = bcs.timeout(durationInMilliseconds(1));
s.listen((event) {
list1.add(event);
receiver.receive();
diff --git a/LibTest/isolate/ReceivePort/asBroadcastStream_A04_t03.dart b/LibTest/isolate/ReceivePort/asBroadcastStream_A04_t03.dart
index a985ee7..88e5387 100644
--- a/LibTest/isolate/ReceivePort/asBroadcastStream_A04_t03.dart
+++ b/LibTest/isolate/ReceivePort/asBroadcastStream_A04_t03.dart
@@ -71,5 +71,5 @@
}
}
- timer = new Timer.periodic(durationMs(10), addSubscribersIfNeeded);
+ timer = new Timer.periodic(durationInMilliseconds(10), addSubscribersIfNeeded);
}
diff --git a/Utils/async_utils.dart b/Utils/async_utils.dart
index 2d5e5ed..c65ca77 100644
--- a/Utils/async_utils.dart
+++ b/Utils/async_utils.dart
@@ -2,22 +2,22 @@
// 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.
-part of Expect;
+part of 'expect.dart';
-const ONE_MS = const Duration(milliseconds: 1);
+const oneMillisecond = const Duration(milliseconds: 1);
typedef CreateStreamFunction = Stream<T> Function<T>(Iterable<T> values);
typedef CreateStreamWithErrorsFunction =
Stream<T> Function<T>(Iterable<T> values,
- {bool Function(T element)? isError, required T defVal});
+ {bool Function(T element)? isError, required T defaultValue});
-Duration durationMs(delay) {
- return delay == null ? Duration.zero : ONE_MS * delay;
+Duration durationInMilliseconds(delay) {
+ return delay == null ? Duration.zero : oneMillisecond * delay;
}
Future runLater(void action(), [int delay = 0]) {
asyncStart();
- return new Future.delayed(durationMs(delay), (){
+ return Future.delayed(durationInMilliseconds(delay), () {
action();
asyncEnd();
});
@@ -31,10 +31,9 @@
});
}
-/// Let the test driver know the test is asynchronous and
-/// continues after the method main() exits.
-/// see co19 issue #423
-/// http://code.google.com/p/co19/issues/detail?id=423
+/// Let the test driver know the test is asynchronous and continues after the
+/// method main() exits.
+/// See http://code.google.com/p/co19/issues/detail?id=423
Completer _completer = new Completer();
Future asyncCompleted = _completer.future;
@@ -48,16 +47,13 @@
void asyncStart() {
_asyncCounter++;
-// print("asyncStart");
}
void asyncMultiStart(int delta) {
-// print("asyncMultiStart $delta");
_asyncCounter += delta;
}
void asyncEnd() {
-// print("asyncEnd");
Expect.isFalse(_asyncCounter == 0, "asyncEnd: _asyncCounter==0");
_asyncCounter--;
if (_asyncCounter == 0) {
@@ -93,17 +89,19 @@
}
/*----------------------------*/
-/// asyncTest is intended for executing tests with asynchronous nature.
-/// If [setup] is provided, it will be executed first in order to prepare
+/// [asyncTest] is intended for executing tests with asynchronous nature.
+///
+/// If [setup] is provided, it will be executed first in order to prepare
/// necessary environment for the test (i.e. create some files, start some
/// services, etc). The [setup] may return some value, which will be passed to
/// [test] and to [cleanup].
-/// [test] is main test code. It should return Future instance, which completes
-/// when test is over. The future may complete with error, in this case the whole
-/// test will fail.
-/// If [cleanup] is provided it will be executed after Future returned by [test]
-/// is completed. [cleanup] is always called, regardless of test's status.
-
+///
+/// [test] is the main test code. It should return [Future] instance, which
+/// completes when test is over. The future may complete with error, in this
+/// case the whole test will fail.
+///
+/// If [cleanup] is provided it will be executed after [Future] returned by
+/// [test] is completed. [cleanup] is always called, regardless of test status.
void asyncTest<T>(Future test(T? value), {required Future<T> setup(),
required void cleanup(T? value)}) {
asyncStart();
@@ -117,28 +115,27 @@
});
}
-/// AsyncExpect is intended for async test to ease checking
-/// Future completion value and checking Stream content.
-
+/// [AsyncExpect] is intended for async test to ease checking [Future]
+/// completion value and checking Stream content.
class AsyncExpect {
-/// Checks whether the given future completes with expected value.
-/// Returns the Future, that may be used for test cleanup via method
-/// whenComplete(). If checks are passed, the returned future completes
-/// the same way as supplied one. Otherwise, the returned future completes
-/// with error.
- static Future<T> value<T>(T expected, Future<T> future, [String? reason = null]) {
- if (reason == null){
- reason = StackTrace.current.toString();
- }
+ /// Checks whether the given future completes with expected value.
+ ///
+ /// Returns [Future], that may be used for test cleanup via method
+ /// [whenComplete]. If checks are passed, the returned future completes the
+ /// same way as a supplied one. Otherwise, the returned future completes with
+ /// error.
+ static Future<T> value<T>(
+ T expected, Future<T> future, [String? reason]) {
+ String msg = reason ?? StackTrace.current.toString();
asyncStart();
return future.then((T value){
if (expected is List) {
- Expect.listEquals(expected, value, reason);
+ Expect.listEquals(expected, value, msg);
} else if (expected is Set) {
- Expect.setEquals(expected, value as Iterable<Object?>, reason);
+ Expect.setEquals(expected, value as Iterable<Object?>, msg);
} else {
- Expect.equals(expected, value, reason);
+ Expect.equals(expected, value, msg);
}
asyncEnd();
return value;
@@ -146,27 +143,26 @@
}
-/// Checks whether the given future completes with expected error.
-/// Returns the Future, that may be used for test cleanup via method
-/// whenComplete(). If checks are passed, the returned future completes
-/// the same way as supplied one. Otherwise, the returned future completes
-/// with error.
- static Future<T?> error<T>(Object error, Future<T> future, [String? reason = null]) {
- if (reason == null){
- reason = StackTrace.current.toString();
- }
+ /// Checks whether the given future completes with expected error.
+ ///
+ /// Returns [Future], that may be used for test cleanup via method
+ /// [whenComplete]. If checks are passed, the returned future completes the
+ /// same way as a supplied one. Otherwise, the returned future completes
+ /// with error.
+ static Future<T?> error<T>(
+ Object error, Future<T> future, [String? reason]) {
+ String msg = reason ?? StackTrace.current.toString();
asyncStart();
return future.then(
(_) {
- Expect.fail("The future is expected to complete with error $reason");
+ Expect.fail("The future is expected to complete with error $msg");
return future;
},
- onError: (e) {
- // print("On error called");
+ onError: (e) {
if (error is Function) {
- Expect.isTrue(Function.apply(error, [e]), reason);
+ Expect.isTrue(Function.apply(error, [e]), msg);
} else {
- Expect.equals(error, e, reason);
+ Expect.equals(error, e, msg);
}
asyncEnd();
return null;
@@ -174,13 +170,12 @@
);
}
-/// Checks whether the given stream contains expected data events.
-/// Any error in the stream is unexpected and wil fail the test.
- static Future<bool> data<T>(List<T> data, Stream<T> stream, [String? reason = null]) {
- if (reason == null){
- reason = StackTrace.current.toString();
- }
- Completer<bool> completer = new Completer<bool>();
+ /// Checks whether the given stream contains expected data events.
+ /// Any error in the stream is unexpected and wil fail the test.
+ static Future<bool> data<T>(
+ List<T> data, Stream<T> stream, [String? reason]) {
+ String msg = reason ?? StackTrace.current.toString();
+ Completer<bool> completer = Completer<bool>();
List<T> actual = [];
asyncStart();
stream.listen(
@@ -188,7 +183,7 @@
actual.add(value);
},
onDone: () {
- Expect.listEquals(data, actual, reason);
+ Expect.listEquals(data, actual, msg);
asyncEnd();
completer.complete(true);
}
@@ -196,11 +191,10 @@
return completer.future;
}
-/// Checks whether the given stream contains expected data and error events.
- static Future<bool> events<T>(List<T> data, List errors, Stream<T> stream, [String? reason = null]) {
- if (reason == null){
- reason = StackTrace.current.toString();
- }
+ /// Checks whether the given stream contains expected data and error events.
+ static Future<bool> events<T>
+ (List<T> data, List errors, Stream<T> stream, [String? reason]) {
+ String msg = reason ?? StackTrace.current.toString();
Completer<bool> completer = new Completer<bool>();
List<T> actualData = [];
List actualErrors = [];
@@ -213,8 +207,8 @@
actualErrors.add(error);
},
onDone: () {
- Expect.listEquals(data, actualData, reason);
- Expect.listEquals(errors, actualErrors, reason);
+ Expect.listEquals(data, actualData, msg);
+ Expect.listEquals(errors, actualErrors, msg);
asyncEnd();
completer.complete(true);
}
diff --git a/Utils/dynamic_check.dart b/Utils/dynamic_check.dart
index 4c24046..dc02fc1 100644
--- a/Utils/dynamic_check.dart
+++ b/Utils/dynamic_check.dart
@@ -3,7 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
library dynamic_check;
-import "expect.dart";
+import 'expect.dart';
checkTypeError(f()) {
Expect.throws(f, (e) => e is TypeError || e is CastError,
@@ -11,10 +11,9 @@
}
/// Check that dynamic error occurs. Dart specification (3rd Edition/June 12015)
-/// does not specify what is 'dynamic erros'
+/// does not specify what is 'dynamic errors'
/// (see https://github.com/dart-lang/sdk/issues/24394 ). So, for now,
-/// this is a stub that checks that Error is thrown
-
+/// this is a stub that checks that [Error] is thrown
checkDynamicError(f()) {
Expect.throws(f, (e) => e is Error, "Dynamic Error should be thrown");
}
diff --git a/Utils/expect.dart b/Utils/expect.dart
index 828c002..26221e3 100644
--- a/Utils/expect.dart
+++ b/Utils/expect.dart
@@ -2,18 +2,17 @@
// 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.
-library Expect;
-import "dart:async";
-part "expect_common.dart";
-part "async_utils.dart";
-part "lang_feature_check.dart";
+library expect;
+import 'dart:async';
+part 'expect_common.dart';
+part 'async_utils.dart';
+part 'lang_feature_check.dart';
-/// Expect is used for tests that do not want to make use of the
-/// Dart unit test library - for example, the core language tests.
-/// Third parties are discouraged from using this, and should use
-/// the expect() function in the unit test library instead for
-/// test assertions.
-
+/// [Expect] is used for tests that do not want to make use of the Dart unit
+/// test library - for example, the core language tests.
+///
+/// Third parties are discouraged from using this, and should use the [expect]
+/// function in the unit test library instead for the test assertions.
void _fail(String message) {
throw new ExpectException(message);
diff --git a/Utils/expect_common.dart b/Utils/expect_common.dart
index e477e75..4af927e 100644
--- a/Utils/expect_common.dart
+++ b/Utils/expect_common.dart
@@ -2,143 +2,112 @@
// 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.
-part of Expect;
-
-/// Expect is used for tests that do not want to make use of the
-/// Dart unit test library - for example, the core language tests.
-/// Third parties are discouraged from using this, and should use
-/// the expect() function in the unit test library instead for
-/// test assertions.
-///
-/// This part contains all except
-/// static void _fail(String message) {}
+part of 'expect.dart';
class Expect {
- /**
- * Checks whether the expected and actual values are equal (using `==`).
- */
- static void equals(var expected, var actual, [String? reason = null]) {
- if (expected == actual) return;
- if ((expected is double) &&
- (actual is double) &&
- (expected.isNaN) &&
- (actual.isNaN)) {
- return;
+
+ /// Checks whether the expected and actual values are equal using `==`.
+ static void equals(var expected, var actual, [String reason = '']) {
+ if ((expected != actual) &&
+ !((expected is double) &&
+ (actual is double) &&
+ (expected.isNaN) &&
+ (actual.isNaN))) {
+ _fail('Expect.equals(expected: <$expected>, actual: <$actual>$reason) '
+ 'fails.');
}
- String msg = _getMessage(reason);
- _fail("Expect.equals(expected: <$expected>, actual: <$actual>$msg) fails.");
}
- /**
- * Checks whether the actual value is a bool and its value is true.
- */
- static void isTrue(var actual, [String? reason = null]) {
- if (_identical(actual, true)) return;
- String msg = _getMessage(reason);
- _fail("Expect.isTrue($actual$msg) fails.");
- }
-
- /**
- * Checks whether the actual value is a bool and its value is false.
- */
- static void isFalse(var actual, [String? reason = null]) {
- if (_identical(actual, false)) return;
- String msg = _getMessage(reason);
- _fail("Expect.isFalse($actual$msg) fails.");
- }
-
- /**
- * Checks whether [actual] is null.
- */
- static void isNull(actual, [String? reason = null]) {
- if (null == actual) return;
- String msg = _getMessage(reason);
- _fail("Expect.isNull(actual: <$actual>$msg) fails.");
- }
-
- /**
- * Checks whether [actual] is not null.
- */
- static void isNotNull(actual, [String? reason = null]) {
- if (null != actual) return;
- String msg = _getMessage(reason);
- _fail("Expect.isNotNull(actual: <$actual>$msg) fails.");
- }
-
- /**
- * Checks whether the expected and actual values are identical
- * (using `identical`).
- */
- static void identical(var expected, var actual, [String? reason = null]) {
- if (_identical(expected, actual)) return;
- String msg = _getMessage(reason);
- _fail("Expect.identical(expected: <$expected>, actual: <$actual>$msg) "
- "fails.");
- }
-
- // Unconditional failure.
- static void fail(String? msg) {
- _fail("Expect.fail('$msg')");
- }
-
- /**
- * Failure if the difference between expected and actual is greater than the
- * given tolerance. If no tolerance is given, tolerance is assumed to be the
- * value 4 significant digits smaller than the value given for expected.
- */
- static void approxEquals(num expected, num actual,
- [num? tolerance = null, String? reason = null]) {
- if (tolerance == null) {
- tolerance = (expected / 1e4).abs();
+ /// Checks whether the actual value is [bool] and its value is [true].
+ static void isTrue(var actual, [String reason = '']) {
+ if (!_identical(actual, true)) {
+ _fail('Expect.isTrue($actual$reason) fails.');
}
+ }
+
+ /// Checks whether the actual value is [bool] and its value is [false].
+ static void isFalse(var actual, [String reason = '']) {
+ if (!_identical(actual, false)) {
+ _fail('Expect.isFalse($actual$reason) fails.');
+ }
+ }
+
+ /// Checks whether [actual] is [null].
+ static void isNull(actual, [String reason = '']) {
+ if (null != actual) {
+ _fail('Expect.isNull(actual: <$actual>$reason) fails.');
+ }
+ }
+
+ /// Checks whether [actual] is not [null].
+ static void isNotNull(actual, [String reason = '']) {
+ if (null == actual) {
+ _fail('Expect.isNotNull(actual: <$actual>$reason) fails.');
+ }
+ }
+
+ /// Checks whether the expected and actual values are identical (using
+ /// `identical`).
+ static void identical(var expected, var actual, [String reason = '']) {
+ if (!_identical(expected, actual)) {
+ _fail('Expect.identical(expected: <$expected>, '
+ 'actual: <$actual>$reason) fails.');
+ }
+ }
+
+ /// Unconditional failure.
+ static void fail(String reason) {
+ _fail('Expect.fail($reason)');
+ }
+
+ /// Checks whether the difference between expected and actual is greater than
+ /// the given tolerance. If no tolerance is given, tolerance is assumed to be
+ /// a value of the 4 significant digits smaller than the value given for
+ /// [expected].
+ static void approxEquals(
+ num expected, num actual, [num? tolerance, String reason = '']) {
+ tolerance ??= (expected / 1e4).abs();
+
// Note: use !( <= ) rather than > so we fail on NaNs
- if ((expected - actual).abs() <= tolerance) return;
-
- String msg = _getMessage(reason);
- _fail('Expect.approxEquals(expected:<$expected>, actual:<$actual>, '
- 'tolerance:<$tolerance>$msg) fails');
- }
-
- static void notEquals(unexpected, actual, [String? reason = null]) {
- if (unexpected != actual) return;
- String msg = _getMessage(reason);
- _fail("Expect.notEquals(unexpected: <$unexpected>, actual:<$actual>$msg) "
- "fails.");
- }
-
- /**
- * Specialized equality test for strings. When the strings don't match,
- * this method shows where the mismatch starts and ends.
- */
- static void stringEquals(String? expected, String? actual,
- [String? reason = null]) {
- String msg = _getMessage(reason);
- String defaultMessage =
- 'Expect.stringEquals(expected: <$expected>", <$actual>$msg) fails';
-
- if (expected == actual) return;
- if ((expected == null) || (actual == null)) {
- _fail('$defaultMessage');
- return;
+ if (!((expected - actual).abs() <= tolerance)) {
+ _fail('Expect.approxEquals(expected:<$expected>, actual:<$actual>, '
+ 'tolerance:<$tolerance>$reason) fails');
}
- // scan from the left until we find a mismatch
+ }
+
+ /// Checks whether the expected and actual values are not equal.
+ static void notEquals(unexpected, actual, [String reason = '']) {
+ if (unexpected == actual) {
+ _fail('Expect.notEquals(unexpected: <$unexpected>, '
+ 'actual:<$actual>$reason) fails.');
+ }
+ }
+
+ /// Specialized equality test for strings. When the strings don't match,
+ /// this method shows where the mismatch starts and ends.
+ static void stringEquals(
+ String? expected, String? actual, [String reason = '']) {
+ String defaultMessage =
+ 'Expect.stringEquals(expected: <$expected>, <$actual>$reason) fails';
+ if (expected == actual) return;
+
+ if (expected == null || actual == null) {
+ _fail('$defaultMessage');
+ } else {
+ // Scan from the left until we find a mismatch
int left = 0;
- int eLen = expected.length;
- int aLen = actual.length;
+ int expLength = expected.length;
+ int actLength = actual.length;
while (true) {
- if (left == eLen) {
- assert(left < aLen);
- String snippet = actual.substring(left, aLen);
+ if (left == expLength) {
+ assert(left < actLength);
+ String snippet = actual.substring(left, actLength);
_fail('$defaultMessage\nDiff:\n...[ ]\n...[ $snippet ]');
- return;
- }
- if (left == aLen) {
- assert(left < eLen);
- String snippet = expected.substring(left, eLen);
+ } else if (left == actLength) {
+ assert(left < expLength);
+ String snippet = expected.substring(left, expLength);
_fail('$defaultMessage\nDiff:\n...[ ]\n...[ $snippet ]');
- return;
- }
- if (expected[left] != actual[left]) {
+ } else if (expected[left] != actual[left]) {
break;
}
left++;
@@ -147,125 +116,116 @@
// scan from the right until we find a mismatch
int right = 0;
while (true) {
- if (right == eLen) {
- assert(right < aLen);
- String snippet = actual.substring(0, aLen - right);
+ if (right == expLength) {
+ assert(right < actLength);
+ String snippet = actual.substring(0, actLength - right);
_fail('$defaultMessage\nDiff:\n[ ]...\n[ $snippet ]...');
- return;
- }
- if (right == aLen) {
- assert(right < eLen);
- String snippet = expected.substring(0, eLen - right);
+ } else if (right == actLength) {
+ assert(right < expLength);
+ String snippet = expected.substring(0, expLength - right);
_fail('$defaultMessage\nDiff:\n[ ]...\n[ $snippet ]...');
- return;
- }
- // stop scanning if we've reached the end of the left-to-right match
- if (eLen - right <= left || aLen - right <= left) {
- break;
- }
- if (expected[eLen - right - 1] != actual[aLen - right - 1]) {
+ } else if ((expLength - right <= left || actLength - right <= left) ||
+ ((expected[expLength - right - 1] != actual[actLength - right - 1]))){
+ // Stop scanning if we've reached the end of the left-to-right match
break;
}
right++;
}
- String eSnippet = expected.substring(left, eLen - right);
- String aSnippet = actual.substring(left, aLen - right);
+
+ String eSnippet = expected.substring(left, expLength - right);
+ String aSnippet = actual.substring(left, actLength - right);
String diff = '\nDiff:\n...[ $eSnippet ]...\n...[ $aSnippet ]...';
_fail('$defaultMessage$diff');
}
+ }
- /**
- * Checks that every element of [expected] is also in [actual], and that
- * every element of [actual] is also in [expected].
- */
- static void setEquals(Iterable<Object?> expected, Iterable<Object?> actual,
- [String? reason = null]) {
+ /// Checks that every element of [expected] is also in [actual], and that
+ /// every element of [actual] is also in [expected].
+ static void setEquals(Iterable<Object?> expected,
+ Iterable<Object?> actual, [String reason = '']) {
final missingSet = new Set.from(expected);
missingSet.removeAll(actual);
final extraSet = new Set.from(actual);
extraSet.removeAll(expected);
- if (extraSet.isEmpty && missingSet.isEmpty) return;
- String msg = _getMessage(reason);
+ if (!extraSet.isEmpty || !missingSet.isEmpty) {
- StringBuffer sb = new StringBuffer("Expect.setEquals($msg) fails");
- // Report any missing items.
- if (!missingSet.isEmpty) {
- sb.write('\nExpected collection does not contain: ');
- }
+ StringBuffer buffer = StringBuffer('Expect.setEquals($reason) fails');
+ // Report any missing items.
+ if (!missingSet.isEmpty) {
+ buffer.write('\nExpected collection does not contain: ');
+ }
- for (final val in missingSet) {
- sb.write('$val ');
- }
+ for (final val in missingSet) {
+ buffer.write('$val ');
+ }
- // Report any extra items.
- if (!extraSet.isEmpty) {
- sb.write('\nExpected collection should not contain: ');
- }
+ // Report any extra items.
+ if (!extraSet.isEmpty) {
+ buffer.write('\nExpected collection should not contain: ');
+ }
- for (final val in extraSet) {
- sb.write('$val ');
+ for (final val in extraSet) {
+ buffer.write('$val ');
+ }
+
+ _fail(buffer.toString());
}
- _fail(sb.toString());
}
- /**
- * Calls the function [f] and verifies that it throws an exception.
- * The optional [check] function can provide additional validation
- * that the correct exception is being thrown. For example, to check
- * the type of the exception you could write this:
- *
- * Expect.throws(myThrowingFunction, (e) => e is MyException);
- */
- static void throws(void f(),
- [_CheckExceptionFn? check = null, String? reason = null]) {
+ /// Calls the function [func] and verifies that it throws an exception.
+ ///
+ /// The optional [check] function can provide additional validation that
+ /// correct exception is being thrown. For example, to check the type of the
+ /// exception you could write this:
+ ///
+ /// Expect.throws(myThrowingFunction, (e) => e is MyException);
+ static void throws(
+ void func(), [_CheckExceptionFn? check, String reason = '']) {
try {
- f();
- } catch (e, s) {
- if (check != null) {
- if (!check(e)) {
- String msg = reason == null ? "" : reason;
- _fail("Expect.throws($msg): Unexpected ${e.runtimeType}('$e')\n$s");
- }
+ func();
+ } catch (exception, str) {
+ if (check != null && !check(exception)) {
+ _fail('Expect.throws($reason): '
+ 'Unexpected ${exception.runtimeType}($exception)\n$str');
}
return;
}
- String msg = reason == null ? "" : reason;
- _fail('Expect.throws($msg) fails');
+ _fail('Expect.throws($reason) fails');
}
- static String _getMessage(String? reason) =>
- (reason == null) ? "" : ", '$reason'";
-
- static void listEquals(var expected, var actual, [String? reason = null]) {
- if (expected is! List) {
- Expect.fail("expected is not a List:$expected");
+ /// Checks that given lists are equal.
+ static void listEquals(var expected, var actual, [String reason = '']) {
+ if (expected is ! List) {
+ Expect.fail('expected is not a List:$expected');
+ } else if (actual is! List) {
+ Expect.fail('actual is not a List:$expected');
+ } else {
+ deepEquals(expected, actual, reason);
}
- if (actual is! List) {
- Expect.fail("actual is not a List:$expected");
- }
- deepEquals(expected, actual, reason);
}
- static void mapEquals(var expected, var actual, [String? reason = null]) {
+ /// Checks that given maps are equal.
+ static void mapEquals(var expected, var actual, [String reason = '']) {
if ((expected is! Map) || (actual is! Map)) {
- Expect.fail("not a Map");
+ Expect.fail('not a Map');
+ } else {
+ deepEquals(expected, actual, reason);
}
- deepEquals(expected, actual, reason);
}
- /** checks that both collections have identical topology and equal primitive elements.
- * useful to check cyclic collections passed through ports and streams.
- */
- static void deepEquals(var expected, var actual, [String? reason = null]) {
- Map planned = new Map();
- Map processed = new Map();
+ /// Checks that both collections have identical topology and equal primitive
+ /// elements. Useful to check cyclic collections passed through ports and
+ /// streams.
+ static void deepEquals(var expected, var actual, [String reason = '']) {
+ Map planned = Map();
+ Map processed = Map();
void plan2check(var expected, var actual) {
if (expected == null) {
Expect.isNull(actual);
}
- ;
+
if ((expected is Map) || (expected is List)) {
var savedActual = planned[expected];
if (savedActual != null) {
@@ -277,18 +237,21 @@
} else {
// this pair is not yet investigated
Expect.equals(expected.length, actual.length,
- "Collections' lengths are not equal: expected length=${expected.length}, actual length=${actual.length}");
+ 'Collection lengths are not equal: '
+ 'expected length=${expected.length}, '
+ 'actual length=${actual.length}');
planned[expected] = actual;
}
} else {
- Expect.equals(expected, actual);
+ Expect.equals(expected, actual, reason);
}
}
void runPlanned(var expected, var actual) {
if (expected is Map) {
for (var key in expected.keys) {
-// TODO check that key sets are equivalent. Following method does not work:
+// TODO check that key sets are equivalent.
+// The following method does not work:
// Expect.isTrue(actual.keys.toSet().remove(key)");
plan2check(expected[key], actual[key]);
}
@@ -299,7 +262,7 @@
} else {
Expect.fail("only Lists and Maps expected in the plan");
}
- // move pair from planned to processed
+ // Move pair from planned to processed
planned.remove(expected);
processed[expected] = actual;
}
@@ -315,19 +278,19 @@
runPlanned(key, planned[key]);
}
} catch (error) {
- String msg = _getMessage(reason);
- _fail('deepEquals($expected, $actual, $msg) fails\n [cause: $error]');
+ _fail('deepEquals($expected, $actual, $reason) fails\n [cause: $error]');
}
}
+ // Checks that given шеукфидуы are equal.
static void iterableEquals(Iterable expected, Iterable actual) {
- Iterator eit = expected.iterator;
- Iterator ait = actual.iterator;
- while (eit.moveNext()) {
- Expect.isTrue(ait.moveNext());
- Expect.equals(eit.current, ait.current);
+ Iterator expIterator = expected.iterator;
+ Iterator actIterator = actual.iterator;
+ while (expIterator.moveNext()) {
+ Expect.isTrue(actIterator.moveNext());
+ Expect.equals(expIterator.current, actIterator.current);
}
- Expect.isFalse(ait.moveNext());
+ Expect.isFalse(actIterator.moveNext());
}
}
@@ -343,10 +306,10 @@
/// Is true iff `assert` statements are enabled.
final bool assertStatementsEnabled = (() {
- bool result = false;
- assert(result = true);
- return result;
-})();
+ bool result = false;
+ assert(result = true);
+ return result;
+ })();
/// Is true iff js compiler is used
final bool isJS = identical(1.0, 1);
@@ -355,13 +318,15 @@
class CheckIdentical {
const CheckIdentical(Object? o1, Object? o2) : assert(identical(o1, o2));
}
+
/// Checks that objects are not identical at the compile time
class CheckNotIdentical {
const CheckNotIdentical(Object? o1, Object? o2) : assert(!identical(o1, o2));
}
-void checkIs<T>(bool expected, Object? o) {
- Expect.equals(expected, o is T);
+/// Checks that [obj] object is of the type [T] or not.
+void checkIs<T>(bool expected, Object? obj) {
+ Expect.equals(expected, obj is T);
}
/// Call this function with `checkIs` as the first parameter to check the type
diff --git a/Utils/lang_feature_check.dart b/Utils/lang_feature_check.dart
index 20096a0..8cd810a 100644
--- a/Utils/lang_feature_check.dart
+++ b/Utils/lang_feature_check.dart
@@ -2,25 +2,26 @@
// 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.
-part of Expect;
+part of 'expect.dart';
+/// Auxiliary generic function typedef
typedef F<X> = void Function<Y extends X>();
-typedef expected_target = Function<X>();
-
-// Functions for correct type comparison in language feature tests
+/// Returns [F] function with the type parameter of the tested type
F<X> toF<X>(X x) => <Y extends X>() {};
+
+/// Returns [Type] object for the given [X] type
Type typeOf<X>() => X;
-// Function to check nnbd_top_merge feature
-class CHECK_TOP_MERGE<T> {
+/// Auxiliary function to check nnbd top merge overriding feature
+class CheckTopMerge<T> {
T Function(T) get f => (x) => x;
}
-// Functions to check least and greatest closures
-// See https://github.com/dart-lang/co19/issues/575#issuecomment-613542349
Type? _capturedTypeArgument;
+// Auxiliary functions to check least and greatest closures
+// See https://github.com/dart-lang/co19/issues/575#issuecomment-613542349
X captureTypeArgument<X>() {
_capturedTypeArgument = X;
throw "Error";
@@ -32,6 +33,6 @@
return result;
}
-// Sound/Unsound null safety flags (formerly known as weak/strong mode)
+/// Sound/Unsound null safety flags (formerly known as weak/strong mode)
bool get hasUnsoundNullSafety => const <Null>[] is List<Object>;
bool get hasSoundNullSafety => !hasUnsoundNullSafety;
diff --git a/Utils/test_mode_check.dart b/Utils/test_mode_check.dart
index 9861bb2..d982afa 100644
--- a/Utils/test_mode_check.dart
+++ b/Utils/test_mode_check.dart
@@ -3,20 +3,21 @@
// BSD-style license that can be found in the LICENSE file.
library test_mode_check;
-import "dart:io";
+import 'dart:io';
-typedef CheckExecutable = bool Function(String s);
+typedef CheckFunction = bool Function(String str);
-bool checkMode(CheckExecutable ret) {
- var parts = Uri.file(Platform.resolvedExecutable).pathSegments;
- String basename = parts[parts.length - 1];
- var pos = basename.lastIndexOf('.');
- String result = (pos != -1) ? basename.substring(0, pos) : basename;
- return ret(result);
+bool checkResolvedExecutable(CheckFunction function) {
+ var uriParts = Uri.file(Platform.resolvedExecutable).pathSegments;
+ String baseName = uriParts[uriParts.length - 1];
+ var pos = baseName.lastIndexOf('.');
+ String result = (pos != -1) ? baseName.substring(0, pos) : baseName;
+ return function(result);
}
-// Checks that application runs in dart precompiled runtime mode.
-bool get isDartkp => checkMode(((String s) => s == "dart_precompiled_runtime"));
+/// Checks that application runs in dart precompiled runtime mode.
+bool get isDartkp =>
+ checkResolvedExecutable(((String s) => s == "dart_precompiled_runtime"));
-// Checks that application runs in AOT mode.
-bool get isAOT => checkMode(((String s) => s != "dart"));
+/// Checks that application runs in AOT mode.
+bool get isAot => checkResolvedExecutable(((String str) => str != "dart"));
diff --git a/Utils/tests/Expect/approxEquals_A01_t01.dart b/Utils/tests/Expect/approxEquals_A01_t01.dart
index 4a7a055..7c6a5a3 100644
--- a/Utils/tests/Expect/approxEquals_A01_t01.dart
+++ b/Utils/tests/Expect/approxEquals_A01_t01.dart
@@ -2,7 +2,8 @@
// 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.
-/// @assertion static void approxEquals(num expected, num actual, [num tolerance = null, String reason = null])
+/// @assertion static void approxEquals(num expected, num actual,
+/// [num tolerance = null, String reason = ''])
/// Failure if the difference between expected and actual is greater than the
/// given tolerance.
/// @description Checks that no exception is thrown when the difference between
@@ -17,7 +18,8 @@
main() {
final double MIN_DOUBLE = Math.pow(2.0, -1074) as double;
final double NEG_MIN_DOUBLE = -1 * MIN_DOUBLE;
- final double MAX_DOUBLE = (2 - Math.pow(2.0, -52)) * Math.pow(2.0, 1023) as double;
+ final double MAX_DOUBLE =
+ (2 - Math.pow(2.0, -52)) * Math.pow(2.0, 1023) as double;
final double NEG_MAX_DOUBLE = -1 * MAX_DOUBLE;
Expect.approxEquals(100.0, 101, 1);
diff --git a/Utils/tests/Expect/approxEquals_A01_t02.dart b/Utils/tests/Expect/approxEquals_A01_t02.dart
index f8d88bc..ac044c7 100644
--- a/Utils/tests/Expect/approxEquals_A01_t02.dart
+++ b/Utils/tests/Expect/approxEquals_A01_t02.dart
@@ -2,7 +2,8 @@
// 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.
-/// @assertion static void approxEquals(num expected, num actual, [num tolerance = null, String reason = null])
+/// @assertion static void approxEquals(num expected, num actual,
+/// [num tolerance = null, String reason = ''])
/// Failure if the difference between expected and actual is greater than the
/// given tolerance.
/// @description Checks that using arguments with (non-NAN) difference exceeding
@@ -16,7 +17,8 @@
main() {
final double MIN_DOUBLE = Math.pow(2.0, -1074) as double;
final double NEG_MIN_DOUBLE = -1 * MIN_DOUBLE;
- final double MAX_DOUBLE = (2 - Math.pow(2.0, -52)) * Math.pow(2.0, 1023) as double;
+ final double MAX_DOUBLE =
+ (2 - Math.pow(2.0, -52)) * Math.pow(2.0, 1023) as double;
final double NEG_MAX_DOUBLE = -1 * MAX_DOUBLE;
check(100.0, 101, 0.1);
@@ -56,7 +58,7 @@
check(double.negativeInfinity, NEG_MAX_DOUBLE, MAX_DOUBLE, "not empty");
}
-void check(num arg1, num arg2, num tolerance, [String? reason = null]) {
+void check(num arg1, num arg2, num tolerance, [String reason = '']) {
try {
Expect.approxEquals(arg1, arg2, tolerance, reason);
throw new Exception("ExpectException expected");
diff --git a/Utils/tests/Expect/approxEquals_A01_t03.dart b/Utils/tests/Expect/approxEquals_A01_t03.dart
index 6fabc7a..a2ff24c 100644
--- a/Utils/tests/Expect/approxEquals_A01_t03.dart
+++ b/Utils/tests/Expect/approxEquals_A01_t03.dart
@@ -2,7 +2,8 @@
// 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.
-/// @assertion static void approxEquals(num expected, num actual, [num tolerance = null, String reason = null])
+/// @assertion static void approxEquals(num expected, num actual,
+/// [num tolerance = null, String reason = ''])
/// Failure if the difference between expected and actual is greater than the
/// given tolerance.
/// @description Checks that using negative tolerance (except negative zero) or
@@ -17,7 +18,8 @@
main() {
final double MIN_DOUBLE = Math.pow(2.0, -1074) as double;
final double NEG_MIN_DOUBLE = -1 * MIN_DOUBLE;
- final double MAX_DOUBLE = (2 - Math.pow(2.0, -52)) * Math.pow(2.0, 1023) as double;
+ final double MAX_DOUBLE =
+ (2 - Math.pow(2.0, -52)) * Math.pow(2.0, 1023) as double;
final double NEG_MAX_DOUBLE = -1 * MAX_DOUBLE;
check(0, 0, double.negativeInfinity);
@@ -39,7 +41,8 @@
check(double.negativeInfinity, double.negativeInfinity, double.infinity);
check(double.negativeInfinity, double.negativeInfinity, double.infinity, "");
- check(double.negativeInfinity, double.negativeInfinity, double.infinity, "not empty");
+ check(double.negativeInfinity, double.negativeInfinity, double.infinity,
+ "not empty");
check(0, double.nan, double.infinity);
check(0, double.nan, double.infinity, "");
@@ -50,7 +53,7 @@
check(0, 0, double.nan, "not empty");
}
-void check(num arg1, num arg2, num tolerance, [String? reason = null]) {
+void check(num arg1, num arg2, num tolerance, [String reason = '']) {
try {
Expect.approxEquals(arg1, arg2, tolerance, reason);
throw new Exception("ExpectException expected");
diff --git a/Utils/tests/Expect/approxEquals_A01_t04.dart b/Utils/tests/Expect/approxEquals_A01_t04.dart
index 65cdd0d..30dff7f 100644
--- a/Utils/tests/Expect/approxEquals_A01_t04.dart
+++ b/Utils/tests/Expect/approxEquals_A01_t04.dart
@@ -2,7 +2,8 @@
// 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.
-/// @assertion static void approxEquals(num expected, num actual, [num tolerance = null, String reason = null])
+/// @assertion static void approxEquals(num expected, num actual,
+/// [num tolerance = null, String reason = null])
/// Failure if the difference between expected and actual is greater than the
/// given tolerance.
/// @description Checks that no exception is thrown when the absolute difference
@@ -18,7 +19,8 @@
main() {
final double MIN_DOUBLE = Math.pow(2.0, -1074) as double;
final double NEG_MIN_DOUBLE = -1 * MIN_DOUBLE;
- final double MAX_DOUBLE = (2 - Math.pow(2.0, -52)) * Math.pow(2.0, 1023) as double;
+ final double MAX_DOUBLE =
+ (2 - Math.pow(2.0, -52)) * Math.pow(2.0, 1023) as double;
final double NEG_MAX_DOUBLE = -1 * MAX_DOUBLE;
Expect.approxEquals(100.0, 101, 1.1);
diff --git a/Utils/tests/Expect/approxEquals_A02_t01.dart b/Utils/tests/Expect/approxEquals_A02_t01.dart
index 07e269c..0d35853 100644
--- a/Utils/tests/Expect/approxEquals_A02_t01.dart
+++ b/Utils/tests/Expect/approxEquals_A02_t01.dart
@@ -2,11 +2,12 @@
// 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.
-/// @assertion static void approxEquals(num expected, num actual, [num tolerance = null, String reason = null])
+/// @assertion static void approxEquals(num expected, num actual,
+/// [num tolerance = null, String reason = null])
/// If no tolerance is given, tolerance is assumed to be the value 4 significant
/// digits smaller than the value given for expected.
-/// @description Checks that with no tolerance specified, it is indeed assumed to
-/// be 1/10000th of [expected].
+/// @description Checks that with no tolerance specified, it is indeed assumed
+/// to be 1/10000th of [expected].
/// Zeros and infinities of both signs are tested.
/// @author rodionov
@@ -17,7 +18,8 @@
main() {
final double MIN_DOUBLE = Math.pow(2.0, -1074) as double;
final double NEG_MIN_DOUBLE = -1 * MIN_DOUBLE;
- final double MAX_DOUBLE = (2 - Math.pow(2.0, -52)) * Math.pow(2.0, 1023) as double;
+ final double MAX_DOUBLE =
+ (2 - Math.pow(2.0, -52)) * Math.pow(2.0, 1023) as double;
final double NEG_MAX_DOUBLE = -1 * MAX_DOUBLE;
Expect.approxEquals(0, 0);
@@ -59,7 +61,7 @@
Expect.approxEquals(double.negativeInfinity, 0, null, "not empty");
}
-void check(num arg1, num arg2, [String? reason = null]) {
+void check(num arg1, num arg2, [String reason = '']) {
try {
Expect.approxEquals(arg1, arg2, null, reason);
throw new Exception("ExpectException expected");
diff --git a/Utils/tests/Expect/approxEquals_A03_t01.dart b/Utils/tests/Expect/approxEquals_A03_t01.dart
index 20f0072..2cb6989 100644
--- a/Utils/tests/Expect/approxEquals_A03_t01.dart
+++ b/Utils/tests/Expect/approxEquals_A03_t01.dart
@@ -2,9 +2,11 @@
// 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.
-/// @assertion static void approxEquals(num expected, num actual, [num tolerance = null, String reason = null])
+/// @assertion static void approxEquals(num expected, num actual,
+/// [num tolerance = null, String reason = null])
/// Passing null as either expected or actual results in Error.
-/// @description Checks that Error is thrown if any of the required arguments are null.
+/// @description Checks that Error is thrown if any of the required arguments
+/// are null.
/// @author rodionov
import "../../../Utils/expect.dart";
@@ -35,7 +37,7 @@
check(null, null, 0, "not empty");
}
-void check(num? arg1, num? arg2, [num? tolerance = null, String? reason = null]) {
+void check(num? arg1, num? arg2, [num? tolerance = null, String reason = '']) {
try {
Expect.approxEquals(arg1 as num, arg2 as num, tolerance, reason);
Expect.fail("Error expected");
diff --git a/Utils/tests/Expect/approxEquals_A04_t01.dart b/Utils/tests/Expect/approxEquals_A04_t01.dart
index 47bf7fa..4b60173 100644
--- a/Utils/tests/Expect/approxEquals_A04_t01.dart
+++ b/Utils/tests/Expect/approxEquals_A04_t01.dart
@@ -2,9 +2,11 @@
// 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.
-/// @assertion static void approxEquals(num expected, num actual, [num tolerance = null, String reason = null])
+/// @assertion static void approxEquals(num expected, num actual, [
+/// num tolerance = null, String reason = null])
/// Descriptive error message is provided in case of failure.
-/// @description Checks that message of thrown ExpectException includes
+///
+/// @description Checks that message of thrown [ExpectException] includes
/// representation of the expected, actual and tolerance values, as well as the
/// reason.
/// @author varlax
@@ -16,7 +18,8 @@
main() {
final double MIN_DOUBLE = Math.pow(2.0, -1074) as double;
final double NEG_MIN_DOUBLE = -1 * MIN_DOUBLE;
- final double MAX_DOUBLE = (2 - Math.pow(2.0, -52)) * Math.pow(2.0, 1023) as double;
+ final double MAX_DOUBLE =
+ (2 - Math.pow(2.0, -52)) * Math.pow(2.0, 1023) as double;
final double NEG_MAX_DOUBLE = -1 * MAX_DOUBLE;
// min double > 0 / 10000
@@ -36,7 +39,7 @@
check(0, -0.0, double.nan, "");
}
-void check(num arg1, num arg2, [num? tol = null, String? reason = null]) {
+void check(num arg1, num arg2, [num? tol = null, String reason = '']) {
try {
Expect.approxEquals(arg1, arg2, tol, reason);
throw new Exception("ExpectException expected");
@@ -45,10 +48,8 @@
String msg = e.message as String;
if (!msg.contains(arg1.toString(), 0)) throw "no expected value";
if (!msg.contains(arg2.toString(), 0)) throw "no actual value";
- if (reason != null && !reason.isEmpty && !msg.contains(reason, 0)) throw "no reason";
- if (tol == null) {
- tol = (arg1 / Math.pow(10.0, 4.0)).abs();
- }
+ if (!reason.isEmpty && !msg.contains(reason, 0)) throw "no reason";
+ tol ??= (arg1 / Math.pow(10.0, 4.0)).abs();
if (!msg.contains(tol.toString(), 0)) throw "no tolerance";
}
}
diff --git a/Utils/tests/Expect/equals_A01_t01.dart b/Utils/tests/Expect/equals_A01_t01.dart
index b27e0ae..0dcd839 100644
--- a/Utils/tests/Expect/equals_A01_t01.dart
+++ b/Utils/tests/Expect/equals_A01_t01.dart
@@ -2,11 +2,12 @@
// 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.
-/// @assertion static void equals(var expected, var actual, [String reason = null])
+/// @assertion static void equals(var expected, var actual, [String reason = ''])
/// Checks whether the expected and actual values are equal (using [:==:]).
-/// @description Checks that no exception is thrown when the arguments are equal,
-/// regardless of reason (the last argument). Null, numeric and Object values are
-/// tested.
+///
+/// @description Checks that no exception is thrown when the arguments are
+/// equal, regardless of reason (the last argument). Null, numeric and [Object]
+/// values are tested.
/// @author rodionov
import "../../../Utils/expect.dart";
diff --git a/Utils/tests/Expect/equals_A01_t02.dart b/Utils/tests/Expect/equals_A01_t02.dart
index 4d56b0a..fe487f7 100644
--- a/Utils/tests/Expect/equals_A01_t02.dart
+++ b/Utils/tests/Expect/equals_A01_t02.dart
@@ -2,11 +2,14 @@
// 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.
-/// @assertion static void equals(var expected, var actual, [String reason = null])
+/// @assertion static void equals(var expected, var actual, [String reason = ''])
/// Checks whether the expected and actual values are equal (using [:==:]).
-/// @description Checks that using non-equal arguments results in ExpectException
-/// being thrown. Arguments being tested include null, boolean, numeric and
-/// Object, along with null, empty and non-empty reason arguments.
+///
+/// @description Checks that using non-equal arguments results in
+/// [ExpectException] being thrown. Arguments being tested include null,
+/// boolean, numeric and [Object], along with empty and non-empty reason
+/// arguments.
+///
/// @author rodionov
import "../../../Utils/expect.dart";
@@ -27,7 +30,7 @@
check(null, false);
}
-void check(var arg1, var arg2, [String? reason = null]) {
+void check(var arg1, var arg2, [String reason = '']) {
try {
Expect.equals(arg1, arg2, reason);
throw new Exception("ExpectException expected");
diff --git a/Utils/tests/Expect/equals_A01_t03.dart b/Utils/tests/Expect/equals_A01_t03.dart
index c0af4b3..7b7dc22 100644
--- a/Utils/tests/Expect/equals_A01_t03.dart
+++ b/Utils/tests/Expect/equals_A01_t03.dart
@@ -2,9 +2,12 @@
// 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.
-/// @assertion static void equals(var expected, var actual, [String reason = null])
+/// @assertion static void equals(var expected, var actual, [String reason = ''])
/// Checks whether the expected and actual values are equal (using [:==:]).
-/// @description Checks that object equality is checked with == operator (on expected value).
+///
+/// @description Checks that object equality is checked with == operator (on
+/// expected value).
+///
/// @author varlax
import "../../../Utils/expect.dart";
diff --git a/Utils/tests/Expect/equals_A01_t04.dart b/Utils/tests/Expect/equals_A01_t04.dart
index 4eacf71..3c81ff9 100644
--- a/Utils/tests/Expect/equals_A01_t04.dart
+++ b/Utils/tests/Expect/equals_A01_t04.dart
@@ -2,7 +2,7 @@
// 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.
-/// @assertion static void equals(var expected, var actual, [String reason = null])
+/// @assertion static void equals(var expected, var actual, [String reason = ''])
/// Checks whether the expected and actual values are equal (using [:==:]).
/// @description NaNs considered equals
/// @author varlax
diff --git a/Utils/tests/Expect/equals_A02_t01.dart b/Utils/tests/Expect/equals_A02_t01.dart
index b70721a..c22859d 100644
--- a/Utils/tests/Expect/equals_A02_t01.dart
+++ b/Utils/tests/Expect/equals_A02_t01.dart
@@ -2,9 +2,9 @@
// 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.
-/// @assertion static void equals(var expected, var actual, [String reason = null])
+/// @assertion static void equals(var expected, var actual, [String reason = ''])
/// Descriptive error message is provided in case of failure.
-/// @description Checks that message of thrown ExpectException includes
+/// @description Checks that message of thrown [ExpectException] includes
/// representation of the expected and actual values, as well as the reason.
/// @author varlax
@@ -26,15 +26,18 @@
check(null, false);
}
-void check(var arg1, var arg2, [String? reason = null]) {
+void check(var arg1, var arg2, [String reason = '']) {
try {
Expect.equals(arg1, arg2, reason);
throw new Exception("ExpectException expected");
} on ExpectException catch(e) {
if (e.message == null) throw "Exception message is empty";
String msg = e.message as String;
- if (!msg.contains(arg1 != null ? arg1.toString() : "null", 0)) throw "no expected value";
- if (!msg.contains(arg2 != null ? arg2.toString() : "null", 0)) throw "no actual value";
- if (reason != null && !reason.isEmpty && !msg.contains(reason, 0)) throw "no reason";
+ if (!msg.contains(arg1 != null ? arg1.toString() : "null", 0))
+ throw "no expected value";
+ if (!msg.contains(arg2 != null ? arg2.toString() : "null", 0))
+ throw "no actual value";
+ if (reason != null && !reason.isEmpty && !msg.contains(reason, 0))
+ throw "no reason";
}
}
diff --git a/Utils/tests/Expect/fail_A01_t01.dart b/Utils/tests/Expect/fail_A01_t01.dart
index a5ecb21..94ae214 100644
--- a/Utils/tests/Expect/fail_A01_t01.dart
+++ b/Utils/tests/Expect/fail_A01_t01.dart
@@ -4,24 +4,23 @@
/// @assertion static void fail(String msg)
/// Unconditional failure.
-/// @description Checks that this method always results in failure, regardless of
-/// whether or not the argument is null or empty.
+/// @description Checks that this method always results in failure, regardless
+/// of whether or not the argument is empty.
/// @author rodionov
/// @needsreview The exact mechanism of signaling failure is not documented. We
/// know it's ExpectException, though.
-import "../../../Utils/expect.dart";
+import '../../../Utils/expect.dart';
main() {
- check(null);
- check("");
- check("sdjgksjdg");
+ check('');
+ check('sdjgksjdg');
}
-void check(String? msg) {
+void check(String msg) {
try {
Expect.fail(msg);
- throw new Exception("ExpectException expected");
+ throw new Exception('ExpectException expected');
} on ExpectException catch(e) {
}
}
diff --git a/Utils/tests/Expect/fail_A02_t01.dart b/Utils/tests/Expect/fail_A02_t01.dart
index af24574..aa8856b 100644
--- a/Utils/tests/Expect/fail_A02_t01.dart
+++ b/Utils/tests/Expect/fail_A02_t01.dart
@@ -4,24 +4,25 @@
/// @assertion static void fail(String msg)
/// Descriptive error message is provided.
-/// @description Checks that message of thrown ExpectException is set to the msg argument.
+/// @description Checks that message of thrown ExpectException is set to the msg
+/// argument.
/// @author varlax
import "../../../Utils/expect.dart";
main() {
- check(null);
check("");
check("sdjgksjdg");
}
-void check(String? msg) {
+void check(String msg) {
try {
Expect.fail(msg);
throw new Exception("ExpectException expected");
} on ExpectException catch(e) {
String res = e.message as String;
- if (!res.contains(msg.toString(), 0)) throw "ExpectException message: '${res}'"
- " doesn't contain the argument of fail() ( ${ msg.toString()} )";
+ if (!res.contains(msg.toString(), 0))
+ throw "ExpectException message: '${res}'"
+ " doesn't contain the argument of fail() ( ${ msg.toString()} )";
}
}
diff --git a/Utils/tests/Expect/identical_A01_t01.dart b/Utils/tests/Expect/identical_A01_t01.dart
index 8521b56..5401ad9 100644
--- a/Utils/tests/Expect/identical_A01_t01.dart
+++ b/Utils/tests/Expect/identical_A01_t01.dart
@@ -2,7 +2,8 @@
// 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.
-/// @assertion static void identical(var expected, var actual, [String reason = null])
+/// @assertion static void identical(
+/// var expected, var actual, [String reason = ''])
/// Checks whether the expected and actual values are identical.
/// @description Checks that no exception is thrown when the arguments are
/// identical, regardless of reason (the last argument). Null, numeric, String
diff --git a/Utils/tests/Expect/identical_A01_t02.dart b/Utils/tests/Expect/identical_A01_t02.dart
index e6905c7..6bc54fb 100644
--- a/Utils/tests/Expect/identical_A01_t02.dart
+++ b/Utils/tests/Expect/identical_A01_t02.dart
@@ -2,12 +2,12 @@
// 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.
-/// @assertion static void identical(var expected, var actual, [String reason = null])
+/// @assertion static void identical(
+/// var expected, var actual, [String reason = ''])
/// Checks whether the expected and actual values are identical.
/// @description Checks that using non-identical arguments results in
/// [ExpectException] being thrown. Arguments being tested include null, boolean,
-/// String, numeric and Object, along with null, empty and non-empty reason
-/// arguments.
+/// String, numeric and Object, along with empty and non-empty reason arguments.
/// @author rodionov
import "../../../Utils/expect.dart";
@@ -42,7 +42,7 @@
check(new Object(), new Object(), "not empty");
}
-void check(var arg1, var arg2, [String? reason = null]) {
+void check(var arg1, var arg2, [String reason = '']) {
try {
Expect.identical(arg1, arg2, reason);
throw new Exception("ExpectException expected");
diff --git a/Utils/tests/Expect/identical_A01_t03.dart b/Utils/tests/Expect/identical_A01_t03.dart
index 08a1546..13a540e 100644
--- a/Utils/tests/Expect/identical_A01_t03.dart
+++ b/Utils/tests/Expect/identical_A01_t03.dart
@@ -2,7 +2,8 @@
// 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.
-/// @assertion static void identical(var expected, var actual, [String reason = null])
+/// @assertion static void identical(
+/// var expected, var actual, [String reason = ''])
/// Checks whether the expected and actual values are identical.
/// @description Checks that equality operator is not used.
/// @author varlax
@@ -15,10 +16,9 @@
}
}
-
main() {
try {
- Expect.identical(new A(), new A());
+ Expect.identical(A(), A());
throw "ExpectException expected";
} on ExpectException catch(ok) {
}
diff --git a/Utils/tests/Expect/identical_A02_t01.dart b/Utils/tests/Expect/identical_A02_t01.dart
index 7b65c63..01823b7 100644
--- a/Utils/tests/Expect/identical_A02_t01.dart
+++ b/Utils/tests/Expect/identical_A02_t01.dart
@@ -2,7 +2,8 @@
// 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.
-/// @assertion static void identical(var expected, var actual, [String reason = null])
+/// @assertion static void identical(
+/// var expected, var actual, [String reason = ''])
/// Descriptive error message is provided in case of failure.
/// @description Checks that message of thrown ExpectException includes
/// representation of the expected and actual values, as well as the reason.
@@ -40,14 +41,17 @@
check(new Object(), new Object(), "not empty");
}
-void check(var arg1, var arg2, [String? reason = null]) {
+void check(var arg1, var arg2, [String reason = '']) {
try {
Expect.identical(arg1, arg2, reason);
throw new Exception("ExpectException expected");
} on ExpectException catch(e) {
String msg = e.message as String;
- if (!msg.contains(arg1 != null ? arg1.toString() : "null", 0)) throw "no expected value";
- if (!msg.contains(arg2 != null ? arg2.toString() : "null", 0)) throw "no actual value";
- if (reason != null && !reason.isEmpty && !msg.contains(reason, 0)) throw "no reason";
+ if (!msg.contains(arg1 != null ? arg1.toString() : "null", 0))
+ throw "no expected value";
+ if (!msg.contains(arg2 != null ? arg2.toString() : "null", 0))
+ throw "no actual value";
+ if (reason != null && !reason.isEmpty && !msg.contains(reason, 0))
+ throw "no reason";
}
}
diff --git a/Utils/tests/Expect/isFalse_A01_t01.dart b/Utils/tests/Expect/isFalse_A01_t01.dart
index 8d6387d..a71cb93 100644
--- a/Utils/tests/Expect/isFalse_A01_t01.dart
+++ b/Utils/tests/Expect/isFalse_A01_t01.dart
@@ -2,7 +2,7 @@
// 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.
-/// @assertion static void isFalse(var actual, [String reason = null])
+/// @assertion static void isFalse(var actual, [String reason = ''])
/// Checks whether the actual value is a bool and its value is false.
/// @description Checks that no exception is thrown when the argument is a bool
/// and its value is false, regardless of reason (the last argument).
diff --git a/Utils/tests/Expect/isFalse_A01_t02.dart b/Utils/tests/Expect/isFalse_A01_t02.dart
index 97c0b5c..6d8e74e 100644
--- a/Utils/tests/Expect/isFalse_A01_t02.dart
+++ b/Utils/tests/Expect/isFalse_A01_t02.dart
@@ -2,11 +2,11 @@
// 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.
-/// @assertion static void isFalse(var actual, [String reason = null])
+/// @assertion static void isFalse(var actual, [String reason = ''])
/// Checks whether the actual value is a bool and its value is false.
/// @description Checks that using non-boolean argument or boolean true results
-/// in ExpectException being thrown. Arguments being tested include null, numeric
-/// and Object, along with null, empty and non-empty reason arguments.
+/// in [ExpectException] being thrown. Arguments being tested include null,
+/// numeric and [Object], along with empty and non-empty reason arguments.
/// @author rodionov
import "../../../Utils/expect.dart";
@@ -29,7 +29,7 @@
check(new Object(), "not empty");
}
-void check(var arg, [String? reason = null]) {
+void check(var arg, [String reason = '']) {
try {
Expect.isFalse(arg, reason);
throw new Exception("ExpectException expected");
diff --git a/Utils/tests/Expect/isFalse_A02_t01.dart b/Utils/tests/Expect/isFalse_A02_t01.dart
index 017b943..9193f38 100644
--- a/Utils/tests/Expect/isFalse_A02_t01.dart
+++ b/Utils/tests/Expect/isFalse_A02_t01.dart
@@ -2,7 +2,7 @@
// 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.
-/// @assertion static void isFalse(var actual, [String reason = null])
+/// @assertion static void isFalse(var actual, [String reason = ''])
/// Descriptive error message is provided in case of failure.
/// @description Checks that message of thrown ExpectException includes
/// representation of the actual value, as well as the reason.
@@ -28,7 +28,7 @@
check(new Object(), "not empty");
}
-void check(var arg, [String? reason = null]) {
+void check(var arg, [String reason = '']) {
try {
Expect.isFalse(arg, reason);
throw new Exception("ExpectException expected");
diff --git a/Utils/tests/Expect/isNotNull_A01_t01.dart b/Utils/tests/Expect/isNotNull_A01_t01.dart
index 059b9b2..7a2edb9 100644
--- a/Utils/tests/Expect/isNotNull_A01_t01.dart
+++ b/Utils/tests/Expect/isNotNull_A01_t01.dart
@@ -2,10 +2,10 @@
// 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.
-/// @assertion static void isNotNull(var actual, [String reason = null])
+/// @assertion static void isNotNull(var actual, [String reason = ''])
/// Checks whether [actual] is not null.
-/// @description Checks that no exception is thrown when the argument is not null,
-/// regardless of reason (the last argument). Boolean, numeric and Object
+/// @description Checks that no exception is thrown when the argument is not
+/// null, regardless of reason (the last argument). Boolean, numeric and Object
/// arguments are used.
/// @author rodionov
diff --git a/Utils/tests/Expect/isNotNull_A01_t02.dart b/Utils/tests/Expect/isNotNull_A01_t02.dart
index 6b9f0d1..61e9983 100644
--- a/Utils/tests/Expect/isNotNull_A01_t02.dart
+++ b/Utils/tests/Expect/isNotNull_A01_t02.dart
@@ -5,7 +5,7 @@
/// @assertion static void isNotNull(var actual, [String reason = null])
/// Checks whether [actual] is not null.
/// @description Checks that using a null argument results in ExpectException
-/// being thrown, regardless of whether the reason (2nd argument) is null.
+/// being thrown, regardless of whether the reason (2nd argument) is empty.
/// @author rodionov
import "../../../Utils/expect.dart";
@@ -16,7 +16,7 @@
check(null, "not empty");
}
-void check(var arg, [String? reason = null]) {
+void check(var arg, [String reason = '']) {
try {
Expect.isNotNull(arg, reason);
throw new Exception("ExpectException expected");
diff --git a/Utils/tests/Expect/isNotNull_A02_t01.dart b/Utils/tests/Expect/isNotNull_A02_t01.dart
index ad53c0b..2c6e51d 100644
--- a/Utils/tests/Expect/isNotNull_A02_t01.dart
+++ b/Utils/tests/Expect/isNotNull_A02_t01.dart
@@ -2,9 +2,9 @@
// 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.
-/// @assertion static void isNotNull(var actual, [String reason = null])
+/// @assertion static void isNotNull(var actual, [String reason = ''])
/// Descriptive error message is provided in case of failure.
-/// @description Checks that message of thrown ExpectException includes
+/// @description Checks that message of thrown [ExpectException] includes
/// representation of the actual value, as well as the reason.
/// @author varlax
@@ -16,13 +16,14 @@
check(null, "not empty");
}
-void check(var arg, [String? reason = null]) {
+void check(var arg, [String reason = '']) {
try {
Expect.isNotNull(arg, reason);
throw new Exception("ExpectException expected");
} on ExpectException catch(e) {
String msg = e.message as String;
if (!msg.contains("null", 0)) throw "no actual value";
- if (reason != null && !reason.isEmpty && !msg.contains(reason, 0)) throw "no reason";
+ if (reason != null && !reason.isEmpty && !msg.contains(reason, 0))
+ throw "no reason";
}
}
diff --git a/Utils/tests/Expect/isNull_A01_t01.dart b/Utils/tests/Expect/isNull_A01_t01.dart
index 013f8fd..d3b56e9 100644
--- a/Utils/tests/Expect/isNull_A01_t01.dart
+++ b/Utils/tests/Expect/isNull_A01_t01.dart
@@ -2,7 +2,7 @@
// 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.
-/// @assertion static void isNull(var actual, [String reason = null])
+/// @assertion static void isNull(var actual, [String reason = ''])
/// Checks whether [actual] is null.
/// @description Checks that no exception is thrown when the argument is null,
/// regardless of reason (the last argument).
diff --git a/Utils/tests/Expect/isNull_A01_t02.dart b/Utils/tests/Expect/isNull_A01_t02.dart
index 94e4e55..51e8088 100644
--- a/Utils/tests/Expect/isNull_A01_t02.dart
+++ b/Utils/tests/Expect/isNull_A01_t02.dart
@@ -2,11 +2,11 @@
// 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.
-/// @assertion static void isNull(var actual, [String reason = null])
+/// @assertion static void isNull(var actual, [String reason = ''])
/// Checks whether [actual] is null.
-/// @description Checks that using non-null argument results in ExpectException
-/// being thrown. Arguments being tested include boolean, numeric and Object,
-/// along with null, empty and non-empty reason arguments.
+/// @description Checks that using non-null argument results in
+/// [ExpectException] being thrown. Arguments being tested include boolean,
+/// numeric and [Object], along with empty and non-empty reason arguments.
/// @author rodionov
import "../../../Utils/expect.dart";
@@ -29,7 +29,7 @@
check(new Object(), "not empty");
}
-void check(var arg, [String? reason = null]) {
+void check(var arg, [String reason = '']) {
try {
Expect.isNull(arg, reason);
throw new Exception("ExpectException expected");
diff --git a/Utils/tests/Expect/isNull_A02_t01.dart b/Utils/tests/Expect/isNull_A02_t01.dart
index cc74e23..a0f62e0 100644
--- a/Utils/tests/Expect/isNull_A02_t01.dart
+++ b/Utils/tests/Expect/isNull_A02_t01.dart
@@ -2,7 +2,7 @@
// 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.
-/// @assertion static void isNull(var actual, [String reason = null])
+/// @assertion static void isNull(var actual, [String reason = ''])
/// Descriptive error message is provided in case of failure.
/// @description Checks that message of thrown ExpectException includes
/// representation of the actual value, as well as the reason.
@@ -28,13 +28,14 @@
check(new Object(), "not empty");
}
-void check(var arg, [String? reason = null]) {
+void check(var arg, [String reason = '']) {
try {
Expect.isNull(arg, reason);
throw new Exception("ExpectException expected");
} on ExpectException catch(e) {
String msg = e.message as String;
if (!msg.contains(arg.toString(), 0)) throw "no actual value";
- if (reason != null && !reason.isEmpty && !msg.contains(reason, 0)) throw "no reason";
+ if (reason != null && !reason.isEmpty && !msg.contains(reason, 0))
+ throw "no reason";
}
}
diff --git a/Utils/tests/Expect/isTrue_A01_t02.dart b/Utils/tests/Expect/isTrue_A01_t02.dart
index 37768f6..838d1d8 100644
--- a/Utils/tests/Expect/isTrue_A01_t02.dart
+++ b/Utils/tests/Expect/isTrue_A01_t02.dart
@@ -2,11 +2,11 @@
// 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.
-/// @assertion static void isTrue(var actual, [String reason = null])
+/// @assertion static void isTrue(var actual, [String reason = ''])
/// Checks whether the actual value is a bool and its value is true.
/// @description Checks that using non-boolean argument or boolean false results
/// in ExpectException being thrown. Arguments being tested include null,
-/// numeric and Object, along with null, empty and non-empty reason arguments.
+/// numeric and Object, along with empty and non-empty reason arguments.
/// @author rodionov
import "../../../Utils/expect.dart";
@@ -29,7 +29,7 @@
check(new Object(), "not empty");
}
-void check(var arg, [String? reason = null]) {
+void check(var arg, [String reason = '']) {
try {
Expect.isTrue(arg, reason);
throw new Exception("ExpectException expected");
diff --git a/Utils/tests/Expect/isTrue_A02_t01.dart b/Utils/tests/Expect/isTrue_A02_t01.dart
index 3d6fa8c..b325cf1 100644
--- a/Utils/tests/Expect/isTrue_A02_t01.dart
+++ b/Utils/tests/Expect/isTrue_A02_t01.dart
@@ -2,9 +2,9 @@
// 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.
-/// @assertion static void isTrue(var actual, [String reason = null])
+/// @assertion static void isTrue(var actual, [String reason = ''])
/// Descriptive error message is provided in case of failure.
-/// @description Checks that message of thrown ExpectException includes
+/// @description Checks that message of thrown [ExpectException] includes
/// representation of the actual value, as well as the reason.
/// @author varlax
@@ -28,13 +28,15 @@
check(new Object(), "not empty");
}
-void check(var arg, [String? reason = null]) {
+void check(var arg, [String reason = '']) {
try {
Expect.isTrue(arg, reason);
throw new Exception("ExpectException expected");
} on ExpectException catch(e) {
String msg = e.message as String;
- if (!msg.contains(arg != null ? arg.toString() : "null", 0)) throw "no actual value";
- if (reason != null && !reason.isEmpty && !msg.contains(reason, 0)) throw "no reason";
+ if (!msg.contains(arg != null ? arg.toString() : "null", 0))
+ throw "no actual value";
+ if (reason != null && !reason.isEmpty && !msg.contains(reason, 0))
+ throw "no reason";
}
}
diff --git a/Utils/tests/Expect/listEquals_A01_t01.dart b/Utils/tests/Expect/listEquals_A01_t01.dart
index c9f1eac..3e76fff 100644
--- a/Utils/tests/Expect/listEquals_A01_t01.dart
+++ b/Utils/tests/Expect/listEquals_A01_t01.dart
@@ -2,7 +2,8 @@
// 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.
-/// @assertion static void listEquals(List expected, List actual, [String reason = null])
+/// @assertion static void listEquals(
+/// List expected, List actual, [String reason = ''])
/// Checks that all elements in [expected] and [actual] are equal [:==:].
/// @description Checks that no exception is thrown when the compared lists have
/// equal contents, regardless of reason (the last argument).
diff --git a/Utils/tests/Expect/listEquals_A01_t02.dart b/Utils/tests/Expect/listEquals_A01_t02.dart
index 5116f13..bedcca8 100644
--- a/Utils/tests/Expect/listEquals_A01_t02.dart
+++ b/Utils/tests/Expect/listEquals_A01_t02.dart
@@ -2,10 +2,11 @@
// 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.
-/// @assertion static void listEquals(List expected, List actual, [String reason = null])
+/// @assertion static void listEquals(
+/// List expected, List actual, [String reason = ''])
/// Checks that all elements in [expected] and [actual] are equal [:==:].
/// @description Checks that using list with non-equal contents results in
-/// ExpectException being thrown.
+/// [ExpectException] being thrown.
/// @author rodionov
import "../../../Utils/expect.dart";
@@ -31,7 +32,7 @@
check([0,1,2,3],[1,2,3]);
}
-void check(List arg1, List arg2, [String? reason = null]) {
+void check(List arg1, List arg2, [String reason = '']) {
try {
Expect.listEquals(arg1, arg2, reason);
throw new Exception("ExpectException expected");
diff --git a/Utils/tests/Expect/listEquals_A01_t03.dart b/Utils/tests/Expect/listEquals_A01_t03.dart
index 9ca72a4..a3d393e 100644
--- a/Utils/tests/Expect/listEquals_A01_t03.dart
+++ b/Utils/tests/Expect/listEquals_A01_t03.dart
@@ -2,7 +2,8 @@
// 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.
-/// @assertion static void listEquals(List expected, List actual, [String reason = null])
+/// @assertion static void listEquals(
+/// List expected, List actual, [String reason = ''])
/// Checks that all elements in [expected] and [actual] are equal [:==:].
/// @description Checks that operator == on elements is used for checking.
/// @author varlax
diff --git a/Utils/tests/Expect/listEquals_A02_t01.dart b/Utils/tests/Expect/listEquals_A02_t01.dart
index ffe8fae..bed50f8 100644
--- a/Utils/tests/Expect/listEquals_A02_t01.dart
+++ b/Utils/tests/Expect/listEquals_A02_t01.dart
@@ -2,7 +2,8 @@
// 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.
-/// @assertion static void listEquals(List expected, List actual, [String reason = null])
+/// @assertion static void listEquals(
+/// List expected, List actual, [String reason = ''])
/// Passing null as either expected or actual results in ExpectException.
/// @description Checks that ExpectException is thrown if any of the required
/// arguments are null.
@@ -24,7 +25,7 @@
check(null, null, "not empty");
}
-void check(List? arg1, List? arg2, [String? reason = null]) {
+void check(List? arg1, List? arg2, [String reason = '']) {
try {
Expect.listEquals(arg1, arg2, reason);
Expect.fail("Error expected");
diff --git a/Utils/tests/Expect/listEquals_A03_t01.dart b/Utils/tests/Expect/listEquals_A03_t01.dart
index 171b69e..db55f26 100644
--- a/Utils/tests/Expect/listEquals_A03_t01.dart
+++ b/Utils/tests/Expect/listEquals_A03_t01.dart
@@ -2,10 +2,12 @@
// 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.
-/// @assertion static void listEquals(List expected, List actual, [String reason = null])
+/// @assertion static void listEquals(
+/// List expected, List actual, [String reason = ''])
/// Descriptive error message is provided in case of failure.
-/// @description Checks that message of thrown ExpectException includes
-/// representation of the expected and mismatched elements, as well as the reason.
+/// @description Checks that message of thrown [ExpectException] includes
+/// representation of the expected and mismatched elements, as well as the
+/// reason.
/// @author varlax
import "../../../Utils/expect.dart";
@@ -29,21 +31,22 @@
check([1,2,3], [1,2,3,4]);
check([0,1,2,3], [1,2,3], "235dsf435g gret sd");
- check([1, 5, 3], [1, 10, 3], null, 1);
+ check([1, 5, 3], [1, 10, 3], '', 1);
}
-void check(List arg1, List arg2, [String? reason = null, int index = 0]) {
+void check(List arg1, List arg2, [String reason = '', int index = 0]) {
try {
Expect.listEquals(arg1, arg2, reason);
throw new Exception("ExpectException expected");
} on ExpectException catch(e) {
-// } on Error catch(e) {
String msg = e.message as String;
if(arg1.length != arg2.length) {
- if(!msg.contains(arg1.length.toString(), 0) && !msg.contains(arg2.length.toString(), 0)) {
+ if(!msg.contains(arg1.length.toString(), 0)
+ && !msg.contains(arg2.length.toString(), 0)) {
throw "exception message ( ${msg} ) doesn't mention list lengths";
}
- if (reason != null && !reason.isEmpty && !msg.contains(reason, 0)) throw "no reason";
+ if (reason != null && !reason.isEmpty && !msg.contains(reason, 0))
+ throw "no reason";
} else {
var a1 = arg1[index], a2 = arg2[index];
String a1str = a1 != null ? a1.toString() : "null",
@@ -51,16 +54,17 @@
// TODO improve Expect.listEquals to inform index of the first mismatch
// if (!msg.contains('$index', 0))
-// throw "exception message: ( ${msg} ) doesn't mention the index of first mismatch ($index)";
+// throw "exception message: ( ${msg} ) doesn't mention the index of "
+// "first mismatch ($index)";
- if (!msg.contains(a1str, 0))
- throw "exception message: ( ${msg} ) doesn't mention the expected value ($a1str)";
+ if (!msg.contains(a1str, 0)) throw "exception message: ( ${msg} ) "
+ "doesn't mention the expected value ($a1str)";
- if (!msg.contains(a2str, 0))
- throw "exception message: ( ${msg} ) doesn't mention the actual value ($a2str)";
+ if (!msg.contains(a2str, 0)) throw "exception message: ( ${msg} ) "
+ "doesn't mention the actual value ($a2str)";
- if (reason != null && !reason.isEmpty && !msg.contains(reason, 0))
- "exception message: ( ${msg} ) doesn't mention the specified reason ($reason)";
+ if (!reason.isEmpty && !msg.contains(reason, 0)) throw "exception "
+ "message: ( ${msg} ) doesn't mention the specified reason ($reason)";
}
}
}
diff --git a/Utils/tests/Expect/notEquals_A01_t01.dart b/Utils/tests/Expect/notEquals_A01_t01.dart
index 04172b3..8f5580f 100644
--- a/Utils/tests/Expect/notEquals_A01_t01.dart
+++ b/Utils/tests/Expect/notEquals_A01_t01.dart
@@ -2,7 +2,8 @@
// 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.
-/// @assertion static void notEquals(var unexpected, var actual, [String reason = null])
+/// @assertion static void notEquals(
+/// var unexpected, var actual, [String reason = ''])
/// Checks whether the unexpected and actual values are not equal (using [:!=:]).
/// @description Checks that no exception is thrown when the arguments are not
/// equal, regardless of reason (the last argument). Null, numeric and Object
diff --git a/Utils/tests/Expect/notEquals_A01_t02.dart b/Utils/tests/Expect/notEquals_A01_t02.dart
index 3e74033..afb6bab 100644
--- a/Utils/tests/Expect/notEquals_A01_t02.dart
+++ b/Utils/tests/Expect/notEquals_A01_t02.dart
@@ -2,11 +2,12 @@
// 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.
-/// @assertion static void notEquals(var unexpected, var actual, [String reason = null])
+/// @assertion static void notEquals(
+/// var unexpected, var actual, [String reason = ''])
/// Checks whether the unexpected and actual values are not equal (using [:!=:]).
/// @description Checks that using equal arguments results in ExpectException
/// being thrown. Arguments being tested include boolean, numeric and Object,
-/// along with null, empty and non-empty reason arguments.
+/// along with empty and non-empty reason arguments.
/// @author rodionov
import "../../../Utils/expect.dart";
@@ -32,7 +33,7 @@
check("", "", "bla");
}
-void check(var arg1, var arg2, [String? reason = null]) {
+void check(var arg1, var arg2, [String reason = '']) {
try {
Expect.notEquals(arg1, arg2, reason);
throw new Exception("ExpectException expected");
diff --git a/Utils/tests/Expect/notEquals_A01_t03.dart b/Utils/tests/Expect/notEquals_A01_t03.dart
index fcc1e3c..77292e1 100644
--- a/Utils/tests/Expect/notEquals_A01_t03.dart
+++ b/Utils/tests/Expect/notEquals_A01_t03.dart
@@ -2,7 +2,8 @@
// 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.
-/// @assertion static void notEquals(var unexpected, var actual, [String reason = null])
+/// @assertion static void notEquals(
+/// var unexpected, var actual, [String reason = ''])
/// Checks whether the unexpected and actual values are not equal (using [:!=:]).
/// @description Checks that object equality is checked with == operator (on
/// unexpected value).
diff --git a/Utils/tests/Expect/notEquals_A02_t01.dart b/Utils/tests/Expect/notEquals_A02_t01.dart
index cff336b..83660f4 100644
--- a/Utils/tests/Expect/notEquals_A02_t01.dart
+++ b/Utils/tests/Expect/notEquals_A02_t01.dart
@@ -2,7 +2,7 @@
// 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.
-/// @assertion static void notEquals(var unexpected, var actual, [String reason = null])
+/// @assertion static void notEquals(var unexpected, var actual, [String reason = ''])
/// Descriptive error message is provided in case of failure.
/// @description Checks that message of thrown ExpectException includes
/// representation of the unexpected and actual values, as well as the reason.
@@ -31,14 +31,16 @@
check("", "", "bla");
}
-void check(var arg1, var arg2, [String? reason = null]) {
+void check(var arg1, var arg2, [String reason = '']) {
try {
Expect.notEquals(arg1, arg2, reason);
throw new Exception("ExpectException expected");
} on ExpectException catch(e) {
String msg = e.message as String;
- if (!msg.contains(arg1 != null ? arg1.toString() : "null", 0)) throw "no unexpected value";
- if (!msg.contains(arg2 != null ? arg2.toString() : "null", 0)) throw "no actual value";
- if (reason != null && !reason.isEmpty && !msg.contains(reason, 0)) throw "no reason";
+ if (!msg.contains(arg1 != null ? arg1.toString() : "null", 0))
+ throw "no unexpected value";
+ if (!msg.contains(arg2 != null ? arg2.toString() : "null", 0))
+ throw "no actual value";
+ if (!reason.isEmpty && !msg.contains(reason, 0)) throw "no reason";
}
}
diff --git a/Utils/tests/Expect/setEquals_A01_t01.dart b/Utils/tests/Expect/setEquals_A01_t01.dart
index df29145..ed67ca2 100644
--- a/Utils/tests/Expect/setEquals_A01_t01.dart
+++ b/Utils/tests/Expect/setEquals_A01_t01.dart
@@ -2,11 +2,13 @@
// 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.
-/// @assertion static void setEquals(Iterable expected, Iterable actual, [String reason = null])
+/// @assertion static void setEquals(
+/// Iterable expected, Iterable actual, [String reason = ''])
/// Checks that every element of [expected] is also in [actual], and that every
/// element of [actual] is also in [expected].
/// @description Checks that no exception is thrown when the compared Iterables
-/// have equal contents, regardless of their order and reason (the last argument).
+/// have equal contents, regardless of their order and reason (the last
+/// argument).
/// @author rodionov
import "../../../Utils/expect.dart";
diff --git a/Utils/tests/Expect/setEquals_A01_t02.dart b/Utils/tests/Expect/setEquals_A01_t02.dart
index ac968a8..847c45f 100644
--- a/Utils/tests/Expect/setEquals_A01_t02.dart
+++ b/Utils/tests/Expect/setEquals_A01_t02.dart
@@ -2,11 +2,12 @@
// 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.
-/// @assertion static void setEquals(Iterable expected, Iterable actual, [String reason = null])
+/// @assertion static void setEquals(
+/// Iterable expected, Iterable actual, [String reason = ''])
/// Checks that every element of [expected] is also in [actual], and that every
/// element of [actual] is also in [expected].
/// @description Checks that using Iterables with non-equal contents results in
-/// ExpectException being thrown.
+/// [ExpectException] being thrown.
/// @author rodionov
import "../../../Utils/expect.dart";
@@ -33,7 +34,7 @@
}
}
-void check(Iterable arg1, Iterable arg2, [String? reason = null]) {
+void check(Iterable arg1, Iterable arg2, [String reason = '']) {
try {
Expect.setEquals(arg1, arg2, reason);
throw new Exception("ExpectException expected");
diff --git a/Utils/tests/Expect/setEquals_A02_t01.dart b/Utils/tests/Expect/setEquals_A02_t01.dart
index eed9030..5a085af 100644
--- a/Utils/tests/Expect/setEquals_A02_t01.dart
+++ b/Utils/tests/Expect/setEquals_A02_t01.dart
@@ -2,10 +2,11 @@
// 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.
-/// @assertion static void setEquals(Iterable expected, Iterable actual, [String reason = null])
-/// Passing null as either expected or actual results in Error.
-/// @description Checks that Error is thrown if any of the required arguments are
-/// null.
+/// @assertion static void setEquals(
+/// Iterable expected, Iterable actual, [String reason = ''])
+/// Passing null as either expected or actual results in [Error].
+/// @description Checks that Error is thrown if any of the required arguments
+/// are null.
/// @author rodionov
import "../../../Utils/expect.dart";
@@ -24,7 +25,7 @@
check(null, null, "not empty");
}
-void check(var arg1, var arg2, [String ?reason = null]) {
+void check(var arg1, var arg2, [String reason = '']) {
try {
Expect.setEquals(arg1, arg2, reason);
Expect.fail("Error expected");
diff --git a/Utils/tests/Expect/setEquals_A03_t01.dart b/Utils/tests/Expect/setEquals_A03_t01.dart
index d188ad7..66ce433 100644
--- a/Utils/tests/Expect/setEquals_A03_t01.dart
+++ b/Utils/tests/Expect/setEquals_A03_t01.dart
@@ -2,7 +2,8 @@
// 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.
-/// @assertion static void setEquals(Iterable expected, Iterable actual, [String reason = null])
+/// @assertion static void setEquals(
+/// Iterable expected, Iterable actual, [String reason = ''])
/// Descriptive error message is provided in case of failure.
/// @description Checks that message of thrown ExpectException includes
/// representation of extra and missing elements, as well as the reason.
@@ -17,20 +18,29 @@
[1, 2]
);
- check([1,2,3],[2,3],[1], "blah sdsder rt3 4");
- check([234,456,777],[92374,3425,"assa"], [234,456,777,92374,3425,"assa"], "4 4 44 45 45 2__");
-
+ check(
+ [1,2,3],
+ [2,3],
+ [1],
+ "blah sdsder rt3 4");
+
+ check(
+ [234,456,777],
+ [92374,3425,"assa"],
+ [234,456,777,92374,3425,"assa"],
+ "4 4 44 45 45 2__");
}
-void check(Iterable arg1, Iterable arg2, Iterable arg3, [String? reason = null]) {
+void check(Iterable arg1, Iterable arg2, Iterable arg3, [String reason = '']) {
try {
Expect.setEquals(arg1, arg2, reason);
throw new Exception("ExpectException expected");
} on ExpectException catch(e) {
String msg = e.message as String;
for (var el in arg3) {
- if (!msg.contains(el != null ? el.toString() : "null", 0)) throw "no element $el";
+ if (!msg.contains(el != null ? el.toString() : "null", 0))
+ throw "no element $el";
}
- if (reason != null && !reason.isEmpty && !msg.contains(reason, 0)) throw "no reason";
+ if (!reason.isEmpty && !msg.contains(reason, 0)) throw "no reason";
}
}
diff --git a/Utils/tests/Expect/stringEquals_A01_t01.dart b/Utils/tests/Expect/stringEquals_A01_t01.dart
index bf88934..940deb5 100644
--- a/Utils/tests/Expect/stringEquals_A01_t01.dart
+++ b/Utils/tests/Expect/stringEquals_A01_t01.dart
@@ -2,11 +2,12 @@
// 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.
-/// @assertion static void stringEquals(String expected, String actual, [String reason = null])
+/// @assertion static void stringEquals(
+/// String expected, String actual, [String reason = ''])
/// Specialized equality test for strings.
-/// @description Checks that no exception is thrown when the string arguments are
-/// equal (including the case when they're null), regardless of reason (the last
-/// argument). Null, numeric and Object values are tested.
+/// @description Checks that no exception is thrown when the string arguments
+/// are equal (including the case when they're null), regardless of reason (the
+/// last argument). Null, numeric and Object values are tested.
/// @author rodionov
import "../../../Utils/expect.dart";
diff --git a/Utils/tests/Expect/stringEquals_A01_t02.dart b/Utils/tests/Expect/stringEquals_A01_t02.dart
index 3e299e6..5feff5b 100644
--- a/Utils/tests/Expect/stringEquals_A01_t02.dart
+++ b/Utils/tests/Expect/stringEquals_A01_t02.dart
@@ -2,10 +2,11 @@
// 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.
-/// @assertion static void stringEquals(String expected, String actual, [String reason = null])
+/// @assertion static void stringEquals(
+/// String expected, String actual, [String reason = ''])
/// Specialized equality test for strings.
/// @description Checks that using non-equal string arguments results in
-/// ExpectException being thrown, regardless of reason (the last argument).
+/// [ExpectException] being thrown, regardless of reason (the last argument).
/// @author rodionov
import "../../../Utils/expect.dart";
@@ -26,7 +27,7 @@
check("1", "1.0");
}
-void check(var arg1, var arg2, [String? reason = null]) {
+void check(var arg1, var arg2, [String reason = '']) {
try {
Expect.stringEquals(arg1, arg2, reason);
throw new Exception("ExpectException expected");
diff --git a/Utils/tests/Expect/stringEquals_A02_t01.dart b/Utils/tests/Expect/stringEquals_A02_t01.dart
index 403ecb5..cad3ac2 100644
--- a/Utils/tests/Expect/stringEquals_A02_t01.dart
+++ b/Utils/tests/Expect/stringEquals_A02_t01.dart
@@ -2,7 +2,8 @@
// 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.
-/// @assertion static void stringEquals(String expected, String actual, [String reason = null])
+/// @assertion static void stringEquals(
+/// String expected, String actual, [String reason = ''])
/// When the strings don't match,
/// this method shows where the mismatch starts and ends.
/// @description Checks that message of thrown ExpectException includes
@@ -22,7 +23,7 @@
check("", null, "null", null, "not empty");
}
-void check(var exp, var act, var arg1, [var arg2 = null, String? reason = null]) {
+void check(var exp, var act, var arg1, [var arg2 = null, String reason = '']) {
try {
Expect.stringEquals(exp, act, reason);
throw new Exception("ExpectException expected");
@@ -32,6 +33,6 @@
if (!msg.contains(act.toString(), 0)) throw "no actual value";
if (arg1 != null && !msg.contains(arg1, 0)) throw "no correct diff";
if (arg2 != null && !msg.contains(arg2, 0)) throw "no correct diff";
- if (reason != null && !reason.isEmpty && !msg.contains(reason, 0)) throw "no reason";
+ if (!reason.isEmpty && !msg.contains(reason, 0)) throw "no reason";
}
}
diff --git a/Utils/tests/Expect/throws_A01_t01.dart b/Utils/tests/Expect/throws_A01_t01.dart
index 44938ca..6919d86 100644
--- a/Utils/tests/Expect/throws_A01_t01.dart
+++ b/Utils/tests/Expect/throws_A01_t01.dart
@@ -2,14 +2,17 @@
// 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.
-/// @assertion static void throws(void f(), [_CheckExceptionFn check = null, String reason = null])
+/// @assertion static void throws(
+/// void f(), [_CheckExceptionFn check = null, String reason = ''])
/// typedef bool _CheckExceptionFn(exception)
/// Calls the function [f] and verifies that it throws an exception.
/// The optional [check] function can provide additional validation that the
/// correct exception is being thrown.
+///
/// @description Checks that if the tested method doesn't throw an exception,
/// this method fails regardless of whether the validating function is null,
/// returns true or false and whether the reason is null.
+///
/// @author rodionov
import "../../../Utils/expect.dart";
@@ -34,7 +37,7 @@
check(badboy, (e) => false, "not empty");
}
-void check(void f(), [checkFn? ch = null, String? reason = null]) {
+void check(void f(), [checkFn? ch = null, String reason = '']) {
try {
Expect.throws(f, ch, reason);
throw new Exception("ExpectException expected");
diff --git a/Utils/tests/Expect/throws_A01_t02.dart b/Utils/tests/Expect/throws_A01_t02.dart
index 6a99b0b..189947d 100644
--- a/Utils/tests/Expect/throws_A01_t02.dart
+++ b/Utils/tests/Expect/throws_A01_t02.dart
@@ -2,14 +2,17 @@
// 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.
-/// @assertion static void throws(void f(), [_CheckExceptionFn check = null, String reason = null])
+/// @assertion static void throws(
+/// void f(), [_CheckExceptionFn check = null, String reason = ''])
/// typedef bool _CheckExceptionFn(exception)
/// Calls the function [f] and verifies that it throws an exception.
/// The optional [check] function can provide additional validation that the
/// correct exception is being thrown.
+///
/// @description Checks that if the tested method throws an exception, this
/// method fails only if the validating function is not null and returns false,
-/// regardless of whether the specified reason is null or not.
+/// regardless of whether the specified reason is empty or not.
+///
/// @author rodionov
import "../../../Utils/expect.dart";
@@ -34,7 +37,7 @@
check(goodboy, (e) => false, "not empty");
}
-void check(void f(), [checkFn? ch = null, String? reason = null]) {
+void check(void f(), [checkFn? ch = null, String reason = '']) {
try {
Expect.throws(f, ch, reason);
throw new Exception("ExpectException expected");
diff --git a/Utils/tests/Expect/throws_A01_t03.dart b/Utils/tests/Expect/throws_A01_t03.dart
index 8cfcf84..c3f8ef8 100644
--- a/Utils/tests/Expect/throws_A01_t03.dart
+++ b/Utils/tests/Expect/throws_A01_t03.dart
@@ -2,14 +2,17 @@
// 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.
-/// @assertion static void throws(void f(), [_CheckExceptionFn check = null, String reason = null])
+/// @assertion static void throws(
+/// void f(), [_CheckExceptionFn check = null, String reason = ''])
/// typedef bool _CheckExceptionFn(exception)
/// Calls the function [f] and verifies that it throws an exception.
/// The optional [check] function can provide additional validation that the
/// correct exception is being thrown.
+///
/// @description Checks that a function being checked can throw arbitrary value,
/// possibly not assignable to Exception.
/// Testing with functions that throw null, String and Object.
+///
/// @author rodionov
/// @author varlax
@@ -45,7 +48,7 @@
check(badboy3, (e) => false, "not empty");
}
-void check(void f(), [checkFn? ch = null, String? reason = null]) {
+void check(void f(), [checkFn? ch = null, String reason = '']) {
try {
Expect.throws(f, ch, reason);
throw new Exception("ExpectException expected");
diff --git a/Utils/tests/Expect/throws_A01_t04.dart b/Utils/tests/Expect/throws_A01_t04.dart
index 2567397..6137f94 100644
--- a/Utils/tests/Expect/throws_A01_t04.dart
+++ b/Utils/tests/Expect/throws_A01_t04.dart
@@ -2,13 +2,16 @@
// 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.
-/// @assertion static void throws(void f(), [_CheckExceptionFn check = null, String reason = null])
+/// @assertion static void throws(
+/// void f(), [_CheckExceptionFn check = null, String reason = ''])
/// typedef bool _CheckExceptionFn(exception)
/// Calls the function [f] and verifies that it throws an exception.
/// The optional [check] function can provide additional validation that the
/// correct exception is being thrown.
+///
/// @description Checks that the optional check function is called with the
/// thrown object.
+///
/// @author varlax
import "../../../Utils/expect.dart";
diff --git a/Utils/tests/Expect/throws_A01_t05.dart b/Utils/tests/Expect/throws_A01_t05.dart
index 675f265..9f99cb9 100644
--- a/Utils/tests/Expect/throws_A01_t05.dart
+++ b/Utils/tests/Expect/throws_A01_t05.dart
@@ -2,13 +2,16 @@
// 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.
-/// @assertion static void throws(void f(), [_CheckExceptionFn check = null, String reason = null])
+/// @assertion static void throws(
+/// void f(), [_CheckExceptionFn check = null, String reason = ''])
/// typedef bool _CheckExceptionFn(exception)
/// Calls the function [f] and verifies that it throws an exception.
/// The optional [check] function can provide additional validation that the
/// correct exception is being thrown.
+///
/// @description Checks that exception thrown by the optional check function is
/// not caught.
+///
/// @author varlax
import "../../../Utils/expect.dart";
diff --git a/Utils/tests/Expect/throws_A02_t01.dart b/Utils/tests/Expect/throws_A02_t01.dart
index 383e8dd..e682acd 100644
--- a/Utils/tests/Expect/throws_A02_t01.dart
+++ b/Utils/tests/Expect/throws_A02_t01.dart
@@ -2,11 +2,14 @@
// 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.
-/// @assertion static void throws(void f(), [_CheckExceptionFn check = null, String reason = null])
+/// @assertion static void throws(
+/// void f(), [_CheckExceptionFn check = null, String reason = ''])
/// Descriptive error message is provided in case of failure.
-/// @description Checks that message of thrown ExpectException includes the
+///
+/// @description Checks that message of thrown [ExpectException] includes the
/// specified reason argument if any, both when the tested method doesn't throw
/// any exceptions and when the check function returns false.
+///
/// @author varlax
import "../../../Utils/expect.dart";
@@ -23,12 +26,13 @@
}
-void check(test tFun, [checkFn? checkFun = null, String? reason = null]) {
+void check(test tFun, [checkFn? checkFun = null, String reason = '']) {
try {
Expect.throws(tFun, checkFun, reason);
Expect.fail("ExpectException expected");
} on ExpectException catch(e) {
if (!(e.message as String).contains(reason as String, 0))
- throw "reason ($reason) not mentioned in ExpectException message (${e.message})";
+ throw "reason ($reason) not mentioned in ExpectException message "
+ "(${e.message})";
}
}