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

     1  -- in.cue --
     2  given: {
     3  	INC: USD: 2.0
     4  	USD: GBP: 3.0
     5  }
     6  hydrated: {
     7  	for k,v in given {
     8  		for k1,r in v {
     9  			"\(k)": "\(k)":  1.0
    10  			"\(k1)": "\(k1)": 1.0
    11  			"\(k)": "\(k1)": r
    12  			"\(k1)": "\(k)": number
    13  		}
    14  	}
    15  }
    16  
    17  foo: {
    18      a: 10
    19      if a < 20 {
    20          if a < 50 {
    21              b: 20
    22          }
    23      }
    24  }
    25  -- out/eval --
    26  (struct){
    27    given: (struct){
    28      INC: (struct){
    29        USD: (float){ 2.0 }
    30      }
    31      USD: (struct){
    32        GBP: (float){ 3.0 }
    33      }
    34    }
    35    hydrated: (struct){
    36      INC: (struct){
    37        INC: (float){ 1.0 }
    38        USD: (float){ 2.0 }
    39      }
    40      USD: (struct){
    41        USD: (float){ 1.0 }
    42        INC: (number){ number }
    43        GBP: (float){ 3.0 }
    44      }
    45      GBP: (struct){
    46        GBP: (float){ 1.0 }
    47        USD: (number){ number }
    48      }
    49    }
    50    foo: (struct){
    51      a: (int){ 10 }
    52      b: (int){ 20 }
    53    }
    54  }
    55  -- out/compile --
    56  --- in.cue
    57  {
    58    given: {
    59      INC: {
    60        USD: 2.0
    61      }
    62      USD: {
    63        GBP: 3.0
    64      }
    65    }
    66    hydrated: {
    67      for k, v in 〈1;given〉 {
    68        for k1, r in 〈1;v〉 {
    69          "\(〈3;k〉)": {
    70            "\(〈4;k〉)": 1.0
    71          }
    72          "\(〈1;k1〉)": {
    73            "\(〈2;k1〉)": 1.0
    74          }
    75          "\(〈3;k〉)": {
    76            "\(〈2;k1〉)": 〈2;r〉
    77          }
    78          "\(〈1;k1〉)": {
    79            "\(〈4;k〉)": number
    80          }
    81        }
    82      }
    83    }
    84    foo: {
    85      a: 10
    86      if (〈0;a〉 < 20) {
    87        if (〈1;a〉 < 50) {
    88          b: 20
    89        }
    90      }
    91    }
    92  }