[mlir][sparse] implement non-permutation MapRef encoding (#69406)
[llvm-project.git] / clang-tools-extra / clangd / test / protocol.test
blob5e852d1d9deebca1791566d85d96bfcc8594b10a
1 # RUN: not clangd -pretty -sync -enable-test-uri-scheme < %s | FileCheck -strict-whitespace %s\r
2 # RUN: not clangd -pretty -sync -enable-test-uri-scheme < %s 2>&1 | FileCheck -check-prefix=STDERR %s\r
3 # vim: fileformat=dos\r
4 # It is absolutely vital that this file has CRLF line endings.\r
5 #\r
6 # Note that we invert the test because we intent to let clangd exit prematurely.\r
7 #\r
8 # Test protocol parsing\r
9 Content-Length: 125\r
10 Content-Type: application/vscode-jsonrpc; charset-utf-8\r
12 {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}\r
13 # Test message with Content-Type after Content-Length\r
14 #\r
15 #      CHECK:  "jsonrpc": "2.0",\r
16 # CHECK-NEXT:  "result": {\r
17 #      CHECK:  }\r
18 Content-Length: 246\r
20 {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///main.cpp","languageId":"cpp","version":1,"text":"struct fake { int a, bb, ccc; int f(int i, const float f) const; };\nint main() {\n  fake f;\n  f.\n}\n"}}}\r
22 Content-Length: 104\r
24 {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"test:///main.cpp"}}}\r
26 Content-Type: application/vscode-jsonrpc; charset-utf-8\r
27 Content-Length: 146\r
29 {"jsonrpc":"2.0","id":1,"method":"textDocument/completion","params":{"textDocument":{"uri":"test:/main.cpp"},"position":{"line":3,"character":5}}}\r
30 # Test message with Content-Type before Content-Length\r
31 #\r
32 #      CHECK:  "id": 1,\r
33 # CHECK-NEXT:  "jsonrpc": "2.0",\r
34 # CHECK-NEXT:  "result": {\r
35 # CHECK-NEXT:    "isIncomplete": false,\r
36 # CHECK-NEXT:    "items": [\r
37 #      CHECK:        "filterText": "a",\r
38 # CHECK-NEXT:        "insertText": "a",\r
39 # CHECK-NEXT:        "insertTextFormat": 1,\r
40 # CHECK-NEXT:        "kind": 5,\r
41 # CHECK-NEXT:        "label": " a",\r
42 # CHECK-NEXT:        "score": {{[0-9]+.[0-9]+}},\r
43 # CHECK-NEXT:        "sortText": "{{.*}}"\r
44 #      CHECK:    ]\r
45 # CHECK-NEXT:  }\r
47 X-Test: Testing\r
48 Content-Type: application/vscode-jsonrpc; charset-utf-8\r
49 Content-Length: 146\r
50 Content-Type: application/vscode-jsonrpc; charset-utf-8\r
51 X-Testing: Test\r
53 {"jsonrpc":"2.0","id":2,"method":"textDocument/completion","params":{"textDocument":{"uri":"test:/main.cpp"},"position":{"line":3,"character":5}}}\r
55 Content-Type: application/vscode-jsonrpc; charset-utf-8\r
56 Content-Length: 10\r
57 Content-Length: 146\r
59 {"jsonrpc":"2.0","id":3,"method":"textDocument/completion","params":{"textDocument":{"uri":"test:/main.cpp"},"position":{"line":3,"character":5}}}\r
60 # Test message with duplicate Content-Length headers\r
61 #\r
62 #      CHECK:  "id": 3,\r
63 # CHECK-NEXT:  "jsonrpc": "2.0",\r
64 # CHECK-NEXT:  "result": {\r
65 # CHECK-NEXT:    "isIncomplete": false,\r
66 # CHECK-NEXT:    "items": [\r
67 #      CHECK:        "filterText": "a",\r
68 # CHECK-NEXT:        "insertText": "a",\r
69 # CHECK-NEXT:        "insertTextFormat": 1,\r
70 # CHECK-NEXT:        "kind": 5,\r
71 # CHECK-NEXT:        "label": " a",\r
72 # CHECK-NEXT:        "score": {{[0-9]+.[0-9]+}},\r
73 # CHECK-NEXT:        "sortText": "{{.*}}"\r
74 #      CHECK:    ]\r
75 # CHECK-NEXT:  }\r
76 # STDERR: Warning: Duplicate Content-Length header received. The previous value for this message (10) was ignored.\r
78 Content-Type: application/vscode-jsonrpc; charset-utf-8\r
79 Content-Length: 10\r
81 {"jsonrpc":"2.0","id":4,"method":"textDocument/completion","params":{"textDocument":{"uri":"test:/main.cpp"},"position":{"line":3,"character":5}}}\r
82 # Test message with malformed Content-Length\r
83 #\r
84 # STDERR: JSON parse error\r
85 # Ensure we recover by sending another (valid) message\r
87 Content-Length: 146\r
89 {"jsonrpc":"2.0","id":5,"method":"textDocument/completion","params":{"textDocument":{"uri":"test:/main.cpp"},"position":{"line":3,"character":5}}}\r
90 # Test message with Content-Type before Content-Length\r
91 #\r
92 #      CHECK:  "id": 5,\r
93 # CHECK-NEXT:  "jsonrpc": "2.0",\r
94 # CHECK-NEXT:  "result": {\r
95 # CHECK-NEXT:    "isIncomplete": false,\r
96 # CHECK-NEXT:    "items": [\r
97 #      CHECK:        "filterText": "a",\r
98 # CHECK-NEXT:        "insertText": "a",\r
99 # CHECK-NEXT:        "insertTextFormat": 1,\r
100 # CHECK-NEXT:        "kind": 5,\r
101 # CHECK-NEXT:        "label": " a",\r
102 # CHECK-NEXT:        "score": {{[0-9]+.[0-9]+}},\r
103 # CHECK-NEXT:        "sortText": "{{.*}}"\r
104 #      CHECK:    ]\r
105 # CHECK-NEXT:  }\r
106 Content-Length: 1024\r
108 {"jsonrpc":"2.0","id":5,"method":"textDocument/completion","params":{"textDocument":{"uri":"test:/main.cpp"},"position":{"line":3,"character":5}}}\r
109 # Test message which reads beyond the end of the stream.\r
111 # Ensure this is the last test in the file!\r
112 # STDERR: Input was aborted. Read only {{[0-9]+}} bytes of expected {{[0-9]+}}.\r