@@ -66,6 +66,12 @@ struct ConditionMacroTests {
66
66
##"Testing.__checkValue(a.b(&c, d), sourceCode: .__fromSyntaxNode("a.b(&c, d)"), comments: [], isRequired: false, sourceLocation: Testing.SourceLocation()).__expected()"## ,
67
67
##"#expect(a.b(try c()))"## :
68
68
##"Testing.__checkValue(a.b(try c()), sourceCode: .__fromSyntaxNode("a.b(try c())"), comments: [], isRequired: false, sourceLocation: Testing.SourceLocation()).__expected()"## ,
69
+ ##"#expect(a?.b(c))"## :
70
+ ##"Testing.__checkFunctionCall(a.self, calling: { $0?.b($1) }, c, sourceCode: .__functionCall("a", "b", (nil, "c")), comments: [], isRequired: false, sourceLocation: Testing.SourceLocation()).__expected()"## ,
71
+ ##"#expect(a???.b(c))"## :
72
+ ##"Testing.__checkFunctionCall(a.self, calling: { $0???.b($1) }, c, sourceCode: .__functionCall("a", "b", (nil, "c")), comments: [], isRequired: false, sourceLocation: Testing.SourceLocation()).__expected()"## ,
73
+ ##"#expect(a?.b.c(d))"## :
74
+ ##"Testing.__checkFunctionCall(a?.b.self, calling: { $0?.c($1) }, d, sourceCode: .__functionCall("a?.b", "c", (nil, "d")), comments: [], isRequired: false, sourceLocation: Testing.SourceLocation()).__expected()"## ,
69
75
##"#expect({}())"## :
70
76
##"Testing.__checkValue({}(), sourceCode: .__fromSyntaxNode("{}()"), comments: [], isRequired: false, sourceLocation: Testing.SourceLocation()).__expected()"## ,
71
77
##"#expect(a.b(c: d))"## :
@@ -74,6 +80,12 @@ struct ConditionMacroTests {
74
80
##"Testing.__checkValue(a.b { c }, sourceCode: .__fromSyntaxNode("a.b { c }"), comments: [], isRequired: false, sourceLocation: Testing.SourceLocation()).__expected()"## ,
75
81
##"#expect(a, sourceLocation: someValue)"## :
76
82
##"Testing.__checkValue(a, sourceCode: .__fromSyntaxNode("a"), comments: [], isRequired: false, sourceLocation: someValue).__expected()"## ,
83
+ ##"#expect(a.isB)"## :
84
+ ##"Testing.__checkPropertyAccess(a.self, getting: { $0.isB }, sourceCode: .__fromPropertyAccess("a", "isB"), comments: [], isRequired: false, sourceLocation: Testing.SourceLocation()).__expected()"## ,
85
+ ##"#expect(a???.isB)"## :
86
+ ##"Testing.__checkPropertyAccess(a.self, getting: { $0???.isB }, sourceCode: .__fromPropertyAccess("a", "isB"), comments: [], isRequired: false, sourceLocation: Testing.SourceLocation()).__expected()"## ,
87
+ ##"#expect(a?.b.isB)"## :
88
+ ##"Testing.__checkPropertyAccess(a?.b.self, getting: { $0?.isB }, sourceCode: .__fromPropertyAccess("a?.b", "isB"), comments: [], isRequired: false, sourceLocation: Testing.SourceLocation()).__expected()"## ,
77
89
]
78
90
)
79
91
func expectMacro( input: String , expectedOutput: String ) throws {
@@ -128,6 +140,12 @@ struct ConditionMacroTests {
128
140
##"Testing.__checkValue(a.b(&c, d), sourceCode: .__fromSyntaxNode("a.b(&c, d)"), comments: [], isRequired: true, sourceLocation: Testing.SourceLocation()).__required()"## ,
129
141
##"#require(a.b(try c()))"## :
130
142
##"Testing.__checkValue(a.b(try c()), sourceCode: .__fromSyntaxNode("a.b(try c())"), comments: [], isRequired: true, sourceLocation: Testing.SourceLocation()).__required()"## ,
143
+ ##"#require(a?.b(c))"## :
144
+ ##"Testing.__checkFunctionCall(a.self, calling: { $0?.b($1) }, c, sourceCode: .__functionCall("a", "b", (nil, "c")), comments: [], isRequired: true, sourceLocation: Testing.SourceLocation()).__required()"## ,
145
+ ##"#require(a???.b(c))"## :
146
+ ##"Testing.__checkFunctionCall(a.self, calling: { $0???.b($1) }, c, sourceCode: .__functionCall("a", "b", (nil, "c")), comments: [], isRequired: true, sourceLocation: Testing.SourceLocation()).__required()"## ,
147
+ ##"#require(a?.b.c(d))"## :
148
+ ##"Testing.__checkFunctionCall(a?.b.self, calling: { $0?.c($1) }, d, sourceCode: .__functionCall("a?.b", "c", (nil, "d")), comments: [], isRequired: true, sourceLocation: Testing.SourceLocation()).__required()"## ,
131
149
##"#require({}())"## :
132
150
##"Testing.__checkValue({}(), sourceCode: .__fromSyntaxNode("{}()"), comments: [], isRequired: true, sourceLocation: Testing.SourceLocation()).__required()"## ,
133
151
##"#require(a.b(c: d))"## :
@@ -136,6 +154,12 @@ struct ConditionMacroTests {
136
154
##"Testing.__checkValue(a.b { c }, sourceCode: .__fromSyntaxNode("a.b { c }"), comments: [], isRequired: true, sourceLocation: Testing.SourceLocation()).__required()"## ,
137
155
##"#require(a, sourceLocation: someValue)"## :
138
156
##"Testing.__checkValue(a, sourceCode: .__fromSyntaxNode("a"), comments: [], isRequired: true, sourceLocation: someValue).__required()"## ,
157
+ ##"#require(a.isB)"## :
158
+ ##"Testing.__checkPropertyAccess(a.self, getting: { $0.isB }, sourceCode: .__fromPropertyAccess("a", "isB"), comments: [], isRequired: true, sourceLocation: Testing.SourceLocation()).__required()"## ,
159
+ ##"#require(a???.isB)"## :
160
+ ##"Testing.__checkPropertyAccess(a.self, getting: { $0???.isB }, sourceCode: .__fromPropertyAccess("a", "isB"), comments: [], isRequired: true, sourceLocation: Testing.SourceLocation()).__required()"## ,
161
+ ##"#require(a?.b.isB)"## :
162
+ ##"Testing.__checkPropertyAccess(a?.b.self, getting: { $0?.isB }, sourceCode: .__fromPropertyAccess("a?.b", "isB"), comments: [], isRequired: true, sourceLocation: Testing.SourceLocation()).__required()"## ,
139
163
]
140
164
)
141
165
func requireMacro( input: String , expectedOutput: String ) throws {
@@ -147,7 +171,7 @@ struct ConditionMacroTests {
147
171
@Test ( " Unwrapping #require() macro " ,
148
172
arguments: [
149
173
##"#require(Optional<Int>.none)"## :
150
- ##"Testing.__checkValue (Optional<Int>.none, sourceCode: .__fromSyntaxNode ("Optional<Int>. none"), comments: [], isRequired: true, sourceLocation: Testing.SourceLocation()).__required()"## ,
174
+ ##"Testing.__checkPropertyAccess (Optional<Int>.self, getting: { $0. none } , sourceCode: .__fromPropertyAccess ("Optional<Int>", " none"), comments: [], isRequired: true, sourceLocation: Testing.SourceLocation()).__required()"## ,
151
175
##"#require(nil ?? 123)"## :
152
176
##"Testing.__checkBinaryOperation(nil, { $0 ?? $1() }, 123, sourceCode: .__fromBinaryOperation("nil", "??", "123"), comments: [], isRequired: true, sourceLocation: Testing.SourceLocation()).__required()"## ,
153
177
##"#require(123 ?? nil)"## :
0 commit comments