|
From: Darren C. <da...@dc...> - 2006-05-26 08:35:19
|
I finally found time to get back to the project I want to unit test, and
hit a bump when testing for an expected NaN.
I was going to propose extending assertEquals to handle NaN as a special
case but convinced myself that examples like this make that a bad idea:
assertEquals("should this pass when x==0?", x/1, x/2);
So I wrote assertIsNaN(); I was going to send a patch but it is so short
that I just included it below. It goes somewhere in Assert.as (only
tested on as2 branch).
If you want a proper patch let me know.
Darren
/**
* Asserts that assertion isNaN(); any valid number or any other
* type of object will fail the test.
*/
public static function assertIsNaN(msg:Object, assertion:Object):Void {
if(arguments.length == 1) addTestResult("", "assertIsNaN", isNaN(msg));
else addTestResult(String(msg), "assertIsNaN", isNaN(assertion));
}
|