Add a toString to Simulation (#7364)

Also, make hasOneLineDescription more discerning.
Also, add a test for hasOneLineDescription.
Also, add a test for GravitySimulation, to test the toString.
This commit is contained in:
Ian Hickson
2017-01-05 16:33:40 -08:00
committed by GitHub
parent 11d1d54c8a
commit 79c8e5c7c7
6 changed files with 29 additions and 4 deletions

View File

@@ -62,8 +62,8 @@ const Matcher isNotInCard = const _IsNotInCard();
/// Asserts that an object's toString() is a plausible one-line description.
///
/// Specifically, this matcher checks that the string does not contains newline
/// characters, and does not have leading or trailing whitespace, and is not
/// empty.
/// characters, and does not have leading or trailing whitespace, is not
/// empty, and does not contain the default `Instance of ...` string.
const Matcher hasOneLineDescription = const _HasOneLineDescription();
/// Asserts that two [double]s are equal, within some tolerated error.
@@ -242,6 +242,7 @@ class _HasOneLineDescription extends Matcher {
String description = object.toString();
return description.isNotEmpty
&& !description.contains('\n')
&& !description.contains('Instance of ')
&& description.trim() == description;
}