@@ -621,6 +621,11 @@ final class DocumentTestDiscoveryTests: XCTestCase {
621
621
func oneIsTwo() {
622
622
#expect(1 == 2)
623
623
}2️⃣
624
+
625
+ 3️⃣@Test( " One is two " )
626
+ func `one is two`() {
627
+ #expect(1 == 2)
628
+ }4️⃣
624
629
""" ,
625
630
uri: uri
626
631
)
@@ -634,7 +639,13 @@ final class DocumentTestDiscoveryTests: XCTestCase {
634
639
label: " One is two " ,
635
640
style: TestStyle . swiftTesting,
636
641
location: Location ( uri: uri, range: positions [ " 1️⃣ " ] ..< positions [ " 2️⃣ " ] )
637
- )
642
+ ) ,
643
+ TestItem (
644
+ id: " `one is two`() " ,
645
+ label: " One is two " ,
646
+ style: TestStyle . swiftTesting,
647
+ location: Location ( uri: uri, range: positions [ " 3️⃣ " ] ..< positions [ " 4️⃣ " ] )
648
+ ) ,
638
649
]
639
650
)
640
651
}
@@ -692,6 +703,126 @@ final class DocumentTestDiscoveryTests: XCTestCase {
692
703
)
693
704
}
694
705
706
+ func testSwiftTestingTestWithRawIdentifiers( ) async throws {
707
+ let testClient = try await TestSourceKitLSPClient ( )
708
+ let uri = DocumentURI ( for: . swift)
709
+
710
+ let positions = testClient. openDocument (
711
+ """
712
+ import Testing
713
+
714
+ 1️⃣struct MyTests {
715
+ 2️⃣@Test
716
+ func `one two`(`a b`: Int, c: Int, `3`: Int, `$`: Int, `+1`: Int) {
717
+ #expect(1 == 2)
718
+ }3️⃣
719
+ }4️⃣
720
+
721
+ extension MyTests {
722
+ 5️⃣@Test
723
+ func `3four`() {
724
+ #expect(2 == 3)
725
+ }6️⃣
726
+ // Don't include operators
727
+ @Test
728
+ func +() {
729
+ #expect(2 == 3)
730
+ }
731
+ // This is invalid, but we'll pick it up as identifier.
732
+ 7️⃣@Test
733
+ func `+`() {
734
+ #expect(2 == 3)
735
+ }8️⃣
736
+ // Also invalid.
737
+ 9️⃣@Test
738
+ func ``() {
739
+ #expect(2 == 3)
740
+ }🔟
741
+ }
742
+ """ ,
743
+ uri: uri
744
+ )
745
+
746
+ let tests = try await testClient. send ( DocumentTestsRequest ( textDocument: TextDocumentIdentifier ( uri) ) )
747
+ XCTAssertEqual (
748
+ tests,
749
+ [
750
+ TestItem (
751
+ id: " MyTests " ,
752
+ label: " MyTests " ,
753
+ style: TestStyle . swiftTesting,
754
+ location: Location ( uri: uri, range: positions [ " 1️⃣ " ] ..< positions [ " 4️⃣ " ] ) ,
755
+ children: [
756
+ TestItem (
757
+ id: " MyTests/`one two`(`a b`:c:`3`:`$`:`+1`:) " ,
758
+ label: " one two " ,
759
+ style: TestStyle . swiftTesting,
760
+ location: Location ( uri: uri, range: positions [ " 2️⃣ " ] ..< positions [ " 3️⃣ " ] )
761
+ ) ,
762
+ TestItem (
763
+ id: " MyTests/`3four`() " ,
764
+ label: " 3four " ,
765
+ style: TestStyle . swiftTesting,
766
+ location: Location ( uri: uri, range: positions [ " 5️⃣ " ] ..< positions [ " 6️⃣ " ] )
767
+ ) ,
768
+ TestItem (
769
+ id: " MyTests/`+`() " ,
770
+ label: " + " ,
771
+ style: TestStyle . swiftTesting,
772
+ location: Location ( uri: uri, range: positions [ " 7️⃣ " ] ..< positions [ " 8️⃣ " ] )
773
+ ) ,
774
+ TestItem (
775
+ id: " MyTests/``() " ,
776
+ label: " `` " ,
777
+ style: TestStyle . swiftTesting,
778
+ location: Location ( uri: uri, range: positions [ " 9️⃣ " ] ..< positions [ " 🔟 " ] )
779
+ ) ,
780
+ ]
781
+ )
782
+ ]
783
+ )
784
+ }
785
+
786
+ func testSwiftTestingTestWithSlashRawIdentifiers( ) async throws {
787
+ let testClient = try await TestSourceKitLSPClient ( )
788
+ let uri = DocumentURI ( for: . swift)
789
+
790
+ let positions = testClient. openDocument (
791
+ """
792
+ import Testing
793
+
794
+ 1️⃣struct MyTests {
795
+ 2️⃣@Test
796
+ func `x/y`() {
797
+ #expect(1 == 2)
798
+ }3️⃣
799
+ }4️⃣
800
+ """ ,
801
+ uri: uri
802
+ )
803
+
804
+ let tests = try await testClient. send ( DocumentTestsRequest ( textDocument: TextDocumentIdentifier ( uri) ) )
805
+ XCTAssertEqual (
806
+ tests,
807
+ [
808
+ TestItem (
809
+ id: " MyTests " ,
810
+ label: " MyTests " ,
811
+ style: TestStyle . swiftTesting,
812
+ location: Location ( uri: uri, range: positions [ " 1️⃣ " ] ..< positions [ " 4️⃣ " ] ) ,
813
+ children: [
814
+ TestItem (
815
+ id: " MyTests/`x/y`() " ,
816
+ label: " x/y " ,
817
+ style: TestStyle . swiftTesting,
818
+ location: Location ( uri: uri, range: positions [ " 2️⃣ " ] ..< positions [ " 3️⃣ " ] )
819
+ )
820
+ ]
821
+ )
822
+ ]
823
+ )
824
+ }
825
+
695
826
func testSwiftTestingTestDisabledTest( ) async throws {
696
827
let testClient = try await TestSourceKitLSPClient ( )
697
828
let uri = DocumentURI ( for: . swift)
0 commit comments