this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

internal/core/adt: add tests for issue 3763

Issue #3763

Signed-off-by: Marcel van Lohuizen <mpvl@gmail.com>
Change-Id: Ib4c4e245654bb88f2ad8db58814c71dfdf538834
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1210976
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>

+376 -1
+374
cue/testdata/comprehensions/issue3763.txtar
··· 1 + -- reduced.cue -- 2 + reduced: { 3 + A: x1: y?: int // needs to be optional 4 + A: x2: y?: int 5 + A: x3: y?: int 6 + 7 + if true { 8 + let Z = [for _, x in A {x}] 9 + B: [for z in Z if z.y != _|_ { b: 1 }] 10 + } 11 + } 12 + -- full.cue -- 13 + full: { 14 + _core_v1: { 15 + #cp: { 16 + hostPort?: int32 17 + cp: int32 18 + } 19 + } 20 + 21 + k: n: n1: { 22 + _CL: "l" 23 + } 24 + 25 + let nc = { 26 + _ports: [ID=_]: _core_v1.#cp 27 + } 28 + 29 + _cl: [ID=_]: nc & { 30 + _ports: { 31 + "1": {} 32 + "2": {} 33 + "3": {} 34 + } 35 + } 36 + 37 + k: n: [ID=_]: { 38 + _CL: string 39 + _cs: (_CL): _cl[(_CL)] 40 + } 41 + 42 + for _, n in k.n { 43 + let cps = [for _, c in n._cs for _, cps in c._ports {cps}] 44 + ports: [for cp in cps if cp.hostPort != _|_ { 45 + port: "\(cp.hostPort)" 46 + }] 47 + } 48 + 49 + _cl: l: {} 50 + } 51 + -- out/eval/stats -- 52 + Leaks: 4 53 + Freed: 66 54 + Reused: 58 55 + Allocs: 12 56 + Retain: 10 57 + 58 + Unifications: 70 59 + Conjuncts: 129 60 + Disjuncts: 76 61 + -- out/evalalpha -- 62 + (struct){ 63 + full: (struct){ 64 + _core_v1: (struct){ 65 + #cp: (#struct){ 66 + hostPort?: (int){ &(>=-2147483648, <=2147483647, int) } 67 + cp: (int){ &(>=-2147483648, <=2147483647, int) } 68 + } 69 + } 70 + k: (struct){ 71 + n: (struct){ 72 + n1: (struct){ 73 + _CL: (string){ "l" } 74 + _cs: (struct){ 75 + l: ~(full._cl.l) 76 + } 77 + } 78 + } 79 + } 80 + let nc#1 = (struct){ 81 + _ports: (struct){ 82 + } 83 + } 84 + _cl: (struct){ 85 + l: (struct){ 86 + _ports: (struct){ 87 + "1": (#struct){ 88 + hostPort?: (int){ &(>=-2147483648, <=2147483647, int) } 89 + cp: (int){ &(>=-2147483648, <=2147483647, int) } 90 + } 91 + "2": (#struct){ 92 + hostPort?: (int){ &(>=-2147483648, <=2147483647, int) } 93 + cp: (int){ &(>=-2147483648, <=2147483647, int) } 94 + } 95 + "3": (#struct){ 96 + hostPort?: (int){ &(>=-2147483648, <=2147483647, int) } 97 + cp: (int){ &(>=-2147483648, <=2147483647, int) } 98 + } 99 + } 100 + } 101 + } 102 + let cps#2multi = [ 103 + for _, c in 〈2;n〉._cs for _, cps in 〈0;c〉._ports { 104 + 〈1;cps〉 105 + }, 106 + ] 107 + ports: (list){ list } 108 + } 109 + reduced: (struct){ 110 + A: (struct){ 111 + x1: (struct){ 112 + y?: (int){ int } 113 + } 114 + x2: (struct){ 115 + y?: (int){ int } 116 + } 117 + x3: (struct){ 118 + y?: (int){ int } 119 + } 120 + } 121 + let Z#3multi = [ 122 + for _, x in 〈2;A〉 { 123 + 〈1;x〉 124 + }, 125 + ] 126 + B: (list){ list } 127 + } 128 + } 129 + -- diff/-out/evalalpha<==>+out/eval -- 130 + diff old new 131 + --- old 132 + +++ new 133 + @@ -11,22 +11,7 @@ 134 + n1: (struct){ 135 + _CL: (string){ "l" } 136 + _cs: (struct){ 137 + - l: (struct){ 138 + - _ports: (struct){ 139 + - "1": (#struct){ 140 + - hostPort?: (int){ &(>=-2147483648, <=2147483647, int) } 141 + - cp: (int){ &(>=-2147483648, <=2147483647, int) } 142 + - } 143 + - "2": (#struct){ 144 + - hostPort?: (int){ &(>=-2147483648, <=2147483647, int) } 145 + - cp: (int){ &(>=-2147483648, <=2147483647, int) } 146 + - } 147 + - "3": (#struct){ 148 + - hostPort?: (int){ &(>=-2147483648, <=2147483647, int) } 149 + - cp: (int){ &(>=-2147483648, <=2147483647, int) } 150 + - } 151 + - } 152 + - } 153 + + l: ~(full._cl.l) 154 + } 155 + } 156 + } 157 + @@ -58,8 +43,7 @@ 158 + 〈1;cps〉 159 + }, 160 + ] 161 + - ports: (#list){ 162 + - } 163 + + ports: (list){ list } 164 + } 165 + reduced: (struct){ 166 + A: (struct){ 167 + @@ -73,18 +57,11 @@ 168 + y?: (int){ int } 169 + } 170 + } 171 + - let Z#3 = (#list){ 172 + - 0: (struct){ 173 + - y?: (int){ int } 174 + - } 175 + - 1: (struct){ 176 + - y?: (int){ int } 177 + - } 178 + - 2: (struct){ 179 + - y?: (int){ int } 180 + - } 181 + - } 182 + - B: (#list){ 183 + - } 184 + + let Z#3multi = [ 185 + + for _, x in 〈2;A〉 { 186 + + 〈1;x〉 187 + + }, 188 + + ] 189 + + B: (list){ list } 190 + } 191 + } 192 + -- diff/todo/p1 -- 193 + full.ports|reduced.B: incomplete value (list) 194 + -- out/eval -- 195 + (struct){ 196 + full: (struct){ 197 + _core_v1: (struct){ 198 + #cp: (#struct){ 199 + hostPort?: (int){ &(>=-2147483648, <=2147483647, int) } 200 + cp: (int){ &(>=-2147483648, <=2147483647, int) } 201 + } 202 + } 203 + k: (struct){ 204 + n: (struct){ 205 + n1: (struct){ 206 + _CL: (string){ "l" } 207 + _cs: (struct){ 208 + l: (struct){ 209 + _ports: (struct){ 210 + "1": (#struct){ 211 + hostPort?: (int){ &(>=-2147483648, <=2147483647, int) } 212 + cp: (int){ &(>=-2147483648, <=2147483647, int) } 213 + } 214 + "2": (#struct){ 215 + hostPort?: (int){ &(>=-2147483648, <=2147483647, int) } 216 + cp: (int){ &(>=-2147483648, <=2147483647, int) } 217 + } 218 + "3": (#struct){ 219 + hostPort?: (int){ &(>=-2147483648, <=2147483647, int) } 220 + cp: (int){ &(>=-2147483648, <=2147483647, int) } 221 + } 222 + } 223 + } 224 + } 225 + } 226 + } 227 + } 228 + let nc#1 = (struct){ 229 + _ports: (struct){ 230 + } 231 + } 232 + _cl: (struct){ 233 + l: (struct){ 234 + _ports: (struct){ 235 + "1": (#struct){ 236 + hostPort?: (int){ &(>=-2147483648, <=2147483647, int) } 237 + cp: (int){ &(>=-2147483648, <=2147483647, int) } 238 + } 239 + "2": (#struct){ 240 + hostPort?: (int){ &(>=-2147483648, <=2147483647, int) } 241 + cp: (int){ &(>=-2147483648, <=2147483647, int) } 242 + } 243 + "3": (#struct){ 244 + hostPort?: (int){ &(>=-2147483648, <=2147483647, int) } 245 + cp: (int){ &(>=-2147483648, <=2147483647, int) } 246 + } 247 + } 248 + } 249 + } 250 + let cps#2multi = [ 251 + for _, c in 〈2;n〉._cs for _, cps in 〈0;c〉._ports { 252 + 〈1;cps〉 253 + }, 254 + ] 255 + ports: (#list){ 256 + } 257 + } 258 + reduced: (struct){ 259 + A: (struct){ 260 + x1: (struct){ 261 + y?: (int){ int } 262 + } 263 + x2: (struct){ 264 + y?: (int){ int } 265 + } 266 + x3: (struct){ 267 + y?: (int){ int } 268 + } 269 + } 270 + let Z#3 = (#list){ 271 + 0: (struct){ 272 + y?: (int){ int } 273 + } 274 + 1: (struct){ 275 + y?: (int){ int } 276 + } 277 + 2: (struct){ 278 + y?: (int){ int } 279 + } 280 + } 281 + B: (#list){ 282 + } 283 + } 284 + } 285 + -- out/compile -- 286 + --- full.cue 287 + { 288 + full: { 289 + _core_v1: { 290 + #cp: { 291 + hostPort?: &(int, >=-2147483648, <=2147483647) 292 + cp: &(int, >=-2147483648, <=2147483647) 293 + } 294 + } 295 + k: { 296 + n: { 297 + n1: { 298 + _CL: "l" 299 + } 300 + } 301 + } 302 + let nc#1 = { 303 + _ports: { 304 + [_]: 〈2;_core_v1〉.#cp 305 + } 306 + } 307 + _cl: { 308 + [_]: (〈1;let nc#1〉 & { 309 + _ports: { 310 + "1": {} 311 + "2": {} 312 + "3": {} 313 + } 314 + }) 315 + } 316 + k: { 317 + n: { 318 + [_]: { 319 + _CL: string 320 + _cs: { 321 + 〈1;_CL〉: 〈4;_cl〉[〈1;_CL〉] 322 + } 323 + } 324 + } 325 + } 326 + for _, n in 〈0;k〉.n { 327 + let cps#2multi = [ 328 + for _, c in 〈2;n〉._cs for _, cps in 〈0;c〉._ports { 329 + 〈1;cps〉 330 + }, 331 + ] 332 + ports: [ 333 + for _, cp in 〈1;let cps#2〉 if (〈0;cp〉.hostPort != _|_(explicit error (_|_ literal) in source)) { 334 + port: "\(〈1;cp〉.hostPort)" 335 + }, 336 + ] 337 + } 338 + _cl: { 339 + l: {} 340 + } 341 + } 342 + } 343 + --- reduced.cue 344 + { 345 + reduced: { 346 + A: { 347 + x1: { 348 + y?: int 349 + } 350 + } 351 + A: { 352 + x2: { 353 + y?: int 354 + } 355 + } 356 + A: { 357 + x3: { 358 + y?: int 359 + } 360 + } 361 + if true { 362 + let Z#3 = [ 363 + for _, x in 〈2;A〉 { 364 + 〈1;x〉 365 + }, 366 + ] 367 + B: [ 368 + for _, z in 〈1;let Z#3〉 if (〈0;z〉.y != _|_(explicit error (_|_ literal) in source)) { 369 + b: 1 370 + }, 371 + ] 372 + } 373 + } 374 + }
+2 -1
internal/core/adt/eval_test.go
··· 98 98 // "comprehensions/issue1732": 8, 99 99 // "comprehensions/issue287": 3, 100 100 // "comprehensions/issue3762": 38, 101 - "comprehensions/issue843": 1, // 2, 101 + "comprehensions/issue3763": 2, 102 + "comprehensions/issue843": 1, // 2, 102 103 // "comprehensions/nested2": 38, 103 104 // "comprehensions/pushdown": 46, 104 105 // "cycle/023_reentrance": 1,