@@ -74,5 +74,53 @@ def test_does_not_choke_on_invalid_characters_in_source_string
74
74
\xC5
75
75
RUBY
76
76
end
77
+
78
+ def test_lambda_vars_with_parameters_location
79
+ tree = SyntaxTree . parse ( <<~RUBY )
80
+ # comment
81
+ # comment
82
+ ->(_i; a) { a }
83
+ RUBY
84
+
85
+ local_location =
86
+ tree . statements . body . last . params . contents . locals . first . location
87
+
88
+ assert_equal ( 3 , local_location . start_line )
89
+ assert_equal ( 3 , local_location . end_line )
90
+ assert_equal ( 7 , local_location . start_column )
91
+ assert_equal ( 8 , local_location . end_column )
92
+ end
93
+
94
+ def test_lambda_vars_location
95
+ tree = SyntaxTree . parse ( <<~RUBY )
96
+ # comment
97
+ # comment
98
+ ->(; a) { a }
99
+ RUBY
100
+
101
+ local_location =
102
+ tree . statements . body . last . params . contents . locals . first . location
103
+
104
+ assert_equal ( 3 , local_location . start_line )
105
+ assert_equal ( 3 , local_location . end_line )
106
+ assert_equal ( 5 , local_location . start_column )
107
+ assert_equal ( 6 , local_location . end_column )
108
+ end
109
+
110
+ def test_multiple_lambda_vars_location
111
+ tree = SyntaxTree . parse ( <<~RUBY )
112
+ # comment
113
+ # comment
114
+ ->(; a, b, c) { a }
115
+ RUBY
116
+
117
+ local_location =
118
+ tree . statements . body . last . params . contents . locals . last . location
119
+
120
+ assert_equal ( 3 , local_location . start_line )
121
+ assert_equal ( 3 , local_location . end_line )
122
+ assert_equal ( 11 , local_location . start_column )
123
+ assert_equal ( 12 , local_location . end_column )
124
+ end
77
125
end
78
126
end
0 commit comments