File tree Expand file tree Collapse file tree 3 files changed +48
-0
lines changed
Tests/SwiftComplexityCoreTests Expand file tree Collapse file tree 3 files changed +48
-0
lines changed Original file line number Diff line number Diff line change 1+ //
2+ // protocol.swift
3+ // swift-complexity
4+ //
5+ // Created by Fumiya Tanaka on 2025/10/18.
6+ //
7+
8+ protocol Foo {
9+ var bar : String { get }
10+ }
Original file line number Diff line number Diff line change 1+ //
2+ // protocol_extension_decl.swift
3+ // swift-complexity
4+ //
5+ // Created by Fumiya Tanaka on 2025/10/18.
6+ //
7+
8+ extension A {
9+ func bar( ) { }
10+ }
Original file line number Diff line number Diff line change @@ -251,6 +251,34 @@ struct FunctionDetectionTests {
251251 #expect( names. contains ( " method1 " ) )
252252 #expect( names. contains ( " method2 " ) )
253253 }
254+
255+ @Test ( " protocol " )
256+ func protocolDeclTests( ) async throws {
257+ // Given
258+ let code = try loadFixture ( " protocol_decl " )
259+ let sourceFile = Parser . parse ( source: code)
260+ let detector = FunctionDetector ( viewMode: . sourceAccurate)
261+
262+ // When
263+ let functions = detector. detectFunctions ( in: sourceFile)
264+
265+ // Then
266+ #expect( functions. count == 0 )
267+ }
268+
269+ @Test ( " protocol_extension " )
270+ func protocolExtensionDeclTests( ) async throws {
271+ // Given
272+ let code = try loadFixture ( " protocol_extension_decl " )
273+ let sourceFile = Parser . parse ( source: code)
274+ let detector = FunctionDetector ( viewMode: . sourceAccurate)
275+
276+ // When
277+ let functions = detector. detectFunctions ( in: sourceFile)
278+
279+ // Then
280+ #expect( functions. count == 1 )
281+ }
254282}
255283
256284// MARK: - Output Formatter Tests
You can’t perform that action at this time.
0 commit comments