@@ -75,6 +75,12 @@ class SelectionRangeSuite extends BaseSelectionRangeSuite:
7575 | b <- Some(2)
7676 | } yield a + b
7777 |}""" .stripMargin,
78+ """ |object Main extends App {
79+ | val total = for {
80+ | >>region>>a <- Some(1)<<region<<
81+ | b <- Some(2)
82+ | } yield a + b
83+ |}""" .stripMargin,
7884 """ |object Main extends App {
7985 | val total = >>region>>for {
8086 | a <- Some(1)
@@ -102,7 +108,7 @@ class SelectionRangeSuite extends BaseSelectionRangeSuite:
102108 )
103109 )
104110
105- @ Test def `function params` =
111+ @ Test def `function- params-1 ` =
106112 check(
107113 """ |object Main extends App {
108114 | def func(a@@: Int, b: Int) =
@@ -124,6 +130,32 @@ class SelectionRangeSuite extends BaseSelectionRangeSuite:
124130 )
125131 )
126132
133+ @ Test def `function-params-2` =
134+ check(
135+ """ |object Main extends App {
136+ | val func = (a@@: Int, b: Int) =>
137+ | a + b
138+ |}""" .stripMargin,
139+ List [String ](
140+ """ |object Main extends App {
141+ | val func = (>>region>>a: Int<<region<<, b: Int) =>
142+ | a + b
143+ |}""" .stripMargin,
144+ """ |object Main extends App {
145+ | val func = (>>region>>a: Int, b: Int<<region<<) =>
146+ | a + b
147+ |}""" .stripMargin,
148+ """ |object Main extends App {
149+ | val func = >>region>>(a: Int, b: Int) =>
150+ | a + b<<region<<
151+ |}""" .stripMargin,
152+ """ |object Main extends App {
153+ | >>region>>val func = (a: Int, b: Int) =>
154+ | a + b<<region<<
155+ |}""" .stripMargin
156+ )
157+ )
158+
127159 @ Test def `def - type params` =
128160 check(
129161 " object Main extends App { def foo[Type@@ <: T1, B](hi: Int, b: Int, c:Int) = ??? }" ,
@@ -133,3 +165,90 @@ class SelectionRangeSuite extends BaseSelectionRangeSuite:
133165 " object Main extends App { >>region>>def foo[Type <: T1, B](hi: Int, b: Int, c:Int) = ???<<region<< }"
134166 )
135167 )
168+
169+
170+ @ Test def `arithmetic` =
171+ check(
172+ """ |object Main extends App {
173+ | def x = 12 * (34 + 5@@6)
174+ |}""" .stripMargin,
175+ List (
176+ """ |object Main extends App {
177+ | def x = 12 * (34 + >>region>>56<<region<<)
178+ |}""" .stripMargin,
179+ """ |object Main extends App {
180+ | def x = 12 * (>>region>>34 + 56<<region<<)
181+ |}""" .stripMargin,
182+ """ |object Main extends App {
183+ | def x = 12 * >>region>>(34 + 56)<<region<<
184+ |}""" .stripMargin,
185+ """ |object Main extends App {
186+ | def x = >>region>>12 * (34 + 56)<<region<<
187+ |}""" .stripMargin
188+ )
189+ )
190+
191+ @ Test def `function` =
192+ check(
193+ " val hello = (aaa: Int, bb@@b: Int, ccc: Int) => ???" ,
194+ List (
195+ " val hello = (aaa: Int, >>region>>bbb: Int<<region<<, ccc: Int) => ???" ,
196+ " val hello = (>>region>>aaa: Int, bbb: Int, ccc: Int<<region<<) => ???" ,
197+ " val hello = >>region>>(aaa: Int, bbb: Int, ccc: Int) => ???<<region<<" ,
198+ " >>region>>val hello = (aaa: Int, bbb: Int, ccc: Int) => ???<<region<<" ,
199+ )
200+ )
201+
202+ @ Test def `defdef` =
203+ check(
204+ " def hello(aaa: Int, bb@@b: Int, ccc: Int) = ???" ,
205+ List (
206+ " def hello(aaa: Int, >>region>>bbb: Int<<region<<, ccc: Int) = ???" ,
207+ " def hello(>>region>>aaa: Int, bbb: Int, ccc: Int<<region<<) = ???" ,
208+ " >>region>>def hello(aaa: Int, bbb: Int, ccc: Int) = ???<<region<<" ,
209+ )
210+ )
211+
212+ @ Test def `apply` =
213+ check(
214+ " def hello = List(111, 2@@22, 333)" ,
215+ List (
216+ " def hello = List(111, >>region>>222<<region<<, 333)" ,
217+ " def hello = List(>>region>>111, 222, 333<<region<<)" ,
218+ " def hello = >>region>>List(111, 222, 333)<<region<<" ,
219+ " >>region>>def hello = List(111, 222, 333)<<region<<" ,
220+ )
221+ )
222+
223+ @ Test def `type-apply` =
224+ check(
225+ " def hello = Map[String, I@@nt]()" ,
226+ List (
227+ " def hello = Map[String, >>region>>Int<<region<<]()" ,
228+ " def hello = Map[>>region>>String, Int<<region<<]()" ,
229+ " def hello = >>region>>Map[String, Int]<<region<<()" ,
230+ " def hello = >>region>>Map[String, Int]()<<region<<" ,
231+ " >>region>>def hello = Map[String, Int]()<<region<<" ,
232+ )
233+ )
234+
235+ @ Test def `unapply` =
236+ check(
237+ " val List(aaa, b@@bb, ccc) = List(111, 222, 333)" ,
238+ List (
239+ " val List(aaa, >>region>>bbb<<region<<, ccc) = List(111, 222, 333)" ,
240+ " val List(>>region>>aaa, bbb, ccc<<region<<) = List(111, 222, 333)" ,
241+ " val >>region>>List(aaa, bbb, ccc)<<region<< = List(111, 222, 333)" ,
242+ " >>region>>val List(aaa, bbb, ccc) = List(111, 222, 333)<<region<<" ,
243+ )
244+ )
245+
246+ @ Test def `single` =
247+ check(
248+ " def hello = List(2@@22)" ,
249+ List (
250+ " def hello = List(>>region>>222<<region<<)" ,
251+ " def hello = >>region>>List(222)<<region<<" ,
252+ " >>region>>def hello = List(222)<<region<<" ,
253+ )
254+ )
0 commit comments