mirror of
https://github.com/nodejs/node.git
synced 2026-11-29 14:27:57 -05:00
buffer: Fix incorrect Buffer.compare behavior
Fixes #7551 Signed-off-by: Trevor Norris <trev.norris@gmail.com>
This commit is contained in:
1 parent
41d8e10f0d
commit
522dda2f12
2 files changed
+5
-5
No files matched your search
+1
-1
@@ -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);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user