1 |
## oils_failures_allowed: 0
|
2 |
|
3 |
|
4 |
= -123
|
5 |
## STDOUT:
|
6 |
(Int) -123
|
7 |
## END
|
8 |
|
9 |
|
10 |
= -0.00
|
11 |
## STDOUT:
|
12 |
(Float) -0.0
|
13 |
## END
|
14 |
|
15 |
|
16 |
= null
|
17 |
## STDOUT:
|
18 |
(Null) null
|
19 |
## END
|
20 |
|
21 |
|
22 |
= true
|
23 |
= false
|
24 |
## STDOUT:
|
25 |
(Bool) true
|
26 |
(Bool) false
|
27 |
## END
|
28 |
|
29 |
|
30 |
= "double quoted"
|
31 |
= 'single quoted'
|
32 |
## STDOUT:
|
33 |
(Str) 'double quoted'
|
34 |
(Str) 'single quoted'
|
35 |
## END
|
36 |
|
37 |
|
38 |
var x = 1..<100
|
39 |
|
40 |
pp value (x)
|
41 |
|
42 |
# TODO: show type here, like (Range 1 ..< 100)
|
43 |
|
44 |
pp value ({k: x})
|
45 |
|
46 |
echo
|
47 |
|
48 |
pp test_ (x)
|
49 |
pp test_ ({k: x})
|
50 |
|
51 |
## STDOUT:
|
52 |
(Range 1 ..< 100)
|
53 |
(Dict) {k: (Range 1 ..< 100)}
|
54 |
|
55 |
<Range>
|
56 |
(Dict) {"k":<Range>}
|
57 |
## END
|
58 |
|
59 |
|
60 |
|
61 |
var pat = /d+/
|
62 |
|
63 |
remove-addr() {
|
64 |
sed 's/0x[0-9a-f]\+/0x---/'
|
65 |
}
|
66 |
|
67 |
pp value (pat) | remove-addr
|
68 |
|
69 |
pp value ({k: pat}) | remove-addr
|
70 |
|
71 |
# TODO: change this
|
72 |
|
73 |
echo
|
74 |
|
75 |
pp test_ (pat)
|
76 |
pp test_ ({k: pat})
|
77 |
|
78 |
## STDOUT:
|
79 |
<Eggex 0x--->
|
80 |
(Dict) {k: <Eggex 0x--->}
|
81 |
|
82 |
<Eggex>
|
83 |
(Dict) {"k":<Eggex>}
|
84 |
## END
|
85 |
|
86 |
|
87 |
declare -a empty=()
|
88 |
declare -a array_1=(hello)
|
89 |
array_1[5]=5
|
90 |
|
91 |
var empty = _a2sp(empty)
|
92 |
var array_1 = _a2sp(array_1)
|
93 |
|
94 |
pp value (empty)
|
95 |
pp value (array_1)
|
96 |
echo
|
97 |
|
98 |
pp value ({k: empty})
|
99 |
pp value ({k: array_1})
|
100 |
echo
|
101 |
|
102 |
pp test_ (empty)
|
103 |
pp test_ (array_1)
|
104 |
echo
|
105 |
|
106 |
pp test_ ({k: empty})
|
107 |
pp test_ ({k: array_1})
|
108 |
|
109 |
## STDOUT:
|
110 |
(SparseArray)
|
111 |
(SparseArray [0]='hello' [5]='5')
|
112 |
|
113 |
(Dict) {k: (SparseArray)}
|
114 |
(Dict) {k: (SparseArray [0]='hello' [5]='5')}
|
115 |
|
116 |
{"type":"SparseArray","data":{}}
|
117 |
{"type":"SparseArray","data":{"0":"hello","5":"5"}}
|
118 |
|
119 |
(Dict) {"k":{"type":"SparseArray","data":{}}}
|
120 |
(Dict) {"k":{"type":"SparseArray","data":{"0":"hello","5":"5"}}}
|
121 |
## END
|
122 |
|
123 |
|
124 |
declare -a empty=()
|
125 |
declare -a array_1=(hello)
|
126 |
|
127 |
pp value (empty)
|
128 |
pp value (array_1)
|
129 |
echo
|
130 |
|
131 |
pp value ({k: empty})
|
132 |
pp value ({k: array_1})
|
133 |
echo
|
134 |
|
135 |
pp test_ (empty)
|
136 |
pp test_ (array_1)
|
137 |
echo
|
138 |
|
139 |
pp test_ ({k: empty})
|
140 |
pp test_ ({k: array_1})
|
141 |
|
142 |
## STDOUT:
|
143 |
(BashArray)
|
144 |
(BashArray 'hello')
|
145 |
|
146 |
(Dict) {k: (BashArray)}
|
147 |
(Dict) {k: (BashArray 'hello')}
|
148 |
|
149 |
{"type":"BashArray","data":{}}
|
150 |
{"type":"BashArray","data":{"0":"hello"}}
|
151 |
|
152 |
(Dict) {"k":{"type":"BashArray","data":{}}}
|
153 |
(Dict) {"k":{"type":"BashArray","data":{"0":"hello"}}}
|
154 |
## END
|
155 |
|
156 |
|
157 |
declare -a array_3
|
158 |
array_3[0]="world"
|
159 |
array_3[2]=*.py
|
160 |
declare array_long=(Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed
|
161 |
do eiusmod.)
|
162 |
= array_3
|
163 |
= array_long
|
164 |
## STDOUT:
|
165 |
(BashArray 'world' null '*.py')
|
166 |
(BashArray
|
167 |
'Lorem' 'ipsum' 'dolor' 'sit' 'amet,'
|
168 |
'consectetur' 'adipiscing' 'elit,' 'sed' 'do'
|
169 |
'eiusmod.'
|
170 |
)
|
171 |
## END
|
172 |
|
173 |
|
174 |
declare -A empty
|
175 |
declare -A assoc=(['k']=$'foo \x01\u03bc')
|
176 |
|
177 |
pp value (empty)
|
178 |
pp value (assoc)
|
179 |
echo
|
180 |
|
181 |
pp value ({k:empty})
|
182 |
pp value ({k:assoc})
|
183 |
echo
|
184 |
|
185 |
pp test_ (empty)
|
186 |
pp test_ (assoc)
|
187 |
echo
|
188 |
|
189 |
pp test_ ({k:empty})
|
190 |
pp test_ ({k:assoc})
|
191 |
|
192 |
## STDOUT:
|
193 |
(BashAssoc)
|
194 |
(BashAssoc ['k']=$'foo \u0001μ')
|
195 |
|
196 |
(Dict) {k: (BashAssoc)}
|
197 |
(Dict) {k: (BashAssoc ['k']=$'foo \u0001μ')}
|
198 |
|
199 |
{"type":"BashAssoc","data":{}}
|
200 |
{"type":"BashAssoc","data":{"k":"foo \u0001μ"}}
|
201 |
|
202 |
(Dict) {"k":{"type":"BashAssoc","data":{}}}
|
203 |
(Dict) {"k":{"type":"BashAssoc","data":{"k":"foo \u0001μ"}}}
|
204 |
## END
|
205 |
|
206 |
|
207 |
|
208 |
declare -A assoc_0=()
|
209 |
declare -A assoc_1=([1]=one)
|
210 |
declare assoc_3=([1]=one [two]=2 [3]=three)
|
211 |
declare assoc_long=([Lorem]=ipsum [dolor]="sit amet," ['consectetur adipiscing']="elit, sed" [do]="eiusmod.")
|
212 |
= assoc_0
|
213 |
= assoc_1
|
214 |
= assoc_3
|
215 |
= assoc_long
|
216 |
## STDOUT:
|
217 |
(BashAssoc)
|
218 |
(BashAssoc ['1']='one')
|
219 |
(BashAssoc ['1']='one' ['two']='2' ['3']='three')
|
220 |
(BashAssoc
|
221 |
['Lorem']='ipsum'
|
222 |
['dolor']='sit amet,'
|
223 |
['consectetur adipiscing']='elit, sed'
|
224 |
['do']='eiusmod.'
|
225 |
)
|
226 |
## END
|
227 |
|
228 |
|
229 |
var cyclic_array = ["one", "two", "three"]
|
230 |
setvar cyclic_array[2] = cyclic_array
|
231 |
var cyclic_dict = {"dead_end": null}
|
232 |
setvar cyclic_dict["live_end"] = cyclic_dict
|
233 |
= cyclic_array
|
234 |
= cyclic_dict
|
235 |
## STDOUT:
|
236 |
(List) ['one', 'two', [...]]
|
237 |
(Dict) {dead_end: null, live_end: {...}}
|
238 |
## END
|
239 |
|
240 |
|
241 |
var dict = {}
|
242 |
setvar dict["nothing"] = null
|
243 |
var simple_cycle = [["dummy"]]
|
244 |
setvar simple_cycle[0][0] = simple_cycle
|
245 |
setvar dict["simple_cycle"] = simple_cycle
|
246 |
var tricky_cycle = ["dummy"]
|
247 |
setvar tricky_cycle[0] = dict
|
248 |
setvar dict["tricky_cycle"] = tricky_cycle
|
249 |
var dag = [1, 2, "dummy"]
|
250 |
setvar dag[2] = dag
|
251 |
setvar dict["dag"] = [dag, dag]
|
252 |
var alpha = {}
|
253 |
var omega = {}
|
254 |
setvar alpha["omega"] = omega
|
255 |
setvar omega["alpha"] = alpha
|
256 |
setvar dict["key_alpha"] = alpha
|
257 |
setvar dict["key_omega"] = omega
|
258 |
= dict
|
259 |
## STDOUT:
|
260 |
(Dict)
|
261 |
{
|
262 |
nothing: null,
|
263 |
simple_cycle: [[[...]]],
|
264 |
tricky_cycle: [{...}],
|
265 |
dag: [[1, 2, [...]], [1, 2, [...]]],
|
266 |
key_alpha: {omega: {alpha: {...}}},
|
267 |
key_omega: {alpha: {omega: {...}}}
|
268 |
}
|
269 |
## END
|
270 |
|
271 |
|
272 |
|
273 |
var no_cycle = [5, 6]
|
274 |
pp test_ (no_cycle)
|
275 |
|
276 |
var two = [no_cycle, no_cycle]
|
277 |
pp test_ (two)
|
278 |
#pp value (two)
|
279 |
|
280 |
echo
|
281 |
|
282 |
var L = [42]
|
283 |
call L->append(L)
|
284 |
pp test_ (L)
|
285 |
#pp value (L)
|
286 |
|
287 |
var two = [L, L]
|
288 |
pp test_ (two)
|
289 |
#pp value (two)
|
290 |
|
291 |
## STDOUT:
|
292 |
(List) [5,6]
|
293 |
(List) [[5,6],[5,6]]
|
294 |
|
295 |
(List) [42,[...]]
|
296 |
(List) [[42,[...]],[42,[...]]]
|
297 |
## END
|
298 |
|
299 |
|
300 |
|
301 |
var no_cycle = {z: 99}
|
302 |
pp test_ (no_cycle)
|
303 |
|
304 |
var two = [no_cycle, no_cycle]
|
305 |
pp test_ (two)
|
306 |
|
307 |
#pp value (two)
|
308 |
|
309 |
echo
|
310 |
|
311 |
var d = {k: 42}
|
312 |
setvar d.cycle = d
|
313 |
pp test_ (d)
|
314 |
#pp value (d)
|
315 |
|
316 |
var two = [d, d]
|
317 |
pp test_ (two)
|
318 |
#pp value (two)
|
319 |
|
320 |
|
321 |
## STDOUT:
|
322 |
(Dict) {"z":99}
|
323 |
(List) [{"z":99},{"z":99}]
|
324 |
|
325 |
(Dict) {"k":42,"cycle":{...}}
|
326 |
(List) [{"k":42,"cycle":{...}},{"k":42,"cycle":{...}}]
|
327 |
## END
|
328 |
|
329 |
|
330 |
|
331 |
var methods = Object(null, {__foo__: null})
|
332 |
var obj = Object(methods, {z: 99})
|
333 |
pp test_ (obj)
|
334 |
pp value (obj)
|
335 |
echo
|
336 |
|
337 |
setvar obj.cycle = obj
|
338 |
pp test_ (obj)
|
339 |
pp value (obj)
|
340 |
|
341 |
echo
|
342 |
|
343 |
var two = [obj, obj]
|
344 |
pp test_ (two)
|
345 |
|
346 |
## STDOUT:
|
347 |
(Obj) ("z":99) --> ("__foo__":null)
|
348 |
(Obj) (z: 99) --> (__foo__: null)
|
349 |
|
350 |
(Obj) ("z":99,"cycle":(...)) --> ("__foo__":null)
|
351 |
(Obj) (z: 99, cycle: (...)) --> (__foo__: null)
|
352 |
|
353 |
(List) [("z":99,"cycle":(...)) --> ("__foo__":null),("z":99,"cycle":(...)) --> ("__foo__":null)]
|
354 |
## END
|
355 |
|
356 |
|
357 |
|
358 |
|
359 |
|
360 |
var methods = Object(null, {__foo__: null})
|
361 |
var no_cycle = Object(methods, {z: 99})
|
362 |
pp test_ (no_cycle)
|
363 |
|
364 |
var two = [no_cycle, no_cycle]
|
365 |
pp test_ (two)
|
366 |
|
367 |
echo
|
368 |
|
369 |
var d = {k: 42}
|
370 |
setvar d.cycle = d
|
371 |
|
372 |
# This cycle detection doesn't quite work
|
373 |
# Because we're only considering the object itself
|
374 |
|
375 |
var o = Object(null, d)
|
376 |
pp test_ (o)
|
377 |
|
378 |
var two = [o, o]
|
379 |
pp test_ (two)
|
380 |
|
381 |
#var o2 = Object(o, {z: 99})
|
382 |
#pp test_ (o2)
|
383 |
|
384 |
## STDOUT:
|
385 |
(Obj) ("z":99) --> ("__foo__":null)
|
386 |
(List) [("z":99) --> ("__foo__":null),("z":99) --> ("__foo__":null)]
|
387 |
|
388 |
(Obj) ("k":42,"cycle":{"k":42,"cycle":{...}})
|
389 |
(List) [("k":42,"cycle":{"k":42,"cycle":{...}}),("k":42,"cycle":{"k":42,"cycle":{...}})]
|
390 |
## END
|
391 |
|