forked from denoland/deno
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(node_compat): enable more stream-writable tests (denoland#24328)
- Loading branch information
1 parent
16622ac
commit 7737755
Showing
6 changed files
with
127 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
tests/node_compat/test/parallel/test-stream-writable-aborted.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// deno-fmt-ignore-file | ||
// deno-lint-ignore-file | ||
|
||
// Copyright Joyent and Node contributors. All rights reserved. MIT license. | ||
// Taken from Node 18.12.1 | ||
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually. | ||
|
||
'use strict'; | ||
|
||
require('../common'); | ||
const assert = require('assert'); | ||
const { Writable } = require('stream'); | ||
|
||
{ | ||
const writable = new Writable({ | ||
write() { | ||
} | ||
}); | ||
assert.strictEqual(writable.writableAborted, false); | ||
writable.destroy(); | ||
assert.strictEqual(writable.writableAborted, true); | ||
} | ||
|
||
{ | ||
const writable = new Writable({ | ||
write() { | ||
} | ||
}); | ||
assert.strictEqual(writable.writableAborted, false); | ||
writable.end(); | ||
writable.destroy(); | ||
assert.strictEqual(writable.writableAborted, true); | ||
} |
32 changes: 32 additions & 0 deletions
32
tests/node_compat/test/parallel/test-stream-writable-final-async.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// deno-fmt-ignore-file | ||
// deno-lint-ignore-file | ||
|
||
// Copyright Joyent and Node contributors. All rights reserved. MIT license. | ||
// Taken from Node 18.12.1 | ||
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually. | ||
|
||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const { | ||
Duplex, | ||
} = require('stream'); | ||
const { setTimeout } = require('timers/promises'); | ||
|
||
{ | ||
class Foo extends Duplex { | ||
async _final(callback) { | ||
await setTimeout(common.platformTimeout(1)); | ||
callback(); | ||
} | ||
|
||
_read() {} | ||
} | ||
|
||
const foo = new Foo(); | ||
foo._write = common.mustCall((chunk, encoding, cb) => { | ||
cb(); | ||
}); | ||
foo.end('test', common.mustCall()); | ||
foo.on('error', common.mustNotCall()); | ||
} |
28 changes: 28 additions & 0 deletions
28
tests/node_compat/test/parallel/test-stream-writable-final-destroy.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// deno-fmt-ignore-file | ||
// deno-lint-ignore-file | ||
|
||
// Copyright Joyent and Node contributors. All rights reserved. MIT license. | ||
// Taken from Node 18.12.1 | ||
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually. | ||
|
||
'use strict'; | ||
const common = require('../common'); | ||
|
||
const { Writable } = require('stream'); | ||
|
||
{ | ||
const w = new Writable({ | ||
write(chunk, encoding, callback) { | ||
callback(null); | ||
}, | ||
final(callback) { | ||
queueMicrotask(callback); | ||
} | ||
}); | ||
w.end(); | ||
w.destroy(); | ||
|
||
w.on('prefinish', common.mustNotCall()); | ||
w.on('finish', common.mustNotCall()); | ||
w.on('close', common.mustCall()); | ||
} |
30 changes: 30 additions & 0 deletions
30
tests/node_compat/test/parallel/test-stream-writable-final-throw.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// deno-fmt-ignore-file | ||
// deno-lint-ignore-file | ||
|
||
// Copyright Joyent and Node contributors. All rights reserved. MIT license. | ||
// Taken from Node 18.12.1 | ||
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually. | ||
|
||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const { | ||
Duplex, | ||
} = require('stream'); | ||
|
||
{ | ||
class Foo extends Duplex { | ||
_final(callback) { | ||
throw new Error('fhqwhgads'); | ||
} | ||
|
||
_read() {} | ||
} | ||
|
||
const foo = new Foo(); | ||
foo._write = common.mustCall((chunk, encoding, cb) => { | ||
cb(); | ||
}); | ||
foo.end('test', common.expectsError({ message: 'fhqwhgads' })); | ||
foo.on('error', common.mustCall()); | ||
} |