| # DO NOT EDIT; generated by go run testdata/gen.go |
| # |
| #name: optionals with label filters |
| #evalFull |
| -- in.cue -- |
| #JobID: =~"^[a-zA-Z]*$" |
| #Job: { |
| name: string |
| cmd: string |
| } |
| #Jobs: { |
| {[#JobID]: #Job} |
| |
| {[=~"Test$"]: name: =~"^test"}// Must work without ... |
| } |
| |
| jobs: foo: name: "allGood" |
| jobs: foo: name: "allGood" |
| |
| jobs1: #Jobs |
| jobs1: foo1: {} // faulty |
| |
| jobs2: #Jobs |
| jobs2: fooTest: name: "badName" // faulty |
| |
| jobs3: #Jobs |
| jobs3: [string]: #Job |
| jobs3: fooTest1: name: "badName" // faulty |
| -- out/def -- |
| #JobID: =~"^[a-zA-Z]*$" |
| #Job: { |
| name: string |
| cmd: string |
| } |
| #Jobs: { |
| {[#JobID]: #Job} |
| {[=~"Test$"]: { |
| name: =~"^test", ... |
| }} |
| } |
| jobs: { |
| foo: { |
| name: "allGood" |
| } |
| } |
| jobs1: _|_ // field "foo1" not allowed in closed struct |
| jobs2: #Jobs & { |
| fooTest: { |
| name: "badName" |
| } |
| } |
| jobs3: _|_ // field "fooTest1" not allowed in closed struct |
| -- out/legacy-debug -- |
| <0>{#JobID: =~"^[a-zA-Z]*$", #Job: <1>C{name: string, cmd: string}, #Jobs: <2>C{[=~"^[a-zA-Z]*$"]: <3>(_: string)-><4>.#Job, [=~"Test$"]: <5>(_: string)-><6>C{name: =~"^test"}, }, jobs: <7>{foo: <8>{name: "allGood"}}, jobs1: _|_(<9>{}:field "foo1" not allowed in closed struct), jobs2: <10>C{[=~"^[a-zA-Z]*$"]: <11>(_: string)-><4>.#Job, [=~"Test$"]: <12>(_: string)-><13>C{name: =~"^test"}, fooTest: _|_(string:field "cmd" not allowed in closed struct)}, jobs3: _|_(<14>{name: "badName"}:field "fooTest1" not allowed in closed struct)} |
| -- out/compile -- |
| --- in.cue |
| { |
| #JobID: =~"^[a-zA-Z]*$" |
| #Job: { |
| name: string |
| cmd: string |
| } |
| #Jobs: { |
| { |
| [〈2;#JobID〉]: 〈2;#Job〉 |
| } |
| { |
| [=~"Test$"]: { |
| name: =~"^test" |
| } |
| } |
| } |
| jobs: { |
| foo: { |
| name: "allGood" |
| } |
| } |
| jobs: { |
| foo: { |
| name: "allGood" |
| } |
| } |
| jobs1: 〈0;#Jobs〉 |
| jobs1: { |
| foo1: {} |
| } |
| jobs2: 〈0;#Jobs〉 |
| jobs2: { |
| fooTest: { |
| name: "badName" |
| } |
| } |
| jobs3: 〈0;#Jobs〉 |
| jobs3: { |
| [string]: 〈1;#Job〉 |
| } |
| jobs3: { |
| fooTest1: { |
| name: "badName" |
| } |
| } |
| } |
| -- out/eval -- |
| Errors: |
| jobs1: field not allowed: foo1: |
| ./in.cue:6:8 |
| ./in.cue:7:2 |
| ./in.cue:9:2 |
| ./in.cue:15:17 |
| ./in.cue:16:8 |
| jobs3: field not allowed: fooTest1: |
| ./in.cue:6:8 |
| ./in.cue:7:2 |
| ./in.cue:9:2 |
| ./in.cue:21:8 |
| ./in.cue:22:8 |
| ./in.cue:23:8 |
| jobs2.fooTest.name: invalid value "badName" (out of bound =~"^test"): |
| ./in.cue:9:22 |
| ./in.cue:19:23 |
| |
| Result: |
| (_|_){ |
| // [eval] |
| #JobID: (string){ =~"^[a-zA-Z]*$" } |
| #Job: (#struct){ |
| name: (string){ string } |
| cmd: (string){ string } |
| } |
| #Jobs: (#struct){ |
| } |
| jobs: (struct){ |
| foo: (struct){ |
| name: (string){ "allGood" } |
| } |
| } |
| jobs1: (_|_){ |
| // [eval] |
| foo1: (_|_){ |
| // [eval] jobs1: field not allowed: foo1: |
| // ./in.cue:6:8 |
| // ./in.cue:7:2 |
| // ./in.cue:9:2 |
| // ./in.cue:15:17 |
| // ./in.cue:16:8 |
| } |
| } |
| jobs2: (_|_){ |
| // [eval] |
| fooTest: (_|_){ |
| // [eval] |
| name: (_|_){ |
| // [eval] jobs2.fooTest.name: invalid value "badName" (out of bound =~"^test"): |
| // ./in.cue:9:22 |
| // ./in.cue:19:23 |
| } |
| cmd: (string){ string } |
| } |
| } |
| jobs3: (_|_){ |
| // [eval] |
| fooTest1: (_|_){ |
| // [eval] jobs3: field not allowed: fooTest1: |
| // ./in.cue:6:8 |
| // ./in.cue:7:2 |
| // ./in.cue:9:2 |
| // ./in.cue:21:8 |
| // ./in.cue:22:8 |
| // ./in.cue:23:8 |
| } |
| } |
| } |