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