@@ -18,6 +18,181 @@ import Testing
1818
1919@Suite
2020struct SwiftDocumentationParsingTests {
21+ @Test (
22+ " Indented Swift func documentation (inside extension) " ,
23+ arguments: [
24+ (
25+ JExtractGenerationMode . jni,
26+ [
27+ """
28+ /**
29+ * Simple summary
30+ *
31+ * <p>Downcall to Swift:
32+ * {@snippet lang=swift :
33+ * public static func f()
34+ * }
35+ */
36+ public static void f() {
37+ """
38+ ]
39+ ) ,
40+ (
41+ JExtractGenerationMode . ffm,
42+ [
43+ """
44+ /**
45+ * Simple summary
46+ *
47+ * <p>Downcall to Swift:
48+ * {@snippet lang=swift :
49+ * public static func f()
50+ * }
51+ */
52+ public static void f() {
53+ """
54+ ]
55+ ) ,
56+ ]
57+ )
58+ func indented( mode: JExtractGenerationMode , expectedJavaChunks: [ String ] ) throws {
59+ let text =
60+ """
61+ public class MyClass {
62+ /// Simple summary
63+ public static func f() {}
64+ }
65+ """
66+
67+ try assertOutput (
68+ input: text,
69+ mode,
70+ . java,
71+ expectedChunks: expectedJavaChunks
72+ )
73+ }
74+
75+ @Test (
76+ " Throws documentation " ,
77+ arguments: [
78+ (
79+ JExtractGenerationMode . jni,
80+ [
81+ """
82+ /**
83+ * Summary
84+ *
85+ * <p>Downcall to Swift:
86+ * {@snippet lang=swift :
87+ * public func f()
88+ * }
89+ *
90+ * @throws Exception - An error if something fails.
91+ * - Another error case.
92+ */
93+ public static void f() {
94+ """
95+ ]
96+ ) ,
97+ (
98+ JExtractGenerationMode . ffm,
99+ [
100+ """
101+ /**
102+ * Summary
103+ *
104+ * <p>Downcall to Swift:
105+ * {@snippet lang=swift :
106+ * public func f()
107+ * }
108+ *
109+ * @throws Exception - An error if something fails.
110+ * - Another error case.
111+ */
112+ public static void f() {
113+ """
114+ ]
115+ ) ,
116+ ]
117+ )
118+ func throwsDocumentation( mode: JExtractGenerationMode , expectedJavaChunks: [ String ] ) throws {
119+ let text =
120+ """
121+ /// Summary
122+ /// - Throws:
123+ /// - An error if something fails.
124+ /// - Another error case.
125+ public func f() {}
126+ """
127+
128+ try assertOutput (
129+ input: text,
130+ mode,
131+ . java,
132+ expectedChunks: expectedJavaChunks
133+ )
134+ }
135+
136+ @Test (
137+ " Multi-line parameter description continuation " ,
138+ arguments: [
139+ (
140+ JExtractGenerationMode . jni,
141+ [
142+ """
143+ /**
144+ * Summary
145+ *
146+ * <p>Downcall to Swift:
147+ * {@snippet lang=swift :
148+ * public func f(arg0: String)
149+ * }
150+ *
151+ * @param arg0 First line of description.
152+ * Continuation line.
153+ */
154+ public static void f(java.lang.String arg0) {
155+ """
156+ ]
157+ ) ,
158+ (
159+ JExtractGenerationMode . ffm,
160+ [
161+ """
162+ /**
163+ * Summary
164+ *
165+ * <p>Downcall to Swift:
166+ * {@snippet lang=swift :
167+ * public func f(arg0: String)
168+ * }
169+ *
170+ * @param arg0 First line of description.
171+ * Continuation line.
172+ */
173+ public static void f(java.lang.String arg0) {
174+ """
175+ ]
176+ ) ,
177+ ]
178+ )
179+ func parameterContinuationLine( mode: JExtractGenerationMode , expectedJavaChunks: [ String ] ) throws {
180+ let text =
181+ """
182+ /// Summary
183+ /// - Parameter arg0: First line of description.
184+ /// Continuation line.
185+ public func f(arg0: String) {}
186+ """
187+
188+ try assertOutput (
189+ input: text,
190+ mode,
191+ . java,
192+ expectedChunks: expectedJavaChunks
193+ )
194+ }
195+
21196 @Test (
22197 " Simple Swift func documentation " ,
23198 arguments: [
0 commit comments