@@ -30,48 +30,85 @@ def test_multi_read
3030 end
3131
3232 def test___END__
33- io = StringIO . new ( "1 + 2\n 3 + 4\n __END__\n 5 + 6" )
33+ io = StringIO . new ( <<~RUBY )
34+ 1 + 2
35+ 3 + 4
36+ __END__
37+ 5 + 6
38+ RUBY
3439 result = Prism . parse_stream ( io )
3540
3641 assert result . success?
3742 assert_equal 2 , result . value . statements . body . length
38- assert_equal "5 + 6" , io . read
43+ assert_equal "5 + 6\n " , io . read
3944 end
4045
4146 def test_false___END___in_string
42- io = StringIO . new ( "1 + 2\n 3 + 4\n \" \n __END__\n \" \n 5 + 6" )
47+ io = StringIO . new ( <<~RUBY )
48+ 1 + 2
49+ 3 + 4
50+ "
51+ __END__
52+ "
53+ 5 + 6
54+ RUBY
4355 result = Prism . parse_stream ( io )
4456
4557 assert result . success?
4658 assert_equal 4 , result . value . statements . body . length
4759 end
4860
4961 def test_false___END___in_regexp
50- io = StringIO . new ( "1 + 2\n 3 + 4\n /\n __END__\n /\n 5 + 6" )
62+ io = StringIO . new ( <<~RUBY )
63+ 1 + 2
64+ 3 + 4
65+ /
66+ __END__
67+ /
68+ 5 + 6
69+ RUBY
5170 result = Prism . parse_stream ( io )
5271
5372 assert result . success?
5473 assert_equal 4 , result . value . statements . body . length
5574 end
5675
5776 def test_false___END___in_list
58- io = StringIO . new ( "1 + 2\n 3 + 4\n %w[\n __END__\n ]\n 5 + 6" )
77+ io = StringIO . new ( <<~RUBY )
78+ 1 + 2
79+ 3 + 4
80+ %w[
81+ __END__
82+ ]
83+ 5 + 6
84+ RUBY
5985 result = Prism . parse_stream ( io )
6086
6187 assert result . success?
6288 assert_equal 4 , result . value . statements . body . length
6389 end
6490
6591 def test_false___END___in_heredoc
66- io = StringIO . new ( "1 + 2\n 3 + 4\n <<-EOF\n __END__\n EOF\n 5 + 6" )
92+ io = StringIO . new ( <<~RUBY )
93+ 1 + 2
94+ 3 + 4
95+ <<-EOF
96+ __END__
97+ EOF
98+ 5 + 6
99+ RUBY
67100 result = Prism . parse_stream ( io )
68101
69102 assert result . success?
70103 assert_equal 4 , result . value . statements . body . length
71104 end
72105
73106 def test_nul_bytes
74- io = StringIO . new ( "1 # \0 \0 \0 \n 2 # \0 \0 \0 \n 3" )
107+ io = StringIO . new ( <<~RUBY )
108+ 1 # \0 \0 \0 \t
109+ 2 # \0 \0 \0
110+ 3
111+ RUBY
75112 result = Prism . parse_stream ( io )
76113
77114 assert result . success?
0 commit comments