testing/debug_utils
library
Functions
-
assertEqualsWithTolerance(double a, double b, double tolerance)
→ void
-
Throws an AssertionError when
a and b differ by more than tolerance.
-
dumpIterable(Iterable it, {int maxItems = 10})
→ String
-
Renders
it as a string, truncating to the first maxItems elements and
appending the total count when the iterable is longer.
-
prettyPrint(Object? obj, {int indent = 0})
→ String
-
Testing/Debug: pretty-print, dump iterable, assert equals with tolerance, range, repeat, timed. Roadmap #366-375.
Recursively renders
obj as an indented, human-readable string for
debugging. Maps and lists are expanded over multiple lines; null becomes
'null' and any other value falls back to its toString(). indent sets
the starting nesting depth (two spaces per level).
-
rangeDouble(double start, double end, double step)
→ List<double>
-
Returns doubles from
start (inclusive) toward end (exclusive) in
increments of step. A negative step counts down; the result is empty
when the range cannot advance toward end.
-
rangeInt(int start, int end, {int step = 1})
→ List<int>
-
Returns integers from
start (inclusive) toward end (exclusive) in
increments of step. A negative step counts down; the result is empty
when the range cannot advance toward end.
-
repeatValue<T>(T value, int n)
→ List<T>
-
Returns a list containing
value repeated n times.
-
retryUntil(bool predicate(), {int maxAttempts = 10})
→ bool
-
Calls
predicate up to maxAttempts times, returning true as soon as it
succeeds, or false if every attempt fails.
-
timed(void fn())
→ Duration
-
Runs
fn synchronously and returns the wall-clock Duration it took.