<commit_before>import check from './support/check.js';

describe('string interpolation', () => {
  it('rewrites interpolations with #{} to ${}', () => {
    check('"a#{b}c"', '`a${b}c`;');
  });

  it('rewrites interpolations with spaces after the "{"', () => {
    check('"a#{ b }c"', '`a${ b }c`;');
  });

  it('can return interpolated strings', () => {
    check('-> "#{a}"', '() => `${a}`;');
  });

  it('ensures backticks are escaped', () => {
    check('"`#{name}` is required"', '`\\`${name}\\` is required`;');
  });

  it('does not double-escape backticks', () => {
    check('"\\`#{name}\\` is required"', '`\\`${name}\\` is required`;');
  });

  it('handles multi-line triple-quoted strings correctly', () => {
    check('a = """\n     #{b}\n     c\n    """', 'let a = `${b}\nc`;');
  });

  it('handles double quotes inside triple-double quotes', () => {
    check(`
      a="""
      bar="#{bar}"
      """
    `, `
      let a=\`bar="\${bar}"\`;
    `);
  });

  it('handles comments inside interpolations', () => {
    check(`
      a="#{
      b # foo!
      }"
    `, `
      let a=\`\${
      b // foo!
      }\`;
    `);
  });

  it('handles nested string interpolations', () => {
    check(`
      "a#{"b#{c}d"}e"
    `, `
      \`a\${\`b\${c}d\`}e\`;
    `);
  });

  it('escapes ${ inside strings that become template strings', () => {
    check(
      '"#{interpolation}${not interpolation}"',
      '`${interpolation}\\${not interpolation}`;'
    );
  });

  it('escapes ${ inside block strings that become template strings', () => {
    check(`
      """
      \${a}
      \${b}
      """
    `, `
      \`\\\${a}
      \\\${b}\`;
    `);
  });

  it('is allowed inside an object with explicit curly braces', () => {
    check(`
      { a: "#{b}" }
    `, `
      ({ a: \`\${b}\` });
    `);
  });

  it.skip('works with two string interpolations separated by something', () => {
    check(`
      "#{a} #{b}"
    `, `
      \`\${a} \${b}\`;
    `);
  });
});
<commit_msg>Enable a formerly-failing test.<commit_after>import check from './support/check.js';

describe('string interpolation', () => {
  it('rewrites interpolations with #{} to ${}', () => {
    check('"a#{b}c"', '`a${b}c`;');
  });

  it('rewrites interpolations with spaces after the "{"', () => {
    check('"a#{ b }c"', '`a${ b }c`;');
  });

  it('can return interpolated strings', () => {
    check('-> "#{a}"', '() => `${a}`;');
  });

  it('ensures backticks are escaped', () => {
    check('"`#{name}` is required"', '`\\`${name}\\` is required`;');
  });

  it('does not double-escape backticks', () => {
    check('"\\`#{name}\\` is required"', '`\\`${name}\\` is required`;');
  });

  it('handles multi-line triple-quoted strings correctly', () => {
    check('a = """\n     #{b}\n     c\n    """', 'let a = `${b}\nc`;');
  });

  it('handles double quotes inside triple-double quotes', () => {
    check(`
      a="""
      bar="#{bar}"
      """
    `, `
      let a=\`bar="\${bar}"\`;
    `);
  });

  it('handles comments inside interpolations', () => {
    check(`
      a="#{
      b # foo!
      }"
    `, `
      let a=\`\${
      b // foo!
      }\`;
    `);
  });

  it('handles nested string interpolations', () => {
    check(`
      "a#{"b#{c}d"}e"
    `, `
      \`a\${\`b\${c}d\`}e\`;
    `);
  });

  it('escapes ${ inside strings that become template strings', () => {
    check(
      '"#{interpolation}${not interpolation}"',
      '`${interpolation}\\${not interpolation}`;'
    );
  });

  it('escapes ${ inside block strings that become template strings', () => {
    check(`
      """
      \${a}
      \${b}
      """
    `, `
      \`\\\${a}
      \\\${b}\`;
    `);
  });

  it('is allowed inside an object with explicit curly braces', () => {
    check(`
      { a: "#{b}" }
    `, `
      ({ a: \`\${b}\` });
    `);
  });

  it('works with two string interpolations separated by something', () => {
    check(`
      "#{a} #{b}"
    `, `
      \`\${a} \${b}\`;
    `);
  });
});

{'fraction_non_alphanumeric': 0.283827560428607, 'fraction_numerical': 0.0, 'mean_word_length': 2.203511572226656, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5880018', 'n_tokens_mistral': 1509, 'n_tokens_neox': 1464, 'n_words': 293}