11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst common = require('../common'); 41cb0ef41Sopenharmony_ciconst assert = require('node:assert'); 51cb0ef41Sopenharmony_ciconst { spawnSync, spawn } = require('node:child_process'); 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ciassert.strictEqual(RegExp.$_, ''); 81cb0ef41Sopenharmony_ciassert.strictEqual(RegExp.$0, undefined); 91cb0ef41Sopenharmony_ciassert.strictEqual(RegExp.$1, ''); 101cb0ef41Sopenharmony_ciassert.strictEqual(RegExp.$2, ''); 111cb0ef41Sopenharmony_ciassert.strictEqual(RegExp.$3, ''); 121cb0ef41Sopenharmony_ciassert.strictEqual(RegExp.$4, ''); 131cb0ef41Sopenharmony_ciassert.strictEqual(RegExp.$5, ''); 141cb0ef41Sopenharmony_ciassert.strictEqual(RegExp.$6, ''); 151cb0ef41Sopenharmony_ciassert.strictEqual(RegExp.$7, ''); 161cb0ef41Sopenharmony_ciassert.strictEqual(RegExp.$8, ''); 171cb0ef41Sopenharmony_ciassert.strictEqual(RegExp.$9, ''); 181cb0ef41Sopenharmony_ciassert.strictEqual(RegExp.input, ''); 191cb0ef41Sopenharmony_ciassert.strictEqual(RegExp.lastMatch, ''); 201cb0ef41Sopenharmony_ciassert.strictEqual(RegExp.lastParen, ''); 211cb0ef41Sopenharmony_ciassert.strictEqual(RegExp.leftContext, ''); 221cb0ef41Sopenharmony_ciassert.strictEqual(RegExp.rightContext, ''); 231cb0ef41Sopenharmony_ciassert.strictEqual(RegExp['$&'], ''); 241cb0ef41Sopenharmony_ciassert.strictEqual(RegExp['$`'], ''); 251cb0ef41Sopenharmony_ciassert.strictEqual(RegExp['$+'], ''); 261cb0ef41Sopenharmony_ciassert.strictEqual(RegExp["$'"], ''); 271cb0ef41Sopenharmony_ci 281cb0ef41Sopenharmony_ciconst allRegExpStatics = 291cb0ef41Sopenharmony_ci 'RegExp.$_ + RegExp["$&"] + RegExp["$`"] + RegExp["$+"] + RegExp["$\'"] + ' + 301cb0ef41Sopenharmony_ci 'RegExp.input + RegExp.lastMatch + RegExp.lastParen + ' + 311cb0ef41Sopenharmony_ci 'RegExp.leftContext + RegExp.rightContext + ' + 321cb0ef41Sopenharmony_ci Array.from({ length: 10 }, (_, i) => `RegExp.$${i}`).join(' + '); 331cb0ef41Sopenharmony_ci 341cb0ef41Sopenharmony_ci{ 351cb0ef41Sopenharmony_ci const child = spawnSync(process.execPath, 361cb0ef41Sopenharmony_ci [ '-p', allRegExpStatics ], 371cb0ef41Sopenharmony_ci { stdio: ['inherit', 'pipe', 'inherit'] }); 381cb0ef41Sopenharmony_ci assert.match(child.stdout.toString(), /^undefined\r?\n$/); 391cb0ef41Sopenharmony_ci assert.strictEqual(child.status, 0); 401cb0ef41Sopenharmony_ci assert.strictEqual(child.signal, null); 411cb0ef41Sopenharmony_ci} 421cb0ef41Sopenharmony_ci 431cb0ef41Sopenharmony_ci{ 441cb0ef41Sopenharmony_ci const child = spawnSync(process.execPath, 451cb0ef41Sopenharmony_ci [ '--expose-internals', '-p', `const { 461cb0ef41Sopenharmony_ci SideEffectFreeRegExpPrototypeExec, 471cb0ef41Sopenharmony_ci SideEffectFreeRegExpPrototypeSymbolReplace, 481cb0ef41Sopenharmony_ci SideEffectFreeRegExpPrototypeSymbolSplit, 491cb0ef41Sopenharmony_ci } = require("internal/util"); 501cb0ef41Sopenharmony_ci SideEffectFreeRegExpPrototypeExec(/foo/, "foo"); 511cb0ef41Sopenharmony_ci SideEffectFreeRegExpPrototypeSymbolReplace(/o/, "foo", "a"); 521cb0ef41Sopenharmony_ci SideEffectFreeRegExpPrototypeSymbolSplit(/o/, "foo"); 531cb0ef41Sopenharmony_ci ${allRegExpStatics}` ], 541cb0ef41Sopenharmony_ci { stdio: ['inherit', 'pipe', 'inherit'] }); 551cb0ef41Sopenharmony_ci assert.match(child.stdout.toString(), /^undefined\r?\n$/); 561cb0ef41Sopenharmony_ci assert.strictEqual(child.status, 0); 571cb0ef41Sopenharmony_ci assert.strictEqual(child.signal, null); 581cb0ef41Sopenharmony_ci} 591cb0ef41Sopenharmony_ci 601cb0ef41Sopenharmony_ci{ 611cb0ef41Sopenharmony_ci const child = spawnSync(process.execPath, 621cb0ef41Sopenharmony_ci [ '-e', `console.log(${allRegExpStatics})`, '--input-type=module' ], 631cb0ef41Sopenharmony_ci { stdio: ['inherit', 'pipe', 'inherit'] }); 641cb0ef41Sopenharmony_ci assert.match(child.stdout.toString(), /^undefined\r?\n$/); 651cb0ef41Sopenharmony_ci assert.strictEqual(child.status, 0); 661cb0ef41Sopenharmony_ci assert.strictEqual(child.signal, null); 671cb0ef41Sopenharmony_ci} 681cb0ef41Sopenharmony_ci 691cb0ef41Sopenharmony_ci{ 701cb0ef41Sopenharmony_ci const child = spawn(process.execPath, [], { stdio: ['pipe', 'pipe', 'inherit'], encoding: 'utf8' }); 711cb0ef41Sopenharmony_ci 721cb0ef41Sopenharmony_ci let stdout = ''; 731cb0ef41Sopenharmony_ci child.stdout.on('data', (chunk) => { 741cb0ef41Sopenharmony_ci stdout += chunk; 751cb0ef41Sopenharmony_ci }); 761cb0ef41Sopenharmony_ci 771cb0ef41Sopenharmony_ci child.on('exit', common.mustCall((status, signal) => { 781cb0ef41Sopenharmony_ci assert.match(stdout, /^undefined\r?\n$/); 791cb0ef41Sopenharmony_ci assert.strictEqual(status, 0); 801cb0ef41Sopenharmony_ci assert.strictEqual(signal, null); 811cb0ef41Sopenharmony_ci })); 821cb0ef41Sopenharmony_ci child.on('error', common.mustNotCall()); 831cb0ef41Sopenharmony_ci 841cb0ef41Sopenharmony_ci child.stdin.end(`console.log(${allRegExpStatics});\n`); 851cb0ef41Sopenharmony_ci} 86