Skip to content

Commit 72e7f9a

Browse files
authored
[test] Add some tests for swift-api-digester's data generation for complex type changes. (#8917)
1 parent 077340a commit 72e7f9a

File tree

4 files changed

+148
-0
lines changed

4 files changed

+148
-0
lines changed

test/api-digester/Inputs/macro-gen-left.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ public struct S1 {
55
public func foo3() {}
66
public func foo4() -> Void {}
77
public func foo5(x : Int, y: Int) {}
8+
9+
public func foo6(x : Int, y: Int) -> Int { return 0 }
10+
public func foo7(x : Int, y: Int?) -> Int? { return 0 }
11+
public func foo8(x : Int, y: Int!) -> Int! { return 0 }
12+
public func foo9(x : [[Int: String?]], y: [Int]) {}
13+
public func foo10(x : (Int, [Int: [String: [Int]]])->String) {}
14+
public func foo11(x : (Int, [Int: [String: [Int]]])->String) {}
15+
public func foo12(x : (Int, [Int: [String: [(((Int)))]]])->String) {}
816
}
917

1018
public class C1 {

test/api-digester/Inputs/macro-gen-right.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ public struct S1 {
55
public static func foo3() {}
66
public func foo4() {}
77
public func foo5(x : Int, y: Int, z: Int) {}
8+
9+
public func foo6(x : Int, y: Int?) -> Int? { return 0 }
10+
public func foo7(x : Int, y: Int) -> Int { return 0 }
11+
public func foo8(x : Int, y: Int?) -> Int? { return 0 }
12+
public func foo9(x : [[Int: String]], y: [Int?]) {}
13+
public func foo10(x : (Int, [Int: [String: [Int?]]])->String) {}
14+
public func foo11(x : (Int, [Int: Int])->String) {}
15+
public func foo12(x : (Int, [Int: [String: [(((String)))]]])->String) {}
816
}
917

1018
public class C1 {

test/api-digester/Outputs/macro-gen.def

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@ SDK_CHANGE(Function, TypeRewritten, "0", "s:12macrogenleft2C1C4foo2SSSi_SitF", "
66
SDK_CHANGE(Function, TypeRewritten, "1", "s:12macrogenleft2C1C4foo2SSSi_SitF", "", "Int", "() -> ()", "macrogenleft")
77
SDK_CHANGE(Function, TypeRewritten, "2", "s:12macrogenleft2C1C4foo2SSSi_SitF", "", "Int", "String", "macrogenleft")
88
SDK_CHANGE(Function, Rename, "0", "s:12macrogenleft2S1V4foo5ySi1x_Si1ytF", "", "foo5(x:y:)", "foo5(x:y:z:)", "macrogenleft")
9+
SDK_CHANGE(Function, WrapOptional, "0", "s:12macrogenleft2S1V4foo6S2i1x_Si1ytF", "", "", "", "macrogenleft")
10+
SDK_CHANGE(Function, WrapOptional, "2", "s:12macrogenleft2S1V4foo6S2i1x_Si1ytF", "", "", "", "macrogenleft")
11+
SDK_CHANGE(Function, UnwrapOptional, "0", "s:12macrogenleft2S1V4foo7SiSgSi1x_AE1ytF", "", "", "", "macrogenleft")
12+
SDK_CHANGE(Function, UnwrapOptional, "2", "s:12macrogenleft2S1V4foo7SiSgSi1x_AE1ytF", "", "", "", "macrogenleft")
13+
SDK_CHANGE(Function, ImplicitOptionalToOptional, "0", "s:12macrogenleft2S1V4foo8SQySiGSi1x_AE1ytF", "", "", "", "macrogenleft")
14+
SDK_CHANGE(Function, ImplicitOptionalToOptional, "2", "s:12macrogenleft2S1V4foo8SQySiGSi1x_AE1ytF", "", "", "", "macrogenleft")
15+
SDK_CHANGE(Function, WrapOptional, "2:0", "s:12macrogenleft2S1V4foo9ySays10DictionaryVySiSSSgGG1x_SaySiG1ytF", "", "", "", "macrogenleft")
16+
SDK_CHANGE(Function, UnwrapOptional, "1:0:1", "s:12macrogenleft2S1V4foo9ySays10DictionaryVySiSSSgGG1x_SaySiG1ytF", "", "", "", "macrogenleft")
17+
SDK_CHANGE(Function, WrapOptional, "1:1:1:1:1:0", "s:12macrogenleft2S1V5foo10ySSSi_s10DictionaryVySiAFySSSaySiGGGtc1x_tF", "", "", "", "macrogenleft")
18+
SDK_CHANGE(Function, TypeRewritten, "1:1:1:1", "s:12macrogenleft2S1V5foo11ySSSi_s10DictionaryVySiAFySSSaySiGGGtc1x_tF", "", "[String : [Int]]", "Int", "macrogenleft")
19+
SDK_CHANGE(Function, TypeRewritten, "1:1:1:1:1:0:0:0:0", "s:12macrogenleft2S1V5foo12ySSSi_s10DictionaryVySiAFySSSaySiGGGtc1x_tF", "", "Int", "String", "macrogenleft")
920
SDK_CHANGE(Constructor, TypeRewritten, "1", "s:12macrogenleft2S1VACSicfc", "", "Int", "Double", "macrogenleft")
1021
#undef SDK_CHANGE
1122

test/api-digester/Outputs/macro-gen.json

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,127 @@
2121
"RightComment": "foo5(x:y:z:)",
2222
"ModuleName": "macrogenleft"
2323
},
24+
{
25+
"DiffItemKind": "CommonDiffItem",
26+
"NodeKind": "Function",
27+
"NodeAnnotation": "WrapOptional",
28+
"ChildIndex": "0",
29+
"LeftUsr": "s:12macrogenleft2S1V4foo6S2i1x_Si1ytF",
30+
"LeftComment": "",
31+
"RightUsr": "",
32+
"RightComment": "",
33+
"ModuleName": "macrogenleft"
34+
},
35+
{
36+
"DiffItemKind": "CommonDiffItem",
37+
"NodeKind": "Function",
38+
"NodeAnnotation": "WrapOptional",
39+
"ChildIndex": "2",
40+
"LeftUsr": "s:12macrogenleft2S1V4foo6S2i1x_Si1ytF",
41+
"LeftComment": "",
42+
"RightUsr": "",
43+
"RightComment": "",
44+
"ModuleName": "macrogenleft"
45+
},
46+
{
47+
"DiffItemKind": "CommonDiffItem",
48+
"NodeKind": "Function",
49+
"NodeAnnotation": "UnwrapOptional",
50+
"ChildIndex": "0",
51+
"LeftUsr": "s:12macrogenleft2S1V4foo7SiSgSi1x_AE1ytF",
52+
"LeftComment": "",
53+
"RightUsr": "",
54+
"RightComment": "",
55+
"ModuleName": "macrogenleft"
56+
},
57+
{
58+
"DiffItemKind": "CommonDiffItem",
59+
"NodeKind": "Function",
60+
"NodeAnnotation": "UnwrapOptional",
61+
"ChildIndex": "2",
62+
"LeftUsr": "s:12macrogenleft2S1V4foo7SiSgSi1x_AE1ytF",
63+
"LeftComment": "",
64+
"RightUsr": "",
65+
"RightComment": "",
66+
"ModuleName": "macrogenleft"
67+
},
68+
{
69+
"DiffItemKind": "CommonDiffItem",
70+
"NodeKind": "Function",
71+
"NodeAnnotation": "ImplicitOptionalToOptional",
72+
"ChildIndex": "0",
73+
"LeftUsr": "s:12macrogenleft2S1V4foo8SQySiGSi1x_AE1ytF",
74+
"LeftComment": "",
75+
"RightUsr": "",
76+
"RightComment": "",
77+
"ModuleName": "macrogenleft"
78+
},
79+
{
80+
"DiffItemKind": "CommonDiffItem",
81+
"NodeKind": "Function",
82+
"NodeAnnotation": "ImplicitOptionalToOptional",
83+
"ChildIndex": "2",
84+
"LeftUsr": "s:12macrogenleft2S1V4foo8SQySiGSi1x_AE1ytF",
85+
"LeftComment": "",
86+
"RightUsr": "",
87+
"RightComment": "",
88+
"ModuleName": "macrogenleft"
89+
},
90+
{
91+
"DiffItemKind": "CommonDiffItem",
92+
"NodeKind": "Function",
93+
"NodeAnnotation": "UnwrapOptional",
94+
"ChildIndex": "1:0:1",
95+
"LeftUsr": "s:12macrogenleft2S1V4foo9ySays10DictionaryVySiSSSgGG1x_SaySiG1ytF",
96+
"LeftComment": "",
97+
"RightUsr": "",
98+
"RightComment": "",
99+
"ModuleName": "macrogenleft"
100+
},
101+
{
102+
"DiffItemKind": "CommonDiffItem",
103+
"NodeKind": "Function",
104+
"NodeAnnotation": "WrapOptional",
105+
"ChildIndex": "2:0",
106+
"LeftUsr": "s:12macrogenleft2S1V4foo9ySays10DictionaryVySiSSSgGG1x_SaySiG1ytF",
107+
"LeftComment": "",
108+
"RightUsr": "",
109+
"RightComment": "",
110+
"ModuleName": "macrogenleft"
111+
},
112+
{
113+
"DiffItemKind": "CommonDiffItem",
114+
"NodeKind": "Function",
115+
"NodeAnnotation": "WrapOptional",
116+
"ChildIndex": "1:1:1:1:1:0",
117+
"LeftUsr": "s:12macrogenleft2S1V5foo10ySSSi_s10DictionaryVySiAFySSSaySiGGGtc1x_tF",
118+
"LeftComment": "",
119+
"RightUsr": "",
120+
"RightComment": "",
121+
"ModuleName": "macrogenleft"
122+
},
123+
{
124+
"DiffItemKind": "CommonDiffItem",
125+
"NodeKind": "Function",
126+
"NodeAnnotation": "TypeRewritten",
127+
"ChildIndex": "1:1:1:1",
128+
"LeftUsr": "s:12macrogenleft2S1V5foo11ySSSi_s10DictionaryVySiAFySSSaySiGGGtc1x_tF",
129+
"LeftComment": "[String : [Int]]",
130+
"RightUsr": "",
131+
"RightComment": "Int",
132+
"ModuleName": "macrogenleft"
133+
},
134+
{
135+
"DiffItemKind": "CommonDiffItem",
136+
"NodeKind": "Function",
137+
"NodeAnnotation": "TypeRewritten",
138+
"ChildIndex": "1:1:1:1:1:0:0:0:0",
139+
"LeftUsr": "s:12macrogenleft2S1V5foo12ySSSi_s10DictionaryVySiAFySSSaySiGGGtc1x_tF",
140+
"LeftComment": "Int",
141+
"RightUsr": "",
142+
"RightComment": "String",
143+
"ModuleName": "macrogenleft"
144+
},
24145
{
25146
"DiffItemKind": "CommonDiffItem",
26147
"NodeKind": "Function",

0 commit comments

Comments
 (0)