From 522dda2f12e2bc8cb1a83b4cc8d5c88020bb68b2 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Fri, 2 May 2014 22:48:34 -0700 Subject: [PATCH] buffer: Fix incorrect Buffer.compare behavior Fixes #7551 Signed-off-by: Trevor Norris --- lib/buffer.js | 2 +- test/simple/test-buffer.js | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/buffer.js b/lib/buffer.js index 65f4886..686c072 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -135,7 +135,7 @@ Buffer.compare = function compare(a, b) { !(b instanceof Buffer)) throw new TypeError('Arguments must be Buffers'); - return internal.compare(b, a); + return internal.compare(a, b); }; diff --git a/test/simple/test-buffer.js b/test/simple/test-buffer.js index 095551b..140fd0b 100644 --- a/test/simple/test-buffer.js +++ b/test/simple/test-buffer.js @@ -1048,10 +1048,10 @@ assert.equal(c.compare(d), 1); assert.equal(d.compare(b), 1); assert.equal(b.compare(d), -1); -assert.equal(Buffer.compare(b, c), 1); -assert.equal(Buffer.compare(c, d), -1); -assert.equal(Buffer.compare(d, b), -1); -assert.equal(Buffer.compare(b, d), 1); +assert.equal(Buffer.compare(b, c), -1); +assert.equal(Buffer.compare(c, d), 1); +assert.equal(Buffer.compare(d, b), 1); +assert.equal(Buffer.compare(b, d), -1); assert.throws(function() { var b = new Buffer(1); -- 2.7.4