11cb0ef41Sopenharmony_ciimport * as common from '../common/index.mjs';
21cb0ef41Sopenharmony_ciimport * as fixtures from '../common/fixtures.mjs';
31cb0ef41Sopenharmony_ciimport * as snapshot from '../common/assertSnapshot.js';
41cb0ef41Sopenharmony_ciimport * as path from 'node:path';
51cb0ef41Sopenharmony_ciimport { describe, it } from 'node:test';
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_cidescribe('sourcemaps output', { concurrency: true }, () => {
81cb0ef41Sopenharmony_ci  function normalize(str) {
91cb0ef41Sopenharmony_ci    const result = str
101cb0ef41Sopenharmony_ci    .replaceAll(snapshot.replaceWindowsPaths(process.cwd()), '')
111cb0ef41Sopenharmony_ci    .replaceAll('//', '*')
121cb0ef41Sopenharmony_ci    .replaceAll('/Users/bencoe/oss/coffee-script-test', '')
131cb0ef41Sopenharmony_ci    .replaceAll(/\/(\w)/g, '*$1')
141cb0ef41Sopenharmony_ci    .replaceAll('*test*', '*')
151cb0ef41Sopenharmony_ci    .replaceAll('*fixtures*source-map*', '*')
161cb0ef41Sopenharmony_ci    .replaceAll(/(\W+).*node:internal\*modules.*/g, '$1*');
171cb0ef41Sopenharmony_ci    if (common.isWindows) {
181cb0ef41Sopenharmony_ci      const currentDeviceLetter = path.parse(process.cwd()).root.substring(0, 1).toLowerCase();
191cb0ef41Sopenharmony_ci      const regex = new RegExp(`${currentDeviceLetter}:/?`, 'gi');
201cb0ef41Sopenharmony_ci      return result.replaceAll(regex, '');
211cb0ef41Sopenharmony_ci    }
221cb0ef41Sopenharmony_ci    return result;
231cb0ef41Sopenharmony_ci  }
241cb0ef41Sopenharmony_ci  const defaultTransform = snapshot
251cb0ef41Sopenharmony_ci    .transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths,
261cb0ef41Sopenharmony_ci               normalize, snapshot.replaceNodeVersion);
271cb0ef41Sopenharmony_ci
281cb0ef41Sopenharmony_ci  const tests = [
291cb0ef41Sopenharmony_ci    { name: 'source-map/output/source_map_disabled_by_api.js' },
301cb0ef41Sopenharmony_ci    { name: 'source-map/output/source_map_enabled_by_api.js' },
311cb0ef41Sopenharmony_ci    { name: 'source-map/output/source_map_enclosing_function.js' },
321cb0ef41Sopenharmony_ci    { name: 'source-map/output/source_map_eval.js' },
331cb0ef41Sopenharmony_ci    { name: 'source-map/output/source_map_no_source_file.js' },
341cb0ef41Sopenharmony_ci    { name: 'source-map/output/source_map_reference_error_tabs.js' },
351cb0ef41Sopenharmony_ci    { name: 'source-map/output/source_map_sourcemapping_url_string.js' },
361cb0ef41Sopenharmony_ci    { name: 'source-map/output/source_map_throw_catch.js' },
371cb0ef41Sopenharmony_ci    { name: 'source-map/output/source_map_throw_first_tick.js' },
381cb0ef41Sopenharmony_ci    { name: 'source-map/output/source_map_throw_icu.js' },
391cb0ef41Sopenharmony_ci    { name: 'source-map/output/source_map_throw_set_immediate.js' },
401cb0ef41Sopenharmony_ci  ];
411cb0ef41Sopenharmony_ci  for (const { name, transform } of tests) {
421cb0ef41Sopenharmony_ci    it(name, async () => {
431cb0ef41Sopenharmony_ci      await snapshot.spawnAndAssert(fixtures.path(name), transform ?? defaultTransform);
441cb0ef41Sopenharmony_ci    });
451cb0ef41Sopenharmony_ci  }
461cb0ef41Sopenharmony_ci});
47