@@ -20,20 +20,9 @@ struct FunctionTests {
2020 """
2121
2222 // Normalize whitespace, remove comments and modifiers, and normalize colon spacing
23- let normalizedGenerated = function. syntax. description
24- . replacingOccurrences ( of: " //.*$ " , with: " " , options: . regularExpression) // Remove comments
25- . replacingOccurrences ( of: " public \\ s+ " , with: " " , options: . regularExpression) // Remove public modifier
26- . replacingOccurrences ( of: " \\ s*: \\ s* " , with: " : " , options: . regularExpression) // Normalize colon spacing
27- . replacingOccurrences ( of: " \\ s+ " , with: " " , options: . regularExpression) // Normalize whitespace
28- . trimmingCharacters ( in: . whitespacesAndNewlines)
29-
30- let normalizedExpected =
31- expected
32- . replacingOccurrences ( of: " //.*$ " , with: " " , options: . regularExpression) // Remove comments
33- . replacingOccurrences ( of: " public \\ s+ " , with: " " , options: . regularExpression) // Remove public modifier
34- . replacingOccurrences ( of: " \\ s*: \\ s* " , with: " : " , options: . regularExpression) // Normalize colon spacing
35- . replacingOccurrences ( of: " \\ s+ " , with: " " , options: . regularExpression) // Normalize whitespace
36- . trimmingCharacters ( in: . whitespacesAndNewlines)
23+ let normalizedGenerated = function. syntax. description. normalize ( )
24+
25+ let normalizedExpected = expected. normalize ( )
3726
3827 #expect( normalizedGenerated == normalizedExpected)
3928 }
@@ -59,20 +48,9 @@ struct FunctionTests {
5948 """
6049
6150 // Normalize whitespace, remove comments and modifiers, and normalize colon spacing
62- let normalizedGenerated = function. syntax. description
63- . replacingOccurrences ( of: " //.*$ " , with: " " , options: . regularExpression) // Remove comments
64- . replacingOccurrences ( of: " public \\ s+ " , with: " " , options: . regularExpression) // Remove public modifier
65- . replacingOccurrences ( of: " \\ s*: \\ s* " , with: " : " , options: . regularExpression) // Normalize colon spacing
66- . replacingOccurrences ( of: " \\ s+ " , with: " " , options: . regularExpression) // Normalize whitespace
67- . trimmingCharacters ( in: . whitespacesAndNewlines)
68-
69- let normalizedExpected =
70- expected
71- . replacingOccurrences ( of: " //.*$ " , with: " " , options: . regularExpression) // Remove comments
72- . replacingOccurrences ( of: " public \\ s+ " , with: " " , options: . regularExpression) // Remove public modifier
73- . replacingOccurrences ( of: " \\ s*: \\ s* " , with: " : " , options: . regularExpression) // Normalize colon spacing
74- . replacingOccurrences ( of: " \\ s+ " , with: " " , options: . regularExpression) // Normalize whitespace
75- . trimmingCharacters ( in: . whitespacesAndNewlines)
51+ let normalizedGenerated = function. syntax. description. normalize ( )
52+
53+ let normalizedExpected = expected. normalize ( )
7654
7755 #expect( normalizedGenerated == normalizedExpected)
7856 }
@@ -94,20 +72,9 @@ struct FunctionTests {
9472 """
9573
9674 // Normalize whitespace, remove comments and modifiers, and normalize colon spacing
97- let normalizedGenerated = function. syntax. description
98- . replacingOccurrences ( of: " //.*$ " , with: " " , options: . regularExpression) // Remove comments
99- . replacingOccurrences ( of: " public \\ s+ " , with: " " , options: . regularExpression) // Remove public modifier
100- . replacingOccurrences ( of: " \\ s*: \\ s* " , with: " : " , options: . regularExpression) // Normalize colon spacing
101- . replacingOccurrences ( of: " \\ s+ " , with: " " , options: . regularExpression) // Normalize whitespace
102- . trimmingCharacters ( in: . whitespacesAndNewlines)
103-
104- let normalizedExpected =
105- expected
106- . replacingOccurrences ( of: " //.*$ " , with: " " , options: . regularExpression) // Remove comments
107- . replacingOccurrences ( of: " public \\ s+ " , with: " " , options: . regularExpression) // Remove public modifier
108- . replacingOccurrences ( of: " \\ s*: \\ s* " , with: " : " , options: . regularExpression) // Normalize colon spacing
109- . replacingOccurrences ( of: " \\ s+ " , with: " " , options: . regularExpression) // Normalize whitespace
110- . trimmingCharacters ( in: . whitespacesAndNewlines)
75+ let normalizedGenerated = function. syntax. description. normalize ( )
76+
77+ let normalizedExpected = expected. normalize ( )
11178
11279 #expect( normalizedGenerated == normalizedExpected)
11380 }
0 commit comments