cuelang.org/go@v0.13.0/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  
    26  indirectlyNested: {
    27  	a: true // must be declared outside of the nested comprehensions for test.
    28  	if true {
    29  		b: {
    30  			if a {
    31  				a
    32  			}
    33  		}
    34  	}
    35  }
    36  
    37  directlyNestedEmpty: {
    38  	a: true
    39  	if true {
    40  		if a {
    41  		}
    42  	}
    43  }
    44  
    45  directlyDoublyNestedEmpty: {
    46  	a: true 
    47  	if true {
    48  		if a {
    49  		}
    50  	}
    51  }
    52  
    53  indirectlyDoublyNestedEmpty: {
    54  	a: true
    55  	b: {
    56  		if true {
    57  			if a {
    58  				if a {
    59  					a
    60  				}
    61  			}
    62  			if a {
    63  				a
    64  			}
    65  		}
    66  	}
    67  }
    68  
    69  indirectlyDoublyNested: {
    70  	a: true
    71  	if true {
    72  		if a {
    73  			if a {
    74  				b: 1
    75  			}
    76  		}
    77  		if a {
    78  			c: 1
    79  		}
    80  	}
    81  }
    82  
    83  // This case used to trigger an over-aggressive deduplication.
    84  issue1974: {
    85  	X: {
    86  		foo: {
    87  			bar: ""
    88  			baz: ""
    89  		}
    90  	}
    91  	out: {
    92  		for k, v in X for vk, vv in v {
    93  			"\(k)": "\(vk)": vv
    94  		}
    95  	}
    96  }
    97  -- pending.cue --
    98  // Trigger notification while an arc is still pending.
    99  T: int
   100  for C in Y {
   101  	let X = C.M
   102  	T:  X.V
   103  }
   104  Y: x: {
   105  	M: V: 1
   106  	for _ in M {
   107  		if true { M: {} }
   108  	}
   109  }
   110  -- out/eval/stats --
   111  Leaks:  2
   112  Freed:  50
   113  Reused: 45
   114  Allocs: 7
   115  Retain: 12
   116  
   117  Unifications: 52
   118  Conjuncts:    91
   119  Disjuncts:    57
   120  -- out/eval --
   121  (struct){
   122    given: (struct){
   123      INC: (struct){
   124        USD: (float){ 2.0 }
   125      }
   126      USD: (struct){
   127        GBP: (float){ 3.0 }
   128      }
   129    }
   130    hydrated: (struct){
   131      INC: (struct){
   132        INC: (float){ 1.0 }
   133        USD: (float){ 2.0 }
   134      }
   135      USD: (struct){
   136        USD: (float){ 1.0 }
   137        INC: (number){ number }
   138        GBP: (float){ 3.0 }
   139      }
   140      GBP: (struct){
   141        GBP: (float){ 1.0 }
   142        USD: (number){ number }
   143      }
   144    }
   145    foo: (struct){
   146      a: (int){ 10 }
   147      b: (int){ 20 }
   148    }
   149    indirectlyNested: (struct){
   150      a: (bool){ true }
   151      b: (bool){ true }
   152    }
   153    directlyNestedEmpty: (struct){
   154      a: (bool){ true }
   155    }
   156    directlyDoublyNestedEmpty: (struct){
   157      a: (bool){ true }
   158    }
   159    indirectlyDoublyNestedEmpty: (struct){
   160      a: (bool){ true }
   161      b: (bool){ true }
   162    }
   163    indirectlyDoublyNested: (struct){
   164      a: (bool){ true }
   165      c: (int){ 1 }
   166      b: (int){ 1 }
   167    }
   168    issue1974: (struct){
   169      X: (struct){
   170        foo: (struct){
   171          bar: (string){ "" }
   172          baz: (string){ "" }
   173        }
   174      }
   175      out: (struct){
   176        foo: (struct){
   177          bar: (string){ "" }
   178          baz: (string){ "" }
   179        }
   180      }
   181    }
   182    T: (int){ 1 }
   183    let X#1multi = 〈1;C〉.M
   184    Y: (struct){
   185      x: (struct){
   186        M: (struct){
   187          V: (int){ 1 }
   188        }
   189      }
   190    }
   191  }
   192  -- out/compile --
   193  --- in.cue
   194  {
   195    given: {
   196      INC: {
   197        USD: 2.0
   198      }
   199      USD: {
   200        GBP: 3.0
   201      }
   202    }
   203    hydrated: {
   204      for k, v in 〈1;given〉 {
   205        for k1, r in 〈1;v〉 {
   206          "\(〈3;k〉)": {
   207            "\(〈4;k〉)": 1.0
   208          }
   209          "\(〈1;k1〉)": {
   210            "\(〈2;k1〉)": 1.0
   211          }
   212          "\(〈3;k〉)": {
   213            "\(〈2;k1〉)": 〈2;r〉
   214          }
   215          "\(〈1;k1〉)": {
   216            "\(〈4;k〉)": number
   217          }
   218        }
   219      }
   220    }
   221    foo: {
   222      a: 10
   223      if (〈0;a〉 < 20) {
   224        if (〈1;a〉 < 50) {
   225          b: 20
   226        }
   227      }
   228    }
   229    indirectlyNested: {
   230      a: true
   231      if true {
   232        b: {
   233          if 〈2;a〉 {
   234            〈3;a〉
   235          }
   236        }
   237      }
   238    }
   239    directlyNestedEmpty: {
   240      a: true
   241      if true {
   242        if 〈1;a〉 {}
   243      }
   244    }
   245    directlyDoublyNestedEmpty: {
   246      a: true
   247      if true {
   248        if 〈1;a〉 {}
   249      }
   250    }
   251    indirectlyDoublyNestedEmpty: {
   252      a: true
   253      b: {
   254        if true {
   255          if 〈2;a〉 {
   256            if 〈3;a〉 {
   257              〈4;a〉
   258            }
   259          }
   260          if 〈2;a〉 {
   261            〈3;a〉
   262          }
   263        }
   264      }
   265    }
   266    indirectlyDoublyNested: {
   267      a: true
   268      if true {
   269        if 〈1;a〉 {
   270          if 〈2;a〉 {
   271            b: 1
   272          }
   273        }
   274        if 〈1;a〉 {
   275          c: 1
   276        }
   277      }
   278    }
   279    issue1974: {
   280      X: {
   281        foo: {
   282          bar: ""
   283          baz: ""
   284        }
   285      }
   286      out: {
   287        for k, v in 〈1;X〉 for vk, vv in 〈0;v〉 {
   288          "\(〈2;k〉)": {
   289            "\(〈2;vk〉)": 〈2;vv〉
   290          }
   291        }
   292      }
   293    }
   294  }
   295  --- pending.cue
   296  {
   297    T: int
   298    for _, C in 〈0;Y〉 {
   299      let X#1multi = 〈1;C〉.M
   300      T: 〈0;let X#1〉.V
   301    }
   302    Y: {
   303      x: {
   304        M: {
   305          V: 1
   306        }
   307        for _, _ in 〈0;M〉 {
   308          if true {
   309            M: {}
   310          }
   311        }
   312      }
   313    }
   314  }