cuelang.org/go@v0.10.1/cue/testdata/disjunctions/operands.txtar (about)

     1  # This file tests disjunctions used as operands.
     2  
     3  -- in.cue --
     4  list:      *[1] | [2]
     5  condition: *true | false
     6  num:       *1 | 2
     7  object:    *{a: 1} | {a: 2}
     8  
     9  forLoop: [
    10  	for e in list {
    11  		"count: \(e)"
    12  	},
    13  ]
    14  
    15  conditional: {
    16  	if condition {
    17  		a: 3
    18  	}
    19  	if num < 5 {
    20  		b: 3
    21  	}
    22  }
    23  
    24  selector: {
    25  	a: object.a
    26  }
    27  
    28  index: {
    29  	a: list[0]
    30  }
    31  
    32  binOp: {
    33  	a: num + 4
    34  }
    35  
    36  unaryOp: {
    37  	a: -num
    38  }
    39  -- out/eval/stats --
    40  Leaks:  0
    41  Freed:  30
    42  Reused: 25
    43  Allocs: 5
    44  Retain: 0
    45  
    46  Unifications: 22
    47  Conjuncts:    33
    48  Disjuncts:    30
    49  -- out/eval --
    50  (struct){
    51    list: (list){ |(*(#list){
    52        0: (int){ 1 }
    53      }, (#list){
    54        0: (int){ 2 }
    55      }) }
    56    condition: (bool){ |(*(bool){ true }, (bool){ false }) }
    57    num: (int){ |(*(int){ 1 }, (int){ 2 }) }
    58    object: (struct){ |(*(struct){
    59        a: (int){ 1 }
    60      }, (struct){
    61        a: (int){ 2 }
    62      }) }
    63    forLoop: (#list){
    64      0: (string){ "count: 1" }
    65    }
    66    conditional: (struct){
    67      a: (int){ 3 }
    68      b: (int){ 3 }
    69    }
    70    selector: (struct){
    71      a: (int){ 1 }
    72    }
    73    index: (struct){
    74      a: (int){ 1 }
    75    }
    76    binOp: (struct){
    77      a: (int){ 5 }
    78    }
    79    unaryOp: (struct){
    80      a: (int){ -1 }
    81    }
    82  }
    83  -- out/compile --
    84  --- in.cue
    85  {
    86    list: (*[
    87      1,
    88    ]|[
    89      2,
    90    ])
    91    condition: (*true|false)
    92    num: (*1|2)
    93    object: (*{
    94      a: 1
    95    }|{
    96      a: 2
    97    })
    98    forLoop: [
    99      for _, e in 〈1;list〉 {
   100        "count: \(〈1;e〉)"
   101      },
   102    ]
   103    conditional: {
   104      if 〈1;condition〉 {
   105        a: 3
   106      }
   107      if (〈1;num〉 < 5) {
   108        b: 3
   109      }
   110    }
   111    selector: {
   112      a: 〈1;object〉.a
   113    }
   114    index: {
   115      a: 〈1;list〉[0]
   116    }
   117    binOp: {
   118      a: (〈1;num〉 + 4)
   119    }
   120    unaryOp: {
   121      a: -〈1;num〉
   122    }
   123  }