xref: /third_party/node/test/parallel/test-socket-address.js
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/test/parallel/
11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ciconst common = require('../common');
31cb0ef41Sopenharmony_ciconst assert = require('assert');
41cb0ef41Sopenharmony_ciconst net = require('net');
51cb0ef41Sopenharmony_ci
61cb0ef41Sopenharmony_ci// This tests checks that if server._handle.getsockname
71cb0ef41Sopenharmony_ci// returns an error number, an error is thrown.
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_ciconst server = net.createServer({});
101cb0ef41Sopenharmony_ciserver.listen(0, common.mustCall(function() {
111cb0ef41Sopenharmony_ci  server._handle.getsockname = function(out) {
121cb0ef41Sopenharmony_ci    return -1;
131cb0ef41Sopenharmony_ci  };
141cb0ef41Sopenharmony_ci  assert.throws(() => this.address(),
151cb0ef41Sopenharmony_ci                /^Error: address [\w|\s-\d]+$/);
161cb0ef41Sopenharmony_ci  server.close();
171cb0ef41Sopenharmony_ci}));
18

Indexes created Thu Nov 07 10:32:03 CST 2024