• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3require('../common');
4const assert = require('assert');
5
6function FakeBuffer() { }
7Object.setPrototypeOf(FakeBuffer, Buffer);
8Object.setPrototypeOf(FakeBuffer.prototype, Buffer.prototype);
9
10const fb = new FakeBuffer();
11
12assert.throws(function() {
13  Buffer.from(fb);
14}, TypeError);
15
16assert.throws(function() {
17  +Buffer.prototype; // eslint-disable-line no-unused-expressions
18}, TypeError);
19
20assert.throws(function() {
21  Buffer.compare(fb, Buffer.alloc(0));
22}, TypeError);
23
24assert.throws(function() {
25  fb.write('foo');
26}, TypeError);
27
28assert.throws(function() {
29  Buffer.concat([fb, fb]);
30}, TypeError);
31
32assert.throws(function() {
33  fb.toString();
34}, TypeError);
35
36assert.throws(function() {
37  fb.equals(Buffer.alloc(0));
38}, TypeError);
39
40assert.throws(function() {
41  fb.indexOf(5);
42}, TypeError);
43
44assert.throws(function() {
45  fb.readFloatLE(0);
46}, TypeError);
47
48assert.throws(function() {
49  fb.writeFloatLE(0);
50}, TypeError);
51
52assert.throws(function() {
53  fb.fill(0);
54}, TypeError);
55