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