1'use strict'; 2 3const common = require('../common'); 4if (!common.hasCrypto) 5 common.skip('missing crypto'); 6common.requireNoPackageJSONAbove(); 7 8const fixtures = require('../common/fixtures'); 9 10const assert = require('assert'); 11const { spawnSync } = require('child_process'); 12 13const encodings = ['buffer', 'utf8', 'utf16le', 'latin1', 'base64', 'hex']; 14 15for (const encoding of encodings) { 16 const dep = fixtures.path('policy', 'crypto-default-encoding', 'parent.js'); 17 const depPolicy = fixtures.path( 18 'policy', 19 'crypto-default-encoding', 20 'policy.json'); 21 const { status } = spawnSync( 22 process.execPath, 23 [ 24 '--experimental-policy', depPolicy, dep, 25 ], 26 { 27 env: { 28 ...process.env, 29 DEFAULT_ENCODING: encoding 30 } 31 } 32 ); 33 assert.strictEqual(status, 0); 34} 35