cuelang.org/go@v0.13.0/cue/testdata/comprehensions/nestembed.txtar (about)

     1  Issue #556
     2  
     3  -- in.cue --
     4  import "list"
     5  
     6  DeleteThis: ["this", "that"]
     7  useful_infra: {
     8  	gcp: cluters:   10
     9  	aws: clusters:  20
    10  	this: clusters: 1
    11  	that: clusters: 2
    12  }
    13  New_infra: {
    14  	for k, v in useful_infra {
    15  		if !list.Contains(DeleteThis, k) {
    16  			"\(k)": v
    17  		}
    18  	}
    19  }
    20  -- out/eval/stats --
    21  Leaks:  0
    22  Freed:  18
    23  Reused: 14
    24  Allocs: 4
    25  Retain: 0
    26  
    27  Unifications: 18
    28  Conjuncts:    26
    29  Disjuncts:    18
    30  -- out/evalalpha --
    31  (struct){
    32    DeleteThis: (#list){
    33      0: (string){ "this" }
    34      1: (string){ "that" }
    35    }
    36    useful_infra: (struct){
    37      gcp: (struct){
    38        cluters: (int){ 10 }
    39      }
    40      aws: (struct){
    41        clusters: (int){ 20 }
    42      }
    43      this: (struct){
    44        clusters: (int){ 1 }
    45      }
    46      that: (struct){
    47        clusters: (int){ 2 }
    48      }
    49    }
    50    New_infra: (struct){
    51      gcp: ~(useful_infra.gcp)
    52      aws: ~(useful_infra.aws)
    53    }
    54  }
    55  -- diff/-out/evalalpha<==>+out/eval --
    56  diff old new
    57  --- old
    58  +++ new
    59  @@ -18,11 +18,7 @@
    60       }
    61     }
    62     New_infra: (struct){
    63  -    gcp: (struct){
    64  -      cluters: (int){ 10 }
    65  -    }
    66  -    aws: (struct){
    67  -      clusters: (int){ 20 }
    68  -    }
    69  +    gcp: ~(useful_infra.gcp)
    70  +    aws: ~(useful_infra.aws)
    71     }
    72   }
    73  -- out/eval --
    74  (struct){
    75    DeleteThis: (#list){
    76      0: (string){ "this" }
    77      1: (string){ "that" }
    78    }
    79    useful_infra: (struct){
    80      gcp: (struct){
    81        cluters: (int){ 10 }
    82      }
    83      aws: (struct){
    84        clusters: (int){ 20 }
    85      }
    86      this: (struct){
    87        clusters: (int){ 1 }
    88      }
    89      that: (struct){
    90        clusters: (int){ 2 }
    91      }
    92    }
    93    New_infra: (struct){
    94      gcp: (struct){
    95        cluters: (int){ 10 }
    96      }
    97      aws: (struct){
    98        clusters: (int){ 20 }
    99      }
   100    }
   101  }
   102  -- out/compile --
   103  --- in.cue
   104  {
   105    DeleteThis: [
   106      "this",
   107      "that",
   108    ]
   109    useful_infra: {
   110      gcp: {
   111        cluters: 10
   112      }
   113      aws: {
   114        clusters: 20
   115      }
   116      this: {
   117        clusters: 1
   118      }
   119      that: {
   120        clusters: 2
   121      }
   122    }
   123    New_infra: {
   124      for k, v in 〈1;useful_infra〉 {
   125        if !〈import;list〉.Contains(〈3;DeleteThis〉, 〈1;k〉) {
   126          "\(〈2;k〉)": 〈2;v〉
   127        }
   128      }
   129    }
   130  }