github.com/solo-io/cue@v0.4.7/cue/testdata/comprehensions/015_list_comprehension.txtar (about)

     1  # DO NOT EDIT; generated by go run testdata/gen.go
     2  #
     3  #name: list comprehension
     4  #evalFull
     5  -- in.cue --
     6  a: [ for k, v in b if k < "d" if v > b.a {k}]
     7  b: {
     8  	a: 1
     9  	b: 2
    10  	c: 3
    11  	d: 4
    12  }
    13  c: [ for _, x in b for _, y in b if x < y {x}]
    14  d: [ for x, _ in a {x}]
    15  -- out/def --
    16  a: ["b", "c"]
    17  b: {
    18  	a: 1
    19  	b: 2
    20  	c: 3
    21  	d: 4
    22  }
    23  c: [1, 1, 1, 2, 2, 3]
    24  d: [0, 1]
    25  -- out/export --
    26  a: ["b", "c"]
    27  b: {
    28  	a: 1
    29  	b: 2
    30  	c: 3
    31  	d: 4
    32  }
    33  c: [1, 1, 1, 2, 2, 3]
    34  d: [0, 1]
    35  -- out/yaml --
    36  a:
    37  - b
    38  - c
    39  b:
    40    a: 1
    41    b: 2
    42    c: 3
    43    d: 4
    44  c:
    45  - 1
    46  - 1
    47  - 1
    48  - 2
    49  - 2
    50  - 3
    51  d:
    52  - 0
    53  - 1
    54  -- out/json --
    55  {"a":["b","c"],"b":{"a":1,"b":2,"c":3,"d":4},"c":[1,1,1,2,2,3],"d":[0,1]}
    56  -- out/legacy-debug --
    57  <0>{a: ["b","c"], b: <1>{a: 1, b: 2, c: 3, d: 4}, c: [1,1,1,2,2,3], d: [0,1]}
    58  -- out/compile --
    59  --- in.cue
    60  {
    61    a: [
    62      for k, v in 〈0;b〉 if (〈0;k〉 < "d") if (〈0;v〉 > 〈1;b〉.a) {
    63        〈1;k〉
    64      },
    65    ]
    66    b: {
    67      a: 1
    68      b: 2
    69      c: 3
    70      d: 4
    71    }
    72    c: [
    73      for _, x in 〈0;b〉 for _, y in 〈1;b〉 if (〈1;x〉 < 〈0;y〉) {
    74        〈2;x〉
    75      },
    76    ]
    77    d: [
    78      for x, _ in 〈0;a〉 {
    79        〈1;x〉
    80      },
    81    ]
    82  }
    83  -- out/eval --
    84  (struct){
    85    a: (#list){
    86      0: (string){ "b" }
    87      1: (string){ "c" }
    88    }
    89    b: (struct){
    90      a: (int){ 1 }
    91      b: (int){ 2 }
    92      c: (int){ 3 }
    93      d: (int){ 4 }
    94    }
    95    c: (#list){
    96      0: (int){ 1 }
    97      1: (int){ 1 }
    98      2: (int){ 1 }
    99      3: (int){ 2 }
   100      4: (int){ 2 }
   101      5: (int){ 3 }
   102    }
   103    d: (#list){
   104      0: (int){ 0 }
   105      1: (int){ 1 }
   106    }
   107  }