@@ -46,9 +46,9 @@ struct DiagnosticTest : ExpressibleByStringLiteral, Hashable, CustomStringConver
46
46
47
47
var mappedToExpression : Self {
48
48
DiagnosticTest (
49
- message. _replacing ( " Predicate " , with: " Expression " ) . _replacing ( " predicate " , with: " expression " ) ,
49
+ message. replacing ( " Predicate " , with: " Expression " ) . replacing ( " predicate " , with: " expression " ) ,
50
50
fixIts: fixIts. map {
51
- FixItTest ( $0. message, result: $0. result. _replacing ( " #Predicate " , with: " #Expression " ) )
51
+ FixItTest ( $0. message, result: $0. result. replacing ( " #Predicate " , with: " #Expression " ) )
52
52
}
53
53
)
54
54
}
@@ -125,7 +125,9 @@ func AssertMacroExpansion(macros: [String : Macro.Type], testModuleName: String
125
125
let origSourceFile = Parser . parse ( source: source)
126
126
let expandedSourceFile : Syntax
127
127
do {
128
- expandedSourceFile = try OperatorTable . standardOperators. foldAll ( origSourceFile) . expand ( macros: macros, in: context)
128
+ expandedSourceFile = try OperatorTable . standardOperators. foldAll ( origSourceFile) . expand ( macros: macros) { syntax in
129
+ BasicMacroExpansionContext ( sharingWith: context, lexicalContext: [ syntax] )
130
+ }
129
131
} catch {
130
132
XCTFail ( " Operator folding on input source failed with error \( error) " )
131
133
return
@@ -157,22 +159,10 @@ func AssertPredicateExpansion(_ source: String, _ result: String = "", diagnosti
157
159
)
158
160
AssertMacroExpansion (
159
161
macros: [ " Expression " : FoundationMacros . ExpressionMacro. self] ,
160
- source. _replacing ( " #Predicate " , with: " #Expression " ) ,
161
- result. _replacing ( " .Predicate " , with: " .Expression " ) ,
162
+ source. replacing ( " #Predicate " , with: " #Expression " ) ,
163
+ result. replacing ( " .Predicate " , with: " .Expression " ) ,
162
164
diagnostics: Set ( diagnostics. map ( \. mappedToExpression) ) ,
163
165
file: file,
164
166
line: line
165
167
)
166
168
}
167
-
168
- extension String {
169
- func _replacing( _ text: String , with other: String ) -> Self {
170
- if #available( macOS 13 . 0 , * ) {
171
- // Use the stdlib API if available
172
- self . replacing ( text, with: other)
173
- } else {
174
- // Use the Foundation API on older OSes
175
- self . replacingOccurrences ( of: text, with: other, options: [ . literal] )
176
- }
177
- }
178
- }
0 commit comments