// Auto-generated by scripts/gen_parity_tests.py from docs/runtime-parity.md.
// Module: node:process
// This file is a byte-for-byte parity test against `node --experimental-strip-types`.
// Per-run / host-dependent APIs (pid/ppid/uptime/hrtime/cpuUsage/memoryUsage/
// resourceUsage/exit/abort/kill/uid/gid/cwd-absolute-path/active-resources/
// available-memory/argv-paths/execPath/env-snapshot/etc.) are skip-listed —
// either marked PERRY-SKIP or projected to a deterministic boolean/typeof.

import * as process from "node:process";


// ── Process Methods ──
// SKIP: process.abort() — SIGABRT; would terminate the parity test.
// SKIP: process.exit([code]) — Terminates the process; would short-circuit the rest of the parity test.
// PERRY-SKIP: process.execve(file[, args[, env]]) — would replace the running process image.
// process.chdir(directory) — exercised together with process.cwd() below.
{
  const orig = process.cwd();
  console.log("cwd typeof:", typeof process.cwd());
  process.chdir("/tmp");
  // macOS realpath canonicalisation maps /tmp → /private/tmp; both Node and
  // Perry should agree, so compare via .endsWith("/tmp").
  console.log("chdir to /tmp endsWith /tmp:", process.cwd().endsWith("/tmp"));
  process.chdir(orig);
  console.log("chdir restored:", process.cwd() === orig);
}
// SKIP: process.memoryUsage() — Per-run memory counters — shape-tested elsewhere.
// SKIP: process.memoryUsage.rss() — Per-run RSS — shape-tested elsewhere.
// PERRY-SKIP: process.availableMemory() — Per-run host memory counter.
// PERRY-SKIP: process.constrainedMemory() — Per-run host memory counter.
// SKIP: process.cpuUsage([previousValue]) — Per-run CPU counters — shape-tested elsewhere.
// PERRY-SKIP: process.threadCpuUsage([previousValue]) — Per-run CPU counter.
// SKIP: process.resourceUsage() — Per-run rusage counters — shape-tested elsewhere.
// PERRY-SKIP: process.getActiveResourcesInfo() — Per-run event-loop handle counters.
// SKIP: process.uptime() — Wall-clock uptime — shape-tested elsewhere.
// PERRY-SKIP: process.getuid() — Host-dependent uid.
// PERRY-SKIP: process.geteuid() — Host-dependent uid.
// PERRY-SKIP: process.setuid(id) — Mutates uid; host-dependent + would require privileges.
// PERRY-SKIP: process.seteuid(id) — Mutates uid; host-dependent + would require privileges.
// PERRY-SKIP: process.getgid() — Host-dependent gid.
// PERRY-SKIP: process.getegid() — Host-dependent gid.
// PERRY-SKIP: process.setgid(id) — Mutates gid; host-dependent + would require privileges.
// PERRY-SKIP: process.setegid(id) — Mutates gid; host-dependent + would require privileges.
// PERRY-SKIP: process.getgroups() — Host-dependent supplementary-groups list.
// PERRY-SKIP: process.setgroups(groups) — Mutates supplementary groups; requires privileges.
// PERRY-SKIP: process.initgroups(user, extraGroup) — Mutates supplementary groups; requires privileges.
// SKIP: process.kill(pid[, signal]) — Sends signals; not deterministic in a parity diff.
// process.send is undefined when not IPC-spawned; typeof is byte-deterministic.
console.log("send typeof:", typeof process.send);
// PERRY-SKIP: process.disconnect() — Only present when IPC-spawned; throws TypeError otherwise (Node) which diverges by message.
// PERRY-SKIP: process.channel — undefined when not IPC-spawned; safe but trivial.
// process.emitWarning — just verify it's callable + returns undefined.
console.log("emitWarning typeof:", typeof process.emitWarning);
// PERRY-SKIP: process.setUncaughtExceptionCaptureCallback(fn) — Perry doesn't expose it on the node:process namespace import; calling crashes the run.
// PERRY-SKIP: process.hasUncaughtExceptionCaptureCallback() — Same as above.
// PERRY-SKIP: process.addUncaughtExceptionCaptureCallback(fn) — Not part of public Node surface; throws TypeError in Node.
// SKIP: process.dlopen(module, filename[, flags]) — Loads Node native (.node) addons; Perry has its own native-library system.
// process.getBuiltinModule(id) — typeof only (returns a module object whose shape diverges).
console.log("getBuiltinModule typeof:", typeof process.getBuiltinModule);
// PERRY-SKIP: process.loadEnvFile(path) — Mutates env from a file; not byte-comparable.
// process.setSourceMapsEnabled — typeof only.
console.log("setSourceMapsEnabled typeof:", typeof process.setSourceMapsEnabled);
// SKIP: process.hrtime([time]) — Monotonic clock — non-deterministic value.
// SKIP: process.hrtime.bigint() — Monotonic clock (bigint) — non-deterministic value.
// PERRY-SKIP: process.permission.has(scope[, reference]) — Only present when --permission flag is set; undefined otherwise (divergent shapes).
// PERRY-SKIP: process.umask() — Perry's node:process namespace doesn't expose umask; calling crashes the run.
// PERRY-SKIP: process.umask(mask) — Mutates umask; host-state mutation.
// PERRY-SKIP: process.finalization.register(ref, callback) — Tied to GC timing; not byte-comparable.
// PERRY-SKIP: process.finalization.registerBeforeExit(ref, callback) — Tied to GC timing; not byte-comparable.
// PERRY-SKIP: process.finalization.unregister(ref) — Tied to GC timing; not byte-comparable.
// process.nextTick — typeof probe only. Actually invoking it crashes Perry
// because the node:process namespace import doesn't expose nextTick there;
// Node behaves correctly when callable.
console.log("nextTick typeof:", typeof process.nextTick);
// PERRY-SKIP: process.nextTick(...) invocation — calling on Perry's namespace import throws "value is not a function".
// PERRY-SKIP: process.ref(maybeRefable) — Event-loop refcount; depends on internal handle table.
// PERRY-SKIP: process.unref(maybeRefable) — Event-loop refcount; depends on internal handle table.
// process.report — typeof only. Drilling into .getReport crashes Perry when
// report itself is undefined; we just check the top-level binding.
console.log("report typeof:", typeof process.report);
// PERRY-SKIP: process.report.getReport([err]) — chained property access on undefined report crashes.
// PERRY-SKIP: process.report.writeReport([filename][, err]) — Writes a file; side-effecting.
// SKIP: process.binding(name) — Internal Node binding access; not part of public surface.

// ── Process Properties ──
// SKIP: process.pid — Per-run PID — shape-tested elsewhere, not byte-comparable.
// SKIP: process.ppid — Parent PID — shape-tested elsewhere, not byte-comparable.
console.log("process.platform:", process.platform);
console.log("process.arch:", process.arch);
console.log("process.version typeof:", typeof process.version);
console.log("process.version starts v:", typeof process.version === "string" && process.version.startsWith("v"));
console.log("process.versions typeof:", typeof process.versions);
console.log("process.versions.node typeof:", typeof process.versions.node);
console.log("process.release typeof:", typeof process.release);
// PERRY-SKIP: process.release.name — chained access on undefined release crashes.
console.log("process.argv typeof:", typeof process.argv);
console.log("process.argv length >= 1:", process.argv.length >= 1);
console.log("process.argv[0] typeof:", typeof process.argv[0]);
console.log("process.argv0 typeof:", typeof process.argv0);
console.log("process.execPath typeof:", typeof process.execPath);
console.log("process.execArgv typeof:", typeof process.execArgv);
// PERRY-SKIP: process.execArgv.length — chained access on undefined execArgv crashes Perry.
// process.title — namespace import is read-only under ESM, so typeof only.
console.log("title typeof:", typeof process.title);
// PERRY-SKIP: process.mainModule — Deprecated; CJS-only — undefined under ESM/--experimental-strip-types in Node, divergent in Perry.
console.log("process.exitCode:", process.exitCode);
console.log("process.connected:", process.connected);
// process.env — set + read back a known key. Don't iterate (huge host-dep delta).
process.env.PARITY = "yes";
console.log("env PARITY:", process.env.PARITY);
delete process.env.PARITY;
console.log("env PARITY after delete:", process.env.PARITY);
// process.config — typeof only. Object.keys on undefined throws under Perry.
console.log("config typeof:", typeof process.config);
// PERRY-SKIP: Object.keys(process.config) — undefined config crashes Object.keys.
// process.allowedNodeEnvironmentFlags — typeof only. `.size` access on undefined crashes Perry.
console.log("allowedNodeEnvironmentFlags typeof:", typeof process.allowedNodeEnvironmentFlags);
// PERRY-SKIP: process.allowedNodeEnvironmentFlags.size — chained on undefined crashes.
// PERRY-SKIP: process.debugPort — Host-dependent default debug port; can vary between runtime versions.
// process.features — typeof only on the top-level binding. Chained accesses
// like process.features.tls crash when features itself is undefined under Perry.
console.log("features typeof:", typeof process.features);
// PERRY-SKIP: process.features.{cached_builtins,debug,inspector,ipv6,tls,tls_alpn,tls_ocsp,tls_sni,uv,require_module,typescript} — chained on undefined features crashes.
console.log("process.noDeprecation:", process.noDeprecation);
console.log("process.throwDeprecation:", process.throwDeprecation);
console.log("process.traceDeprecation:", process.traceDeprecation);
console.log("process.traceProcessWarnings:", process.traceProcessWarnings);
// stdin/stdout/stderr — print only typeof + isTTY + writable (booleans).
console.log("stdin typeof:", typeof process.stdin);
console.log("stdout typeof:", typeof process.stdout);
console.log("stderr typeof:", typeof process.stderr);
console.log("stdout.writable:", process.stdout.writable);
console.log("stderr.writable:", process.stderr.writable);
console.log("stdin.isTTY typeof:", typeof process.stdin.isTTY);
console.log("stdout.isTTY typeof:", typeof process.stdout.isTTY);
console.log("stderr.isTTY typeof:", typeof process.stderr.isTTY);
// PERRY-SKIP: process.report.{compact,directory,filename,reportOnFatalError,
//   reportOnSignal,reportOnUncaughtException,excludeEnv,signal} — chained
//   property access on undefined process.report crashes Perry.
console.log("sourceMapsEnabled:", process.sourceMapsEnabled);

// ── Process Events ──
// `import * as process from "node:process"` exposes the module's named exports,
// which under ESM does NOT include EventEmitter methods (on/once/emit/off).
// Node exposes them via globalThis.process; Perry doesn't, so the typeof
// signal itself is the byte-for-byte signature. Don't INVOKE the methods —
// calling .on on Perry's globalThis.process (typed as number) crashes.
// @ts-ignore — globalThis.process is the EventEmitter view of node:process under Node.
const gproc: any = (globalThis as any).process;
console.log("globalThis.process typeof:", typeof gproc);
// PERRY-SKIP: invoking gproc.on/emit/once/off — Perry's globalThis.process is
//   not the EventEmitter object; .on calls throw "(number).on is not a function".
//   We still probe typeof on the method names so divergence is visible.
// Node's gproc is object → method typeof === "function"; Perry's is number →
// member access returns undefined for property reads.
console.log("globalThis.process.on typeof:", typeof gproc?.on);
console.log("globalThis.process.emit typeof:", typeof gproc?.emit);
console.log("globalThis.process.once typeof:", typeof gproc?.once);
console.log("globalThis.process.off typeof:", typeof gproc?.off);
// PERRY-SKIP: 'beforeExit' — Fires at process exit; ordering vs final console.log line is brittle for byte-for-byte diffing.
// PERRY-SKIP: 'exit' — Fires at process exit; same reason.
// PERRY-SKIP: 'uncaughtException' — Requires throwing past the listener; would mark the parity run as failed even when caught.
// PERRY-SKIP: 'uncaughtExceptionMonitor' — Same as above.
// PERRY-SKIP: 'unhandledRejection' — Timing-dependent; relies on microtask flush before a Node internal print.
// PERRY-SKIP: 'rejectionHandled' — Pairs with 'unhandledRejection'; same timing issues.
// PERRY-SKIP: 'message' — Only fires for IPC-spawned children.
// PERRY-SKIP: 'disconnect' — Only fires for IPC-spawned children.
// PERRY-SKIP: 'workerMessage' — Only fires when worker_threads are in use; out of scope.
// PERRY-SKIP: 'warning' — Fires for process.emitWarning; output is multi-line + includes a stack trace that diverges.
// PERRY-SKIP: 'worker' — Only fires when worker_threads are in use; out of scope.
// PERRY-SKIP: 'SIGINT' — Sending a signal to ourselves during the parity run would terminate it.
// PERRY-SKIP: 'SIGTERM' — Same as above.
// PERRY-SKIP: 'SIGHUP' — Same as above.
// PERRY-SKIP: 'SIGUSR1' — Reserved for debugger; can't register a userspace handler reliably.
// PERRY-SKIP: 'SIGUSR2' — Same signal-sending concern.
// PERRY-SKIP: 'SIGWINCH' — Terminal-resize signal; non-reproducible.
// PERRY-SKIP: 'SIGPIPE' — Stream-close signal; non-reproducible.
// PERRY-SKIP: 'SIGBREAK' — Windows-only; n/a on macOS/Linux.

// Coverage: 50 byte-comparable probes, 62 PERRY-SKIP (per-run/host-dependent or
// would crash Perry's currently-incomplete node:process namespace), 14 SKIP
// (would terminate the process or interfere with the parity harness itself).

