<commit_before>{Stacktrace} = require '../lib/stacktrace'
{RUBY: {FUNCTION: TRACE}} = require './trace-fixtures'

describe 'Stacktrace', ->
  describe 'with a Ruby trace', ->
    [trace, checksum] = []

    beforeEach ->
      [trace] = Stacktrace.parse(TRACE)
      checksum = '9528763b5ab8ef052e2400e39d0f32dbe59ffcd06f039adc487f4f956511691f'

    describe 'preparation', ->
      it 'trims leading and trailing whitespace from each raw line', ->
        lines = (frame.rawLine for frame in trace.frames)
        expected = [
          "/home/smash/samples/tracer/otherdir/file2.rb:6:in `block in outerfunction': whoops (RuntimeError)"
          "from /home/smash/samples/tracer/dir/file1.rb:3:in `innerfunction'"
          "from /home/smash/samples/tracer/otherdir/file2.rb:5:in `outerfunction'"
          "from /home/smash/samples/tracer/entry.rb:7:in `toplevel'"
          "from /home/smash/samples/tracer/entry.rb:10:in `<main>'"
        ]
        expect(lines).toEqual(expected)

    describe 'parsing a Ruby stack trace', ->
      it 'parses the error message', ->
        expect(trace.message).toBe('whoops (RuntimeError)')

      it 'parses file paths from each frame', ->
        filePaths = (frame.path for frame in trace.frames)
        expected = [
          '/home/smash/samples/tracer/otherdir/file2.rb'
          '/home/smash/samples/tracer/dir/file1.rb'
          '/home/smash/samples/tracer/otherdir/file2.rb'
          '/home/smash/samples/tracer/entry.rb'
          '/home/smash/samples/tracer/entry.rb'
        ]
        expect(filePaths).toEqual(expected)

      it 'parses line numbers from each frame', ->
        lineNumbers = (frame.lineNumber for frame in trace.frames)
        expected = [6, 3, 5, 7, 10]
        expect(lineNumbers).toEqual(lineNumbers)

      it 'parses function names from each frame', ->
        functionNames = (frame.functionName for frame in trace.frames)
        expected = [
          'block in outerfunction'
          'innerfunction'
          'outerfunction'<commit_msg>Oops, broke that test when I renamed path.<commit_after>{Stacktrace} = require '../lib/stacktrace'
{RUBY: {FUNCTION: TRACE}} = require './trace-fixtures'

describe 'Stacktrace', ->
  describe 'with a Ruby trace', ->
    [trace, checksum] = []

    beforeEach ->
      [trace] = Stacktrace.parse(TRACE)
      checksum = '9528763b5ab8ef052e2400e39d0f32dbe59ffcd06f039adc487f4f956511691f'

    describe 'preparation', ->
      it 'trims leading and trailing whitespace from each raw line', ->
        lines = (frame.rawLine for frame in trace.frames)
        expected = [
          "/home/smash/samples/tracer/otherdir/file2.rb:6:in `block in outerfunction': whoops (RuntimeError)"
          "from /home/smash/samples/tracer/dir/file1.rb:3:in `innerfunction'"
          "from /home/smash/samples/tracer/otherdir/file2.rb:5:in `outerfunction'"
          "from /home/smash/samples/tracer/entry.rb:7:in `toplevel'"
          "from /home/smash/samples/tracer/entry.rb:10:in `<main>'"
        ]
        expect(lines).toEqual(expected)

    describe 'parsing a Ruby stack trace', ->
      it 'parses the error message', ->
        expect(trace.message).toBe('whoops (RuntimeError)')

      it 'parses file paths from each frame', ->
        filePaths = (frame.realPath for frame in trace.frames)
        expected = [
          '/home/smash/samples/tracer/otherdir/file2.rb'
          '/home/smash/samples/tracer/dir/file1.rb'
          '/home/smash/samples/tracer/otherdir/file2.rb'
          '/home/smash/samples/tracer/entry.rb'
          '/home/smash/samples/tracer/entry.rb'
        ]
        expect(filePaths).toEqual(expected)

      it 'parses line numbers from each frame', ->
        lineNumbers = (frame.lineNumber for frame in trace.frames)
        expected = [6, 3, 5, 7, 10]
        expect(lineNumbers).toEqual(lineNumbers)

      it 'parses function names from each frame', ->
        functionNames = (frame.functionName for frame in trace.frames)
        expected = [
          'block in outerfunction'
          'innerfunction'
          'outerfunction'
{'fraction_non_alphanumeric': 0.1291901149987766, 'fraction_numerical': 0.028872033276241743, 'mean_word_length': 2.5828220858895707, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 25, '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': '5295844', 'n_tokens_mistral': 1353, 'n_tokens_neox': 1280, 'n_words': 270}