hexMachina icon indicating copy to clipboard operation
hexMachina copied to clipboard

Assert.assertionThrows

Open FrancisBourre opened this issue 9 years ago • 0 comments

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

FrancisBourre avatar Aug 25 '16 19:08 FrancisBourre