1
0
Fork 0

Added function to prefix failed client-side assertions with 'Assertion failed: '

closure/master
Mike Gerwitz 2010-12-28 13:26:04 -05:00
parent c29d3a15d7
commit 729d7083da
1 changed files with 11 additions and 5 deletions

View File

@ -26,6 +26,12 @@ exports.common = {
};
function failAssertion( err )
{
throw Error( 'Assertion failed: ' + err.toString() );
}
/**
* Bare-bones implementation of node.js assert module
*
@ -36,7 +42,7 @@ exports.assert = {
{
if ( val !== cmp )
{
throw Error( err );
failAssertion( err );
}
},
@ -45,7 +51,7 @@ exports.assert = {
{
if ( val === cmp )
{
throw Error( err );
failAssertion( err );
}
},
@ -60,7 +66,7 @@ exports.assert = {
{
if ( !result )
{
throw Error( err );
failAssertion( err );
}
},
@ -75,7 +81,7 @@ exports.assert = {
{
if ( !( e instanceof expected ) )
{
throw Error( err );
failAssertion( err );
}
}
},
@ -91,7 +97,7 @@ exports.assert = {
{
if ( e instanceof not_expected )
{
throw Error( err );
failAssertion( err );
}
}
},