testing/debug_utils library
Testing/Debug: pretty-print, dump iterable, assert equals with tolerance, range, repeat, timed. Roadmap #366-375.
Functions
-
assertEqualsWithTolerance(
double a, double b, double tolerance) → void -
Throws an AssertionError when
aandbdiffer by more thantolerance. -
dumpIterable(
Iterable it, {int maxItems = 10}) → String -
Renders
itas a string, truncating to the firstmaxItemselements and appending the total count when the iterable is longer. -
prettyPrint(
Object? obj, {int indent = 0}) → String -
Recursively renders
objas an indented, human-readable string for debugging. Maps and lists are expanded over multiple lines;nullbecomes'null'and any other value falls back to itstoString().indentsets the starting nesting depth (two spaces per level). -
rangeDouble(
double start, double end, double step) → List< double> -
Returns doubles from
start(inclusive) towardend(exclusive) in increments ofstep. A negativestepcounts down; the result is empty when the range cannot advance towardend. -
rangeInt(
int start, int end, {int step = 1}) → List< int> -
Returns integers from
start(inclusive) towardend(exclusive) in increments ofstep. A negativestepcounts down; the result is empty when the range cannot advance towardend. -
repeatValue<
T> (T value, int n) → List< T> -
Returns a list containing
valuerepeatedntimes. -
retryUntil(
bool predicate(), {int maxAttempts = 10}) → bool -
Calls
predicateup tomaxAttemptstimes, returningtrueas soon as it succeeds, orfalseif every attempt fails. -
timed(
void fn()) → Duration -
Runs
fnsynchronously and returns the wall-clock Duration it took.