PR-URL: https://github.com/iojs/io.js/pull/742
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
!(b instanceof Buffer))
throw new TypeError('Arguments must be Buffers');
!(b instanceof Buffer))
throw new TypeError('Arguments must be Buffers');
+ if (a === b)
+ return 0;
+
return internal.compare(a, b);
};
return internal.compare(a, b);
};
if (!(b instanceof Buffer))
throw new TypeError('Argument must be a Buffer');
if (!(b instanceof Buffer))
throw new TypeError('Argument must be a Buffer');
+ if (this === b)
+ return true;
+
return internal.compare(this, b) === 0;
};
return internal.compare(this, b) === 0;
};
if (!(b instanceof Buffer))
throw new TypeError('Argument must be a Buffer');
if (!(b instanceof Buffer))
throw new TypeError('Argument must be a Buffer');
+ if (this === b)
+ return 0;
+
return internal.compare(this, b);
};
return internal.compare(this, b);
};
assert.equal(c.compare(d), 1);
assert.equal(d.compare(b), 1);
assert.equal(b.compare(d), -1);
assert.equal(c.compare(d), 1);
assert.equal(d.compare(b), 1);
assert.equal(b.compare(d), -1);
+assert.equal(b.compare(b), 0);
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.equal(Buffer.compare(c, c), 0);
+
assert.throws(function() {
var b = new Buffer(1);
assert.throws(function() {
var b = new Buffer(1);
assert.ok(b.equals(c));
assert.ok(!c.equals(d));
assert.ok(!d.equals(e));
assert.ok(b.equals(c));
assert.ok(!c.equals(d));
assert.ok(!d.equals(e));
assert.throws(function() {
var b = new Buffer(1);
assert.throws(function() {
var b = new Buffer(1);