mirror of
https://github.com/denoland/deno.git
synced 2024-12-27 01:29:14 -05:00
6915a9b7a7
This PR adds the remaining ~650 Node.js compat test cases from std/node. Among these 650 cases, about 130 cases are now failing. These failing cases are prefixed with `TODO:` in `tests/node_compat/config.json`. These will be addressed in later PRs.
47 lines
1.3 KiB
JavaScript
47 lines
1.3 KiB
JavaScript
// deno-fmt-ignore-file
|
|
// deno-lint-ignore-file
|
|
|
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
|
// Taken from Node 16.13.0
|
|
// This file is automatically generated by "node/_tools/setup.ts". Do not modify this file manually
|
|
|
|
// TODO(cmorten): uncomment dns module code once dns.setServer() has been
|
|
// implemented
|
|
|
|
'use strict';
|
|
const common = require('../common');
|
|
const mustCall = common.mustCall;
|
|
const assert = require('assert');
|
|
const dgram = require('dgram');
|
|
// const dns = require('dns');
|
|
|
|
const socket = dgram.createSocket('udp4');
|
|
const buffer = Buffer.from('gary busey');
|
|
|
|
// dns.setServers([]);
|
|
|
|
socket.once('error', onEvent);
|
|
|
|
// assert that:
|
|
// * callbacks act as "error" listeners if given.
|
|
// * error is never emitter for missing dns entries
|
|
// if a callback that handles error is present
|
|
// * error is emitted if a callback with no argument is passed
|
|
socket.send(buffer, 0, buffer.length, 100,
|
|
'dne.example.com', mustCall(callbackOnly));
|
|
|
|
function callbackOnly(err) {
|
|
assert.ok(err);
|
|
socket.removeListener('error', onEvent);
|
|
socket.on('error', mustCall(onError));
|
|
socket.send(buffer, 0, buffer.length, 100, 'dne.invalid');
|
|
}
|
|
|
|
function onEvent(err) {
|
|
assert.fail(`Error should not be emitted if there is callback: ${err}`);
|
|
}
|
|
|
|
function onError(err) {
|
|
assert.ok(err);
|
|
socket.close();
|
|
}
|