cuelang.org/go@v0.13.0/pkg/list/testdata/list.txtar (about) 1 -- in.cue -- 2 import "list" 3 4 repeat: { 5 [string]: {x: _, n: int, v: list.Repeat(x, n)} 6 7 t1: {x: [], n: 0} 8 t2: {x: [1], n: 0} 9 10 t3: {x: [1], n: 1} 11 t4: {x: [1, 2], n: 1} 12 13 t5: {x: [], n: 3} 14 t6: {x: [1, 2], n: 3} 15 t7: {x: [1, 2, 3, 4], n: 3} 16 17 t8: {x: [1], n: -1} 18 } 19 concat: { 20 [string]: {x: _, v: list.Concat(x)} 21 22 t1: x: [] 23 t2: x: [[]] 24 25 t3: x: [[1]] 26 t4: x: [[1, 2]] 27 t5: x: [[1], [2]] 28 29 t6: x: [[1, 2], [3, 4]] 30 31 t7: x: 1 32 t8: x: [1, [2]] 33 } 34 unique: { 35 issue797: { 36 mylst: [ 37 {foo: "bar"}, 38 {foo: "baz"}, 39 ] 40 41 _testmylst: list.UniqueItems & [ for x in mylst {x.foo}] 42 } 43 } 44 // Issue #2099 45 minItems: { 46 [string]: list.MinItems(1) 47 incomplete1: [...] 48 fail1: [] 49 ok1: [0, ...] 50 ok2: [0] 51 } 52 53 maxItems: { 54 [string]: list.MaxItems(1) 55 ok1: [...] 56 ok2: [0, ...] 57 ok3: [0, ...] 58 59 fail1: [0, 1] 60 } 61 62 reverse: { 63 [string]: {x: _, v: list.Reverse(x)} 64 65 t1: x: [] 66 t2: x: [1] 67 t3: x: [1, 2, 3, 4] 68 69 fail1: x: 1 70 fail2: x: "bad" 71 } 72 73 -- out/list -- 74 Errors: 75 repeat.t8.v: error in call to list.Repeat: negative count: 76 ./in.cue:4:30 77 concat.t8.v: error in call to list.Concat: cannot use value 1 (type int) as list: 78 ./in.cue:19:22 79 ./in.cue:31:10 80 concat.t7.v: cannot use 1 (type int) as list in argument 1 to list.Concat: 81 ./in.cue:30:9 82 minItems.fail1: invalid value [] (does not satisfy list.MinItems(1)): len(list) < MinItems(1) (0 < 1): 83 ./in.cue:45:12 84 ./in.cue:45:26 85 ./in.cue:47:9 86 maxItems.fail1: invalid value [0,1] (does not satisfy list.MaxItems(1)): len(list) > MaxItems(1) (2 > 1): 87 ./in.cue:53:12 88 ./in.cue:53:26 89 ./in.cue:58:9 90 reverse.fail1.v: cannot use 1 (type int) as list in argument 1 to list.Reverse: 91 ./in.cue:68:15 92 reverse.fail2.v: cannot use "bad" (type string) as list in argument 1 to list.Reverse: 93 ./in.cue:69:15 94 95 Result: 96 import "list" 97 98 repeat: { 99 t1: { 100 x: [] 101 n: 0 102 v: [] 103 } 104 t2: { 105 x: [1] 106 n: 0 107 v: [] 108 } 109 t3: { 110 x: [1] 111 n: 1 112 v: [1] 113 } 114 t4: { 115 x: [1, 2] 116 n: 1 117 v: [1, 2] 118 } 119 t5: { 120 x: [] 121 n: 3 122 v: [] 123 } 124 t6: { 125 x: [1, 2] 126 n: 3 127 v: [1, 2, 1, 2, 1, 2] 128 } 129 t7: { 130 x: [1, 2, 3, 4] 131 n: 3 132 v: [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] 133 } 134 t8: { 135 x: [1] 136 n: -1 137 v: _|_ // repeat.t8.v: error in call to list.Repeat: negative count 138 } 139 } 140 concat: { 141 t1: { 142 x: [] 143 v: [] 144 } 145 t2: { 146 x: [[]] 147 v: [] 148 } 149 t3: { 150 x: [[1]] 151 v: [1] 152 } 153 t4: { 154 x: [[1, 2]] 155 v: [1, 2] 156 } 157 t5: { 158 x: [[1], [2]] 159 v: [1, 2] 160 } 161 t6: { 162 x: [[1, 2], [3, 4]] 163 v: [1, 2, 3, 4] 164 } 165 t7: { 166 x: 1 167 v: _|_ // concat.t7.v: cannot use 1 (type int) as list in argument 1 to list.Concat 168 } 169 t8: { 170 x: [1, [2]] 171 v: _|_ // concat.t8.v: error in call to list.Concat: cannot use value 1 (type int) as list 172 } 173 } 174 unique: { 175 issue797: { 176 mylst: [{ 177 foo: "bar" 178 }, { 179 foo: "baz" 180 }] 181 } 182 } 183 // Issue #2099 184 minItems: { 185 incomplete1: list.MinItems(1) & [...] 186 fail1: _|_ // minItems.fail1: invalid value [] (does not satisfy list.MinItems(1)): len(list) < MinItems(1) (0 < 1) 187 ok1: [0, ...] 188 ok2: [0] 189 } 190 maxItems: { 191 ok1: [...] 192 ok2: [0, ...] 193 ok3: [0, ...] 194 fail1: _|_ // maxItems.fail1: invalid value [0,1] (does not satisfy list.MaxItems(1)): len(list) > MaxItems(1) (2 > 1) 195 } 196 reverse: { 197 t1: { 198 x: [] 199 v: [] 200 } 201 t2: { 202 x: [1] 203 v: [1] 204 } 205 t3: { 206 x: [1, 2, 3, 4] 207 v: [4, 3, 2, 1] 208 } 209 fail1: { 210 x: 1 211 v: _|_ // reverse.fail1.v: cannot use 1 (type int) as list in argument 1 to list.Reverse 212 } 213 fail2: { 214 x: "bad" 215 v: _|_ // reverse.fail2.v: cannot use "bad" (type string) as list in argument 1 to list.Reverse 216 } 217 }