@@ -19,100 +19,92 @@ class Test_RecursionDetector_Generic: Test_Core {
19
19
20
20
func testEmpty( ) throws { try _test ( rootNodes: [ ] , putIntoContainer: [ ] , expected: [ ] ) }
21
21
22
- func testSingleNode( ) throws { try _test ( rootNodes: [ " A " ] , putIntoContainer: [ " A - > " ] , expected: [ ] ) }
22
+ func testSingleNode( ) throws { try _test ( rootNodes: [ " A " ] , putIntoContainer: [ " A > " ] , expected: [ ] ) }
23
23
24
24
func testMultipleNodesNoEdges( ) throws {
25
- try _test ( rootNodes: [ " A " , " B " , " C " ] , putIntoContainer: [ " A - > " , " B - > " , " C - > " ] , expected: [ ] )
25
+ try _test ( rootNodes: [ " A " , " B " , " C " ] , putIntoContainer: [ " A > " , " B > " , " C > " ] , expected: [ ] )
26
26
}
27
27
28
28
func testNoCycle( ) throws {
29
- try _test (
30
- rootNodes: [ " A " , " B " , " C " , " D " ] ,
31
- putIntoContainer: [ " A -> B " , " B -> C " , " C -> D " , " D -> " ] ,
32
- expected: [ ]
33
- )
29
+ try _test ( rootNodes: [ " A " , " B " , " C " , " D " ] , putIntoContainer: [ " A > B " , " B > C " , " C > D " , " D > " ] , expected: [ ] )
34
30
}
35
31
36
32
func testNoCycleAndDoubleEdge( ) throws {
37
33
try _test (
38
34
rootNodes: [ " A " , " B " , " C " , " D " ] ,
39
- putIntoContainer: [ " A - > B " , " B - > C,D " , " C - > D " , " D - > " ] ,
35
+ putIntoContainer: [ " A > B " , " B > C,D " , " C > D " , " D > " ] ,
40
36
expected: [ ]
41
37
)
42
38
}
43
39
44
- func testSelfLoop( ) throws { try _test ( rootNodes: [ " A " ] , putIntoContainer: [ " A - > A " ] , expected: [ " A " ] ) }
40
+ func testSelfLoop( ) throws { try _test ( rootNodes: [ " A " ] , putIntoContainer: [ " A > A " ] , expected: [ " A " ] ) }
45
41
46
42
func testSimpleCycle( ) throws {
47
- try _test ( rootNodes: [ " A " , " B " ] , putIntoContainer: [ " A - > B " , " B - > A " ] , expected: [ " A " ] )
43
+ try _test ( rootNodes: [ " A " , " B " ] , putIntoContainer: [ " A > B " , " B > A " ] , expected: [ " A " ] )
48
44
}
49
45
50
46
func testLongerCycleStartA( ) throws {
51
- try _test ( rootNodes: [ " A " , " C " , " B " ] , putIntoContainer: [ " A - > B " , " B - > C " , " C - > A " ] , expected: [ " A " ] )
47
+ try _test ( rootNodes: [ " A " , " C " , " B " ] , putIntoContainer: [ " A > B " , " B > C " , " C > A " ] , expected: [ " A " ] )
52
48
}
53
49
54
50
func testLongerCycleStartC( ) throws {
55
- try _test ( rootNodes: [ " C " , " A " , " B " ] , putIntoContainer: [ " A - > B " , " B - > C " , " C - > A " ] , expected: [ " C " ] )
51
+ try _test ( rootNodes: [ " C " , " A " , " B " ] , putIntoContainer: [ " A > B " , " B > C " , " C > A " ] , expected: [ " C " ] )
56
52
}
57
53
58
54
func testLongerCycleStartAButNotBoxable( ) throws {
59
- try _test ( rootNodes: [ " A " , " C " , " B " ] , putIntoContainer: [ " A! - > B " , " B - > C " , " C - > A " ] , expected: [ " B " ] )
55
+ try _test ( rootNodes: [ " A " , " C " , " B " ] , putIntoContainer: [ " A! > B " , " B > C " , " C > A " ] , expected: [ " B " ] )
60
56
}
61
57
62
58
func testMultipleCycles( ) throws {
63
59
try _test (
64
60
rootNodes: [ " A " , " C " , " B " , " D " ] ,
65
- putIntoContainer: [ " A - > B " , " B - > A " , " C - > D " , " D - > C " ] ,
61
+ putIntoContainer: [ " A > B " , " B > A " , " C > D " , " D > C " ] ,
66
62
expected: [ " A " , " C " ]
67
63
)
68
64
}
69
65
70
66
func testMultipleCyclesOverlapping( ) throws {
71
67
try _test (
72
68
rootNodes: [ " C " , " A " , " B " , " D " ] ,
73
- putIntoContainer: [ " A - > B " , " B - > C " , " C - > A,D " , " D - > C " ] ,
69
+ putIntoContainer: [ " A > B " , " B > C " , " C > A,D " , " D > C " ] ,
74
70
expected: [ " C " ]
75
71
)
76
72
}
77
73
78
74
func testMultipleCycles3( ) throws {
79
75
try _test (
80
76
rootNodes: [ " A " , " B " , " C " , " D " ] ,
81
- putIntoContainer: [ " A - > C " , " B - > D,A " , " C - > B,D " , " D - > B,C " ] ,
77
+ putIntoContainer: [ " A > C " , " B > D,A " , " C > B,D " , " D > B,C " ] ,
82
78
expected: [ " A " , " B " , " C " ]
83
79
)
84
80
}
85
81
86
82
func testNested( ) throws {
87
83
try _test (
88
84
rootNodes: [ " A " , " C " , " B " , " D " ] ,
89
- putIntoContainer: [ " A - > B " , " B - > C " , " C - > B,D " , " D - > C " ] ,
85
+ putIntoContainer: [ " A > B " , " B > C " , " C > B,D " , " D > C " ] ,
90
86
expected: [ " B " , " C " ]
91
87
)
92
88
}
93
89
94
90
func testDisconnected( ) throws {
95
91
try _test (
96
92
rootNodes: [ " A " , " C " , " B " , " D " ] ,
97
- putIntoContainer: [ " A - > B " , " B - > A " , " C - > D " , " D - > " ] ,
93
+ putIntoContainer: [ " A > B " , " B > A " , " C > D " , " D > " ] ,
98
94
expected: [ " A " ]
99
95
)
100
96
}
101
97
102
98
func testCycleWithLeadingNode( ) throws {
103
99
try _test (
104
100
rootNodes: [ " A " , " B " , " C " , " D " ] ,
105
- putIntoContainer: [ " A - > B " , " B - > C " , " C - > D " , " D - > B " ] ,
101
+ putIntoContainer: [ " A > B " , " B > C " , " C > D " , " D > B " ] ,
106
102
expected: [ " B " ]
107
103
)
108
104
}
109
105
110
106
func testDifferentCyclesForSameNode( ) throws {
111
- try _test (
112
- rootNodes: [ " C " , " A " , " B " ] ,
113
- putIntoContainer: [ " A -> B " , " B -> C,A " , " C -> A " ] ,
114
- expected: [ " C " , " A " ]
115
- )
107
+ try _test ( rootNodes: [ " C " , " A " , " B " ] , putIntoContainer: [ " A > B " , " B > C,A " , " C > A " ] , expected: [ " C " , " A " ] )
116
108
}
117
109
118
110
// MARK: - Private
@@ -147,9 +139,9 @@ private struct TestNode: TypeNode, ExpressibleByStringLiteral {
147
139
}
148
140
149
141
init ( stringLiteral value: StringLiteralType ) {
150
- // A - > B,C,D for boxable
151
- // A! - > B,C,D for unboxable
152
- let comps = value. split ( separator: " - >" , omittingEmptySubsequences: false )
142
+ // A > B,C,D for boxable
143
+ // A! > B,C,D for unboxable
144
+ let comps = value. split ( separator: " > " , omittingEmptySubsequences: false )
153
145
. map { $0. trimmingCharacters ( in: . whitespaces) }
154
146
precondition ( comps. count == 2 , " Invalid syntax " )
155
147
let edges = comps [ 1 ] . split ( separator: " , " ) . map ( String . init)
0 commit comments