lib/assert.js
function( e, match ) {
		var result = { passed: false }, message = '';

		// Get a string for matching on the error
		if ( munit.isError( e ) ) {
			message = e.message;
		}
		else if ( munit.isString( e ) ) {
			message = e;
		}

		// No match required
		if ( match === undefined ) {
			result.passed = true;
		}
		// Non Error/String error object, string matching required
		else if ( ! munit.isError( e ) && ! munit.isString( e ) ) {
			if ( e === match ) {
				result.passed = true;
			}
			else {
				result.extra = "Match object '" + match + "' does not match error '" + e + "'";
			}
		}
		// Function error class matching
		else if ( munit.isFunction( match ) ) {
			if ( e instanceof match ) {
				result.passed = true;
			}
			else {
				result.extra = "Error does not match class '" + match.name + "'";
			}
		}
		// Regex checking on the error message
		else if ( munit.isRegExp( match ) ) {
			if ( match.exec( message ) ) {
				result.passed = true;
			}
			else {
				result.extra = "Regex (" + match + ") could not find match on:\n" + message;
			}
		}
		// String matching on the error message
		else if ( munit.isString( match ) ) {
			if ( match === message ) {
				result.passed = true;
			}
			else {
				result.extra = "Error message doesn't match:\nActual: " + message + "\nExpected: " + match;
			}
		}
		// Unkown error type passed
		else {
			result.extra = "Unknown error match type '" + match + "'";
		}

		return result;
	}
function( e, match ) {
		var result = { passed: false }, message = '';

		// Get a string for matching on the error
		if ( munit.isError( e ) ) {
			message = e.message;
		}
		else if ( munit.isString( e ) ) {
			message = e;
		}

		// No match required
		if ( match === undefined ) {
			result.passed = true;
		}
		// Non Error/String error object, string matching required
		else if ( ! munit.isError( e ) && ! munit.isString( e ) ) {
			if ( e === match ) {
				result.passed = true;
			}
			else {
				result.extra = "Match object '" + match + "' does not match error '" + e + "'";
			}
		}
		// Function error class matching
		else if ( munit.isFunction( match ) ) {
			if ( e instanceof match ) {
				result.passed = true;
			}
			else {
				result.extra = "Error does not match class '" + match.name + "'";
			}
		}
		// Regex checking on the error message
		else if ( munit.isRegExp( match ) ) {
			if ( match.exec( message ) ) {
				result.passed = true;
			}
			else {
				result.extra = "Regex (" + match + ") could not find match on:\n" + message;
			}
		}
		// String matching on the error message
		else if ( munit.isString( match ) ) {
			if ( match === message ) {
				result.passed = true;
			}
			else {
				result.extra = "Error message doesn't match:\nActual: " + message + "\nExpected: " + match;
			}
		}
		// Unkown error type passed
		else {
			result.extra = "Unknown error match type '" + match + "'";
		}

		return result;
	}
function ( e , match ) { var result = { passed : false } , message = '' ; // Get a string for matching on the error if ( munit . isError ( e ) ) { message = e . message ; } else if ( munit . isString ( e ) ) { message = e ; } // No match required if ( match === undefined ) { result . passed = true ; } // Non Error/String error object, string matching required else if ( ! munit . isError ( e ) && ! munit . isString ( e ) ) { if ( e === match ) { result . passed = true ; } else { result . extra = "Match object '" + match + "' does not match error '" + e + "'" ; } } // Function error class matching else if ( munit . isFunction ( match ) ) { if ( e instanceof match ) { result . passed = true ; } else { result . extra = "Error does not match class '" + match . name + "'" ; } } // Regex checking on the error message else if ( munit . isRegExp ( match ) ) { if ( match . exec ( message ) ) { result . passed = true ; } else { result . extra = "Regex (" + match + ") could not find match on:\n" + message ; } } // String matching on the error message else if ( munit . isString ( match ) ) { if ( match === message ) { result . passed = true ; } else { result . extra = "Error message doesn't match:\nActual: " + message + "\nExpected: " + match ; } } // Unkown error type passed else { result . extra = "Unknown error match type '" + match + "'" ; } return result ; }
Utility for error object matching
Utility for error object matching