Skip to content

Commit

Permalink
Do not support Node v6 anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
mcollina committed Aug 27, 2021
1 parent 494eadd commit 75f2f01
Showing 1 changed file with 40 additions and 44 deletions.
84 changes: 40 additions & 44 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -881,65 +881,61 @@ test('sync writing is fully sync', (t) => {
t.equal(data, 'hello world\nsomething else\n')
})

// These they will fail on Node 6, as we cannot allocate a string this
// big. It's considered a won't fix on Node 6, as it's deprecated.
if (process.versions.node.indexOf('6.') !== 0) {
test('write enormously large buffers async', (t) => {
t.plan(3)
test('write enormously large buffers async', (t) => {
t.plan(3)

const dest = file()
const fd = fs.openSync(dest, 'w')
const stream = new SonicBoom({ fd, minLength: 0, sync: false })
const dest = file()
const fd = fs.openSync(dest, 'w')
const stream = new SonicBoom({ fd, minLength: 0, sync: false })

const buf = Buffer.alloc(1024).fill('x').toString() // 1 MB
let length = 0
const buf = Buffer.alloc(1024).fill('x').toString() // 1 MB
let length = 0

for (let i = 0; i < 1024 * 512; i++) {
length += buf.length
stream.write(buf)
}
for (let i = 0; i < 1024 * 512; i++) {
length += buf.length
stream.write(buf)
}

stream.end()
stream.end()

stream.on('finish', () => {
fs.stat(dest, (err, stat) => {
t.error(err)
t.equal(stat.size, length)
})
})
stream.on('close', () => {
t.pass('close emitted')
stream.on('finish', () => {
fs.stat(dest, (err, stat) => {
t.error(err)
t.equal(stat.size, length)
})
})
stream.on('close', () => {
t.pass('close emitted')
})
})

test('write enormously large buffers sync', (t) => {
t.plan(3)
test('write enormously large buffers sync', (t) => {
t.plan(3)

const dest = file()
const fd = fs.openSync(dest, 'w')
const stream = new SonicBoom({ fd, minLength: 0, sync: true })
const dest = file()
const fd = fs.openSync(dest, 'w')
const stream = new SonicBoom({ fd, minLength: 0, sync: true })

const buf = Buffer.alloc(1024).fill('x').toString() // 1 MB
let length = 0
const buf = Buffer.alloc(1024).fill('x').toString() // 1 MB
let length = 0

for (let i = 0; i < 1024 * 512; i++) {
length += buf.length
stream.write(buf)
}
for (let i = 0; i < 1024 * 512; i++) {
length += buf.length
stream.write(buf)
}

stream.end()
stream.end()

stream.on('finish', () => {
fs.stat(dest, (err, stat) => {
t.error(err)
t.equal(stat.size, length)
})
})
stream.on('close', () => {
t.pass('close emitted')
stream.on('finish', () => {
fs.stat(dest, (err, stat) => {
t.error(err)
t.equal(stat.size, length)
})
})
}
stream.on('close', () => {
t.pass('close emitted')
})
})

test('write enormously large buffers sync with utf8 multi-byte split', (t) => {
t.plan(4)
Expand Down

0 comments on commit 75f2f01

Please sign in to comment.