summaryrefslogtreecommitdiff
path: root/test/parallel/test-assert.js
diff options
context:
space:
mode:
authorRuben Bridgewater <ruben@bridgewater.de>2018-05-16 18:10:08 +0200
committerRuben Bridgewater <ruben@bridgewater.de>2018-05-21 17:56:56 +0200
commit9c2e67ba97a4af0bb83c621b0c724f84198eac2d (patch)
treee18e9d4abeac4e02197a18504ed8c26083f8468d /test/parallel/test-assert.js
parent352ae2397434ddde058c14cd357e3bdd1d029cb6 (diff)
downloadandroid-node-v8-9c2e67ba97a4af0bb83c621b0c724f84198eac2d.tar.gz
android-node-v8-9c2e67ba97a4af0bb83c621b0c724f84198eac2d.tar.bz2
android-node-v8-9c2e67ba97a4af0bb83c621b0c724f84198eac2d.zip
assert: fix wrong message indentation
If code is read from a file and that code is indented, it would be misaligned. This makes sure it has a natural indentation that is relative to the starting point of the assertion. PR-URL: https://github.com/nodejs/node/pull/20791 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Khaidi Chu <i@2333.moe> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'test/parallel/test-assert.js')
-rw-r--r--test/parallel/test-assert.js53
1 files changed, 47 insertions, 6 deletions
diff --git a/test/parallel/test-assert.js b/test/parallel/test-assert.js
index b731b9a73e..bb58e2857f 100644
--- a/test/parallel/test-assert.js
+++ b/test/parallel/test-assert.js
@@ -694,14 +694,55 @@ common.expectsError(
{
code: 'ERR_ASSERTION',
type: assert.AssertionError,
- message: 'The expression evaluated to a falsy value:\n\n ' +
- "assert((() => 'string')()\n" +
- ' // eslint-disable-next-line\n' +
- ' ===\n' +
- ' 123 instanceof\n' +
- ' Buffer)\n'
+ message: 'The expression evaluated to a falsy value:\n\n' +
+ ' assert((() => \'string\')()\n' +
+ ' // eslint-disable-next-line\n' +
+ ' ===\n' +
+ ' 123 instanceof\n' +
+ ' Buffer)\n'
+ }
+);
+
+common.expectsError(
+ () => {
+ a(
+ (() => 'string')()
+ // eslint-disable-next-line
+ ===
+ 123 instanceof
+ Buffer
+ );
+ },
+ {
+ code: 'ERR_ASSERTION',
+ type: assert.AssertionError,
+ message: 'The expression evaluated to a falsy value:\n\n' +
+ ' assert((() => \'string\')()\n' +
+ ' // eslint-disable-next-line\n' +
+ ' ===\n' +
+ ' 123 instanceof\n' +
+ ' Buffer)\n'
+ }
+);
+
+/* eslint-disable indent */
+common.expectsError(() => {
+a((
+ () => 'string')() ===
+123 instanceof
+Buffer
+);
+}, {
+ code: 'ERR_ASSERTION',
+ type: assert.AssertionError,
+ message: 'The expression evaluated to a falsy value:\n\n' +
+ ' assert((\n' +
+ ' () => \'string\')() ===\n' +
+ ' 123 instanceof\n' +
+ ' Buffer)\n'
}
);
+/* eslint-enable indent */
common.expectsError(
() => assert(null, undefined),