This repository was archived by the owner on Apr 22, 2023. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -42,7 +42,13 @@ assert.AssertionError = function AssertionError(options) {
4242 this . actual = options . actual ;
4343 this . expected = options . expected ;
4444 this . operator = options . operator ;
45- this . message = options . message || getMessage ( this ) ;
45+ if ( options . message ) {
46+ this . message = options . message ;
47+ this . generatedMessage = false ;
48+ } else {
49+ this . message = getMessage ( this ) ;
50+ this . generatedMessage = true ;
51+ }
4652 var stackStartFunction = options . stackStartFunction || fail ;
4753 Error . captureStackTrace ( this , stackStartFunction ) ;
4854} ;
Original file line number Diff line number Diff line change @@ -260,6 +260,7 @@ function testAssertionMessage(actual, expected) {
260260 } catch ( e ) {
261261 assert . equal ( e . toString ( ) ,
262262 [ 'AssertionError:' , expected , '==' , '""' ] . join ( ' ' ) ) ;
263+ assert . ok ( e . generatedMessage , "Message not marked as generated" ) ;
263264 }
264265}
265266testAssertionMessage ( undefined , '"undefined"' ) ;
@@ -299,10 +300,13 @@ try {
299300 assert . equal ( 1 , 2 ) ;
300301} catch ( e ) {
301302 assert . equal ( e . toString ( ) . split ( '\n' ) [ 0 ] , 'AssertionError: 1 == 2' )
303+ assert . ok ( e . generatedMessage , 'Message not marked as generated' ) ;
302304}
303305
304306try {
305307 assert . equal ( 1 , 2 , 'oh no' ) ;
306308} catch ( e ) {
307309 assert . equal ( e . toString ( ) . split ( '\n' ) [ 0 ] , 'AssertionError: oh no' )
310+ assert . equal ( e . generatedMessage , false ,
311+ 'Message incorrectly marked as generated' ) ;
308312}
You can’t perform that action at this time.
0 commit comments