xref: /third_party/node/test/parallel/test-fs-mkdtemp-prefix-check.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 fs = require('fs');
51cb0ef41Sopenharmony_ci
61cb0ef41Sopenharmony_ciconst prefixValues = [undefined, null, 0, true, false, 1];
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_cifunction fail(value) {
91cb0ef41Sopenharmony_ci  assert.throws(
101cb0ef41Sopenharmony_ci    () => {
111cb0ef41Sopenharmony_ci      fs.mkdtempSync(value, {});
121cb0ef41Sopenharmony_ci    },
131cb0ef41Sopenharmony_ci    {
141cb0ef41Sopenharmony_ci      code: 'ERR_INVALID_ARG_TYPE',
151cb0ef41Sopenharmony_ci      name: 'TypeError'
161cb0ef41Sopenharmony_ci    });
171cb0ef41Sopenharmony_ci}
181cb0ef41Sopenharmony_ci
191cb0ef41Sopenharmony_cifunction failAsync(value) {
201cb0ef41Sopenharmony_ci  assert.throws(
211cb0ef41Sopenharmony_ci    () => {
221cb0ef41Sopenharmony_ci      fs.mkdtemp(value, common.mustNotCall());
231cb0ef41Sopenharmony_ci    },
241cb0ef41Sopenharmony_ci    {
251cb0ef41Sopenharmony_ci      code: 'ERR_INVALID_ARG_TYPE',
261cb0ef41Sopenharmony_ci      name: 'TypeError'
271cb0ef41Sopenharmony_ci    });
281cb0ef41Sopenharmony_ci}
291cb0ef41Sopenharmony_ci
301cb0ef41Sopenharmony_ciprefixValues.forEach((prefixValue) => {
311cb0ef41Sopenharmony_ci  fail(prefixValue);
321cb0ef41Sopenharmony_ci  failAsync(prefixValue);
331cb0ef41Sopenharmony_ci});
34

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