@@ -18,6 +18,9 @@ class PrettyPrintTestCase: DiagnosingTestCase {
1818 /// changes that insert or remove non-whitespace characters (like trailing commas).
1919 /// - findings: A list of `FindingSpec` values that describe the findings that are expected to
2020 /// be emitted. These are currently only checked if `whitespaceOnly` is true.
21+ /// - experimentalFeatures: The set of experimental features that should be enabled in the
22+ /// parser. The names of these features correspond to the names of the
23+ /// `Parser.ExperimentalFeatures` enum in the `SwiftParser` module of swift-syntax.
2124 /// - file: The file in which failure occurred. Defaults to the file name of the test case in
2225 /// which this function was called.
2326 /// - line: The line number on which failure occurred. Defaults to the line number on which this
@@ -29,6 +32,7 @@ class PrettyPrintTestCase: DiagnosingTestCase {
2932 configuration: Configuration = Configuration . forTesting,
3033 whitespaceOnly: Bool = false ,
3134 findings: [ FindingSpec ] = [ ] ,
35+ experimentalFeatures: Set < String > = [ ] ,
3236 file: StaticString = #file,
3337 line: UInt = #line
3438 ) {
@@ -44,6 +48,7 @@ class PrettyPrintTestCase: DiagnosingTestCase {
4448 configuration: configuration,
4549 selection: markedInput. selection,
4650 whitespaceOnly: whitespaceOnly,
51+ experimentalFeatures: experimentalFeatures,
4752 findingConsumer: { emittedFindings. append ( $0) }
4853 )
4954 assertStringsEqualWithDiff (
@@ -76,6 +81,7 @@ class PrettyPrintTestCase: DiagnosingTestCase {
7681 configuration: configuration,
7782 selection: markedInput. selection,
7883 whitespaceOnly: whitespaceOnly,
84+ experimentalFeatures: experimentalFeatures,
7985 findingConsumer: { _ in } // Ignore findings during the idempotence check.
8086 )
8187 assertStringsEqualWithDiff (
@@ -95,18 +101,24 @@ class PrettyPrintTestCase: DiagnosingTestCase {
95101 /// - configuration: The formatter configuration.
96102 /// - whitespaceOnly: If true, the pretty printer should only apply whitespace changes and omit
97103 /// changes that insert or remove non-whitespace characters (like trailing commas).
104+ /// - experimentalFeatures: The set of experimental features that should be enabled in the
105+ /// parser. The names of these features correspond to the names of the
106+ /// `Parser.ExperimentalFeatures` enum in the `SwiftParser` module of swift-syntax.
98107 /// - findingConsumer: A function called for each finding that is emitted by the pretty printer.
99108 /// - Returns: The pretty-printed text, or nil if an error occurred and a test failure was logged.
100109 private func prettyPrintedSource(
101110 _ source: String ,
102111 configuration: Configuration ,
103112 selection: Selection ,
104113 whitespaceOnly: Bool ,
114+ experimentalFeatures: Set < String > = [ ] ,
105115 findingConsumer: @escaping ( Finding ) -> Void
106116 ) -> ( String , Context ) {
107117 // Ignore folding errors for unrecognized operators so that we fallback to a reasonable default.
108118 let sourceFileSyntax =
109- OperatorTable . standardOperators. foldAll ( Parser . parse ( source: source) ) { _ in }
119+ OperatorTable . standardOperators. foldAll (
120+ parseForTesting ( source: source, experimentalFeatures: experimentalFeatures)
121+ ) { _ in }
110122 . as ( SourceFileSyntax . self) !
111123 let context = makeContext (
112124 sourceFileSyntax: sourceFileSyntax,
0 commit comments