equalsIgnoringWhitespace function

Matcher equalsIgnoringWhitespace (String value)

Returns a matcher which matches if the match argument is a string and is equal to value, ignoring whitespace.

In this matcher, "ignoring whitespace" means comparing with all runs of whitespace collapsed to single space characters and leading and trailing whitespace removed.

For example, the following will all match successfully:

expect("hello   world", equalsIgnoringWhitespace("hello world"));
expect("  hello world", equalsIgnoringWhitespace("hello world"));
expect("hello world  ", equalsIgnoringWhitespace("hello world"));

The following will not match:

expect("helloworld", equalsIgnoringWhitespace("hello world"));
expect("he llo world", equalsIgnoringWhitespace("hello world"));

Implementation

Matcher equalsIgnoringWhitespace(String value) =>
    new _IsEqualIgnoringWhitespace(value);