github.com/solo-io/cue@v0.4.7/internal/core/export/testdata/adt.txtar (about) 1 -- in.cue -- 2 import mystrings "strings" 3 4 @foo(bar) 5 6 p1: [X=string]: name: X 7 8 d1: "foo\(bar)": int 9 bar: "bar" 10 11 // XXX: reference not resolving. 12 d2: C="foo\(bar)": { 13 name: "xx" 14 foo: C.name 15 } 16 17 bytes: '\xeb \x1a\xf5\xaa\xf0\xd6\x06)' 18 19 c1: mystrings.Contains("aa", "a") 20 21 s1: """ 22 multi 23 \(bar) 24 line 25 """ 26 27 l1: [3, ...int] 28 l2: [...int] 29 l3: [] 30 l4: [1, 2] 31 l5: [1, 3] & { 32 [1, 3] 33 34 #foo: int 35 } 36 37 #foo: int 38 l6: [1, #foo] & { 39 [1, 3] 40 41 #foo: int 42 } 43 44 n1: 1.0 45 n10: 10 46 47 // Ignored comment. 48 49 // t is true 50 t: true 51 52 // Dangling comment. 53 54 e1: <n1 55 e2: >n1 & <n10 56 e3: l4[2] 57 e4: l4[2:3] 58 e5: e1 + e2 - e3 59 e6: !t 60 e7: !t || !false 61 e8?: !false 62 63 m1: {[string]: uint} & { 64 // this is a pattern constraint 65 {[string]: int} & {[string]: int64} 66 // foo is an optional field 67 foo?: 3 68 69 // Dangling comment. 70 71 // bar is a field 72 bar: 4 73 74 // a comment too many. 75 76 ... 77 } 78 79 if true { 80 x: int 81 } 82 83 y1: { 84 src: [1, 2, 3] 85 for i, v in src for j, w in src if i < j { 86 "foo\(i)": v 87 "bar\(j)": w 88 } 89 90 for i, v in src { 91 "foo\(i)": v 92 } 93 94 x: [ 95 for x in src 96 let y = x { 97 y 98 } 99 ] 100 } 101 102 errorStructDef: { 103 a: 1 104 b: 1 & 2 105 106 #Def: 1 107 } 108 109 errorList: [ 110 1, 111 1 & 2, 112 ] 113 114 errorListDef: { 115 errorList 116 117 #Def: 1 118 } 119 120 -- out/definition -- 121 import mystrings "strings" 122 123 @foo(bar) 124 p1: { 125 [X=string]: { 126 name: X 127 } 128 } 129 d1: { 130 "foo\(bar)": int 131 } 132 bar: "bar" 133 d2: { 134 C="foo\(bar)": { 135 name: "xx" 136 foo: C.name 137 } 138 } 139 bytes: '\xeb \x1a\xf5\xaa\xf0\xd6\x06)' 140 c1: mystrings.Contains("aa", "a") 141 s1: """ 142 multi 143 \(bar) 144 line 145 """ 146 l1: [3, ...int] 147 l2: [...int] 148 l3: [] 149 l4: [1, 2] 150 l5: [1, 3] & { 151 [1, 3] 152 #foo: int 153 } 154 #foo: int 155 l6: [1, #foo] & { 156 [1, 3] 157 #foo: int 158 } 159 n1: 1.0 160 n10: 10 161 t: true 162 e1: <n1 163 e2: >n1 & <n10 164 e3: l4[2] 165 e4: l4[2:3] 166 e5: e1 + e2 - e3 167 e6: !t 168 e7: !t || !false 169 e8?: !false 170 m1: { 171 [string]: int & >=0 172 } & { 173 { 174 [string]: int 175 } & { 176 [string]: int64 177 } 178 179 // foo is an optional field 180 foo?: 3 181 182 // bar is a field 183 bar: 4 184 ... 185 } 186 if true { 187 x: int 188 } 189 y1: { 190 src: [1, 2, 3] 191 for i, v in src for j, w in src if i < j { 192 "foo\(i)": v 193 "bar\(j)": w 194 } 195 for i, v in src { 196 "foo\(i)": v 197 } 198 x: [ for x in src let y = x { 199 y 200 }] 201 } 202 errorStructDef: { 203 a: 1 204 b: _|_ // conflicting values 2 and 1 205 #Def: 1 206 } 207 errorList: [1, 1 & 2] 208 errorListDef: { 209 errorList 210 #Def: 1 211 } 212 -- out/doc -- 213 [] 214 [p1] 215 [d1] 216 [d1 foobar] 217 [bar] 218 [d2] 219 - XXX: reference not resolving. 220 221 [d2 foobar] 222 [d2 foobar name] 223 [d2 foobar foo] 224 [bytes] 225 [c1] 226 [s1] 227 [l1] 228 [l1 0] 229 [l2] 230 [l3] 231 [l4] 232 [l4 0] 233 [l4 1] 234 [l5] 235 [l5 #foo] 236 [l5 0] 237 [l5 1] 238 [#foo] 239 [l6] 240 [l6 #foo] 241 [l6 0] 242 [l6 1] 243 [n1] 244 [n10] 245 [t] 246 - t is true 247 248 [e1] 249 [e2] 250 [e3] 251 [e4] 252 [e5] 253 [e6] 254 [e7] 255 [m1] 256 [m1 bar] 257 - bar is a field 258 259 [y1] 260 [y1 src] 261 [y1 src 0] 262 [y1 src 1] 263 [y1 src 2] 264 [y1 x] 265 [y1 x 0] 266 [y1 x 1] 267 [y1 x 2] 268 [y1 foo0] 269 [y1 bar1] 270 [y1 bar2] 271 [y1 foo1] 272 [y1 foo2] 273 [errorStructDef] 274 [errorStructDef a] 275 [errorStructDef b] 276 [errorStructDef #Def] 277 [errorList] 278 [errorList 0] 279 [errorList 1] 280 [errorListDef] 281 [errorListDef #Def] 282 [errorListDef 0] 283 [errorListDef 1] 284 [x] 285 -- out/value -- 286 == Simplified 287 _|_ // e3: index out of range [2] with length 2 288 == Raw 289 _|_ // e3: index out of range [2] with length 2 290 == Final 291 _|_ // e3: index out of range [2] with length 2 292 == All 293 { 294 @foo(bar) 295 p1: {} 296 d1: { 297 foobar: int 298 } 299 bar: "bar" 300 301 // XXX: reference not resolving. 302 d2: { 303 foobar: { 304 name: "xx" 305 foo: "xx" 306 } 307 } 308 bytes: '\xeb \x1a\xf5\xaa\xf0\xd6\x06)' 309 c1: true 310 s1: """ 311 multi 312 bar 313 line 314 """ 315 l1: [3] 316 l2: [] 317 l3: [] 318 l4: [1, 2] 319 l5: { 320 #foo: int 321 [1, 3] 322 } 323 #foo: int 324 l6: { 325 #foo: int 326 [1, 3] 327 } 328 n1: 1.0 329 n10: 10 330 331 // t is true 332 t: true 333 e1: <1.0 334 e2: >1.0 & <10 335 e3: _|_ // e3: index out of range [2] with length 2 336 e4: _|_ // e4: index 3 out of range 337 e5: _|_ // e3: index out of range [2] with length 2 338 e6: false 339 e7: true 340 e8?: true 341 m1: { 342 // foo is an optional field 343 foo?: 3 344 345 // bar is a field 346 bar: 4 347 } 348 y1: { 349 src: [1, 2, 3] 350 foo0: 1 351 bar1: 2 352 bar2: 3 353 foo1: 2 354 x: [1, 2, 3] 355 foo2: 3 356 } 357 errorStructDef: { 358 a: 1 359 b: _|_ // errorStructDef.b: conflicting values 2 and 1 360 #Def: 1 361 } 362 errorList: [1, _|_] 363 x: int 364 errorListDef: { 365 #Def: 1 366 [1, _|_] 367 } 368 } 369 == Eval 370 _|_ // e3: index out of range [2] with length 2