Debian Codegraph @

test_suite/formatter.jsonnet

raw
1 /*
2 Copyright 2015 Google Inc. All rights reserved.
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15 */
16
17
18 {
19 local test_local = {
20 f: 1,
21 },
22
23 local test_local2 =
24 {
25 g: 2,
26 },
27
28 local test_local3(x,
29 y) =
30 {
31 g: 2,
32 },
33
34 local test_local4(
35 x, y) = {
36 g: 2,
37 },
38
39 local test_local5 = {
40 x:
41 true
42 ,
43 },
44
45 local test_local_default1(x=100, y=200) = {
46 g: 2,
47 },
48
49 local test_local_default2(
50 x=100,
51 y=200)
52 = {
53 g: 2,
54 },
55
56 local f(a, b) = null,
57 func: /*0*/ f/*1*/(/*2*/ "x"/*3*/, /*4*/"y"/*5*/,/*6*/)/*7*/,
58
59 test_field0A: {
60 g: 1,
61 },
62
63 test_field1A:
64 {
65 g: 1,
66 },
67
68 test_field0B: { f: 1,
69 g: 1,
70 },
71
72 test_field1B:
73 { f: 1,
74 g: 1,
75 },
76
77 test_field2: if true then
78 100
79 else
80 200,
81
82 test_field2b: if true
83 && true
84 then
85 100
86 else
87 200,
88
89 test_field2c: if
90 true
91 then
92 100
93 else
94 200,
95
96 test_field2d: if true
97 then 100
98 else 200,
99
100 test_field3:
101 if true then
102 100
103 else
104 200,
105
106 test_field4: 1000
107 + 2000,
108
109 test_field4b: 1000 +
110 2000,
111
112 test_field4c: 1000 + 2000 + 3000
113 + 4000 + 5000,
114
115 test_field5:
116 1000
117 + 2000,
118
119 local A = {},
120
121 test_field6: A {
122 g: 1,
123 },
124
125 test_field7: A
126 {
127 f: 3,
128 },
129
130 test_field7f: f
131 (
132 1,
133 2,
134 ),
135
136 test_field7f2: /* hello */ f
137 (1,
138 2)
139 tailstrict,
140
141 local g(a) = null,
142 test_field8: g({
143 f: 3,
144 }),
145
146 test_field8b: f(10, {
147 f: 3,
148 }),
149
150 test_field9a: g(
151 {
152 f: 3,
153 }),
154
155 test_field9b: g(
156 {
157 f: 3,
158 }
159 ),
160
161 test_field9c: f(10,
162 {
163 f: 3,
164 }),
165
166 test_field9d: f(10,
167 {
168 f: 3,
169 }
170 ),
171
172 test_field9e: f(local x = 10;
173 x + 20, {
174 f: 3,
175 }),
176
177 test_field9g: f(local x = 10;
178 x + 20,
179 {
180 f: 3,
181 }),
182
183 local h(a, b, c) = null,
184 test_field9h: h("blah",
185 {
186 f: 3,
187 },
188 "blah"),
189
190 test_field10: if true then [
191 null,
192 ],
193
194 test_field11: (
195 "lol"
196 ),
197
198 test_field11b: (1
199 + 2) + (
200 3
201 ),
202
203 test_field11c: ([
204 "foo",
205 ]),
206
207 test_field12: [
208 1,
209 ],
210
211 test_field13: [1,
212 2,
213 ],
214
215 test_field14(obj):: if 10000 == 10000 then "wheeeeeeeee"
216 else if 10000 == 1000 then "whoooooo"
217 else "nah",
218
219 test_field14b(obj):: if 10000 == 10000
220 then "wheeeeeeeee"
221 else if 10000 == 1000 then "whoooooo"
222 else "nah",
223
224 test_field14c(obj):: if 10000 == 10000
225 then
226 "wheeeeeeeee"
227 else
228 if 10000 == 1000
229 then "whoooooo"
230 else
231 "nah",
232
233 test_field15: [
234 { f: 2 }
235 for i in []
236 ],
237
238 test_field16:
239 if true then
240 null
241 else [
242 null,
243 ],
244
245 test_field16b:
246 if true then [
247 null,
248 ] else
249 null,
250
251 test_field17: if true then
252 null
253 else [
254 null,
255 ],
256
257 test_field17b: if true then [
258 null,
259 ] else
260 null,
261
262 test_field18: if true
263 then
264 null
265 else [
266 null,
267 ],
268
269 test_field18b: if true
270 then [
271 null,
272 ] else
273 null,
274
275 test_field19:: [1, 2, 3][/*foo*/ 1/*bar*/:],
276 test_field20:: [1, 2, 3][/*foo*/ 1/*bar*/:/*baz*/:],
277
278 prettyFields: {
279 'identifier': true,
280 "not identifier": true,
281 "function": true, // Test keyword.
282 },
283
284 field: 1,
285
286 dollarUnary: - $.field,
287
288 objects1():: ['something']
289 + if true then ['something']
290 else [],
291
292 objects2():: ['something']
293 + if true then
294 ['something']
295 else [],
296
297 objects3():: ['something'] + if true then
298 ['something']
299 else [],
300
301 strongIndent:: {
302 foo: ["foo"]
303 + if true then [
304 "baz"
305 ] else [],
306
307 bar: ["foo"]
308 + if true then
309 ["baz"]
310 else [],
311
312 fow: ["foo"] +
313 if true then [
314 "baz"
315 ] else [],
316
317 baw: ["foo"] +
318 if true then
319 ["baz"]
320 else [],
321
322 fox: std.equals(["foo"],
323 if true then [
324 "baz"
325 ] else [],
326 ),
327
328 bax: std.equals(["foo"],
329 if true then
330 ["baz"]
331 else [],
332 ),
333
334 foy: [["foo"],
335 if true then [
336 "baz"
337 ] else [],
338 ],
339
340 bay: [["foo"],
341 if true then
342 ["baz"]
343 else [],
344 ],
345
346 foz: (["foo"]
347 + if true then [
348 "baz"
349 ] else []),
350
351 baz: (["foo"]
352 + if true then
353 ["baz"]
354 else []),
355 },
356
357 user4: std.toString(
358 a='value1',
359 ),
360 }
361