-
-
Notifications
You must be signed in to change notification settings - Fork 428
Expand file tree
/
Copy path_hover_formatter_tests.pony
More file actions
397 lines (355 loc) · 9.5 KB
/
_hover_formatter_tests.pony
File metadata and controls
397 lines (355 loc) · 9.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
use "pony_test"
use "../workspace"
primitive _HoverFormatterTests is TestList
new make() =>
None
fun tag tests(test: PonyTest) =>
test(_HoverFormatEntityTest)
test(_HoverFormatEntityWithTypeParamsTest)
test(_HoverFormatEntityWithDocstringTest)
test(_HoverFormatMethodTest)
test(_HoverFormatMethodWithReturnTypeTest)
test(_HoverFormatMethodWithDocstringTest)
test(_HoverFormatMethodWithTypeParamsTest)
test(_HoverFormatFieldTest)
test(_HoverFormatFieldWithTypeTest)
test(
_HoverFormatEntityWithMultipleTypeParamsTest)
test(_HoverFormatFieldWithGenericTypeTest)
test(_HoverFormatMethodWithArrowTypeTest)
test(_HoverFormatFieldWithUnionTypeTest)
test(_HoverFormatFieldWithTupleTypeTest)
test(
_HoverFormatMethodWithCompleteSignatureTest)
test(
_HoverFormatEntityWithTypeParamsAndDocstringTest)
test(
_HoverFormatFieldWithNestedGenericTypeTest)
test(_HoverFormatParameterTest)
test(_HoverFormatParameterWithTypeTest)
test(_HoverFormatMethodWithReceiverCapTest)
class \nodoc\ iso _HoverFormatEntityTest
is UnitTest
fun name(): String => "hover/formatter/entity"
fun apply(h: TestHelper) =>
let info = EntityInfo("class", "MyClass")
let result =
HoverFormatter.format_entity(info)
h.assert_eq[String](
"```pony\nclass MyClass\n```", result)
class \nodoc\ iso
_HoverFormatEntityWithTypeParamsTest
is UnitTest
fun name(): String =>
"hover/formatter/entity_with_type_params"
fun apply(h: TestHelper) =>
let info =
EntityInfo(
"class", "MyClass", "[T: Any val]")
let result =
HoverFormatter.format_entity(info)
h.assert_eq[String](
"```pony\nclass MyClass[T: Any val]\n```",
result)
class \nodoc\ iso
_HoverFormatEntityWithDocstringTest
is UnitTest
fun name(): String =>
"hover/formatter/entity_with_docstring"
fun apply(h: TestHelper) =>
let info =
EntityInfo(
"actor",
"MyActor",
"",
"A sample actor.")
let result =
HoverFormatter.format_entity(info)
h.assert_eq[String](
"```pony\nactor MyActor\n```" +
"\n\nA sample actor.",
result)
class \nodoc\ iso _HoverFormatMethodTest
is UnitTest
fun name(): String => "hover/formatter/method"
fun apply(h: TestHelper) =>
let info = MethodInfo("fun", "my_method", "")
let result =
HoverFormatter.format_method(info)
h.assert_eq[String](
"```pony\nfun my_method()\n```", result)
class \nodoc\ iso
_HoverFormatMethodWithReturnTypeTest
is UnitTest
fun name(): String =>
"hover/formatter/method_with_return_type"
fun apply(h: TestHelper) =>
let info =
MethodInfo(
"fun",
"get_value",
"",
"",
"(x: U32)",
": String")
let result =
HoverFormatter.format_method(info)
h.assert_eq[String](
"```pony\n" +
"fun get_value(x: U32): String\n```",
result)
class \nodoc\ iso
_HoverFormatMethodWithDocstringTest
is UnitTest
fun name(): String =>
"hover/formatter/method_with_docstring"
fun apply(h: TestHelper) =>
let info =
MethodInfo(
"be",
"process",
"",
"",
"(data: Array[U8] val)",
"",
"Process data asynchronously.")
let result =
HoverFormatter.format_method(info)
h.assert_eq[String](
"```pony\n" +
"be process(data: Array[U8] val)\n```" +
"\n\nProcess data asynchronously.",
result)
class \nodoc\ iso _HoverFormatFieldTest
is UnitTest
fun name(): String => "hover/formatter/field"
fun apply(h: TestHelper) =>
let info = FieldInfo("let", "name")
let result =
HoverFormatter.format_field(info)
h.assert_eq[String](
"```pony\nlet name\n```", result)
class \nodoc\ iso
_HoverFormatFieldWithTypeTest
is UnitTest
fun name(): String =>
"hover/formatter/field_with_type"
fun apply(h: TestHelper) =>
let info = FieldInfo("var", "count", ": U32")
let result =
HoverFormatter.format_field(info)
h.assert_eq[String](
"```pony\nvar count: U32\n```", result)
class \nodoc\ iso
_HoverFormatMethodWithTypeParamsTest
is UnitTest
fun name(): String =>
"hover/formatter/method_with_type_params"
fun apply(h: TestHelper) =>
let info =
MethodInfo(
"fun",
"map",
"",
"[U: Any val]",
"(f: {(T): U} val)",
": U")
let result =
HoverFormatter.format_method(info)
h.assert_eq[String](
"```pony\n" +
"fun map[U: Any val]" +
"(f: {(T): U} val): U\n```",
result)
class \nodoc\ iso
_HoverFormatEntityWithMultipleTypeParamsTest
is UnitTest
fun name(): String =>
"hover/formatter/entity_with_multiple_type_params"
fun apply(h: TestHelper) =>
let info =
EntityInfo(
"class",
"Pair",
"[A: Any val, B: Any val]")
let result =
HoverFormatter.format_entity(info)
h.assert_eq[String](
"```pony\n" +
"class Pair[A: Any val, B: Any val]\n```",
result)
class \nodoc\ iso
_HoverFormatFieldWithGenericTypeTest
is UnitTest
fun name(): String =>
"hover/formatter/field_with_generic_type"
fun apply(h: TestHelper) =>
let info =
FieldInfo(
"let",
"items",
": Array[String val] ref")
let result =
HoverFormatter.format_field(info)
h.assert_eq[String](
"```pony\n" +
"let items: Array[String val] ref\n```",
result)
class \nodoc\ iso
_HoverFormatMethodWithArrowTypeTest
is UnitTest
fun name(): String =>
"hover/formatter/method_with_arrow_type"
fun apply(h: TestHelper) =>
let info =
MethodInfo(
"fun",
"compare",
"",
"",
"(that: box->T)",
": I32 val")
let result =
HoverFormatter.format_method(info)
h.assert_eq[String](
"```pony\n" +
"fun compare(that: box->T): I32 val\n```",
result)
class \nodoc\ iso
_HoverFormatFieldWithUnionTypeTest
is UnitTest
fun name(): String =>
"hover/formatter/field_with_union_type"
fun apply(h: TestHelper) =>
let info =
FieldInfo(
"let",
"value",
": (String val | U32 val | None val)")
let result =
HoverFormatter.format_field(info)
h.assert_eq[String](
"```pony\n" +
"let value: " +
"(String val | U32 val | None val)\n```",
result)
class \nodoc\ iso
_HoverFormatFieldWithTupleTypeTest
is UnitTest
fun name(): String =>
"hover/formatter/field_with_tuple_type"
fun apply(h: TestHelper) =>
let info =
FieldInfo(
"let",
"pair",
": (String val, U32 val)")
let result =
HoverFormatter.format_field(info)
h.assert_eq[String](
"```pony\n" +
"let pair: (String val, U32 val)\n```",
result)
class \nodoc\ iso
_HoverFormatMethodWithCompleteSignatureTest
is UnitTest
fun name(): String =>
"hover/formatter/method_with_complete_signature"
fun apply(h: TestHelper) =>
let info =
MethodInfo(
"fun",
"transform",
"",
"[U: Any val]",
"(data: Array[T] ref)",
": Array[U] ref",
"Transform elements.")
let result =
HoverFormatter.format_method(info)
h.assert_eq[String](
"```pony\n" +
"fun transform[U: Any val]" +
"(data: Array[T] ref): " +
"Array[U] ref\n```" +
"\n\nTransform elements.",
result)
class \nodoc\ iso
_HoverFormatEntityWithTypeParamsAndDocstringTest
is UnitTest
fun name(): String =>
"hover/formatter/entity_with_" +
"type_params_and_docstring"
fun apply(h: TestHelper) =>
let info =
EntityInfo(
"class",
"Container",
"[T: Any val]",
"A generic container.")
let result =
HoverFormatter.format_entity(info)
h.assert_eq[String](
"```pony\n" +
"class Container[T: Any val]\n```" +
"\n\nA generic container.",
result)
class \nodoc\ iso
_HoverFormatFieldWithNestedGenericTypeTest
is UnitTest
fun name(): String =>
"hover/formatter/field_with_nested_generic_type"
fun apply(h: TestHelper) =>
let info =
FieldInfo(
"let",
"nested",
": Array[Array[String val] ref] ref")
let result =
HoverFormatter.format_field(info)
h.assert_eq[String](
"```pony\n" +
"let nested: " +
"Array[Array[String val] ref] ref\n```",
result)
class \nodoc\ iso _HoverFormatParameterTest
is UnitTest
fun name(): String => "hover/formatter/parameter"
fun apply(h: TestHelper) =>
let info = FieldInfo("param", "value")
let result =
HoverFormatter.format_field(info)
h.assert_eq[String](
"```pony\nparam value\n```", result)
class \nodoc\ iso
_HoverFormatParameterWithTypeTest
is UnitTest
fun name(): String =>
"hover/formatter/parameter_with_type"
fun apply(h: TestHelper) =>
let info =
FieldInfo("param", "name", ": String")
let result =
HoverFormatter.format_field(info)
h.assert_eq[String](
"```pony\nparam name: String\n```", result)
class \nodoc\ iso
_HoverFormatMethodWithReceiverCapTest
is UnitTest
fun name(): String =>
"hover/formatter/method_with_receiver_cap"
fun apply(h: TestHelper) =>
let info =
MethodInfo(
"fun",
"boxed_method",
"box",
"",
"()",
": String")
let result =
HoverFormatter.format_method(info)
h.assert_eq[String](
"```pony\n" +
"fun box boxed_method(): String\n```",
result)