summaryrefslogtreecommitdiff
path: root/test/prism/format_errors_test.rb
blob: a1edbef2e86bd112fcc6bb5eec1fa1d4db30076c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# frozen_string_literal: true

require_relative "test_helper"

return if Prism::BACKEND == :FFI

module Prism
  class FormatErrorsTest < TestCase
    def test_format_errors
      assert_equal <<~ERROR, Debug.format_errors("<>", false)
        > 1 | <>
            | ^ unexpected '<', ignoring it
            |  ^ unexpected '>', ignoring it
      ERROR

      assert_equal <<~'ERROR', Debug.format_errors('"%W"\u"', false)
        > 1 | "%W"\u"
            |     ^ unexpected backslash, ignoring it
            |      ^ unexpected local variable or method, expecting end-of-input
            |        ^ unterminated string meets end of file
      ERROR
    end
  end
end