@@ -36,4 +36,89 @@ struct CodelinkDisambiguators:ParsingSuite
36
36
#expect( !link. path. hasTrailingParentheses)
37
37
#expect( link. suffix == . keywords( . class_var) )
38
38
}
39
+ @Test
40
+ static func ClassVarRequirement( ) throws
41
+ {
42
+ let link : UCF . Selector = try Self . roundtrip ( " Fake.max [class var, requirement] " )
43
+ #expect( link. base == . relative)
44
+ #expect( link. path. components == [ " Fake " , " max " ] )
45
+ #expect( !link. path. hasTrailingParentheses)
46
+ #expect( link. suffix == . unidoc( . init(
47
+ conditions: [
48
+ . init( keywords: . class_var, expected: true ) ,
49
+ . init( keywords: . requirement, expected: true )
50
+ ] ,
51
+ signature: nil ) ) )
52
+ }
53
+ @Test
54
+ static func ClassVarRequirementNegated( ) throws
55
+ {
56
+ let link : UCF . Selector = try Self . roundtrip ( """
57
+ Fake.max [class var: false, requirement: false]
58
+ """ )
59
+ #expect( link. base == . relative)
60
+ #expect( link. path. components == [ " Fake " , " max " ] )
61
+ #expect( !link. path. hasTrailingParentheses)
62
+ #expect( link. suffix == . unidoc( . init(
63
+ conditions: [
64
+ . init( keywords: . class_var, expected: false ) ,
65
+ . init( keywords: . requirement, expected: false )
66
+ ] ,
67
+ signature: nil ) ) )
68
+ }
69
+ @Test
70
+ static func Signature( ) throws
71
+ {
72
+ let link : UCF . Selector = try Self . roundtrip ( """
73
+ Foo.bar(_:_:) (Int, _)
74
+ """ )
75
+ #expect( link. base == . relative)
76
+ #expect( link. path. components == [ " Foo " , " bar(_:_:) " ] )
77
+ #expect( link. path. hasTrailingParentheses)
78
+ #expect( link. suffix == . unidoc( . init(
79
+ conditions: [ ] ,
80
+ signature: . function( [ " Int " , nil ] ) ) ) )
81
+ }
82
+ @Test
83
+ static func SignatureFull( ) throws
84
+ {
85
+ let link : UCF . Selector = try Self . roundtrip ( """
86
+ Foo.bar(_:_:) (_, Int) -> Set<String>
87
+ """ )
88
+ #expect( link. base == . relative)
89
+ #expect( link. path. components == [ " Foo " , " bar(_:_:) " ] )
90
+ #expect( link. path. hasTrailingParentheses)
91
+ #expect( link. suffix == . unidoc( . init(
92
+ conditions: [ ] ,
93
+ signature: . function( [ nil , " Int " ] , [ " Set<String> " ] ) ) ) )
94
+ }
95
+ @Test
96
+ static func SignatureReturns( ) throws
97
+ {
98
+ let link : UCF . Selector = try Self . roundtrip ( """
99
+ Foo.bar(_:_:) -> Set<String>
100
+ """ )
101
+ #expect( link. base == . relative)
102
+ #expect( link. path. components == [ " Foo " , " bar(_:_:) " ] )
103
+ #expect( link. path. hasTrailingParentheses)
104
+ #expect( link. suffix == . unidoc( . init(
105
+ conditions: [ ] ,
106
+ signature: . returns( [ " Set<String> " ] ) ) ) )
107
+ }
108
+ @Test
109
+ static func All( ) throws
110
+ {
111
+ let link : UCF . Selector = try Self . roundtrip ( """
112
+ Foo.bar(_:_:) (_, Int) -> () [static func: false, requirement: true]
113
+ """ )
114
+ #expect( link. base == . relative)
115
+ #expect( link. path. components == [ " Foo " , " bar(_:_:) " ] )
116
+ #expect( link. path. hasTrailingParentheses)
117
+ #expect( link. suffix == . unidoc( . init(
118
+ conditions: [
119
+ . init( keywords: . static_func, expected: false ) ,
120
+ . init( keywords: . requirement, expected: true )
121
+ ] ,
122
+ signature: . function( [ nil , " Int " ] , [ ] ) ) ) )
123
+ }
39
124
}
0 commit comments