hexMachina
hexMachina copied to clipboard
Assert.assertionThrows
From @FrancisBourre on August 18, 2016 3:19
It would be nice to have an assertion that ensures another assertion throws an error. For now, we have to use nasty/boilerplate code for this kind of test:
try { Assert.equals( 45.31, this._lex( "45.a" ).getFloat(), "" ); }
catch ( e : InvalidSyntaxException ) { Assert.revertFailure(); }
catch ( e : Dynamic )
{
Assert.fail( "assertion failed", "'45.a' value should throw an 'InvalidSyntaxException'" );
}
It would be nicer to have something like this:
Assert.assertionThrows(
Assert.equals( 45.31, this._lex( "45.a" ).getFloat() ),
InvalidSyntaxException,
"'45.a' value should throw an 'InvalidSyntaxException'" );
Copied from original issue: DoclerLabs/hexCore#7