1 |
# Pretty printing tests
|
2 |
|
3 |
|
4 |
= -123
|
5 |
## stdout: (Int) -123
|
6 |
|
7 |
|
8 |
= -0.00
|
9 |
## stdout: (Float) -0.0
|
10 |
|
11 |
|
12 |
= null
|
13 |
## stdout: (Null) null
|
14 |
|
15 |
|
16 |
= true
|
17 |
= false
|
18 |
## STDOUT:
|
19 |
(Bool) true
|
20 |
(Bool) false
|
21 |
## END
|
22 |
|
23 |
|
24 |
= "double quoted"
|
25 |
= 'single quoted'
|
26 |
## STDOUT:
|
27 |
(Str) 'double quoted'
|
28 |
(Str) 'single quoted'
|
29 |
## END
|
30 |
|
31 |
|
32 |
var x = 1..100
|
33 |
= x
|
34 |
## stdout: (Range) 1 .. 100
|
35 |
|
36 |
|
37 |
var pat = /d+/
|
38 |
pp (pat) | sed 's/0x[0-9a-f]\+/0x---/'
|
39 |
|
40 |
# TODO: change this
|
41 |
|
42 |
## STDOUT:
|
43 |
(Eggex) <Eggex 0x--->
|
44 |
## END
|
45 |
|
46 |
|
47 |
declare -a array_0=()
|
48 |
declare -a array_1=(hello)
|
49 |
declare -a array_3
|
50 |
array_3[0]="world"
|
51 |
array_3[2]=*.py
|
52 |
declare array_long=(Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed
|
53 |
do eiusmod.)
|
54 |
= array_0
|
55 |
= array_1
|
56 |
= array_3
|
57 |
= array_long
|
58 |
## STDOUT:
|
59 |
(BashArray) (BashArray)
|
60 |
(BashArray) (BashArray 'hello')
|
61 |
(BashArray) (BashArray 'world' null '*.py')
|
62 |
(BashArray)
|
63 |
(BashArray
|
64 |
'Lorem' 'ipsum' 'dolor' 'sit' 'amet,'
|
65 |
'consectetur' 'adipiscing' 'elit,' 'sed' 'do'
|
66 |
'eiusmod.'
|
67 |
)
|
68 |
## END
|
69 |
|
70 |
|
71 |
declare -A assoc=(['k']=$'foo \x01\u03bc')
|
72 |
= assoc
|
73 |
## stdout: (BashAssoc) (BashAssoc ['k']=$'foo \u0001μ')
|
74 |
|
75 |
|
76 |
declare -A assoc_0=()
|
77 |
declare -A assoc_1=([1]=one)
|
78 |
declare assoc_3=([1]=one [two]=2 [3]=three)
|
79 |
declare assoc_long=([Lorem]=ipsum [dolor]="sit amet," ['consectetur adipiscing']="elit, sed" [do]="eiusmod.")
|
80 |
= assoc_0
|
81 |
= assoc_1
|
82 |
= assoc_3
|
83 |
= assoc_long
|
84 |
## STDOUT:
|
85 |
(BashAssoc) (BashAssoc)
|
86 |
(BashAssoc) (BashAssoc ['1']='one')
|
87 |
(BashAssoc) (BashAssoc ['1']='one' ['two']='2' ['3']='three')
|
88 |
(BashAssoc)
|
89 |
(BashAssoc
|
90 |
['Lorem']='ipsum'
|
91 |
['dolor']='sit amet,'
|
92 |
['consectetur adipiscing']='elit, sed'
|
93 |
['do']='eiusmod.'
|
94 |
)
|
95 |
## END
|
96 |
|
97 |
|
98 |
var cyclic_array = ["one", "two", "three"]
|
99 |
setvar cyclic_array[2] = cyclic_array
|
100 |
var cyclic_dict = {"dead_end": null}
|
101 |
setvar cyclic_dict["live_end"] = cyclic_dict
|
102 |
= cyclic_array
|
103 |
= cyclic_dict
|
104 |
## STDOUT:
|
105 |
(List) ['one', 'two', [...]]
|
106 |
(Dict) {dead_end: null, live_end: {...}}
|
107 |
## END
|
108 |
|
109 |
|
110 |
var dict = {}
|
111 |
setvar dict["nothing"] = null
|
112 |
var simple_cycle = [["dummy"]]
|
113 |
setvar simple_cycle[0][0] = simple_cycle
|
114 |
setvar dict["simple_cycle"] = simple_cycle
|
115 |
var tricky_cycle = ["dummy"]
|
116 |
setvar tricky_cycle[0] = dict
|
117 |
setvar dict["tricky_cycle"] = tricky_cycle
|
118 |
var dag = [1, 2, "dummy"]
|
119 |
setvar dag[2] = dag
|
120 |
setvar dict["dag"] = [dag, dag]
|
121 |
var alpha = {}
|
122 |
var omega = {}
|
123 |
setvar alpha["omega"] = omega
|
124 |
setvar omega["alpha"] = alpha
|
125 |
setvar dict["key_alpha"] = alpha
|
126 |
setvar dict["key_omega"] = omega
|
127 |
= dict
|
128 |
## STDOUT:
|
129 |
(Dict)
|
130 |
{
|
131 |
nothing: null,
|
132 |
simple_cycle: [[[...]]],
|
133 |
tricky_cycle: [{...}],
|
134 |
dag: [[1, 2, [...]], [1, 2, [...]]],
|
135 |
key_alpha: {omega: {alpha: {...}}},
|
136 |
key_omega: {alpha: {omega: {...}}}
|
137 |
}
|
138 |
## END
|