1// RUN: rm -rf %t
2// RUN: split-file %s %t
3// RUN: sed -e "s@INPUT_DIR@%{/t:regex_replacement}@g" \
4// RUN: %t/reference.output.json.in >> %t/reference.output.json
5// RUN: %clang -extract-api -x objective-c-header -target arm64-apple-macosx \
6// RUN: %t/input.h -o %t/output.json | FileCheck -allow-empty %s
7
8// Generator version is not consistent across test runs, normalize it.
9// RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \
10// RUN: %t/output.json >> %t/output-normalized.json
11// RUN: diff %t/reference.output.json %t/output-normalized.json
12
13// CHECK-NOT: error:
14// CHECK-NOT: warning:
15
16//--- input.h
17@protocol Protocol
18@end
19
20@protocol AnotherProtocol <Protocol>
21@end
22
23//--- reference.output.json.in
24{
25  "metadata": {
26    "formatVersion": {
27      "major": 0,
28      "minor": 5,
29      "patch": 3
30    },
31    "generator": "?"
32  },
33  "module": {
34    "name": "",
35    "platform": {
36      "architecture": "arm64",
37      "operatingSystem": {
38        "minimumVersion": {
39          "major": 11,
40          "minor": 0,
41          "patch": 0
42        },
43        "name": "macosx"
44      },
45      "vendor": "apple"
46    }
47  },
48  "relationships": [
49    {
50      "kind": "conformsTo",
51      "source": "c:objc(pl)AnotherProtocol",
52      "target": "c:objc(pl)Protocol"
53    }
54  ],
55  "symbols": [
56    {
57      "accessLevel": "public",
58      "declarationFragments": [
59        {
60          "kind": "keyword",
61          "spelling": "@protocol"
62        },
63        {
64          "kind": "text",
65          "spelling": " "
66        },
67        {
68          "kind": "identifier",
69          "spelling": "Protocol"
70        }
71      ],
72      "identifier": {
73        "interfaceLanguage": "objective-c",
74        "precise": "c:objc(pl)Protocol"
75      },
76      "kind": {
77        "displayName": "Protocol",
78        "identifier": "objective-c.protocol"
79      },
80      "location": {
81        "position": {
82          "character": 11,
83          "line": 1
84        },
85        "uri": "file://INPUT_DIR/input.h"
86      },
87      "names": {
88        "navigator": [
89          {
90            "kind": "identifier",
91            "spelling": "Protocol"
92          }
93        ],
94        "subHeading": [
95          {
96            "kind": "identifier",
97            "spelling": "Protocol"
98          }
99        ],
100        "title": "Protocol"
101      },
102      "pathComponents": [
103        "Protocol"
104      ]
105    },
106    {
107      "accessLevel": "public",
108      "declarationFragments": [
109        {
110          "kind": "keyword",
111          "spelling": "@protocol"
112        },
113        {
114          "kind": "text",
115          "spelling": " "
116        },
117        {
118          "kind": "identifier",
119          "spelling": "AnotherProtocol"
120        },
121        {
122          "kind": "text",
123          "spelling": " <"
124        },
125        {
126          "kind": "typeIdentifier",
127          "preciseIdentifier": "c:objc(pl)Protocol",
128          "spelling": "Protocol"
129        },
130        {
131          "kind": "text",
132          "spelling": ">"
133        }
134      ],
135      "identifier": {
136        "interfaceLanguage": "objective-c",
137        "precise": "c:objc(pl)AnotherProtocol"
138      },
139      "kind": {
140        "displayName": "Protocol",
141        "identifier": "objective-c.protocol"
142      },
143      "location": {
144        "position": {
145          "character": 11,
146          "line": 4
147        },
148        "uri": "file://INPUT_DIR/input.h"
149      },
150      "names": {
151        "navigator": [
152          {
153            "kind": "identifier",
154            "spelling": "AnotherProtocol"
155          }
156        ],
157        "subHeading": [
158          {
159            "kind": "identifier",
160            "spelling": "AnotherProtocol"
161          }
162        ],
163        "title": "AnotherProtocol"
164      },
165      "pathComponents": [
166        "AnotherProtocol"
167      ]
168    }
169  ]
170}
171