From 6baba1d54af3afda9ba749393d623ff1230e521d Mon Sep 17 00:00:00 2001 From: James Irwin Date: Fri, 12 Oct 2018 12:28:12 -0500 Subject: [PATCH] test: correct order of args in buffer compare PR-URL: https://github.com/nodejs/node/pull/23521 Reviewed-By: James M Snell Reviewed-By: Hitesh Kanwathirtha Reviewed-By: Colin Ihrig Reviewed-By: Trivikram Kamat Reviewed-By: Ruben Bridgewater --- test/parallel/test-buffer-compare-offset.js | 40 ++++++++++----------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/test/parallel/test-buffer-compare-offset.js b/test/parallel/test-buffer-compare-offset.js index 7f3121bef17ab5..7de1c783d0c1c4 100644 --- a/test/parallel/test-buffer-compare-offset.js +++ b/test/parallel/test-buffer-compare-offset.js @@ -6,56 +6,56 @@ const assert = require('assert'); const a = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8, 9, 0]); const b = Buffer.from([5, 6, 7, 8, 9, 0, 1, 2, 3, 4]); -assert.strictEqual(-1, a.compare(b)); +assert.strictEqual(a.compare(b), -1); // Equivalent to a.compare(b). -assert.strictEqual(-1, a.compare(b, 0)); -assert.strictEqual(-1, a.compare(b, '0')); -assert.strictEqual(-1, a.compare(b, undefined)); +assert.strictEqual(a.compare(b, 0), -1); +assert.strictEqual(a.compare(b, '0'), -1); +assert.strictEqual(a.compare(b, undefined), -1); // Equivalent to a.compare(b). -assert.strictEqual(-1, a.compare(b, 0, undefined, 0)); +assert.strictEqual(a.compare(b, 0, undefined, 0), -1); // Zero-length target, return 1 -assert.strictEqual(1, a.compare(b, 0, 0, 0)); -assert.strictEqual(1, a.compare(b, '0', '0', '0')); +assert.strictEqual(a.compare(b, 0, 0, 0), 1); +assert.strictEqual(a.compare(b, '0', '0', '0'), 1); // Equivalent to Buffer.compare(a, b.slice(6, 10)) -assert.strictEqual(1, a.compare(b, 6, 10)); +assert.strictEqual(a.compare(b, 6, 10), 1); // Zero-length source, return -1 -assert.strictEqual(-1, a.compare(b, 6, 10, 0, 0)); +assert.strictEqual(a.compare(b, 6, 10, 0, 0), -1); // Zero-length source and target, return 0 -assert.strictEqual(0, a.compare(b, 0, 0, 0, 0)); -assert.strictEqual(0, a.compare(b, 1, 1, 2, 2)); +assert.strictEqual(a.compare(b, 0, 0, 0, 0), 0); +assert.strictEqual(a.compare(b, 1, 1, 2, 2), 0); // Equivalent to Buffer.compare(a.slice(4), b.slice(0, 5)) -assert.strictEqual(1, a.compare(b, 0, 5, 4)); +assert.strictEqual(a.compare(b, 0, 5, 4), 1); // Equivalent to Buffer.compare(a.slice(1), b.slice(5)) -assert.strictEqual(1, a.compare(b, 5, undefined, 1)); +assert.strictEqual(a.compare(b, 5, undefined, 1), 1); // Equivalent to Buffer.compare(a.slice(2), b.slice(2, 4)) -assert.strictEqual(-1, a.compare(b, 2, 4, 2)); +assert.strictEqual(a.compare(b, 2, 4, 2), -1); // Equivalent to Buffer.compare(a.slice(4), b.slice(0, 7)) -assert.strictEqual(-1, a.compare(b, 0, 7, 4)); +assert.strictEqual(a.compare(b, 0, 7, 4), -1); // Equivalent to Buffer.compare(a.slice(4, 6), b.slice(0, 7)); -assert.strictEqual(-1, a.compare(b, 0, 7, 4, 6)); +assert.strictEqual(a.compare(b, 0, 7, 4, 6), -1); // zero length target -assert.strictEqual(1, a.compare(b, 0, null)); +assert.strictEqual(a.compare(b, 0, null), 1); // coerces to targetEnd == 5 -assert.strictEqual(-1, a.compare(b, 0, { valueOf: () => 5 })); +assert.strictEqual(a.compare(b, 0, { valueOf: () => 5 }), -1); // zero length target -assert.strictEqual(1, a.compare(b, Infinity, -Infinity)); +assert.strictEqual(a.compare(b, Infinity, -Infinity), 1); // zero length target because default for targetEnd <= targetSource -assert.strictEqual(1, a.compare(b, '0xff')); +assert.strictEqual(a.compare(b, '0xff'), 1); const oor = common.expectsError({ code: 'ERR_INDEX_OUT_OF_RANGE' }, 7);