@@ -15,6 +15,46 @@ var mapOperatorScenarios = []expressionScenario{
15
15
"D0, P[], (!!seq)::[6, 7, 8]\n " ,
16
16
},
17
17
},
18
+ {
19
+ description : "mapping against an empty array should do nothing" ,
20
+ skipDoc : true ,
21
+ document : `[]` ,
22
+ document2 : `["cat"]` ,
23
+ expression : `map(3)` ,
24
+ expected : []string {
25
+ "D0, P[], (!!seq)::[]\n " ,
26
+ "D0, P[], (!!seq)::[3]\n " ,
27
+ },
28
+ },
29
+ {
30
+ description : "mapping against an empty array should do nothing" ,
31
+ skipDoc : true ,
32
+ document : `[[], [5]]` ,
33
+ expression : `.[] |= map(3)` ,
34
+ expected : []string {
35
+ "D0, P[], (!!seq)::[[], [3]]\n " ,
36
+ },
37
+ },
38
+ {
39
+ description : "mapping against an empty array should do nothing #2" ,
40
+ skipDoc : true ,
41
+ document : `[]` ,
42
+ document2 : `[5]` ,
43
+ expression : `map(3 + .)` ,
44
+ expected : []string {
45
+ "D0, P[], (!!seq)::[]\n " ,
46
+ "D0, P[], (!!seq)::[8]\n " ,
47
+ },
48
+ },
49
+ {
50
+ description : "mapping against an empty array should do nothing" ,
51
+ skipDoc : true ,
52
+ document : `[[], [5]]` ,
53
+ expression : `.[] |= map(3 + .)` ,
54
+ expected : []string {
55
+ "D0, P[], (!!seq)::[[], [8]]\n " ,
56
+ },
57
+ },
18
58
{
19
59
skipDoc : true ,
20
60
expression : `[] | map(. + 42)` ,
@@ -39,6 +79,26 @@ var mapOperatorScenarios = []expressionScenario{
39
79
"D0, P[], (!!seq)::[2, 3, 4]\n " ,
40
80
},
41
81
},
82
+ {
83
+ skipDoc : true ,
84
+ document : `{}` ,
85
+ document2 : `{b: 12}` ,
86
+ expression : `map_values(3)` ,
87
+ expected : []string {
88
+ "D0, P[], (!!map)::{}\n " ,
89
+ "D0, P[], (!!map)::{b: 3}\n " ,
90
+ },
91
+ },
92
+ {
93
+ skipDoc : true ,
94
+ document : `{}` ,
95
+ document2 : `{b: 12}` ,
96
+ expression : `map_values(3 + .)` ,
97
+ expected : []string {
98
+ "D0, P[], (!!map)::{}\n " ,
99
+ "D0, P[], (!!map)::{b: 15}\n " ,
100
+ },
101
+ },
42
102
{
43
103
skipDoc : true ,
44
104
document : `{a: 1, b: 2, c: 3}` ,
0 commit comments