@@ -537,6 +537,7 @@ func assertParse(
537537 applyFixIts: [ String ] ? = nil ,
538538 fixedSource expectedFixedSource: String ? = nil ,
539539 options: AssertParseOptions = [ ] ,
540+ experimentalFeatures: Parser . ExperimentalFeatures = [ ] ,
540541 file: StaticString = #file,
541542 line: UInt = #line
542543) {
@@ -549,6 +550,7 @@ func assertParse(
549550 applyFixIts: applyFixIts,
550551 fixedSource: expectedFixedSource,
551552 options: options,
553+ experimentalFeatures: experimentalFeatures,
552554 file: file,
553555 line: line
554556 )
@@ -559,14 +561,15 @@ func assertParse(
559561fileprivate func assertRoundTrip< S: SyntaxProtocol > (
560562 source: [ UInt8 ] ,
561563 _ parse: ( inout Parser ) -> S ,
564+ experimentalFeatures: Parser . ExperimentalFeatures ,
562565 file: StaticString ,
563566 line: UInt
564567) {
565568 source. withUnsafeBufferPointer { buf in
566569 let mutatedSource = String ( decoding: buf, as: UTF8 . self)
567570 // Check that we don't hit any assertions in the parser while parsing
568571 // the mutated source and that it round-trips
569- var mutatedParser = Parser ( buf)
572+ var mutatedParser = Parser ( buf, experimentalFeatures : experimentalFeatures )
570573 let mutatedTree = parse ( & mutatedParser)
571574 // Run the diagnostic generator to make sure it doesn’t crash
572575 _ = ParseDiagnosticsGenerator . diagnostics ( for: mutatedTree)
@@ -615,6 +618,7 @@ func assertParse<S: SyntaxProtocol>(
615618 applyFixIts: [ String ] ? = nil ,
616619 fixedSource expectedFixedSource: String ? = nil ,
617620 options: AssertParseOptions = [ ] ,
621+ experimentalFeatures: Parser . ExperimentalFeatures = [ ] ,
618622 file: StaticString = #file,
619623 line: UInt = #line
620624) {
@@ -624,7 +628,7 @@ func assertParse<S: SyntaxProtocol>(
624628
625629 let enableLongTests = ProcessInfo . processInfo. environment [ " SKIP_LONG_TESTS " ] != " 1 "
626630
627- var parser = Parser ( source)
631+ var parser = Parser ( source, experimentalFeatures : experimentalFeatures )
628632 #if SWIFTPARSER_ENABLE_ALTERNATE_TOKEN_INTROSPECTION
629633 if enableLongTests {
630634 parser. enableAlternativeTokenChoices ( )
@@ -704,14 +708,14 @@ func assertParse<S: SyntaxProtocol>(
704708 }
705709
706710 if expectedDiagnostics. isEmpty {
707- assertBasicFormat ( source: source, parse: parse, file: file, line: line)
711+ assertBasicFormat ( source: source, parse: parse, experimentalFeatures : experimentalFeatures , file: file, line: line)
708712 }
709713
710714 if enableLongTests {
711715 DispatchQueue . concurrentPerform ( iterations: Array ( tree. tokens ( viewMode: . all) ) . count) { tokenIndex in
712716 let flippedTokenTree = TokenPresenceFlipper ( flipTokenAtIndex: tokenIndex) . rewrite ( Syntax ( tree) )
713717 _ = ParseDiagnosticsGenerator . diagnostics ( for: flippedTokenTree)
714- assertRoundTrip ( source: flippedTokenTree. syntaxTextBytes, parse, file: file, line: line)
718+ assertRoundTrip ( source: flippedTokenTree. syntaxTextBytes, parse, experimentalFeatures : experimentalFeatures , file: file, line: line)
715719 }
716720
717721 #if SWIFTPARSER_ENABLE_ALTERNATE_TOKEN_INTROSPECTION
@@ -721,7 +725,7 @@ func assertParse<S: SyntaxProtocol>(
721725 DispatchQueue . concurrentPerform ( iterations: mutations. count) { index in
722726 let mutation = mutations [ index]
723727 let alternateSource = MutatedTreePrinter . print ( tree: Syntax ( tree) , mutations: [ mutation. offset: mutation. replacement] )
724- assertRoundTrip ( source: alternateSource, parse, file: file, line: line)
728+ assertRoundTrip ( source: alternateSource, parse, experimentalFeatures : experimentalFeatures , file: file, line: line)
725729 }
726730 #endif
727731 }
@@ -748,15 +752,16 @@ class TriviaRemover: SyntaxRewriter {
748752func assertBasicFormat< S: SyntaxProtocol > (
749753 source: String ,
750754 parse: ( inout Parser ) -> S ,
755+ experimentalFeatures: Parser . ExperimentalFeatures ,
751756 file: StaticString = #file,
752757 line: UInt = #line
753758) {
754- var parser = Parser ( source)
759+ var parser = Parser ( source, experimentalFeatures : experimentalFeatures )
755760 let sourceTree = parse ( & parser)
756761 let withoutTrivia = TriviaRemover ( viewMode: . sourceAccurate) . rewrite ( sourceTree)
757762 let formatted = withoutTrivia. formatted ( )
758763
759- var formattedParser = Parser ( formatted. description)
764+ var formattedParser = Parser ( formatted. description, experimentalFeatures : experimentalFeatures )
760765 let formattedReparsed = Syntax ( parse ( & formattedParser) )
761766
762767 do {
0 commit comments