2015-06-18 22:07:22 +02:00
|
|
|
'use strict';
|
|
|
|
|
2015-12-24 01:02:12 +01:00
|
|
|
require('../common');
|
2015-06-18 22:07:22 +02:00
|
|
|
const assert = require('assert');
|
|
|
|
|
|
|
|
function FakeBuffer() { }
|
2016-02-08 14:12:09 +01:00
|
|
|
Object.setPrototypeOf(FakeBuffer, Buffer);
|
|
|
|
Object.setPrototypeOf(FakeBuffer.prototype, Buffer.prototype);
|
2015-06-18 22:07:22 +02:00
|
|
|
|
|
|
|
const fb = new FakeBuffer();
|
|
|
|
|
|
|
|
assert.throws(function() {
|
2016-01-26 00:00:06 +01:00
|
|
|
Buffer.from(fb);
|
2015-06-18 22:07:22 +02:00
|
|
|
}, TypeError);
|
|
|
|
|
|
|
|
assert.throws(function() {
|
|
|
|
+Buffer.prototype;
|
|
|
|
}, TypeError);
|
|
|
|
|
|
|
|
assert.throws(function() {
|
2016-01-26 00:00:06 +01:00
|
|
|
Buffer.compare(fb, Buffer.alloc(0));
|
2015-06-18 22:07:22 +02:00
|
|
|
}, TypeError);
|
|
|
|
|
|
|
|
assert.throws(function() {
|
|
|
|
fb.write('foo');
|
|
|
|
}, TypeError);
|
|
|
|
|
|
|
|
assert.throws(function() {
|
|
|
|
Buffer.concat([fb, fb]);
|
|
|
|
}, TypeError);
|
|
|
|
|
|
|
|
assert.throws(function() {
|
|
|
|
fb.toString();
|
|
|
|
}, TypeError);
|
|
|
|
|
|
|
|
assert.throws(function() {
|
2016-01-26 00:00:06 +01:00
|
|
|
fb.equals(Buffer.alloc(0));
|
2015-06-18 22:07:22 +02:00
|
|
|
}, TypeError);
|
|
|
|
|
|
|
|
assert.throws(function() {
|
|
|
|
fb.indexOf(5);
|
|
|
|
}, TypeError);
|
|
|
|
|
|
|
|
assert.throws(function() {
|
|
|
|
fb.readFloatLE(0);
|
|
|
|
}, TypeError);
|
|
|
|
|
|
|
|
assert.throws(function() {
|
|
|
|
fb.writeFloatLE(0);
|
|
|
|
}, TypeError);
|
|
|
|
|
|
|
|
assert.throws(function() {
|
|
|
|
fb.fill(0);
|
|
|
|
}, TypeError);
|