From c91267235c0e787d180c6c4388ff88c6dc99dd56 Mon Sep 17 00:00:00 2001 From: Mike Pennisi Date: Tue, 21 Apr 2015 13:15:19 -0400 Subject: [PATCH] Extend assertion error messages When invoked without a custom assertion message, `assert.sameValue` and `assert.notSameValue` automatically create a message that describes the actual and expected values. Extend both assertion methods to also include this information in cases where a custom message has been specified. --- harness/assert.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/harness/assert.js b/harness/assert.js index 6fafa2df5f..35abaf8f6d 100644 --- a/harness/assert.js +++ b/harness/assert.js @@ -25,8 +25,13 @@ assert.sameValue = function (actual, expected, message) { } if (message === undefined) { - message = 'Expected SameValue(' + String(actual) + ', ' + String(expected) + ') to be true'; + message = ''; + } else { + message += ' '; } + + message += 'Expected SameValue(' + String(actual) + ', ' + String(expected) + ') to be true'; + $ERROR(message); }; @@ -36,8 +41,13 @@ assert.notSameValue = function (actual, unexpected, message) { } if (message === undefined) { - message = 'Expected SameValue(' + String(actual) + ', ' + String(unexpected) + ') to be false'; + message = ''; + } else { + message += ' '; } + + message += 'Expected SameValue(' + String(actual) + ', ' + String(unexpected) + ') to be false'; + $ERROR(message); };