11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_cirequire('../common'); 31cb0ef41Sopenharmony_ciconst assert = require('assert'); 41cb0ef41Sopenharmony_ciconst fs = require('fs'); 51cb0ef41Sopenharmony_ciconst callbackThrowValues = [null, true, false, 0, 1, 'foo', /foo/, [], {}]; 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ciconst { sep } = require('path'); 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_ciconst tmpdir = require('../common/tmpdir'); 101cb0ef41Sopenharmony_citmpdir.refresh(); 111cb0ef41Sopenharmony_ci 121cb0ef41Sopenharmony_cifunction testMakeCallback(cb) { 131cb0ef41Sopenharmony_ci return function() { 141cb0ef41Sopenharmony_ci // fs.mkdtemp() calls makeCallback() on its third argument 151cb0ef41Sopenharmony_ci fs.mkdtemp(`${tmpdir.path}${sep}`, {}, cb); 161cb0ef41Sopenharmony_ci }; 171cb0ef41Sopenharmony_ci} 181cb0ef41Sopenharmony_ci 191cb0ef41Sopenharmony_cifunction invalidCallbackThrowsTests() { 201cb0ef41Sopenharmony_ci callbackThrowValues.forEach((value) => { 211cb0ef41Sopenharmony_ci assert.throws(testMakeCallback(value), { 221cb0ef41Sopenharmony_ci code: 'ERR_INVALID_ARG_TYPE', 231cb0ef41Sopenharmony_ci name: 'TypeError' 241cb0ef41Sopenharmony_ci }); 251cb0ef41Sopenharmony_ci }); 261cb0ef41Sopenharmony_ci} 271cb0ef41Sopenharmony_ci 281cb0ef41Sopenharmony_ciinvalidCallbackThrowsTests(); 29