blob: 6fd825ad06d56f183b83477980753f42c1f3e78b (
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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# frozen_string_literal: true
require_relative "test_helper"
module Prism
module PercentDelimiterTests
def test_newline_terminator_with_lf_crlf
str = l "\n123456\r\n"
assert_parse "123456", str
end
def test_newline_terminator_with_lf_crlf_with_extra_cr
str = l "\n123456\r\r\n"
assert_parse "123456\r", str
end
def test_newline_terminator_with_crlf_pair
str = l "\r\n123456\r\n"
assert_parse "123456", str
end
def test_newline_terminator_with_crlf_crlf_with_extra_cr
str = l "\r\n123456\r\r\n"
assert_parse "123456\r", str
end
def test_newline_terminator_with_cr_cr
str = l "\r123456\r;\n"
assert_parse "123456", str
end
def test_newline_terminator_with_crlf_lf
str = l "\r\n123456\n;\n"
assert_parse "123456", str
end
def test_cr_crlf
str = l "\r1\r\n \r"
assert_parse "1\n ", str
end
def test_lf_crlf
str = l "\n1\r\n \n"
assert_parse "1", str
end
def test_lf_lf
str = l "\n1\n \n"
assert_parse "1", str
end
def assert_parse(expected, str)
assert_equal expected, find_node(str).unescaped
end
end
class PercentDelimiterStringTest < TestCase
include PercentDelimiterTests
def find_node(str)
tree = Prism.parse str
tree.value.breadth_first_search { |x| Prism::StringNode === x }
end
def l(str)
"%" + str
end
end
class PercentDelimiterRegexpTest < TestCase
include PercentDelimiterTests
def l(str)
"%r" + str
end
def find_node(str)
tree = Prism.parse str
tree.value.breadth_first_search { |x| Prism::RegularExpressionNode === x }
end
end
end
|