@@ -190,6 +190,93 @@ final class PredicateMacroBasicTests: XCTestCase {
190
190
})
191
191
"""
192
192
)
193
+ AssertPredicateExpansion (
194
+ """
195
+ #Predicate<Object> {
196
+ $0.foo()
197
+ }
198
+ """ ,
199
+ """
200
+ \( foundationModuleName) .Predicate<Object>({
201
+ PredicateExpressions.build_KeyPath(
202
+ root: PredicateExpressions.build_Arg($0),
203
+ keyPath: \. foo( )
204
+ )
205
+ } )
206
+ """
207
+ )
208
+ AssertPredicateExpansion (
209
+ """
210
+ #Predicate<Object> { input in
211
+ input.foo()
212
+ }
213
+ """ ,
214
+ """
215
+ \( foundationModuleName) .Predicate<Object>({ input in
216
+ PredicateExpressions.build_KeyPath(
217
+ root: PredicateExpressions.build_Arg(input),
218
+ keyPath: \. foo( )
219
+ )
220
+ } )
221
+ """
222
+ )
223
+ AssertPredicateExpansion (
224
+ """
225
+ #Predicate<Object> {
226
+ $0.foo().bar
227
+ }
228
+ """ ,
229
+ """
230
+ \( foundationModuleName) .Predicate<Object>({
231
+ PredicateExpressions.build_KeyPath(
232
+ root: PredicateExpressions.build_KeyPath(
233
+ root: PredicateExpressions.build_Arg($0),
234
+ keyPath: \. foo( )
235
+ ) ,
236
+ keyPath: \. bar
237
+ )
238
+ } )
239
+ """
240
+ )
241
+ AssertPredicateExpansion (
242
+ """
243
+ #Predicate<Object> {
244
+ \Object. init( val: )
245
+ }
246
+ """ ,
247
+ """
248
+ \( foundationModuleName) . Predicate< Object> ( {
249
+ PredicateExpressions. build_KeyPath(
250
+ root: PredicateExpressions . build_Arg ( Object . self) ,
251
+ keyPath: \. init ( val: )
252
+ )
253
+ } )
254
+ """
255
+ )
256
+ AssertPredicateExpansion(
257
+ """
258
+ #Predicate< Object> { input in
259
+ input. unsupportedMethod ( )
260
+ }
261
+ """ ,
262
+ diagnostics: [ " 2:10: The method unsupportedMethod() is not supported in this predicate " ]
263
+ )
264
+ AssertPredicateExpansion(
265
+ """
266
+ #Predicate< Object> { input in
267
+ input. methodWithArgs ( 1 , " test " )
268
+ }
269
+ """ ,
270
+ diagnostics: [ " 2:10: The method methodWithArgs(_:_:) is not supported in this predicate " ]
271
+ )
272
+ AssertPredicateExpansion(
273
+ """
274
+ #Predicate< Object> {
275
+ \Object . unsupportedInit ( param: )
276
+ }
277
+ """ ,
278
+ diagnostics: [ " 2:10: The initializer unsupportedInit(param:) is not supported in this predicate " ]
279
+ )
193
280
}
194
281
195
282
func testComments() {
0 commit comments