diff --git a/internal/core/compile/compile_test.go b/internal/core/compile/compile_test.go index 0e96e859b..e629a7d30 100644 --- a/internal/core/compile/compile_test.go +++ b/internal/core/compile/compile_test.go @@ -109,9 +109,19 @@ func syncTestdataInputsCUE(t *testing.T) { archive := &txtar.Archive{Comment: bytes.Clone(srcArchive.Comment)} for _, f := range srcArchive.Files { - if strings.HasSuffix(f.Name, ".cue") { - archive.Files = append(archive.Files, txtar.File{Name: f.Name, Data: bytes.Clone(f.Data)}) + if !strings.HasSuffix(f.Name, ".cue") { + continue } + // Strip @test attributes from the source before mirroring it. + // They are inline-test assertions for the evalalpha runner and + // have no effect on compile output, but leaving them in causes + // the compile goldens to churn whenever a @test directive is + // added, updated, or removed. + data, err := cuetxtar.StripTestAttrs(f.Data) + if err != nil { + return err + } + archive.Files = append(archive.Files, txtar.File{Name: f.Name, Data: data}) } if err := os.MkdirAll(filepath.Dir(dstPath), 0777); err != nil { return err diff --git a/internal/core/compile/testdata/sync/basicrewrite/000_errors.txtar b/internal/core/compile/testdata/sync/basicrewrite/000_errors.txtar index 918688f83..11bc63dc9 100644 --- a/internal/core/compile/testdata/sync/basicrewrite/000_errors.txtar +++ b/internal/core/compile/testdata/sync/basicrewrite/000_errors.txtar @@ -1,11 +1,11 @@ -- in.cue -- -a: _|_ & _|_ @test(err, code=user) -b: null & _|_ @test(err, code=user) -c: b.a == _|_ @test(eq, true) -d: _|_ != b.a @test(eq, false) -e: _|_ == _|_ @test(eq, true) -f: ({} & false) == _|_ @test(eq, true) -g: _|_ != ({} & false) @test(eq, false) +a: _|_ & _|_ +b: null & _|_ +c: b.a == _|_ +d: _|_ != b.a +e: _|_ == _|_ +f: ({} & false) == _|_ +g: _|_ != ({} & false) -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/basicrewrite/001_regexp.txtar b/internal/core/compile/testdata/sync/basicrewrite/001_regexp.txtar index 144ce8973..b0348e525 100644 --- a/internal/core/compile/testdata/sync/basicrewrite/001_regexp.txtar +++ b/internal/core/compile/testdata/sync/basicrewrite/001_regexp.txtar @@ -1,29 +1,26 @@ -- in.cue -- -c1: "a" =~ "a" @test(eq, true) -c2: "foo" =~ "[a-z]{3}" @test(eq, true) -c3: "foo" =~ "[a-z]{4}" @test(eq, false) -c4: "foo" !~ "[a-z]{4}" @test(eq, true) +c1: "a" =~ "a" +c2: "foo" =~ "[a-z]{3}" +c3: "foo" =~ "[a-z]{4}" +c4: "foo" !~ "[a-z]{4}" -b1: =~"a" @test(eq, "a") +b1: =~"a" b1: "a" -b2: =~"[a-z]{3}" @test(eq, "foo") +b2: =~"[a-z]{3}" b2: "foo" -b3: =~"[a-z]{4}" @test(err, code=eval, contains="out of bound", pos=[0:5, 1:5]) +b3: =~"[a-z]{4}" b3: "foo" -b4: !~"[a-z]{4}" @test(eq, "foo") +b4: !~"[a-z]{4}" b4: "foo" -s1: !="b" & =~"c" @test(eq, =~"c") -s2: =~"c" & !="b" @test(eq, =~"c") -s3: !="b" & =~"[a-z]" @test(eq, !="b" & =~"[a-z]") -s4: =~"[a-z]" & !="b" @test(eq, =~"[a-z]" & !="b") // TODO: allow different order +s1: !="b" & =~"c" +s2: =~"c" & !="b" +s3: !="b" & =~"[a-z]" +s4: =~"[a-z]" & !="b" // TODO: allow different order -e1: "foo" =~ 1 @test(err, code=eval, - contains="cannot use 1", pos=[0:5, 0:14]) -e2: "foo" !~ true @test(err, code=eval, - contains="cannot use true", pos=[0:5, 0:14]) -e3: !="a" & <5 @test(err, code=eval, - contains="conflicting values", pos=[0:5, 0:13]) +e1: "foo" =~ 1 +e2: "foo" !~ true +e3: !="a" & <5 -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/basicrewrite/002_arithmetic.txtar b/internal/core/compile/testdata/sync/basicrewrite/002_arithmetic.txtar index b214a1694..33ca55212 100644 --- a/internal/core/compile/testdata/sync/basicrewrite/002_arithmetic.txtar +++ b/internal/core/compile/testdata/sync/basicrewrite/002_arithmetic.txtar @@ -1,32 +1,31 @@ -- in.cue -- -i1: 1 & int @test(eq, 1) -i2: 2 & int @test(eq, 2) +i1: 1 & int +i2: 2 & int -sum: -1 + +2 @test(eq, 1) -div1: 2.0 / 3 * 6 @test(eq, 4.0) @test(kind=float) -div2: 2 / 3 * 6 @test(eq, 4.0) @test(kind=float, - hint="we may consider this to be int in the future") -div3: 1.00 / 1.00 @test(eq, 1.0) @test(kind=float) -divZero: 1.0 / 0 @test(err, code=eval, contains="division by zero", pos=[0:10]) -div00: 0 / 0 @test(err, code=eval, contains="division undefined", pos=[0:10]) -b: 1 != 4 @test(eq, true) -add: div1 + 1.0 @test(eq, 5.0) +sum: -1 + +2 +div1: 2.0 / 3 * 6 +div2: 2 / 3 * 6 +div3: 1.00 / 1.00 +divZero: 1.0 / 0 +div00: 0 / 0 +b: 1 != 4 +add: div1 + 1.0 -idiv00: div(0, 0) @test(err, code=eval, contains="division by zero", pos=[0:9]) -imod00: mod(0, 0) @test(err, code=eval, contains="division by zero", pos=[0:9]) -iquo00: quo(0, 0) @test(err, code=eval, contains="division by zero", pos=[0:9]) -irem00: rem(0, 0) @test(err, code=eval, contains="division by zero", pos=[0:9]) +idiv00: div(0, 0) +imod00: mod(0, 0) +iquo00: quo(0, 0) +irem00: rem(0, 0) -v1: 1.0T / 2.0 @test(eq, 5.0E+11) -v2: 2.0 == 2 @test(eq, true) -v3: 2.0 / 3.0 @test(eq, 0.6666666666666666666666666666666667) -v5: div(i1, i2) @test(eq, 0) +v1: 1.0T / 2.0 +v2: 2.0 == 2 +v3: 2.0 / 3.0 +v5: div(i1, i2) -e0: 2 + "a" @test(err, code=eval, contains="invalid operands", pos=[0:5, 0:9]) -e5: div(1.0, 2) @test(err, code=eval, contains="cannot use", pos=[0:9]) -e6: rem(2, 2.0) @test(err, code=eval, contains="cannot use", pos=[0:12]) -e7: quo(2, 2.0) @test(err, code=eval, contains="cannot use", pos=[0:12]) -e8: mod(1.0, 1) @test(err, code=eval, contains="cannot use", pos=[0:9]) +e0: 2 + "a" +e5: div(1.0, 2) +e6: rem(2, 2.0) +e7: quo(2, 2.0) +e8: mod(1.0, 1) -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/basicrewrite/003_integer-specific_arithmetic.txtar b/internal/core/compile/testdata/sync/basicrewrite/003_integer-specific_arithmetic.txtar index b7f9c4b9c..231fdeb0c 100644 --- a/internal/core/compile/testdata/sync/basicrewrite/003_integer-specific_arithmetic.txtar +++ b/internal/core/compile/testdata/sync/basicrewrite/003_integer-specific_arithmetic.txtar @@ -1,31 +1,31 @@ -- in.cue -- -q1: quo(5, 2) @test(eq, 2) -q2: quo(5, -2) @test(eq, -2) -q3: quo(-5, 2) @test(eq, -2) -q4: quo(-5, -2) @test(eq, 2) -qe1: quo(2.0, 1) @test(err, code=eval, pos=[0:10], contains="cannot use") -qe2: quo(2, 1.0) @test(err, code=eval, pos=[0:13], contains="cannot use") +q1: quo(5, 2) +q2: quo(5, -2) +q3: quo(-5, 2) +q4: quo(-5, -2) +qe1: quo(2.0, 1) +qe2: quo(2, 1.0) -r1: rem(5, 2) @test(eq, 1) -r2: rem(5, -2) @test(eq, 1) -r3: rem(-5, 2) @test(eq, -1) -r4: rem(-5, -2) @test(eq, -1) -re1: rem(2.0, 1) @test(err, code=eval, pos=[0:10], contains="cannot use") -re2: rem(2, 1.0) @test(err, code=eval, pos=[0:13], contains="cannot use") +r1: rem(5, 2) +r2: rem(5, -2) +r3: rem(-5, 2) +r4: rem(-5, -2) +re1: rem(2.0, 1) +re2: rem(2, 1.0) -d1: div(5, 2) @test(eq, 2) -d2: div(5, -2) @test(eq, -2) -d3: div(-5, 2) @test(eq, -3) -d4: div(-5, -2) @test(eq, 3) -de1: div(2.0, 1) @test(err, code=eval, pos=[0:10], contains="cannot use") -de2: div(2, 1.0) @test(err, code=eval, pos=[0:13], contains="cannot use") +d1: div(5, 2) +d2: div(5, -2) +d3: div(-5, 2) +d4: div(-5, -2) +de1: div(2.0, 1) +de2: div(2, 1.0) -m1: mod(5, 2) @test(eq, 1) -m2: mod(5, -2) @test(eq, 1) -m3: mod(-5, 2) @test(eq, 1) -m4: mod(-5, -2) @test(eq, 1) -me1: mod(2.0, 1) @test(err, code=eval, pos=[0:10], contains="cannot use") -me2: mod(2, 1.0) @test(err, code=eval, pos=[0:13], contains="cannot use") +m1: mod(5, 2) +m2: mod(5, -2) +m3: mod(-5, 2) +m4: mod(-5, -2) +me1: mod(2.0, 1) +me2: mod(2, 1.0) -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/basicrewrite/004_booleans.txtar b/internal/core/compile/testdata/sync/basicrewrite/004_booleans.txtar index 2511640bf..3c95763cc 100644 --- a/internal/core/compile/testdata/sync/basicrewrite/004_booleans.txtar +++ b/internal/core/compile/testdata/sync/basicrewrite/004_booleans.txtar @@ -1,9 +1,9 @@ -- in.cue -- -t: true @test(eq, true) +t: true t: !false -f: false @test(eq, false) +f: false f: !t -e: true @test(err, code=eval, pos=[0:4, 1:4], contains="conflicting values") +e: true e: !true -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/basicrewrite/005_boolean_arithmetic.txtar b/internal/core/compile/testdata/sync/basicrewrite/005_boolean_arithmetic.txtar index 5e9eb0a35..29c639e59 100644 --- a/internal/core/compile/testdata/sync/basicrewrite/005_boolean_arithmetic.txtar +++ b/internal/core/compile/testdata/sync/basicrewrite/005_boolean_arithmetic.txtar @@ -1,10 +1,10 @@ -- in.cue -- -a: true && true @test(eq, true) -b: true || false @test(eq, true) -c: false == true @test(eq, false) -d: false != true @test(eq, true) -e: true & true @test(eq, true) -f: true & false @test(err, code=eval, pos=[0:4, 0:11]) +a: true && true +b: true || false +c: false == true +d: false != true +e: true & true +f: true & false -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/basicrewrite/006_basic_type.txtar b/internal/core/compile/testdata/sync/basicrewrite/006_basic_type.txtar index f816a1920..0fbaf5e68 100644 --- a/internal/core/compile/testdata/sync/basicrewrite/006_basic_type.txtar +++ b/internal/core/compile/testdata/sync/basicrewrite/006_basic_type.txtar @@ -1,11 +1,11 @@ -- in.cue -- -a: 1 & int @test(eq, 1) -b: number & 1 @test(eq, 1) -c: 1.0 @test(eq, 1.0) +a: 1 & int +b: number & 1 +c: 1.0 c: float -d: int & float @test(err, code=eval, pos=[0:4, 0:10]) -e: "4" & string @test(eq, "4") -f: true @test(eq, true) +d: int & float +e: "4" & string +f: true f: bool -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/basicrewrite/007_strings_and_bytes.txtar b/internal/core/compile/testdata/sync/basicrewrite/007_strings_and_bytes.txtar index 618e8de90..d81832429 100644 --- a/internal/core/compile/testdata/sync/basicrewrite/007_strings_and_bytes.txtar +++ b/internal/core/compile/testdata/sync/basicrewrite/007_strings_and_bytes.txtar @@ -1,15 +1,15 @@ -- in.cue -- -s0: "foo" + "bar" @test(eq, "foobar") -s1: 3 * "abc" @test(eq, "abcabcabc") -s2: "abc" * 2 @test(eq, "abcabc") +s0: "foo" + "bar" +s1: 3 * "abc" +s2: "abc" * 2 -b0: 'foo' + 'bar' @test(eq, 'foobar') -b1: 3 * 'abc' @test(eq, 'abcabcabc') -b2: 'abc' * 2 @test(eq, 'abcabc') +b0: 'foo' + 'bar' +b1: 3 * 'abc' +b2: 'abc' * 2 // TODO: consider the semantics of this and perhaps allow this. -e0: "a" + '' @test(err, code=eval) -e1: 'b' + "c" @test(err, code=eval) +e0: "a" + '' +e1: 'b' + "c" -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/basicrewrite/008_escaping.txtar b/internal/core/compile/testdata/sync/basicrewrite/008_escaping.txtar index 6aa065af3..e5d2a1093 100644 --- a/internal/core/compile/testdata/sync/basicrewrite/008_escaping.txtar +++ b/internal/core/compile/testdata/sync/basicrewrite/008_escaping.txtar @@ -1,6 +1,6 @@ -- in.cue -- -a: "foo\nbar" @test(eq, "foo\nbar") -b: a @test(eq, "foo\nbar") +a: "foo\nbar" +b: a // TODO: mimic http://exploringjs.com/es6/ch_template-literals.html#sec_introduction-template-literals -- out/compile -- diff --git a/internal/core/compile/testdata/sync/basicrewrite/009_reference.txtar b/internal/core/compile/testdata/sync/basicrewrite/009_reference.txtar index ddbe243df..efad343eb 100644 --- a/internal/core/compile/testdata/sync/basicrewrite/009_reference.txtar +++ b/internal/core/compile/testdata/sync/basicrewrite/009_reference.txtar @@ -1,15 +1,11 @@ -- in.cue -- -a: b @test(eq, 2) +a: b b: 2 d: { d: 3 - e: d @test(eq, 3) -} @test(eq, {d: 3, e: 3}) + e: d +} e: { - @test(eq, { - e: {v: 1} - f: {v: 1} - }) e: { v: 1 } diff --git a/internal/core/compile/testdata/sync/basicrewrite/010_lists.txtar b/internal/core/compile/testdata/sync/basicrewrite/010_lists.txtar index 17e3fa2d6..cbcf00da6 100644 --- a/internal/core/compile/testdata/sync/basicrewrite/010_lists.txtar +++ b/internal/core/compile/testdata/sync/basicrewrite/010_lists.txtar @@ -1,14 +1,14 @@ -- in.cue -- -list: [1, 2, 3] @test(eq, [1, 2, 3]) -index: [1, 2, 3][1] @test(eq, 2) -unify: [1, 2, 3] & [_, 2, 3] @test(eq, [1, 2, 3]) -e: [] & 4 @test(err, code=eval, pos=[0:8, 0:13], contains="conflicting values", args=[list, int]) +list: [1, 2, 3] +index: [1, 2, 3][1] +unify: [1, 2, 3] & [_, 2, 3] +e: [] & 4 // No "contains" as message may vary by implementation. -e2: [3]["d"] @test(err, code=eval, pos=[0:12]) -e3: [3][-1] @test(err, code=eval, pos=[0:8, 0:12], contains="invalid index", args=[-1]) -e4: [1, 2, ...>=4 & <=5] & [1, 2, 4, 8] @test(err, code=eval, pos=[0:24, 0:41], contains="invalid value", args=[8, <=5]) -e5: [1, 2, 4, 8] & [1, 2, ...>=4 & <=5] @test(err, code=eval, pos=[0:39, 0:18], contains="invalid value", args=[8, <=5]) +e2: [3]["d"] +e3: [3][-1] +e4: [1, 2, ...>=4 & <=5] & [1, 2, 4, 8] +e5: [1, 2, 4, 8] & [1, 2, ...>=4 & <=5] -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/basicrewrite/012_selecting.txtar b/internal/core/compile/testdata/sync/basicrewrite/012_selecting.txtar index 6df67bce8..54dd77032 100644 --- a/internal/core/compile/testdata/sync/basicrewrite/012_selecting.txtar +++ b/internal/core/compile/testdata/sync/basicrewrite/012_selecting.txtar @@ -1,11 +1,11 @@ -- in.cue -- -obj: {a: 1, b: 2} @test(eq, {a: 1, b: 2}) -index: {a: 1, b: 2}["b"] @test(eq, 2) -mulidx: {a: 1, b: {a: 1, b: 3}}["b"]["b"] @test(eq, 3) -e: {a: 1}[4] @test(err, code=eval, pos=[0:16]) -f: {a: 1}.b @test(err, code=incomplete, pos=[0:16]) -g: {a: 1}["b"] @test(err, code=incomplete, pos=[0:16]) -h: [3].b @test(err, code=eval, pos=[0:13]) +obj: {a: 1, b: 2} +index: {a: 1, b: 2}["b"] +mulidx: {a: 1, b: {a: 1, b: 3}}["b"]["b"] +e: {a: 1}[4] +f: {a: 1}.b +g: {a: 1}["b"] +h: [3].b -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/basicrewrite/013_obj_unify.txtar b/internal/core/compile/testdata/sync/basicrewrite/013_obj_unify.txtar index 2714a5a48..d11f02140 100644 --- a/internal/core/compile/testdata/sync/basicrewrite/013_obj_unify.txtar +++ b/internal/core/compile/testdata/sync/basicrewrite/013_obj_unify.txtar @@ -1,12 +1,12 @@ -- in.cue -- -o1: {a: 1} & {b: 2} @test(eq, {a: 1, b: 2}) -o2: {a: 1, b: 2} & {b: 2} @test(eq, {a: 1, b: 2}) -o3: {a: 1} & {a: 1, b: 2} @test(eq, {a: 1, b: 2}) +o1: {a: 1} & {b: 2} +o2: {a: 1, b: 2} & {b: 2} +o3: {a: 1} & {a: 1, b: 2} o4: {a: 1} & {b: 2} o4: {a: 1, b: 2} & {b: 2} -o4: {a: 1} & {a: 1, b: 2} @test(eq, {a: 1, b: 2}) +o4: {a: 1} & {a: 1, b: 2} -e: 1 @test(err, code=eval, pos=[0:4, 1:4], contains="conflicting values") +e: 1 e: {a: 3} -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/basicrewrite/014_disjunctions.txtar b/internal/core/compile/testdata/sync/basicrewrite/014_disjunctions.txtar index bf2beef3c..85fc91d92 100644 --- a/internal/core/compile/testdata/sync/basicrewrite/014_disjunctions.txtar +++ b/internal/core/compile/testdata/sync/basicrewrite/014_disjunctions.txtar @@ -1,20 +1,20 @@ -- in.cue -- -o1: 1 | 2 | 3 @test(eq, 1 | 2 | 3) -o2: (1 | 2 | 3) & 1 @test(eq, 1) -o3: 2 & (1 | *2 | 3) @test(eq, 2) -o4: (1 | *2 | 3) & (1 | 2 | *3) @test(eq, 1 | 2 | 3) -o5: (1 | *2 | 3) & (3 | *2 | 1) @test(eq, *2 | 1 | 3) -o6: (1 | 2 | 3) & (3 | 1 | 2) @test(eq, 1 | 2 | 3) -o7: (1 | 2 | 3) & (2 | 3) @test(eq, 2 | 3) -o8: (1 | 2 | 3) & (3 | 2) @test(eq, 2 | 3) -o9: (2 | 3) & (1 | 2 | 3) @test(eq, 2 | 3) -o10: (3 | 2) & (1 | *2 | 3) @test(eq, *2 | 3) +o1: 1 | 2 | 3 +o2: (1 | 2 | 3) & 1 +o3: 2 & (1 | *2 | 3) +o4: (1 | *2 | 3) & (1 | 2 | *3) +o5: (1 | *2 | 3) & (3 | *2 | 1) +o6: (1 | 2 | 3) & (3 | 1 | 2) +o7: (1 | 2 | 3) & (2 | 3) +o8: (1 | 2 | 3) & (3 | 2) +o9: (2 | 3) & (1 | 2 | 3) +o10: (3 | 2) & (1 | *2 | 3) -m1: (1 | (*2 | 3)) & (>=2 & <=3) @test(eq, *2 | 3) -m2: (1 | (*2 | 3)) & (2 | 3) @test(eq, *2 | 3) -m3: (*1 | *(*2 | 3)) & (2 | 3) @test(eq, *2 | 3) -m4: (2 | 3) & (*2 | 3) @test(eq, *2 | 3) -m5: (*2 | 3) & (2 | 3) @test(eq, *2 | 3) +m1: (1 | (*2 | 3)) & (>=2 & <=3) +m2: (1 | (*2 | 3)) & (2 | 3) +m3: (*1 | *(*2 | 3)) & (2 | 3) +m4: (2 | 3) & (*2 | 3) +m5: (*2 | 3) & (2 | 3) // 2&(*2 | 3) | 3&(*2 | 3) // (*1 | (*2 | 3)) & (2 | 3) @@ -28,7 +28,7 @@ m5: (*2 | 3) & (2 | 3) @test(eq, *2 | 3) // *2 | 3 // All errors are treated the same as per the unification model. -i1: [1, 2][3] | "c" @test(eq, "c") +i1: [1, 2][3] | "c" -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/basicrewrite/015_types.txtar b/internal/core/compile/testdata/sync/basicrewrite/015_types.txtar index 061e745aa..dd75428c5 100644 --- a/internal/core/compile/testdata/sync/basicrewrite/015_types.txtar +++ b/internal/core/compile/testdata/sync/basicrewrite/015_types.txtar @@ -1,13 +1,13 @@ -- in.cue -- -i: int @test(eq, int) -j: int & 3 @test(eq, 3) -s: string @test(eq, string) -t: "s" & string @test(eq, "s") -e: int & string @test(err, code=eval, contains="conflicting values") -e2: 1 & string @test(err, code=eval, contains="conflicting values") -b: !int @test(err, code=eval, pos=[0:6], contains="invalid operand") -p: +true @test(err, code=eval, pos=[0:5], contains="invalid operation") -m: -false @test(err, code=eval, pos=[0:5], contains="invalid operation") +i: int +j: int & 3 +s: string +t: "s" & string +e: int & string +e2: 1 & string +b: !int +p: +true +m: -false -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/basicrewrite/016_comparison.txtar b/internal/core/compile/testdata/sync/basicrewrite/016_comparison.txtar index 95d97492d..626328c6d 100644 --- a/internal/core/compile/testdata/sync/basicrewrite/016_comparison.txtar +++ b/internal/core/compile/testdata/sync/basicrewrite/016_comparison.txtar @@ -10,124 +10,120 @@ language: version: "v0.14.0" // e: permanent error // i: incomplete error numbers: { - tLss: 1 < 2 @test(eq, true) - tLeq: 1 <= 1.0 @test(eq, true) - tLeq: 2.0 <= 3 @test(eq, true) - tEql: 1 == 1.0 @test(eq, true) - tNeq: 1.0 == 1 @test(eq, true) - tGeq: 2.0 >= 2 @test(eq, true) - tGtr: !(2 > 3) @test(eq, true) - tExpr: "a"+"b" == "ab" @test(eq, true) + tLss: 1 < 2 + tLeq: 1 <= 1.0 + tLeq: 2.0 <= 3 + tEql: 1 == 1.0 + tNeq: 1.0 == 1 + tGeq: 2.0 >= 2 + tGtr: !(2 > 3) + tExpr: "a"+"b" == "ab" } -- lists.cue -- lists: { // Equal lists - t1: [] == [] @test(eq, true) - t2: [1, 2, 3] == [1, 2, 3] @test(eq, true) - t3: [1, "foo", true] == [1, "foo", true] @test(eq, true) - t4: [[1, 2], [3, 4]] == [[1, 2], [3, 4]] @test(eq, true) - t5: ([1, ...int] & [1, 2, 3]) == [1, 2, 3] @test(eq, true) - t6: [1] == ([...1] & [_]) @test(eq, true) - t7: [{a: 1}] == ([...{a: 1}] & [_]) @test(eq, true) - t8: [{a: 1}] != [...{a: 1}] @test(eq, true) // true as it is not equal - t9: [...int] == [...string] @test(eq, true) // additional types are irrelevant. + t1: [] == [] + t2: [1, 2, 3] == [1, 2, 3] + t3: [1, "foo", true] == [1, "foo", true] + t4: [[1, 2], [3, 4]] == [[1, 2], [3, 4]] + t5: ([1, ...int] & [1, 2, 3]) == [1, 2, 3] + t6: [1] == ([...1] & [_]) + t7: [{a: 1}] == ([...{a: 1}] & [_]) + t8: [{a: 1}] != [...{a: 1}] // true as it is not equal + t9: [...int] == [...string] // additional types are irrelevant. // Non-equal lists - f1: [1, 2, 3] == [1, 2, 4] @test(eq, false) - f2: [1, 2, 3] == [1, 2] @test(eq, false) - f3: [1, 2, 3] == [1, 3, 2] @test(eq, false) // different order - f4: [] == [1] @test(eq, false) - f5: [1, 2] == [1, "2"] @test(eq, false) // different types - f6: [*1 | 2 | 3] == [*2 | 3 | 4] @test(eq, false) - + f1: [1, 2, 3] == [1, 2, 4] + f2: [1, 2, 3] == [1, 2] + f3: [1, 2, 3] == [1, 3, 2] // different order + f4: [] == [1] + f5: [1, 2] == [1, "2"] // different types + f6: [*1 | 2 | 3] == [*2 | 3 | 4] // TODO: types can never match. This could be a permanent error. // This was V2 behavior. - eIncompat: [int] == [string] @test(err, code=incomplete|eval, pos=[0:13]) @test(err:todo, code=eval, pos=[0:13]) + eIncompat: [int] == [string] // Error cases - eErrPassthrough: [1/0] == [1] @test(err, code=eval, contains="invalid", pos=[0:19]) + eErrPassthrough: [1 / 0] == [1] // incomplete passtrhough _e3l: {} - eErrPassthrough: [_e3l.b] == [1] @test(err, code=eval, - suberr=(code=eval, contains="division by zero", pos=[-4:19]), - suberr=(code=eval, contains="conflicting values", pos=[6:19]), - ) + eErrPassthrough: [_e3l.b] == [1] // error reported as part of combined eErrPassthrough error eErrPassthrough: [1, 2] == [1, int & string] // Inequality tests - tNeq1: [1, 2] != [1, 3] @test(eq, true) - fNeq2: [1, 2] != [1, 2] @test(eq, false) + tNeq1: [1, 2] != [1, 3] + fNeq2: [1, 2] != [1, 2] } -- structs.cue -- @experiment(structcmp) structs: eq: { // Equal structs - t1: {} == {} @test(eq, true) - t2: {a: 1, b: "foo"} == {a: 1, b: "foo"} @test(eq, true) - t3: {a: 1, b: 2} == {b: 2, a: 1} @test(eq, true) // different order - t4: {a: {x: 1, y: 2}} == {a: {x: 1, y: 2}} @test(eq, true) // nested structs - t5: ({a: 1, b: 2, c: 3} & {d: 4}) == {a: 1, b: 2, c: 3, d: 4} @test(eq, true) // unification - t6: {{{{a: 1}}}} == {{a: 1}} @test(eq, true) // embedding - t7: {[string]: int} == {[string]: string} @test(eq, true) + t1: {} == {} + t2: {a: 1, b: "foo"} == {a: 1, b: "foo"} + t3: {a: 1, b: 2} == {b: 2, a: 1} // different order + t4: {a: {x: 1, y: 2}} == {a: {x: 1, y: 2}} // nested structs + t5: ({a: 1, b: 2, c: 3} & {d: 4}) == {a: 1, b: 2, c: 3, d: 4} // unification + t6: {{{{a: 1}}}} == {{a: 1}} // embedding + t7: {[string]: int} == {[string]: string} _t8l: *1 | 2 | 3 - t8: {a: _t8l} == {a: 3| *1} @test(eq, true) + t8: {a: _t8l} == {a: 3 | *1} // Non-equal structs - f1: {a: 1, b: "foo"} == {a: 2, b: "foo"} @test(eq, false) - f2: {a: 1, b: "foo"} == {a: 1, c: "foo"} @test(eq, false) - f3: {a: {x: 1}} == {a: {x: 2}} @test(eq, false) - f4: {a: 1, b: 2} == {a: 1} @test(eq, false) - f5: {} == {a: 1} @test(eq, false) - f6: {a: 1} == 1 @test(eq, false) - f7: {a: 1, b?: 2} == {a: 1, b: 2} @test(eq, false) // optional field does not exist - f8: {{{{a: 1}}}} == {{a: 1, b: 2}} @test(eq, false) // embedding - _f9r: *2 | 3 | 4 - f9: {a: *1 | 2 | 3} == {a: _f9r} @test(eq, false) + f1: {a: 1, b: "foo"} == {a: 2, b: "foo"} + f2: {a: 1, b: "foo"} == {a: 1, c: "foo"} + f3: {a: {x: 1}} == {a: {x: 2}} + f4: {a: 1, b: 2} == {a: 1} + f5: {} == {a: 1} + f6: {a: 1} == 1 + f7: {a: 1, b?: 2} == {a: 1, b: 2} // optional field does not exist + f8: {{{{a: 1}}}} == {{a: 1, b: 2}} // embedding + _f9r: *2 | 3 | 4 + f9: {a: *1 | 2 | 3} == {a: _f9r} // Only test some versions of != recognizing the same code paths are // followed for ==. - tNe1: {a: 1} != {a: 2} @test(eq, true) - fNe1: {a: 2} != {a: 2} @test(eq, false) + tNe1: {a: 1} != {a: 2} + fNe1: {a: 2} != {a: 2} } ignore: { - t0: {_hidden: 1} == {_hidden: 2} @test(eq, true) - t1: {_hidden: 1} == {} @test(eq, true) - t1: {} == {_hidden: 1} @test(eq, true) - t2: {#def: 1} == {#def: 2} @test(eq, true) - t3: {#def: 1} == {} @test(eq, true) - t4: {} == {#def: 1} @test(eq, true) - t5: {_#hiddenDef: 1} == {_#hiddenDef: 2} @test(eq, true) - t6: {_#hiddenDef: 1} == {} @test(eq, true) - t7: {} == {_#hiddenDef: 1} @test(eq, true) + t0: {_hidden: 1} == {_hidden: 2} + t1: {_hidden: 1} == {} + t1: {} == {_hidden: 1} + t2: {#def: 1} == {#def: 2} + t3: {#def: 1} == {} + t4: {} == {#def: 1} + t5: {_#hiddenDef: 1} == {_#hiddenDef: 2} + t6: {_#hiddenDef: 1} == {} + t7: {} == {_#hiddenDef: 1} - f0: {_hidden: 1} != {_hidden: 2} @test(eq, false) - f1: {_hidden: 1} != {} @test(eq, false) - f1: {} != {_hidden: 1} @test(eq, false) - f2: {#def: 1} != {#def: 2} @test(eq, false) - f3: {#def: 1} != {} @test(eq, false) - f4: {} != {#def: 1} @test(eq, false) - f5: {_#hiddenDef: 1} != {_#hiddenDef: 2} @test(eq, false) - f6: {_#hiddenDef: 1} != {} @test(eq, false) - f7: {} != {_#hiddenDef: 1} @test(eq, false) + f0: {_hidden: 1} != {_hidden: 2} + f1: {_hidden: 1} != {} + f1: {} != {_hidden: 1} + f2: {#def: 1} != {#def: 2} + f3: {#def: 1} != {} + f4: {} != {#def: 1} + f5: {_#hiddenDef: 1} != {_#hiddenDef: 2} + f6: {_#hiddenDef: 1} != {} + f7: {} != {_#hiddenDef: 1} } embeddedScalars: { _one: 1 _two: 2 - t1: 1 == {1} @test(eq, true) - t2: [1] == [{1}] @test(eq, true) - t3: {a: 1} == {a: {1}} @test(eq, true) - t4: [_one] == [{_one}] @test(eq, true) + t1: 1 == {1} + t2: [1] == [{1}] + t3: {a: 1} == {a: {1}} + t4: [_one] == [{_one}] - f1: _one == [{_two}] @test(eq, false) - f2: {a: _two} == {a: {_one}} @test(eq, false) - f3: _one == {_two} @test(eq, false) - f4: [_two] == [{_one}] @test(eq, false) + f1: _one == [{_two}] + f2: {a: _two} == {a: {_one}} + f3: _one == {_two} + f4: [_two] == [{_one}] } // Error cases @@ -135,19 +131,19 @@ incomplete: { _int: int _string: string - iErr1: {a!: _int} == {a!: _int} @test(err, code=incomplete, contains="field is required but not present", pos=[0:9]) - iErr2: {a!: _int} == {a!: 1} @test(err, code=incomplete, contains="field is required but not present", pos=[0:9]) - eErr3: {a: _int} == {a: _string} @test(err, code=incomplete|eval, contains="incomplete value int", pos=[0:9]) @test(err:todo, code=eval) - eErr4: {a: 1/0} == {a: 1} @test(err, code=eval, contains="failed arithmetic", pos=[0:9]) // Error passthrough + iErr1: {a!: _int} == {a!: _int} + iErr2: {a!: _int} == {a!: 1} + eErr3: {a: _int} == {a: _string} + eErr4: {a: 1 / 0} == {a: 1} // Error passthrough - eErr5: {a: 1} == {a: _int & _string} @test(err, code=eval, contains="conflicting values", pos=[0:9]) // Error passthrough - iErr6: {a!: 1} == {a: 1} @test(err, code=incomplete, contains="field is required but not present", pos=[0:9]) - eErr7: {a: 1} == {a!: 2} @test(err, code=incomplete, contains="field is required but not present", pos=[0:9]) @test(err:todo, code=eval) // Required cannot match even when concrete. + eErr5: {a: 1} == {a: _int & _string} // Error passthrough + iErr6: {a!: 1} == {a: 1} + eErr7: {a: 1} == {a!: 2} // Required cannot match even when concrete. // Only test some versions of != recognizing the same code paths are // followed for ==. - tNe1: {a: 1} != {a: 2} @test(eq, true) - fNe1: {a: 2} != {a: 2} @test(eq, false) + tNe1: {a: 1} != {a: 2} + fNe1: {a: 2} != {a: 2} } -- typediff.cue -- @experiment(structcmp) @@ -159,40 +155,40 @@ diffTypes: { // true for !=) are permanent errors. // Tests with different types. - fScalar1: 2 == "s" @test(eq, false) - fScalar2: "s" == 2 @test(eq, false) - fScalar3: true == 2 @test(eq, false) + fScalar1: 2 == "s" + fScalar2: "s" == 2 + fScalar3: true == 2 - fStruct1: {a: 1} == "s" @test(eq, false) + fStruct1: {a: 1} == "s" - fList1: 5 == [5] @test(eq, false) - fList2: "ab" == ["a", "b"] @test(eq, false) - fList3: true == [true] @test(eq, false) - fList4: {a: 1} == [{a: 1}] @test(eq, false) - fList5: [1, 2] == 3 @test(eq, false) - fList6: [1, 2] == "ab" @test(eq, false) - fList7: [true] == false @test(eq, false) - fList8: [1, 2] == {a: 1} @test(eq, false) - fList9: [1, 2] == null @test(eq, false) + fList1: 5 == [5] + fList2: "ab" == ["a", "b"] + fList3: true == [true] + fList4: {a: 1} == [{a: 1}] + fList5: [1, 2] == 3 + fList6: [1, 2] == "ab" + fList7: [true] == false + fList8: [1, 2] == {a: 1} + fList9: [1, 2] == null // Negated comparisons - tNeList1: [1, 2] != 3 @test(eq, true) - tNeList2: [1, 2] != "ab" @test(eq, true) + tNeList1: [1, 2] != 3 + tNeList2: [1, 2] != "ab" _int: int _string: string // Lists with incompatible element types - iRecursive1: [_int] == [_int] @test(err, code=incomplete, contains="incomplete value int", pos=[0:15]) // can still match, but not concrete - eRecursive2: [_int] == [_string] @test(err, code=incomplete, contains="incomplete value int", pos=[0:15]) @test(err:todo, code=eval) // can never match - fRecursive3: [1, 2] == [1, "2"] @test(eq, false) - tRecursive4: [...int] == [...string] @test(eq, true) - fRecursive5: [1, "a"] == [1, 2] @test(eq, false) + iRecursive1: [_int] == [_int] // can still match, but not concrete + eRecursive2: [_int] == [_string] // can never match + fRecursive3: [1, 2] == [1, "2"] + tRecursive4: [...int] == [...string] + fRecursive5: [1, "a"] == [1, 2] - eNe1: [1, 2] != [_int] @test(err, code=incomplete, contains="incomplete value int", pos=[0:8]) @test(err:todo, code=eval) // length can never match - iNe2: [_int] != [1] @test(err, code=incomplete, contains="incomplete value int", pos=[0:8]) - iNe3: {a: 1} != {a: _int} @test(err, code=incomplete, contains="incomplete value int", pos=[0:8]) - iNe4: {a: _int} != {a: 1} @test(err, code=incomplete, contains="incomplete value int", pos=[0:8]) + eNe1: [1, 2] != [_int] // length can never match + iNe2: [_int] != [1] + iNe3: {a: 1} != {a: _int} + iNe4: {a: _int} != {a: 1} } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/basicrewrite/017_null.txtar b/internal/core/compile/testdata/sync/basicrewrite/017_null.txtar index 2dc5a87fd..e213fb20f 100644 --- a/internal/core/compile/testdata/sync/basicrewrite/017_null.txtar +++ b/internal/core/compile/testdata/sync/basicrewrite/017_null.txtar @@ -1,13 +1,13 @@ -- in.cue -- -eql: null == null @test(eq, true) -neq: null != null @test(eq, false) -unf: null & null @test(eq, null) +eql: null == null +neq: null != null +unf: null & null // errors -eq1: null == 1 @test(eq, false) -eq2: 1 == null @test(eq, false) -ne1: "s" != null @test(eq, true) -call: null() @test(err, code=eval, pos=[0:7], contains="cannot call non-function") +eq1: null == 1 +eq2: 1 == null +ne1: "s" != null +call: null() -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/basicrewrite/018_self-reference_cycles.txtar b/internal/core/compile/testdata/sync/basicrewrite/018_self-reference_cycles.txtar index 45368c691..550e957cd 100644 --- a/internal/core/compile/testdata/sync/basicrewrite/018_self-reference_cycles.txtar +++ b/internal/core/compile/testdata/sync/basicrewrite/018_self-reference_cycles.txtar @@ -1,29 +1,22 @@ -- in.cue -- -a: b - 100 @test(err, code=cycle) -b: a + 100 @test(err, code=cycle) +a: b - 100 +b: a + 100 -c: [c[1], c[0]] @test(eq, [_, _]) +c: [c[1], c[0]] -d: e - 1 @test(eq, 1) +d: e - 1 e: 1 + d -e: *2 | 0 @test(eq, *2 | 0) +e: *2 | 0 -- disjunction.cue -- oneway: { - t1: { - a: *1 | int - a: b + 1 - b: "b" | string // conjuncts 403 disjuncts 390 (+92; +90) #a: <"a" | >"b" | string // conjuncts 495 disjuncts 480 (+92; +90) } -@test(eq, at=issue3610, { - <"a" - #a: <"a" | >"b" | string -} | { - >"b" - #a: <"a" | >"b" | string -} | { - string - #a: <"a" | >"b" | string -}) - -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/benchmarks/disjunction.txtar b/internal/core/compile/testdata/sync/benchmarks/disjunction.txtar index 23af50b09..64de501d9 100644 --- a/internal/core/compile/testdata/sync/benchmarks/disjunction.txtar +++ b/internal/core/compile/testdata/sync/benchmarks/disjunction.txtar @@ -25,7 +25,6 @@ x: [_]: f: *1 | int x: { a0: {} - @test(eq, {a0: {f: *1 | int}}) } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/benchmarks/inlinedisjunction.txtar b/internal/core/compile/testdata/sync/benchmarks/inlinedisjunction.txtar index f16be32fe..6890bd68c 100644 --- a/internal/core/compile/testdata/sync/benchmarks/inlinedisjunction.txtar +++ b/internal/core/compile/testdata/sync/benchmarks/inlinedisjunction.txtar @@ -1,23 +1,18 @@ -- in.cue -- #def: { - {} | {c: string} - {} | {c: string} - {} | {c: string} - {} | {c: string} - {} | {c: string} - {} | {c: string} - {} | {c: string} - {} | {c: string} - {} | {c: string} - {} | {a: string} + {} | {c: string} + {} | {c: string} + {} | {c: string} + {} | {c: string} + {} | {c: string} + {} | {c: string} + {} | {c: string} + {} | {c: string} + {} | {c: string} + {} | {a: string} } x: #def x: c: "foo" - -@test(eq, { - #def: {} | {a: string} | {c: string} | {c: string, a: string} - x: {c: "foo"} | {c: "foo", a: string} -}) -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/benchmarks/issue1684.txtar b/internal/core/compile/testdata/sync/benchmarks/issue1684.txtar index f6da1deed..e8fefec03 100644 --- a/internal/core/compile/testdata/sync/benchmarks/issue1684.txtar +++ b/internal/core/compile/testdata/sync/benchmarks/issue1684.txtar @@ -23,23 +23,19 @@ out: #secrets & { out: #secrets & { FOO: $secret: _id: "100" ONE: TWO: THREE: $secret: _id: "123" -} @test(eq, { - FOO: $secret: {id: "100", _id: "100"} - ONE: TWO: THREE: $secret: {id: "123", _id: "123"} -}) - +} -- perf.cue -- nestedCross: closed: { #D: {id: string} | {[string]: #D} #D: {id: string} | {[string]: #D} #D: {id: string} | {[string]: #D} -} @test(eq, {#D: {id: string} | {}}) +} nestedCross: open: { D: {id: string} | {[string]: D} D: {id: string} | {[string]: D} D: {id: string} | {[string]: D} -} @test(eq, {D: {id: string} | {}}) +} // TODO(perf): support this case. This is currently exponential, although the // tight bound on the detection of structural cycles mitigates the situation. @@ -50,7 +46,7 @@ nestedClosed: passing: { D: {id: {}} | {[string]: D} D: {id: {}} | {[string]: D} D: {id: {}} | {[string]: D} -} @test(eq, {D: {id: {}} | {}}) +} -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/benchmarks/issue2176.txtar b/internal/core/compile/testdata/sync/benchmarks/issue2176.txtar index a570a55b7..ca247bf3a 100644 --- a/internal/core/compile/testdata/sync/benchmarks/issue2176.txtar +++ b/internal/core/compile/testdata/sync/benchmarks/issue2176.txtar @@ -50,14 +50,8 @@ output: [string]: string output: { "1": (datastream & {marker: length: 4}).marker.position "2": (datastream & {marker: length: 14}).marker.position -} @test(eq, {"1": {"7"}, "2": {"19"}}) +} // NOTE: output contains lots of expanded lets. Use @test(debug) to view. - -@test(eq,at=datastream, { - message: *"mjqjpqmgbljsphdztnvjfqwrcgsmlb" | "qfmfhmhjmjggwbbvdvwvlvrrtsrsccwsslvlffjrrtprprjjvmmclmmghhddpvddclctcqtccgbgdbgdgsdgghqhtqtvvptvppwrwprpvrrrhpphththvhhrnnhnlnslnlhnhnhgnhnpnqqsmsgsllprlprrlzzqzffmzztctbtnbtthlttqvqcqmcmpcpbbczzbqbgghcghchhvwvllfrfnnbssfzsszpsplpglpprnpnfnbnhbnbtbzzvbvpbbhjjlzzbtbvbppczppbwppqwwnwlwccglgvgrgmmdwmwrmrppnfnhhhhqthqthqqrhrshhhqbhqqjgjvjllzvzbzhbbpttjsszvzqqtzzmbmddpldpdcdnccrmcrmmpwprplrrqssvddmpdmmwfwwlrljrrdsssmhsspnpffjggqllnzlnlhnnmddfrfpfbbvssjsrrznngcghgchcmhmrrrtzztjzzhchssslsmlmvvpwpqpjqjdddmsdmmtgtmgtglttfbbgrrcprrqffmmjnjttcmczzgbzggthhsttpggrmmgwwnpnqnqvnqvqppmlpmlpmpjpljljmmtpptfppfrppfdpfdppddmdttgzgzzdbzdzhzhnnsqssvmvbbpjjzwwvnwvvzmvzmzpmpttvrvccqddpgdppgmmthmthtggsfsbbvfbvfvhfvhvvpwpddqrqgqhghnnfmfbbwrbrgbgbvgbbdttffrddqbqpqzzmttlhhsqhsqhsqhhlplttpnpsstpthhpfhpfplprrgfrgffjppghgppghgdggjmmcgmccjvvsrvsrrwgrgmrrngrgttvbtbltthrthrttmfffjpfpssncnrngrrltrltlggjgcgllrzzllhwwjwrwgrgsrgrhrphrhhqwqsqmqlmqlmqmqrmrnnwnhwnhwhzwzjwwgbghhsjspszsznzfztfzfpzzlczztctsstctqtfqfqcfqqjrjccttmqqfpfdfnfwnffqbfbblpbpfpcfcwfccblbwwmqwqrrgprpccngnhghpppwmpplcppfrfjjgmmbzbhbcbzzgdgsdsvvqllzlppnfnlnlslsljlppcscqqfjjjwzwppfgfjjsvvsggjbjljpjpzjzrzjrzzfnfpnfpnfpnfnsnggmpggdllpmmrhhdqqppttgqqcsqsjsbjsjrsrqrbqqmbmcbmcbmbfmfvfqqdbdppmrprnrggmjjhnhbhdhbbfcbbcjjdhhwjwmjmssjswscswcwzccbgbqqmqgmmsdsjsbsdbsddvttjpppcqpcqcgqqslqsssczszrzvvrtvvjppswwhnnwlwtwhhwwzfwwpfpddlvvnvnnvlnntjtqjqjzzjttvvbqbhqbhbbbwnwhnwnppdbpdpvddrqdqjjlvlqqdfdhdjhdjdcjcrcjjggfmfvvfllvfvgglzllmhmzmdddfwddqjjqjfqfcfrrstrssptsstllrflfwwgswslwlbwbwjjvhvfvhfhffhsslwsllbnbblccbwwjqwqqdllrdrnrnffcbbqqpnqqdmdndtntvvrjvvsvmvgvnnmjlwgnjcwljgwnrwpqlztwrpmpgqtwlhrcwsrrhqhjhznrtpqfdnzbfqrzwslptdbdcnqvcllpjsfdvmzqwvzbpnmfcfcjnbmhtwhttjgtnczwctpdthhwmzvzrrgsnmbflgmszgsbvghbzgcmcmszgsbfmlmpbdspqlftmqrcjtmvgcrzznlfwjcbmddplsqrfflqnqfsldwhnncczdmfrrrsbjjqsdzrsgbdbwjbslfcqglsqfddhdsrcdrgqfqthgmfjvnfdfgdncfzpvqcpscnpmfgvqbfwszwzgmqvmcrdrwplfshdgqrchmccpqfznbmfvlhdpctlqgjslrwhjfjlmqfblgjrdlnzdtwlpwhnrhrcrpfwqpmjlgrdbgpbljntmbqlblqqqpgrnjtmjqvjpzvsqdpgtchmmwbhtmgcjqdplrtptqcvdjjpqdzsrcjhcwvdcghlwrdhtdfctmqfcjcqhcvvbzgsvlggcrdgqbtznwwmnbgsfrjprqgcmlswftlwpqqqvshdprldrsghmhrqvmqmvglbvzpvtrjbhcvhqmvdtcvsllznqzjmhpnlbhmlzthbwwhhvdtcdfdcdzhnbsrnqqjvzzsvfjhbsdlsbdlqjnlpnhfcjtdppzmphghltztzcdvzwbftbvwhvgmrllqfzrpbltptdtjjqtfwjfmczzgdvclqbsbftgtlhnhrrvbpvdltstdnhqvpvtjhmghptvsfnlspslmfsftzdrwljrgblgmcbmlszmhnlfdtmsrnjqwrfmsnfgpcqgzmlwppffrmbvhnlstfpgzw" - marker: {length: int, position: {_|_}} -}) - -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/benchmarks/issue3307.txtar b/internal/core/compile/testdata/sync/benchmarks/issue3307.txtar index 039656da2..d4ec06f54 100644 --- a/internal/core/compile/testdata/sync/benchmarks/issue3307.txtar +++ b/internal/core/compile/testdata/sync/benchmarks/issue3307.txtar @@ -3,27 +3,27 @@ # guarded struct should not independently re-evaluate the condition. # https://cuelang.org/issue/3307 -- in.cue -- -@test(err, code=incomplete, contains="incomplete bool") + if _request.enabled { - r1: { - k1: 0 - k2: 0 - k3: 0 - k4: 0 - k5: 0 - k6: 0 - k7: 0 - k8: 0 - k9: 0 - k10: 0 - k11: 0 - k12: 0 - k13: 0 - k14: 0 - k15: 0 - k16: 0 - k17: 0 - } + r1: { + k1: 0 + k2: 0 + k3: 0 + k4: 0 + k5: 0 + k6: 0 + k7: 0 + k8: 0 + k9: 0 + k10: 0 + k11: 0 + k12: 0 + k13: 0 + k14: 0 + k15: 0 + k16: 0 + k17: 0 + } } _request: enabled: _ diff --git a/internal/core/compile/testdata/sync/benchmarks/issue3334.txtar b/internal/core/compile/testdata/sync/benchmarks/issue3334.txtar index a8f855f77..245dd34ea 100644 --- a/internal/core/compile/testdata/sync/benchmarks/issue3334.txtar +++ b/internal/core/compile/testdata/sync/benchmarks/issue3334.txtar @@ -25,7 +25,7 @@ x: properties: { Schema: { title?: string - $ref?: null | string + $ref?: null | string enum?: [...] required?: [...string] items?: null | _ @@ -46,209 +46,6 @@ Schema: { example?: null | _ nullable?: bool } - -@test(eq, at=x, { - properties: { - disableSelfServiceScrape: { - title?: string - $ref?: null | string - enum?: [] - required?: [] - items?: null | _ - anyOf?: [] - allOf?: [] - oneOf?: [] - not?: null | {title?: string, $ref?: null | string, enum?: [], required?: [], items?: null | _, anyOf?: [], allOf?: [], oneOf?: [], not?: null, properties?: {}, additionalProperties?: null | _, patternProperties?: {}, dependencies?: {}, additionalItems?: null | _, definitions?: {}, externalDocs?: null | {description?: string, url?: string}, example?: null | _, nullable?: bool} - properties?: {} - additionalProperties?: null | _ - patternProperties?: {} - dependencies?: {} - additionalItems?: null | _ - definitions?: {} - externalDocs?: null | {description?: string, url?: string} - example?: null | _ - nullable?: bool - } - dnsConfig: { - properties: { - nameservers: { - title?: string - $ref?: null | string - enum?: [] - required?: [] - items?: null | _ - anyOf?: [] - allOf?: [] - oneOf?: [] - not?: null | {title?: string, $ref?: null | string, enum?: [], required?: [], items?: null | _, anyOf?: [], allOf?: [], oneOf?: [], not?: null, properties?: {}, additionalProperties?: null | _, patternProperties?: {}, dependencies?: {}, additionalItems?: null | _, definitions?: {}, externalDocs?: null | {description?: string, url?: string}, example?: null | _, nullable?: bool} - properties?: {} - additionalProperties?: null | _ - patternProperties?: {} - dependencies?: {} - additionalItems?: null | _ - definitions?: {} - externalDocs?: null | {description?: string, url?: string} - example?: null | _ - nullable?: bool - } - } - title?: string - $ref?: null | string - enum?: [] - required?: [] - items?: null | _ - anyOf?: [] - allOf?: [] - oneOf?: [] - not?: null | {title?: string, $ref?: null | string, enum?: [], required?: [], items?: null | _, anyOf?: [], allOf?: [], oneOf?: [], not?: null, properties?: {}, additionalProperties?: null | _, patternProperties?: {}, dependencies?: {}, additionalItems?: null | _, definitions?: {}, externalDocs?: null | {description?: string, url?: string}, example?: null | _, nullable?: bool} - additionalProperties?: null | _ - patternProperties?: {} - dependencies?: {} - additionalItems?: null | _ - definitions?: {} - externalDocs?: null | {description?: string, url?: string} - example?: null | _ - nullable?: bool - } - podDisruptionBudget: { - properties: { - maxUnavailable: { - title?: string - $ref?: null | string - enum?: [] - required?: [] - items?: null | _ - anyOf?: [] - allOf?: [] - oneOf?: [] - not?: null | {title?: string, $ref?: null | string, enum?: [], required?: [], items?: null | _, anyOf?: [], allOf?: [], oneOf?: [], not?: null, properties?: {}, additionalProperties?: null | _, patternProperties?: {}, dependencies?: {}, additionalItems?: null | _, definitions?: {}, externalDocs?: null | {description?: string, url?: string}, example?: null | _, nullable?: bool} - properties?: {} - additionalProperties?: null | _ - patternProperties?: {} - dependencies?: {} - additionalItems?: null | _ - definitions?: {} - externalDocs?: null | {description?: string, url?: string} - example?: null | _ - nullable?: bool - } - minAvailable: { - anyOf: [{ - title?: string - $ref?: null | string - enum?: [] - required?: [] - items?: null | _ - anyOf?: [] - allOf?: [] - oneOf?: [] - not?: null | {title?: string, $ref?: null | string, enum?: [], required?: [], items?: null | _, anyOf?: [], allOf?: [], oneOf?: [], not?: null, properties?: {}, additionalProperties?: null | _, patternProperties?: {}, dependencies?: {}, additionalItems?: null | _, definitions?: {}, externalDocs?: null | {description?: string, url?: string}, example?: null | _, nullable?: bool} - properties?: {} - additionalProperties?: null | _ - patternProperties?: {} - dependencies?: {} - additionalItems?: null | _ - definitions?: {} - externalDocs?: null | {description?: string, url?: string} - example?: null | _ - nullable?: bool - }, - { - title?: string - $ref?: null | string - enum?: [] - required?: [] - items?: null | _ - anyOf?: [] - allOf?: [] - oneOf?: [] - not?: null | {title?: string, $ref?: null | string, enum?: [], required?: [], items?: null | _, anyOf?: [], allOf?: [], oneOf?: [], not?: null, properties?: {}, additionalProperties?: null | _, patternProperties?: {}, dependencies?: {}, additionalItems?: null | _, definitions?: {}, externalDocs?: null | {description?: string, url?: string}, example?: null | _, nullable?: bool} - properties?: {} - additionalProperties?: null | _ - patternProperties?: {} - dependencies?: {} - additionalItems?: null | _ - definitions?: {} - externalDocs?: null | {description?: string, url?: string} - example?: null | _ - nullable?: bool - }] - title?: string - $ref?: null | string - enum?: [] - required?: [] - items?: null | _ - allOf?: [] - oneOf?: [] - not?: null | {title?: string, $ref?: null | string, enum?: [], required?: [], items?: null | _, anyOf?: [], allOf?: [], oneOf?: [], not?: null, properties?: {}, additionalProperties?: null | _, patternProperties?: {}, dependencies?: {}, additionalItems?: null | _, definitions?: {}, externalDocs?: null | {description?: string, url?: string}, example?: null | _, nullable?: bool} - properties?: {} - additionalProperties?: null | _ - patternProperties?: {} - dependencies?: {} - additionalItems?: null | _ - definitions?: {} - externalDocs?: null | {description?: string, url?: string} - example?: null | _ - nullable?: bool - } - labels: { - title?: string - $ref?: null | string - enum?: [] - required?: [] - items?: null | _ - anyOf?: [] - allOf?: [] - oneOf?: [] - not?: null | {title?: string, $ref?: null | string, enum?: [], required?: [], items?: null | _, anyOf?: [], allOf?: [], oneOf?: [], not?: null, properties?: {}, additionalProperties?: null | _, patternProperties?: {}, dependencies?: {}, additionalItems?: null | _, definitions?: {}, externalDocs?: null | {description?: string, url?: string}, example?: null | _, nullable?: bool} - properties?: {} - additionalProperties?: null | _ - patternProperties?: {} - dependencies?: {} - additionalItems?: null | _ - definitions?: {} - externalDocs?: null | {description?: string, url?: string} - example?: null | _ - nullable?: bool - } - } - title?: string - $ref?: null | string - enum?: [] - required?: [] - items?: null | _ - anyOf?: [] - allOf?: [] - oneOf?: [] - not?: null | {title?: string, $ref?: null | string, enum?: [], required?: [], items?: null | _, anyOf?: [], allOf?: [], oneOf?: [], not?: null, properties?: {}, additionalProperties?: null | _, patternProperties?: {}, dependencies?: {}, additionalItems?: null | _, definitions?: {}, externalDocs?: null | {description?: string, url?: string}, example?: null | _, nullable?: bool} - additionalProperties?: null | _ - patternProperties?: {} - dependencies?: {} - additionalItems?: null | _ - definitions?: {} - externalDocs?: null | {description?: string, url?: string} - example?: null | _ - nullable?: bool - } - } - title?: string - $ref?: null | string - enum?: [] - required?: [] - items?: null | _ - anyOf?: [] - allOf?: [] - oneOf?: [] - not?: null | {title?: string, $ref?: null | string, enum?: [], required?: [], items?: null | _, anyOf?: [], allOf?: [], oneOf?: [], not?: null | {title?: string, $ref?: null | string, enum?: [], required?: [], items?: null | _, anyOf?: [], allOf?: [], oneOf?: [], not?: null, properties?: {}, additionalProperties?: null | _, patternProperties?: {}, dependencies?: {}, additionalItems?: null | _, definitions?: {}, externalDocs?: null | {description?: string, url?: string}, example?: null | _, nullable?: bool}, properties?: {}, additionalProperties?: null | _, patternProperties?: {}, dependencies?: {}, additionalItems?: null | _, definitions?: {}, externalDocs?: null | {description?: string, url?: string}, example?: null | _, nullable?: bool} - additionalProperties?: null | _ - patternProperties?: {} - dependencies?: {} - additionalItems?: null | _ - definitions?: {} - externalDocs?: null | {description?: string, url?: string} - example?: null | _ - nullable?: bool -}) -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/benchmarks/issue3514.txtar b/internal/core/compile/testdata/sync/benchmarks/issue3514.txtar index d2af282e7..f45c8b4d6 100644 --- a/internal/core/compile/testdata/sync/benchmarks/issue3514.txtar +++ b/internal/core/compile/testdata/sync/benchmarks/issue3514.txtar @@ -7,40 +7,38 @@ import "list" _schema & _data _data: { - "updates": [ - { - "schedule": { - "interval": "daily" - } - } - ], + "updates": [ + { + "schedule": { + "interval": "daily" + } + } + ] } _schema: { - matchIf( - null | bool | number | string | [...] | {"enable-beta-ecosystems"!: true}, - _, - null | bool | number | string | [...] | { - "updates"?: null | bool | number | string | [...null | bool | number | string | [...] | {...}] | {...} - ... - } - ) & { - "updates"!: [...#update] - } + matchIf( + null | bool | number | string | [...] | {"enable-beta-ecosystems"!: true}, + _, + null | bool | number | string | [...] | { + "updates"?: null | bool | number | string | [...null | bool | number | string | [...] | {...}] | {...} + ... + }, + ) & { + "updates"!: [...#update] + } - #update: { - "schedule"!: { - "timezone"?: #timezone - ... - } - ... - } + #update: { + "schedule"!: { + "timezone"?: #timezone + ... + } + ... + } - // This was originally a list of 571 explicit time zones. - #timezone: or([for i in list.Range(0, 571, 1) {"\(i)"}]) + // This was originally a list of 571 explicit time zones. + #timezone: or([for i in list.Range(0, 571, 1) {"\(i)"}]) } - -@test(eq, at=_data, { updates: [{schedule: {interval: "daily"}}] }) -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/benchmarks/issue3517.txtar b/internal/core/compile/testdata/sync/benchmarks/issue3517.txtar index 6f8a9022f..54fd964da 100644 --- a/internal/core/compile/testdata/sync/benchmarks/issue3517.txtar +++ b/internal/core/compile/testdata/sync/benchmarks/issue3517.txtar @@ -57,16 +57,6 @@ ts: this={ } timeSpan: start: this.#tasks.t1.timeSpan.start } -@test(err, at=ts.#tasks.t1, code=eval, path=ts.#tasks.t2.timeSpan.end, - contains="conflicting values %s and %s (mismatched types %s and %s)", - args=[119, float, int, float], - pos=[-49:12, -18:12, -6:7, -5:19], -) -@test(err, at=ts.#tasks.t2, code=eval, path=ts.#tasks.t2.timeSpan.end, - contains="conflicting values %s and %s (mismatched types %s and %s)", - args=[119, float, int, float], - pos=[-54:12, -23:12, -11:7, -10:19], -) -- out/compile -- --- main.cue { diff --git a/internal/core/compile/testdata/sync/benchmarks/issue3633.txtar b/internal/core/compile/testdata/sync/benchmarks/issue3633.txtar index b13555cfe..7bca1ff8b 100644 --- a/internal/core/compile/testdata/sync/benchmarks/issue3633.txtar +++ b/internal/core/compile/testdata/sync/benchmarks/issue3633.txtar @@ -14,7 +14,7 @@ reduced: { f?: null | bool | string | int | #Schema } - out: #Schema & { #Schema } + out: #Schema & {#Schema} } full: { #Schema: { @@ -48,69 +48,6 @@ full: { properties: foo: required: ["bar", "baz"] }] } - -// TODO(inline): -// 1) format better -// 2) identify repeated elements -// 3) leave at= flag at begginning when generating. -@test(eq, at=full.out, [{ - properties: { - foo: { - required: ["bar", "baz"] - properties?: {} - foo00?: null | bool | string | [] | {string: >=-2147483648 & <=2147483647 & int} - foo01?: null | bool | string | [] | {string: >=-2147483648 & <=2147483647 & int} - foo02?: null | bool | string | [] | {string: >=-2147483648 & <=2147483647 & int} - foo03?: null | bool | string | [] | {string: >=-2147483648 & <=2147483647 & int} - foo04?: null | bool | string | [] | {string: >=-2147483648 & <=2147483647 & int} - foo05?: null | bool | string | [] | {string: >=-2147483648 & <=2147483647 & int} - foo06?: null | bool | string | [] | {string: >=-2147483648 & <=2147483647 & int} - foo07?: null | bool | string | [] | {string: >=-2147483648 & <=2147483647 & int} - foo08?: null | bool | string | [] | {string: >=-2147483648 & <=2147483647 & int} - foo09?: null | bool | string | [] | {string: >=-2147483648 & <=2147483647 & int} - foo10?: null | bool | string | [] | {string: >=-2147483648 & <=2147483647 & int} - foo11?: null | bool | string | [] | {string: >=-2147483648 & <=2147483647 & int} - foo12?: null | bool | string | [] | {string: >=-2147483648 & <=2147483647 & int} - foo13?: null | bool | string | [] | {string: >=-2147483648 & <=2147483647 & int} - foo14?: null | bool | string | [] | {string: >=-2147483648 & <=2147483647 & int} - foo15?: null | bool | string | [] | {string: >=-2147483648 & <=2147483647 & int} - foo16?: null | bool | string | [] | {string: >=-2147483648 & <=2147483647 & int} - foo17?: null | bool | string | [] | {string: >=-2147483648 & <=2147483647 & int} - foo18?: null | bool | string | [] | {string: >=-2147483648 & <=2147483647 & int} - foo19?: null | bool | string | [] | {string: >=-2147483648 & <=2147483647 & int} - } - } - required?: [] - foo00?: null | bool | string | [] | {string: >=-2147483648 & <=2147483647 & int} - foo01?: null | bool | string | [] | {string: >=-2147483648 & <=2147483647 & int} - foo02?: null | bool | string | [] | {string: >=-2147483648 & <=2147483647 & int} - foo03?: null | bool | string | [] | {string: >=-2147483648 & <=2147483647 & int} - foo04?: null | bool | string | [] | {string: >=-2147483648 & <=2147483647 & int} - foo05?: null | bool | string | [] | {string: >=-2147483648 & <=2147483647 & int} - foo06?: null | bool | string | [] | {string: >=-2147483648 & <=2147483647 & int} - foo07?: null | bool | string | [] | {string: >=-2147483648 & <=2147483647 & int} - foo08?: null | bool | string | [] | {string: >=-2147483648 & <=2147483647 & int} - foo09?: null | bool | string | [] | {string: >=-2147483648 & <=2147483647 & int} - foo10?: null | bool | string | [] | {string: >=-2147483648 & <=2147483647 & int} - foo11?: null | bool | string | [] | {string: >=-2147483648 & <=2147483647 & int} - foo12?: null | bool | string | [] | {string: >=-2147483648 & <=2147483647 & int} - foo13?: null | bool | string | [] | {string: >=-2147483648 & <=2147483647 & int} - foo14?: null | bool | string | [] | {string: >=-2147483648 & <=2147483647 & int} - foo15?: null | bool | string | [] | {string: >=-2147483648 & <=2147483647 & int} - foo16?: null | bool | string | [] | {string: >=-2147483648 & <=2147483647 & int} - foo17?: null | bool | string | [] | {string: >=-2147483648 & <=2147483647 & int} - foo18?: null | bool | string | [] | {string: >=-2147483648 & <=2147483647 & int} - foo19?: null | bool | string | [] | {string: >=-2147483648 & <=2147483647 & int} -}]) -@test(eq, { - a?: null | bool | string | int | {a?: null | bool | string | int | {a?: null | bool | string | int, b?: null | bool | string | int, c?: null | bool | string | int, d?: null | bool | string | int, e?: null | bool | string | int, f?: null | bool | string | int}, b?: null | bool | string | int | {a?: null | bool | string | int, b?: null | bool | string | int, c?: null | bool | string | int, d?: null | bool | string | int, e?: null | bool | string | int, f?: null | bool | string | int}, c?: null | bool | string | int | {a?: null | bool | string | int, b?: null | bool | string | int, c?: null | bool | string | int, d?: null | bool | string | int, e?: null | bool | string | int, f?: null | bool | string | int}, d?: null | bool | string | int | {a?: null | bool | string | int, b?: null | bool | string | int, c?: null | bool | string | int, d?: null | bool | string | int, e?: null | bool | string | int, f?: null | bool | string | int}, e?: null | bool | string | int | {a?: null | bool | string | int, b?: null | bool | string | int, c?: null | bool | string | int, d?: null | bool | string | int, e?: null | bool | string | int, f?: null | bool | string | int}, f?: null | bool | string | int | {a?: null | bool | string | int, b?: null | bool | string | int, c?: null | bool | string | int, d?: null | bool | string | int, e?: null | bool | string | int, f?: null | bool | string | int}} - b?: null | bool | string | int | {a?: null | bool | string | int | {a?: null | bool | string | int, b?: null | bool | string | int, c?: null | bool | string | int, d?: null | bool | string | int, e?: null | bool | string | int, f?: null | bool | string | int}, b?: null | bool | string | int | {a?: null | bool | string | int, b?: null | bool | string | int, c?: null | bool | string | int, d?: null | bool | string | int, e?: null | bool | string | int, f?: null | bool | string | int}, c?: null | bool | string | int | {a?: null | bool | string | int, b?: null | bool | string | int, c?: null | bool | string | int, d?: null | bool | string | int, e?: null | bool | string | int, f?: null | bool | string | int}, d?: null | bool | string | int | {a?: null | bool | string | int, b?: null | bool | string | int, c?: null | bool | string | int, d?: null | bool | string | int, e?: null | bool | string | int, f?: null | bool | string | int}, e?: null | bool | string | int | {a?: null | bool | string | int, b?: null | bool | string | int, c?: null | bool | string | int, d?: null | bool | string | int, e?: null | bool | string | int, f?: null | bool | string | int}, f?: null | bool | string | int | {a?: null | bool | string | int, b?: null | bool | string | int, c?: null | bool | string | int, d?: null | bool | string | int, e?: null | bool | string | int, f?: null | bool | string | int}} - c?: null | bool | string | int | {a?: null | bool | string | int | {a?: null | bool | string | int, b?: null | bool | string | int, c?: null | bool | string | int, d?: null | bool | string | int, e?: null | bool | string | int, f?: null | bool | string | int}, b?: null | bool | string | int | {a?: null | bool | string | int, b?: null | bool | string | int, c?: null | bool | string | int, d?: null | bool | string | int, e?: null | bool | string | int, f?: null | bool | string | int}, c?: null | bool | string | int | {a?: null | bool | string | int, b?: null | bool | string | int, c?: null | bool | string | int, d?: null | bool | string | int, e?: null | bool | string | int, f?: null | bool | string | int}, d?: null | bool | string | int | {a?: null | bool | string | int, b?: null | bool | string | int, c?: null | bool | string | int, d?: null | bool | string | int, e?: null | bool | string | int, f?: null | bool | string | int}, e?: null | bool | string | int | {a?: null | bool | string | int, b?: null | bool | string | int, c?: null | bool | string | int, d?: null | bool | string | int, e?: null | bool | string | int, f?: null | bool | string | int}, f?: null | bool | string | int | {a?: null | bool | string | int, b?: null | bool | string | int, c?: null | bool | string | int, d?: null | bool | string | int, e?: null | bool | string | int, f?: null | bool | string | int}} - d?: null | bool | string | int | {a?: null | bool | string | int | {a?: null | bool | string | int, b?: null | bool | string | int, c?: null | bool | string | int, d?: null | bool | string | int, e?: null | bool | string | int, f?: null | bool | string | int}, b?: null | bool | string | int | {a?: null | bool | string | int, b?: null | bool | string | int, c?: null | bool | string | int, d?: null | bool | string | int, e?: null | bool | string | int, f?: null | bool | string | int}, c?: null | bool | string | int | {a?: null | bool | string | int, b?: null | bool | string | int, c?: null | bool | string | int, d?: null | bool | string | int, e?: null | bool | string | int, f?: null | bool | string | int}, d?: null | bool | string | int | {a?: null | bool | string | int, b?: null | bool | string | int, c?: null | bool | string | int, d?: null | bool | string | int, e?: null | bool | string | int, f?: null | bool | string | int}, e?: null | bool | string | int | {a?: null | bool | string | int, b?: null | bool | string | int, c?: null | bool | string | int, d?: null | bool | string | int, e?: null | bool | string | int, f?: null | bool | string | int}, f?: null | bool | string | int | {a?: null | bool | string | int, b?: null | bool | string | int, c?: null | bool | string | int, d?: null | bool | string | int, e?: null | bool | string | int, f?: null | bool | string | int}} - e?: null | bool | string | int | {a?: null | bool | string | int | {a?: null | bool | string | int, b?: null | bool | string | int, c?: null | bool | string | int, d?: null | bool | string | int, e?: null | bool | string | int, f?: null | bool | string | int}, b?: null | bool | string | int | {a?: null | bool | string | int, b?: null | bool | string | int, c?: null | bool | string | int, d?: null | bool | string | int, e?: null | bool | string | int, f?: null | bool | string | int}, c?: null | bool | string | int | {a?: null | bool | string | int, b?: null | bool | string | int, c?: null | bool | string | int, d?: null | bool | string | int, e?: null | bool | string | int, f?: null | bool | string | int}, d?: null | bool | string | int | {a?: null | bool | string | int, b?: null | bool | string | int, c?: null | bool | string | int, d?: null | bool | string | int, e?: null | bool | string | int, f?: null | bool | string | int}, e?: null | bool | string | int | {a?: null | bool | string | int, b?: null | bool | string | int, c?: null | bool | string | int, d?: null | bool | string | int, e?: null | bool | string | int, f?: null | bool | string | int}, f?: null | bool | string | int | {a?: null | bool | string | int, b?: null | bool | string | int, c?: null | bool | string | int, d?: null | bool | string | int, e?: null | bool | string | int, f?: null | bool | string | int}} - f?: null | bool | string | int | {a?: null | bool | string | int | {a?: null | bool | string | int, b?: null | bool | string | int, c?: null | bool | string | int, d?: null | bool | string | int, e?: null | bool | string | int, f?: null | bool | string | int}, b?: null | bool | string | int | {a?: null | bool | string | int, b?: null | bool | string | int, c?: null | bool | string | int, d?: null | bool | string | int, e?: null | bool | string | int, f?: null | bool | string | int}, c?: null | bool | string | int | {a?: null | bool | string | int, b?: null | bool | string | int, c?: null | bool | string | int, d?: null | bool | string | int, e?: null | bool | string | int, f?: null | bool | string | int}, d?: null | bool | string | int | {a?: null | bool | string | int, b?: null | bool | string | int, c?: null | bool | string | int, d?: null | bool | string | int, e?: null | bool | string | int, f?: null | bool | string | int}, e?: null | bool | string | int | {a?: null | bool | string | int, b?: null | bool | string | int, c?: null | bool | string | int, d?: null | bool | string | int, e?: null | bool | string | int, f?: null | bool | string | int}, f?: null | bool | string | int | {a?: null | bool | string | int, b?: null | bool | string | int, c?: null | bool | string | int, d?: null | bool | string | int, e?: null | bool | string | int, f?: null | bool | string | int}} -}, at=reduced.out) - -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/benchmarks/issue572.txtar b/internal/core/compile/testdata/sync/benchmarks/issue572.txtar index 9c0849abd..ccdfd1e3a 100644 --- a/internal/core/compile/testdata/sync/benchmarks/issue572.txtar +++ b/internal/core/compile/testdata/sync/benchmarks/issue572.txtar @@ -13,13 +13,6 @@ unified: { "\(entry)": true } } - -// TODO(inline): _entries$p and [0] don't work here. -// @test(eq, at=_entries$p[0], 1) -// @test(eq, at=_entries$[1498], 1499) -@test(eq, at=unified."1", true) -@test(eq, at=unified."1499", true) - -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/benchmarks/listdedup.txtar b/internal/core/compile/testdata/sync/benchmarks/listdedup.txtar index cc0b1919b..f9d4af4cf 100644 --- a/internal/core/compile/testdata/sync/benchmarks/listdedup.txtar +++ b/internal/core/compile/testdata/sync/benchmarks/listdedup.txtar @@ -9,7 +9,7 @@ A: #Task B: #steps: #Script & {mount: [A]} C: #steps: #Script & {mount: [B]} -#Script: {mount: [...#Task]} @test(eq, {mount: []}) +#Script: {mount: [...#Task]} #Task: { // Without the proper constructs, repeating the below results @@ -22,106 +22,7 @@ C: #steps: #Script & {mount: [B]} ... } -#ref: {a: 1} | {b: 2} @test(eq, {a: 1} | {b: 2}) - -@test(eq, { - A: {#steps: {mount: []}, a: 1} | {#steps: {mount: []}, b: 2} - B: { - #steps: { - mount: [{#steps: {mount: []}, a: 1} | {#steps: {mount: []}, b: 2}] - } - } - C: { - #steps: { - mount: [{#steps: { - mount: [{#steps: {mount: []}, a: 1} | {#steps: {mount: []}, b: 2}] -}, a: 1} | {#steps: { - mount: [{#steps: {mount: []}, a: 1} | {#steps: {mount: []}, b: 2}] -}, b: 2}] - } - } - #Script: {mount: []} - #Task: {#steps: {mount: []}, a: 1} | {#steps: {mount: []}, b: 2} - #ref: {a: 1} | {b: 2} -}) -// TODO(inline): replace @test(debug) with @test(shareID=...) once the -// framework supports asserting sharing inside disjunction members. All -// ~(#Script) occurrences here are inside disjunct arms (A, #Task, -// B.#steps.mount[0]) — the CUE API creates a fresh vertex when projecting -// a field through a disjunction boundary, so pointer-identity checks fail. -@test(debug, """ - (struct){ - A: (#struct){ |((#struct){ - #steps: ~(#Script) - a: (int){ 1 } - }, (#struct){ - #steps: ~(#Script) - b: (int){ 2 } - }) } - B: (struct){ - #steps: (#struct){ - mount: (#list){ - 0: (#struct){ |((#struct){ - #steps: ~(#Script) - a: (int){ 1 } - }, (#struct){ - #steps: ~(#Script) - b: (int){ 2 } - }) } - } - } - } - C: (struct){ - #steps: (#struct){ - mount: (#list){ - 0: (#struct){ |((#struct){ - #steps: (#struct){ - mount: (#list){ - 0: (#struct){ |((#struct){ - #steps: ~(#Script) - a: (int){ 1 } - }, (#struct){ - #steps: ~(#Script) - b: (int){ 2 } - }) } - } - } - a: (int){ 1 } - }, (#struct){ - #steps: (#struct){ - mount: (#list){ - 0: (#struct){ |((#struct){ - #steps: ~(#Script) - a: (int){ 1 } - }, (#struct){ - #steps: ~(#Script) - b: (int){ 2 } - }) } - } - } - b: (int){ 2 } - }) } - } - } - } - #Script: (#struct){ - mount: (list){ - } - } - #Task: (#struct){ |((#struct){ - #steps: ~(#Script) - a: (int){ 1 } - }, (#struct){ - #steps: ~(#Script) - b: (int){ 2 } - }) } - #ref: (#struct){ |((#struct){ - a: (int){ 1 } - }, (#struct){ - b: (int){ 2 } - }) } - } - """) +#ref: {a: 1} | {b: 2} -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/benchmarks/listdisj.txtar b/internal/core/compile/testdata/sync/benchmarks/listdisj.txtar index 54077f40f..aa0e3c186 100644 --- a/internal/core/compile/testdata/sync/benchmarks/listdisj.txtar +++ b/internal/core/compile/testdata/sync/benchmarks/listdisj.txtar @@ -7,14 +7,14 @@ ["a", #T] | ["b", #T] | ["c", #T] | - ["d", ...#T] @test(shareID=T) + ["d", ...#T] -x: #T @test(shareID=T) -y: #T @test(shareID=T) -z: #T @test(shareID=T) -v: #T @test(shareID=T) +x: #T +y: #T +z: #T +v: #T -#X: x @test(shareID=T) +#X: x #X: y #X: z #X: v diff --git a/internal/core/compile/testdata/sync/benchmarks/mergeddisjunction.txtar b/internal/core/compile/testdata/sync/benchmarks/mergeddisjunction.txtar index ea5b1a2d1..1c6f3ff6b 100644 --- a/internal/core/compile/testdata/sync/benchmarks/mergeddisjunction.txtar +++ b/internal/core/compile/testdata/sync/benchmarks/mergeddisjunction.txtar @@ -28,7 +28,7 @@ b: { for x in a { "\(x.text)": {text: x.text} } -} @test(eq, {default: {text: *"default" | string}}) +} -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/benchmarks/share.txtar b/internal/core/compile/testdata/sync/benchmarks/share.txtar index 400be1fac..3e735d46e 100644 --- a/internal/core/compile/testdata/sync/benchmarks/share.txtar +++ b/internal/core/compile/testdata/sync/benchmarks/share.txtar @@ -1,9 +1,9 @@ See https://en.wikipedia.org/wiki/Billion_lauHs_attack. -- in.cue -- -f: [g, g, g, g, g, g, g] @test(shareID=G, at=0) @test(shareID=G, at=3) @test(shareID=G, at=6) -g: [h, h, h, h, h, h, h] @test(shareID=G) @test(shareID=H, at=0) @test(shareID=H, at=3) @test(shareID=H, at=6) -h: [i, i, i, i, i, i, i] @test(shareID=H) @test(shareID=I, at=0) @test(shareID=I, at=3) @test(shareID=I, at=6) -i: [j, j, j, j, j, j, j] @test(shareID=I) +f: [g, g, g, g, g, g, g] +g: [h, h, h, h, h, h, h] +h: [i, i, i, i, i, i, i] +i: [j, j, j, j, j, j, j] j: 1 -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/benchmarks/sharefg.txtar b/internal/core/compile/testdata/sync/benchmarks/sharefg.txtar index 602611fb2..f5dd93171 100644 --- a/internal/core/compile/testdata/sync/benchmarks/sharefg.txtar +++ b/internal/core/compile/testdata/sync/benchmarks/sharefg.txtar @@ -9,28 +9,28 @@ // f1: 5 // f2+: +3 each binexpr: { - f1: { out: x: 2 } - f2: { out: x: f1.out.x + 1 } - f3: { out: x: f2.out.x + 1 } - f4: { out: x: f3.out.x + 1 } - f5: { out: x: f4.out.x + 1 } - f6: { out: x: f5.out.x + 1 } - f7: { out: x: f6.out.x + 1 } - f8: { out: x: f7.out.x + 1 } @test(eq, {out: {x: 9}}) + f1: {out: x: 2} + f2: {out: x: f1.out.x + 1} + f3: {out: x: f2.out.x + 1} + f4: {out: x: f3.out.x + 1} + f5: {out: x: f4.out.x + 1} + f6: {out: x: f5.out.x + 1} + f7: {out: x: f6.out.x + 1} + f8: {out: x: f7.out.x + 1} } // 26 Nodes computed: // f1: 5 // f2+: +3 each parenthesized: { - f1: { out: x: 2 } - f2: { out: x: (f1.out).x + 1 } - f3: { out: x: (f2.out).x + 1 } - f4: { out: x: (f3.out).x + 1 } - f5: { out: x: (f4.out).x + 1 } - f6: { out: x: (f5.out).x + 1 } - f7: { out: x: (f6.out).x + 1 } - f8: { out: x: (f7.out).x + 1 } @test(eq, {out: {x: 9}}) + f1: {out: x: 2} + f2: {out: x: (f1.out).x + 1} + f3: {out: x: (f2.out).x + 1} + f4: {out: x: (f3.out).x + 1} + f5: {out: x: (f4.out).x + 1} + f6: {out: x: (f5.out).x + 1} + f7: {out: x: (f6.out).x + 1} + f8: {out: x: (f7.out).x + 1} } // TODO(perf): fix @@ -42,14 +42,14 @@ parenthesized: { // f1: 5 // f2+: +3 each embedded: { - f1: { out: x: 2 } - f2: { out: x: {f1.out}.x + 1 } - f3: { out: x: {f2.out}.x + 1 } - f4: { out: x: {f3.out}.x + 1 } - f5: { out: x: {f4.out}.x + 1 } - f6: { out: x: {f5.out}.x + 1 } - f7: { out: x: {f6.out}.x + 1 } - f8: { out: x: {f7.out}.x + 1 } @test(eq, {out: {x: 9}}) + f1: {out: x: 2} + f2: {out: x: {f1.out}.x + 1} + f3: {out: x: {f2.out}.x + 1} + f4: {out: x: {f3.out}.x + 1} + f5: {out: x: {f4.out}.x + 1} + f6: {out: x: {f5.out}.x + 1} + f7: {out: x: {f6.out}.x + 1} + f8: {out: x: {f7.out}.x + 1} } // TODO(perf): fix @@ -61,113 +61,53 @@ embedded: { // f1: 5 // f2+: +3 each embeddedWithEmpty: { - f1: { out: x: 2 } - f2: { out: x: {f1.out & {}}.x + 1 } - f3: { out: x: {f2.out & {}}.x + 1 } - f4: { out: x: {f3.out & {}}.x + 1 } - f5: { out: x: {f4.out & {}}.x + 1 } - f6: { out: x: {f5.out & {}}.x + 1 } - f7: { out: x: {f6.out & {}}.x + 1 } - f8: { out: x: {f7.out & {}}.x + 1 } @test(eq, {out: {x: 9}}) + f1: {out: x: 2} + f2: {out: x: {f1.out & {}}.x + 1} + f3: {out: x: {f2.out & {}}.x + 1} + f4: {out: x: {f3.out & {}}.x + 1} + f5: {out: x: {f4.out & {}}.x + 1} + f6: {out: x: {f5.out & {}}.x + 1} + f7: {out: x: {f6.out & {}}.x + 1} + f8: {out: x: {f7.out & {}}.x + 1} } // TODO(perf): fix // This will visualize O(n^2) output size unless CUE allows for a bit more // sophisticated sharing. weave: { - f: X={ + f: X={ out: in + 1 in: X.ref.out + 1 ref: _ & {} } - f8: f&{ ref: f7 } - f7: f&{ ref: f6 } - f6: f&{ ref: f5 } - f5: f&{ ref: f4 } - f4: f&{ ref: f3 } - f3: f&{ ref: f2 } @test(eq, {ref: {ref: {out: 2}, out: 4, in: 3}, out: 6, in: 5 }) - f2: f&{ ref: f1 } @test(eq, {ref: {out: 2}, out: 4, in: 3}) - f1: { out: 2 } @test(eq, {out: 2}) + f8: f & {ref: f7} + f7: f & {ref: f6} + f6: f & {ref: f5} + f5: f & {ref: f4} + f4: f & {ref: f3} + f3: f & {ref: f2} + f2: f & {ref: f1} + f1: {out: 2} } -@test(eq, at=weave.f8, { - ref: { - ref: { - ref: { - ref: { - ref: { - ref: {ref: {out: 2}, out: 4, in: 3} - out: 6 - in: 5 - } - out: 8 - in: 7 - } - out: 10 - in: 9 - } - out: 12 - in: 11 - } - out: 14 - in: 13 - } - out: 16 - in: 15 -}) // TODO(perf): fix // This will visualize O(n^2) output size unless CUE supports fine-grained // sharing. weaveExtraField: { - f: X={ + f: X={ out: in + 1 in: X.ref.out + 1 ref: {y: 4} // Cannot share because of this, but sub arcs still can be. } - f8: f&{ ref: f7 } @test(eq, 16, at=out) - f7: f&{ ref: f6 } - f6: f&{ ref: f5 } - f5: f&{ ref: f4 } - f4: f&{ ref: f3 } - f3: f&{ ref: f2 } - f2: f&{ ref: f1 } @test(eq, {ref: {y: 4, out: 2}, out: 4, in: 3}) - f1: { out: 2 } @test(eq, {out: 2}) + f8: f & {ref: f7} + f7: f & {ref: f6} + f6: f & {ref: f5} + f5: f & {ref: f4} + f4: f & {ref: f3} + f3: f & {ref: f2} + f2: f & {ref: f1} + f1: {out: 2} } - @test(eq, at=weaveExtraField.f8, { - ref: { - y: 4 - ref: { - y: 4 - ref: { - y: 4 - ref: { - y: 4 - ref: { - y: 4 - ref: { - y: 4 - ref: {y: 4, out: 2} - out: 4 - in: 3 - } - out: 6 - in: 5 - } - out: 8 - in: 7 - } - out: 10 - in: 9 - } - out: 12 - in: 11 - } - out: 14 - in: 13 - } - out: 16 - in: 15 -}) -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/benchmarks/sort.txtar b/internal/core/compile/testdata/sync/benchmarks/sort.txtar index 1cdcde44e..e32afe9db 100644 --- a/internal/core/compile/testdata/sync/benchmarks/sort.txtar +++ b/internal/core/compile/testdata/sync/benchmarks/sort.txtar @@ -9,9 +9,6 @@ _b: [_a, _a, _a, _a, _a, _a, _a, _a, _a, _a] _c: [_b, _b, _b, _b, _b, _b, _b, _b, _b, _b] out: list.Sort(list.FlattenN(_c, 4), {x: _, y: _, less: x.name < y.name}) - -@test(eq, at=out.0, {name: 0}) -@test(eq, at=out.899, {name: 9}) -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/benchmarks/typocheck.txtar b/internal/core/compile/testdata/sync/benchmarks/typocheck.txtar index cb82ead90..378bab16f 100644 --- a/internal/core/compile/testdata/sync/benchmarks/typocheck.txtar +++ b/internal/core/compile/testdata/sync/benchmarks/typocheck.txtar @@ -21,9 +21,9 @@ _input: { } } -_checkB1: out.B1 @test(eq, "name1") -_checkB50: out.B50 @test(eq, "name50") -_checkB99: out.B99 @test(eq, "name99") +_checkB1: out.B1 +_checkB50: out.B50 +_checkB99: out.B99 -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/builtins/056_issue314.txtar b/internal/core/compile/testdata/sync/builtins/056_issue314.txtar index e64ad6da2..47441bc5a 100644 --- a/internal/core/compile/testdata/sync/builtins/056_issue314.txtar +++ b/internal/core/compile/testdata/sync/builtins/056_issue314.txtar @@ -12,27 +12,23 @@ import ( x: { s: "myname" #T - @test(eq, {s: "myname", out: "myname"}) } #T: { - s: string + s: string out: template.Execute("{{.s}}", { "s": s - }) @test(err, code=incomplete, - contains="error in call to text/template.Execute: cannot convert non-concrete value string", pos=[0:7, -1:2]) + }) } #V: { - s: string - out: json.Marshal({"s": s}) @test(err, code=incomplete, - contains="cannot convert incomplete value", pos=[0:7, -1:7]) + s: string + out: json.Marshal({"s": s}) } #U: { - s: string - out: yaml.Marshal({"s": s}) @test(err, code=incomplete, - contains="incomplete value string", pos=[0:7, -1:7, 0:26]) + s: string + out: yaml.Marshal({"s": s}) } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/builtins/all.txtar b/internal/core/compile/testdata/sync/builtins/all.txtar index ba8922ddb..4950564d2 100644 --- a/internal/core/compile/testdata/sync/builtins/all.txtar +++ b/internal/core/compile/testdata/sync/builtins/all.txtar @@ -1,14 +1,12 @@ -- in.cue -- fatalArg: { - x: len("eee" + 'eee') @test(err, code=eval, - contains="invalid operands", - args= ["eee", 'eee', string, bytes], pos=[0:9, 0:17]) + x: len("eee" + 'eee') } // don't call builtin for a permanent error of a child node fatalChild: { #b: {} - x: and([{a: #b.c}]) @test(err, at=a, code=eval, contains="undefined field: c", pos=[0:17]) + x: and([{a: #b.c}]) } // allow incomplete child values. The error will persist after `and` is @@ -16,10 +14,7 @@ fatalChild: { // complete later. okIncompleteChild: { b: {} - x: and([{a: b.c}, {b: 1}]) @test(eq, { - a: _|_ @test(err, code=incomplete, contains="undefined field: c") - b: 1 - }) + x: and([{a: b.c}, {b: 1}]) } -- issue3412.cue -- // Tests that using and() in a pattern constraint with a definition @@ -31,11 +26,8 @@ andInPattern: { out: { [and(#constraints)]: _ someKey: {} - } @test(eq, { - [=~"^.*$"]: _ - someKey: {} - }) - #constraints: [=~"^.*$"] @test(eq, [=~"^.*$"]) + } + #constraints: [=~"^.*$"] } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/builtins/and.txtar b/internal/core/compile/testdata/sync/builtins/and.txtar index fc3d2cf8d..423b44230 100644 --- a/internal/core/compile/testdata/sync/builtins/and.txtar +++ b/internal/core/compile/testdata/sync/builtins/and.txtar @@ -1,15 +1,15 @@ -- in.cue -- -merge: and([1, 1]) @test(eq, 1) +merge: and([1, 1]) // ensure definitions along embedded scalars are preserved. -embed: and([{2, #x: 1}, {2, #x: 2}]) @test(err, code=eval, contains="conflicting values", args=[2, 1], pos=[0:13, 0:21, 0:25, 0:33]) +embed: and([{2, #x: 1}, {2, #x: 2}]) // issue3719: and() with a comprehension over an incomplete field failed in // evalv3 while the equivalent expression without and() worked correctly. // https://cuelang.org/issue/3719 issue3719: { - #openStruct: {...} - _filledLater: #openStruct.foo @test(err, code=incomplete, contains="undefined field: foo", pos=[0:28]) + #openStruct: {...} + _filledLater: #openStruct.foo // The comprehension below should work regardless of whether it's wrapped in "and". @@ -17,12 +17,12 @@ issue3719: { for k, v in _filledLater.bar { (k): v } - } @test(err, code=incomplete, contains="undefined field: foo", pos=[in.cue:11:28]) + } withAnd: and([ for k, v in _filledLater.bar { (k): v } - ]) @test(err, code=incomplete, contains="undefined field: foo", pos=[in.cue:11:28]) + ]) } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/builtins/args.txtar b/internal/core/compile/testdata/sync/builtins/args.txtar index f25fe30fa..9deaa7683 100644 --- a/internal/core/compile/testdata/sync/builtins/args.txtar +++ b/internal/core/compile/testdata/sync/builtins/args.txtar @@ -8,20 +8,14 @@ import ( // (e.g. *1 | 2) caused an "error in call" panic in evalv3. // https://cuelang.org/issue/3584 issue3584: reduced: t1: { - ref: out + ref: out trigger: *1 | 2 - out: strings.SliceRunes("ABC", 0, trigger) - @test(eq, { - ref: "A" - trigger: *1 | 2 - out: "A" - }) + out: strings.SliceRunes("ABC", 0, trigger) } issue3584: reduced: t2: { x: math.Abs(y) y: *6 | 5 - @test(eq, {x: 6, y: *6 | 5}) } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/builtins/closeall.txtar b/internal/core/compile/testdata/sync/builtins/closeall.txtar index 82bf9d9b7..000b9edf3 100644 --- a/internal/core/compile/testdata/sync/builtins/closeall.txtar +++ b/internal/core/compile/testdata/sync/builtins/closeall.txtar @@ -7,12 +7,11 @@ a: __closeAll({ nested: { field2: "hello" } -}) @test(eq, {field1: 1, nested: {field2: "hello"}}) +}) // Test that extra fields are not allowed (should error) b: { err: a & {extra: "not allowed"} - @test(err, at=err.extra, code=eval, contains="field not allowed", pos=[1:12]) } // Test that nested extra fields are not allowed (should error) @@ -21,35 +20,31 @@ c: { field1: 1 nested: { field2: "hello" - extra: "not allowed" + extra: "not allowed" } } - @test(err, at=err.nested.extra, code=eval, contains="field not allowed", pos=[5:4]) } // Test with non-struct should error d: { - err: __closeAll("not a struct") @test(err, code=eval, contains="argument must be a struct or list literal", pos=[0:7]) + err: __closeAll("not a struct") } // Test with empty struct -e: __closeAll({}) @test(eq, {}) +e: __closeAll({}) f: { - err: e & {extra: "not allowed"} // should error - @test(err, at=err.extra, code=eval, contains="field not allowed", pos=[1:12]) + err: e & {extra: "not allowed"} // should error } - #A: a: int g: { - err: __closeAll(#A) @test(err, code=eval, contains="argument must be a struct or list literal", pos=[0:7]) + err: __closeAll(#A) } -- old.cue -- // May not be used if explicitopen is not set. h: { - err: __closeAll({}) @test(err, code=eval, contains="__closeAll may only be used when explicitopen is enabled", pos=[0:7]) + err: __closeAll({}) } - -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/builtins/closed.txtar b/internal/core/compile/testdata/sync/builtins/closed.txtar index 9dcbd7689..0608370ce 100644 --- a/internal/core/compile/testdata/sync/builtins/closed.txtar +++ b/internal/core/compile/testdata/sync/builtins/closed.txtar @@ -3,8 +3,8 @@ a: close({ a: b: int }) -b: a & {x: int} @test(err, code=eval, at=x, contains="field not allowed", pos=[0:9]) // err -c: a & {a: c: int} @test(eq, {a: {c: int, b: int}}) // okay (non-recursive close) +b: a & {x: int} // err +c: a & {a: c: int} // okay (non-recursive close) inDisjunctions: { x: [string]: #Def @@ -16,35 +16,6 @@ inDisjunctions: { x: socket: string: {} x: syslog: x.socket x: syslog: xxx: {} - - @test(eq, { - x: { - socket: string: { - a: b: true - uint: a: b: true - } | { - a: b: true - string: a: b: true - } - syslog: { - string: { - a: b: true - uint: a: b: true - } | { - a: b: true - string: a: b: true - } - xxx: { - a: b: true - uint: a: b: true - } | { - a: b: true - string: a: b: true - } - } - } - #Def: {} - }) } // issue642: Tests that close() with merged struct patterns (concrete fields and @@ -55,24 +26,10 @@ issue642: { b: x: _ } & { [string]: y: _ - }) @test(closed) + }) test: a: x: _ test: b: x: _ - - @test(eq, { - test: { - [string]: y: _ - a: { - y: _ - x: _ - } - b: { - x: _ - y: _ - } - } - }) } // Issue 642 @@ -85,30 +42,16 @@ withSubfields: { test: a: x: _ test: b: x: _ - - @test(eq, { - test: { - [string]: y: _ - a: { - y: _ - x: _ - } - b: { - x: _ - y: _ - } - } - }) } // issue3572: Tests that close({...}) allows additional fields when unified // with an open struct. https://cuelang.org/issue/3572 issue3572: { - t1: close({...}) & {a: 5} @test(eq, {a: 5}) @test(closed) + t1: close({...}) & {a: 5} - e: close({...}) @test(closed) // TODO: @test(allows=expr) + e: close({...}) // TODO: @test(allows=expr) - t2: e & {a: 5} @test(eq, {a: 5}) @test(closed) + t2: e & {a: 5} } // issue3580: Tests that close() does not panic when a field inside the closed @@ -117,49 +60,43 @@ issue3580: { x: close({ a: _ b: x.a - }) @test(closed) + }) } -- embed.cue -- nestedEmbedded: base: { - close({ foo?: close({ foo?: _ }) }) + close({foo?: close({foo?: _})}) foo: allowed: 5 - - @test(eq, { foo: { allowed: 5, foo?: _ } }) } nestedEmbedded: t1: { - { close({ foo?: close({ foo?: _ }) }) } + {close({foo?: close({foo?: _})})} foo: allowed: 5 - - @test(eq, { foo: { allowed: 5, foo?: _ } }) } nestedEmbedded: t2: { - {{ close({ foo?: close({ foo?: _ }) }) }} + {{close({foo?: close({foo?: _})})}} foo: allowed: 5 - - @test(eq, { foo: { allowed: 5, foo?: _ } }) } unified: base: { - x: close({ foo?: close({ foo?: _ }) }) - x: foo: disallowed: 5 @test(err, code=eval, contains="field not allowed", pos=[0:10]) + x: close({foo?: close({foo?: _})}) + x: foo: disallowed: 5 } unified: t1: { - x: { close({ foo?: close({ foo?: _ }) }) } - x: foo: disallowed: 5 @test(err, code=eval, contains="field not allowed", pos=[0:10]) + x: {close({foo?: close({foo?: _})})} + x: foo: disallowed: 5 } unified: t2: { - x: {{ close({ foo?: close({ foo?: _ }) }) }} - x: foo: disallowed: 5 @test(err, code=eval, contains="field not allowed", pos=[0:10]) + x: {{close({foo?: close({foo?: _})})}} + x: foo: disallowed: 5 } nestedWithSelfReference: t1: { _schema: close({ foo?: _schema - }) @test(shareID=S) + }) // TODO(inline): make work for hidden fields. // @test(err, at=_schema.foo, code=structural_cycle) // @test(shareID=S, at=x.foo.foo) x: {_schema} - x: foo: disallowed: 5 @test(err, code=eval, contains="field not allowed", pos=[0:10]) + x: foo: disallowed: 5 } nestedWithSelfReference: t2: { _schema: close({ @@ -168,7 +105,7 @@ nestedWithSelfReference: t2: { // TODO(inline): make work for hidden fields. // @test(err, at=foo, code=structural_cycle) x: {{_schema}} - x: foo: disallowed: 5 @test(err, code=eval, contains="field not allowed", pos=[0:10]) + x: foo: disallowed: 5 } -- out/compile -- --- embed.cue diff --git a/internal/core/compile/testdata/sync/builtins/default.txtar b/internal/core/compile/testdata/sync/builtins/default.txtar index e016aeb7b..90e1db1fc 100644 --- a/internal/core/compile/testdata/sync/builtins/default.txtar +++ b/internal/core/compile/testdata/sync/builtins/default.txtar @@ -1,12 +1,12 @@ -- in.cue -- -Len: len(*[1, 2, 3] | 0) @test(eq, 3) -Close: close(*{} | 0) @test(eq, {}) @test(closed) -And: and(*[1, 1] | int) @test(eq, 1) -Or: or(*[1, 1] | int) @test(eq, 1) -Div: div(*5 | string, 2) @test(eq, 2) -Mod: mod(*5 | string, 2) @test(eq, 1) -Quo: quo(*5 | string, 2) @test(eq, 2) -Rem: rem(*5 | string, 2) @test(eq, 1) +Len: len(*[1, 2, 3] | 0) +Close: close(*{} | 0) +And: and(*[1, 1] | int) +Or: or(*[1, 1] | int) +Div: div(*5 | string, 2) +Mod: mod(*5 | string, 2) +Quo: quo(*5 | string, 2) +Rem: rem(*5 | string, 2) -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/builtins/error.txtar b/internal/core/compile/testdata/sync/builtins/error.txtar index 897ce3f62..b4f79af7e 100644 --- a/internal/core/compile/testdata/sync/builtins/error.txtar +++ b/internal/core/compile/testdata/sync/builtins/error.txtar @@ -3,60 +3,53 @@ module: "cuelang.org/error" language: version: "v0.15.0" -- in.cue -- selection: { - dropError: 1 | error("drop me") @test(eq, 1) + dropError: 1 | error("drop me") - useCustomError: 1&2 | error("use me") @test(err, code=eval, contains="use me", pos=[0:24, 0:18, 0:20]) + useCustomError: 1 & 2 | error("use me") - twoCustomErrors: 1&2 | error("error one") | error("error two") @test(err, code=eval, contains="empty disjunction", - suberr=(code=eval, contains="error one", pos=[0:25]), - suberr=(code=eval, contains="error two", pos=[0:46]), - ) + twoCustomErrors: 1 & 2 | error("error one") | error("error two") - x: int - dropIncomplete: x + 1 | error("user msg: x + 1 failed") @test(err, code=incomplete, contains="user msg: x + 1 failed", pos=[0:26, -1:5]) + x: int + dropIncomplete: x+1 | error("user msg: x + 1 failed") } interpolation: { a: {b: int} - world: "world" @test(eq, "world") + world: "world" - substituteAll: a.notExist | error("hello \(world)") @test(err, code=incomplete, contains="hello world", pos=[0:30]) + substituteAll: a.notExist | error("hello \(world)") - substituteFail: a.b + 1 | a.notExist | error("reference failed: \(a.b) | \(a.notExist)") @test(err, code=incomplete, contains="reference failed:", pos=[0:41, -5:9, 0:77]) + substituteFail: a.b+1 | a.notExist | error("reference failed: \(a.b) | \(a.notExist)") // When the error() message itself contains an error, // the custom error should not be thrown away. // For comparison, without interpolation: errorNoInterpolation: "a" | "b" | error("custom") - errorNoInterpolation: "c" @test(err, code=eval, contains="custom", pos=[-1:36, -1:24, 0:24]) + errorNoInterpolation: "c" // When the struct interpolation fails, the custom error should // still be shown rather than being replaced by the interpolation error. errorStructInterpolation: "a" | "b" | error("custom: \({x: 1})") - errorStructInterpolation: "c" @test(err, code=eval, contains="custom: {x:1}", pos=[-1:40, -1:28, -1:57, 0:28]) + errorStructInterpolation: "c" // When the interpolation always results in an error, the custom // error should still be shown. errorBottomInterpolation: "a" | "b" | error("custom: \(1 & 2)") - errorBottomInterpolation: "c" @test(err, code=eval, contains="custom: (1 & 2)", pos=[-1:40, -1:28, -1:57, 0:28]) + errorBottomInterpolation: "c" } indirect: { - x: error @test(eq, error) - y: x("msg") @test(err, code=user, contains="msg", pos=[0:5]) + x: error + y: x("msg") } -- incomplete.cue -- import "struct" // The custom error should not alter the type of error. -minFields: struct.MinFields(2) | error("should remain incomplete") @test(eq, struct.MinFields(2)) -maxFields: a: 1 @test(eq, 1) +minFields: struct.MinFields(2) | error("should remain incomplete") +maxFields: a: 1 -multi: struct.MinFields(2) | error("should remain incomplete") | error("second") @test(err, code=incomplete, - pos=[0:8, 0:25, 4:8], - suberr=(code=eval, contains="should remain incomplete", pos=[0:30]), - suberr=(code=eval, contains="second", pos=[0:66])) +multi: struct.MinFields(2) | error("should remain incomplete") | error("second") multi: a: 1 - -- self.cue -- @experiment(aliasv2) @@ -66,14 +59,13 @@ multi: a: 1 errorSelf: { v: "x" | "y" | error("bad: \(self)") v: "z" - @test(err, code=eval, contains="bad:", pos=[1:17, 0:12, 1:5, 2:5]) } -- issues.cue -- // issue4001: Tests that error() text is shown correctly when the message uses // string concatenation with interpolation. https://cuelang.org/issue/4001 issue4001: { a: "b" - a: int | error("error: "+"a='\(a)'") @test(err, code=eval, contains="error: a='b'", pos=[0:11, -1:5, 0:5]) + a: int | error("error: "+"a='\(a)'") } // issue3983: Tests that multiple error() disjunctions aggregate all user-defined // error messages correctly. https://cuelang.org/issue/3983 @@ -83,17 +75,12 @@ issue3983: { x: <20 | error("I wanted less than 20") x: 3 - @test(err, code=eval, contains="2 errors in empty disjunction", pos=[2:5, 5:5], - suberr=(code=eval, contains="I wanted an integer", hint="this could be dropped"), - suberr=(code=eval, contains="I wanted more than 10"), - hint="we could also include the third condition, if we want to be consistent.", - ) } // issue3984: Tests that error() shows all relevant source locations when the // error builtin is used in a disjunction. https://cuelang.org/issue/3984 issue3984: { v: "a" | error("must be a") - v: "b" @test(err, code=eval, contains="must be a", pos=[-1:11, -1:5, 0:5]) + v: "b" } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/builtins/export.txtar b/internal/core/compile/testdata/sync/builtins/export.txtar index 47ed783ef..bcd01638c 100644 --- a/internal/core/compile/testdata/sync/builtins/export.txtar +++ b/internal/core/compile/testdata/sync/builtins/export.txtar @@ -10,7 +10,7 @@ issue3972: { // was not used in the computation of the test result. That seems correct. // But maybe this test is then not testing what it is supposed to do. // Investigate against the original issue. - output: out0: "static" @test(eq, "static") // has to go first + output: out0: "static" // has to go first input: inputStatic: "static" if false { @@ -23,7 +23,7 @@ issue3972: { } _out1: [for svc, _ in derived {svc}] - output: out1: yaml.Marshal(_out1) @test(eq, "- derivedStatic\n") + output: out1: yaml.Marshal(_out1) } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/builtins/incomplete.txtar b/internal/core/compile/testdata/sync/builtins/incomplete.txtar index 018c7bb97..af7766ef9 100644 --- a/internal/core/compile/testdata/sync/builtins/incomplete.txtar +++ b/internal/core/compile/testdata/sync/builtins/incomplete.txtar @@ -8,92 +8,85 @@ import ( list1: { // Note that Top is not incomplete, only its first element is. // We allow FlattenN to proceed and pass on the incomplete values. - Out1: list.FlattenN(Top, 1) @test(err, at=0, code=incomplete, contains="undefined field: b", pos=[in.cue:19:10]) - Out2: [...] & list.FlattenN(Top, 1) @test(err, at=0, code=incomplete, contains="undefined field: b", pos=[in.cue:19:10]) - Out3: list.FlattenN(Top, 1) & [...] @test(err, at=0, code=incomplete, contains="undefined field: b", pos=[in.cue:19:10]) + Out1: list.FlattenN(Top, 1) + Out2: [...] & list.FlattenN(Top, 1) + Out3: list.FlattenN(Top, 1) & [...] // This evaluates to a list with an incomplete element. Top: [ [for _, F in _Sub {F}], - ] @test(err, at=0, code=incomplete, contains="undefined field: b", pos=[in.cue:19:10]) + ] - _Sub: a.b @test(err, code=incomplete, contains="undefined field: b", pos=[in.cue:19:10]) + _Sub: a.b a: {} // b does not } list2: { - Out1: list.FlattenN(_Top, 1) @test(err, code=incomplete, contains="undefined field: b", pos=[9:10]) - Out2: [...] & list.FlattenN(_Top, 1) @test(err, code=incomplete, contains="undefined field: b", pos=[8:10]) - Out3: list.FlattenN(_Top, 1) & [...] @test(err, code=incomplete, contains="undefined field: b", pos=[7:10]) + Out1: list.FlattenN(_Top, 1) + Out2: [...] & list.FlattenN(_Top, 1) + Out3: list.FlattenN(_Top, 1) & [...] // This evaluates to a list with an incomplete element. _Top: [ for _, F in #Sub {F}, - ] @test(err, code=incomplete, contains="undefined field: b", pos=[4:10]) + ] - #Sub: a.b @test(err, code=incomplete, contains="undefined field: b", pos=[0:10]) + #Sub: a.b a: {} // b does not } value1: { - a: len('sf' | 'dd') @test(err, code=incomplete|eval, - hint="this can never be resolve so could be a permanent error" - contains="unresolved disjunction", pos=[0:5]) @test(err:todo, code=eval) + a: len('sf' | 'dd') } value2: { len('sf' | 'dd') - - @test(err, code=incomplete|eval, - hint="this can never be resolve so could be a permanent error" - contains="unresolved disjunction") - @test(err:todo, code=eval) } incompleteArgDecimalList: { - a: #a & {param: 123} @test(eq, {param: 123, transformed: 123, max: 123}) + a: #a & {param: 123} #a: { param: int - transformed: +param @test(err, code=incomplete, contains="operand param of '+' not concrete", pos=[0:17]) - max: list.Max([transformed]) @test(err, code=incomplete, contains="operand param of '+' not concrete", pos=[0:16, -1:17]) + transformed: +param + max: list.Max([transformed]) } } incompleteArgStringList: { - a: #a & {param: "123"} @test(eq, {param: "123", transformed: "123", joined: "123"}) + a: #a & {param: "123"} #a: { param: string - transformed: param + "" @test(err, code=incomplete, contains="non-concrete value string in operand to +", pos=[0:16, -1:16]) - joined: strings.Join([transformed], "-") @test(err, code=incomplete, contains="non-concrete value string in operand to +", pos=[0:16, -2:16, -1:16]) + transformed: param + "" + joined: strings.Join([transformed], "-") } } incompleteList: { x: _ - decimal: list.Max(x) @test(err, code=incomplete, contains="non-concrete list for argument 0", pos=[0:11]) - str: strings.Join(x, "") @test(err, code=incomplete, contains="non-concrete list for argument 0", pos=[0:11]) + decimal: list.Max(x) + str: strings.Join(x, "") } // TODO: add better error positions. incompleteListError: { - x: y + [] @test(err, code=incomplete, contains="non-concrete value _ in operand to +", pos=[0:11, 1:11]) + x: y + [] y: _ - decimal: list.Max(x) @test(err, code=incomplete, contains="non-concrete value _ in operand to +", pos=[-2:11, -1:11]) - str: strings.Join(x, "") @test(err, code=incomplete, contains="non-concrete value _ in operand to +", pos=[-3:11, -2:11]) + decimal: list.Max(x) + str: strings.Join(x, "") } badListType: { x: 2 - decimal: list.Max(x) @test(err, code=eval, contains="cannot use 2 (type int) as list", pos=[-1:11]) - str: strings.Join(x, "") @test(err, code=eval, contains="cannot use 2 (type int) as list", pos=[-2:11]) + decimal: list.Max(x) + str: strings.Join(x, "") } badListError: { - x: 2 + y @test(err, code=eval, contains="invalid operands 2 and \"foo\" to '+'", pos=[0:11, 1:11]) + x: 2 + y y: "foo" - decimal: list.Max(x) @test(err, code=eval, contains="invalid operands 2 and \"foo\" to '+'", pos=[-2:11, -1:11]) - str: strings.Join(x, "") @test(err, code=eval, contains="invalid operands 2 and \"foo\" to '+'", pos=[-3:11, -2:11]) + decimal: list.Max(x) + str: strings.Join(x, "") } // Issue #1095 @@ -104,7 +97,7 @@ multipleErrors: { x: string y: string } - out: template.Execute("{{.x}} {{.y}}", params) @test(err, code=incomplete, contains="cannot convert non-concrete value string", pos=[0:8, -3:4]) + out: template.Execute("{{.x}} {{.y}}", params) } } -- out/compile -- diff --git a/internal/core/compile/testdata/sync/builtins/intdiv.txtar b/internal/core/compile/testdata/sync/builtins/intdiv.txtar index 473fd5d7f..68e321ad2 100644 --- a/internal/core/compile/testdata/sync/builtins/intdiv.txtar +++ b/internal/core/compile/testdata/sync/builtins/intdiv.txtar @@ -1,43 +1,43 @@ -- in.cue -- -quo1: quo(5, 2) @test(eq, 2) -quo2: quo(5, -2) @test(eq, -2) -quo3: quo(-5, 2) @test(eq, -2) -quo4: quo(-5, -2) @test(eq, 2) +quo1: quo(5, 2) +quo2: quo(5, -2) +quo3: quo(-5, 2) +quo4: quo(-5, -2) -quoDivByZero: quo(2, 0) @test(err, code=eval, contains="division by zero", pos=[0:15]) +quoDivByZero: quo(2, 0) -quoTypeError1: quo(2.0, 1) @test(err, code=eval, contains="cannot use 2.0 (type float) as int in argument 1 to quo", pos=[0:20]) -quoTypeError2: quo(2, 1.0) @test(err, code=eval, contains="cannot use 1.0 (type float) as int in argument 2 to quo", pos=[0:23]) +quoTypeError1: quo(2.0, 1) +quoTypeError2: quo(2, 1.0) -rem1: rem(5, 2) @test(eq, 1) -rem2: rem(5, -2) @test(eq, 1) -rem3: rem(-5, 2) @test(eq, -1) -rem4: rem(-5, -2) @test(eq, -1) +rem1: rem(5, 2) +rem2: rem(5, -2) +rem3: rem(-5, 2) +rem4: rem(-5, -2) -remDivByZero: rem(2, 0) @test(err, code=eval, contains="division by zero", pos=[0:15]) +remDivByZero: rem(2, 0) -remTypeError1: rem(2.0, 1) @test(err, code=eval, contains="cannot use 2.0 (type float) as int in argument 1 to rem", pos=[0:20]) -remTypeError2: rem(2, 1.0) @test(err, code=eval, contains="cannot use 1.0 (type float) as int in argument 2 to rem", pos=[0:23]) +remTypeError1: rem(2.0, 1) +remTypeError2: rem(2, 1.0) -div1: div(5, 2) @test(eq, 2) -div2: div(5, -2) @test(eq, -2) -div3: div(-5, 2) @test(eq, -3) -div4: div(-5, -2) @test(eq, 3) +div1: div(5, 2) +div2: div(5, -2) +div3: div(-5, 2) +div4: div(-5, -2) -divDivByZero: div(2, 0) @test(err, code=eval, contains="division by zero", pos=[0:15]) +divDivByZero: div(2, 0) -divTypeError1: div(2.0, 1) @test(err, code=eval, contains="cannot use 2.0 (type float) as int in argument 1 to div", pos=[0:20]) -divTypeError2: div(2, 1.0) @test(err, code=eval, contains="cannot use 1.0 (type float) as int in argument 2 to div", pos=[0:23]) +divTypeError1: div(2.0, 1) +divTypeError2: div(2, 1.0) -mod1: mod(5, 2) @test(eq, 1) -mod2: mod(5, -2) @test(eq, 1) -mod3: mod(-5, 2) @test(eq, 1) -mod4: mod(-5, -2) @test(eq, 1) +mod1: mod(5, 2) +mod2: mod(5, -2) +mod3: mod(-5, 2) +mod4: mod(-5, -2) -modDivByZero: mod(2, 0) @test(err, code=eval, contains="division by zero", pos=[0:15]) +modDivByZero: mod(2, 0) -modTypeError1: mod(2.0, 1) @test(err, code=eval, contains="cannot use 2.0 (type float) as int in argument 1 to mod", pos=[0:20]) -modTypeError2: mod(2, 1.0) @test(err, code=eval, contains="cannot use 1.0 (type float) as int in argument 2 to mod", pos=[0:23]) +modTypeError1: mod(2.0, 1) +modTypeError2: mod(2, 1.0) -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/builtins/issue299.txtar b/internal/core/compile/testdata/sync/builtins/issue299.txtar index 3cfaefd80..01e748489 100644 --- a/internal/core/compile/testdata/sync/builtins/issue299.txtar +++ b/internal/core/compile/testdata/sync/builtins/issue299.txtar @@ -6,7 +6,7 @@ import "list" x: list.UniqueItems x: [string, ...string] -x: ["x", "x"] @test(err, code=eval, contains="does not satisfy list.UniqueItems", pos=[-2:4, -1:4, 0:4]) +x: ["x", "x"] -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/builtins/issue4208.txtar b/internal/core/compile/testdata/sync/builtins/issue4208.txtar index 5358cf42c..b8b41c112 100644 --- a/internal/core/compile/testdata/sync/builtins/issue4208.txtar +++ b/internal/core/compile/testdata/sync/builtins/issue4208.txtar @@ -7,34 +7,12 @@ #Envs: [Env=#Environment]: {} // Valid key should work fine. -valid: #Envs @test(eq, {["sbx"|"stg"|"pro"]: {}, sbx: {}}, hint="user error should be preserved in pattern") +valid: #Envs valid: sbx: {} // Invalid key should show the custom error message. invalid: #Envs -invalid: foo: {} @test(err, code=eval, contains="field not allowed", incorrect) @test(err:todo, code=eval, contains="Must specify a valid environment") - - -@test(debug, """ - (_|_){ - // [eval] - #Environment: (string){ |((string){ "sbx" }, (string){ "stg" }, (string){ "pro" }) } - #Envs: (#struct){ - } - valid: (#struct){ - sbx: (#struct){ - } - } - invalid: (_|_){ - // [eval] - foo: (_|_){ - // [eval] invalid.foo: field not allowed: - // in.cue:10:10 - } - } - } - """) - +invalid: foo: {} -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/builtins/issue490.txtar b/internal/core/compile/testdata/sync/builtins/issue490.txtar index be60e78e6..821121220 100644 --- a/internal/core/compile/testdata/sync/builtins/issue490.txtar +++ b/internal/core/compile/testdata/sync/builtins/issue490.txtar @@ -5,30 +5,11 @@ A: close({ a: 1 b: 2 -}) @test(eq, {a: 1, b: 2}) +}) B: A & { c: 3 -} @test(err, code=eval, at=c, contains="field not allowed", pos=[1:2]) - -@test(debugCheck, """ - (_|_){ - // [eval] - A: (#struct){ - a: (int){ 1 } - b: (int){ 2 } - } - B: (_|_){ - // [eval] - c: (_|_){ - // [eval] B.c: field not allowed: - // test.cue:7:2 - } - a: (int){ 1 } - b: (int){ 2 } - } - } - """) +} -- out/compile -- --- test.cue { diff --git a/internal/core/compile/testdata/sync/builtins/issue_3567.txtar b/internal/core/compile/testdata/sync/builtins/issue_3567.txtar index 0323b0abb..5ab3d3cfd 100644 --- a/internal/core/compile/testdata/sync/builtins/issue_3567.txtar +++ b/internal/core/compile/testdata/sync/builtins/issue_3567.txtar @@ -1,7 +1,7 @@ -- in.cue -- import "strings" -a: strings.Join( [ strings.Join(["1"]), "2" ], "\n") @test(err, code=eval, contains="not enough arguments in call to strings.Join", pos=[0:4, 0:20]) +a: strings.Join( [strings.Join(["1"]), "2"], "\n") -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/builtins/list/issue332.txtar b/internal/core/compile/testdata/sync/builtins/list/issue332.txtar index ae1f07cfe..0dc77efbe 100644 --- a/internal/core/compile/testdata/sync/builtins/list/issue332.txtar +++ b/internal/core/compile/testdata/sync/builtins/list/issue332.txtar @@ -11,11 +11,11 @@ import "list" } #foo: { X=#x: _ - y: list.FlattenN((#d & {#x: X}).result, 1) + y: list.FlattenN((#d & {#x: X}).result, 1) } r: #foo & { #x: "hello" -} @test(eq, {#x: "hello", y: ["hello"]}) +} -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/builtins/list/sort.txtar b/internal/core/compile/testdata/sync/builtins/list/sort.txtar index 9d5fcbd8e..afd11479a 100644 --- a/internal/core/compile/testdata/sync/builtins/list/sort.txtar +++ b/internal/core/compile/testdata/sync/builtins/list/sort.txtar @@ -1,7 +1,7 @@ -- in.cue -- import "list" -a: list.Sort([2, 3, 1, 4], {x: _, y: _, less: x < y}) @test(eq, [1, 2, 3, 4]) +a: list.Sort([2, 3, 1, 4], {x: _, y: _, less: x < y}) -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/builtins/matchif.txtar b/internal/core/compile/testdata/sync/builtins/matchif.txtar index 306ebf0f1..0c548d002 100644 --- a/internal/core/compile/testdata/sync/builtins/matchif.txtar +++ b/internal/core/compile/testdata/sync/builtins/matchif.txtar @@ -1,17 +1,17 @@ -- in.cue -- regularFields: { [_]: matchIf({x!: >2}, {y!: 5}, {y!: 1}) - ok1: {x: 10, y: 5} @test(eq, {x: 10, y: 5}) - ok2: {x: 11, y: 5} @test(eq, {x: 11, y: 5}) - ok3: {x: 2, y: 1} @test(eq, {x: 2, y: 1}) - ok4: {x: 1, y: 1} @test(eq, {x: 1, y: 1}) + ok1: {x: 10, y: 5} + ok2: {x: 11, y: 5} + ok3: {x: 2, y: 1} + ok4: {x: 1, y: 1} // TODO: allow unwrapping errors so that we can test args in wrapped errors, // without having to match the other arguments. - err1: {x: 10, y: 6} @test(err, code=eval, contains="conflicting values 5 and 6", pos=[in.cue:2:7, in.cue:2:30, 0:8, 0:19]) - err2: {x: 11, y: 6} @test(err, code=eval, contains="conflicting values 5 and 6", pos=[in.cue:2:7, in.cue:2:30, 0:8, 0:19]) - err3: {x: 2, y: 5} @test(err, code=eval, contains="conflicting values 1 and 5", pos=[in.cue:2:7, in.cue:2:39, 0:8, 0:18]) - err4: {x: 1, y: 2} @test(err, code=eval, contains="conflicting values 1 and 2", pos=[in.cue:2:7, in.cue:2:39, 0:8, 0:18]) + err1: {x: 10, y: 6} + err2: {x: 11, y: 6} + err3: {x: 2, y: 5} + err4: {x: 1, y: 2} } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/builtins/matchn.txtar b/internal/core/compile/testdata/sync/builtins/matchn.txtar index fe2b4fdef..6fb69ce20 100644 --- a/internal/core/compile/testdata/sync/builtins/matchn.txtar +++ b/internal/core/compile/testdata/sync/builtins/matchn.txtar @@ -7,17 +7,15 @@ import "math" match: { [=~"^single"]: matchN(1, [#Foo]) - singleOK: {a: 2} @test(eq, {a: 2}) + singleOK: {a: 2} singleErr: { a: "foo" - @test(err, code=eval, contains="does not satisfy matchN", pos=[-2:17, -2:24, 0:13]) } [=~"^incomplete"]: matchN(1, [#Foo]) - incompleteOK: {a: int} @test(eq, {a: int}) + incompleteOK: {a: int} incompleteErr: { a: string - @test(err, code=eval, contains="does not satisfy matchN", pos=[-2:21, -2:28, 0:17]) } #A: { @@ -35,36 +33,24 @@ match: { // issue if the schema matched against is not concrete. [=~"^pickTop"]: matchN(1, [2]) // TODO(inline): this matches the debug output, but it nonetheless doesn't pass. - pickTopOK1: *2 | int @test(eq:todo, *2 | matchN(1, [2]) & int) - pickTopOK2: int @test(eq, matchN(1, [2]) & int) - pickTopErr: *3 | int @test(eq:todo, - hint="or should this be an error? Depends on when value is finalized.", - matchN(1, [2]) & int) @test(debugCheck, """ - (int){ &(matchN(1, (#list){ - 0: (int){ 2 } - }), int) } - """) + pickTopOK1: *2 | int + pickTopOK2: int + pickTopErr: *3 | int // Nested default values will be evaluated and may not be overridden by // values in the validator. [=~"^pickNested1"]: matchN(1, [{a: 2}]) - pickNested1OK1: {a: *2 | int} @test(eq, {a: *2 | int}) - pickNested1OK2: {a: int} @test(eq, {a: int}) + pickNested1OK1: {a: *2 | int} + pickNested1OK2: {a: int} pickNested1Err: { a: *3 | int - @test(err, code=eval, - hint="should this be an incomplete error, as a may still change and pass?", - contains="does not satisfy matchN", pos=[-3:23, -3:30, 0:19]) } [=~"^pickNested2"]: matchN(1, [{a: <=2}]) - pickNested2OK1: {a: *2 | int} @test(eq, {a: *2 | int}) - pickNested2OK2: {a: int} @test(eq, {a: int}) + pickNested2OK1: {a: *2 | int} + pickNested2OK2: {a: int} pickNested2Err: { a: *3 | int - @test(err, code=eval, - hint="should this be an incomplete error, as a may still change and pass?", - contains="does not satisfy matchN", pos=[-3:23, -3:30, 0:19]) } } @@ -75,14 +61,12 @@ match: { a: 2 b: { matchN(4, [#A, #A, #A, #A]) - + a: 3 b: matchN(4, [#A, #A, #A, #A]) b: {a: 4} c: matchN(4, [#A, #A, #A, #A]) c: {a: 5} - - @test(eq, {a: 3, b: {a: 4}, c: {a: 5}}) } c: { matchN(4, [#A, #A, #A, #A]) @@ -92,96 +76,71 @@ match: { b: {a: 4} c: matchN(4, [#A, #A, #A, #A]) c: {a: 5} - - @test(eq, {a: 3, b: {a: 4}, c: {a: 5}}) } } } not: { [=~"^single"]: matchN(0, [#Foo]) - singleOK: {a: "foo"} @test(eq, {a: "foo"}) + singleOK: {a: "foo"} singleErr: { a: 2 - @test(err, code=eval, contains="does not satisfy matchN", pos=[-2:17, -2:24, 0:13]) } [=~"^double"]: matchN(0, [matchN(0, [#Foo])]) - doubleOK: {a: 2} @test(eq, {a: 2}) + doubleOK: {a: 2} doubleErr: { a: "foo" - @test(err, code=eval, contains="does not satisfy matchN", pos=[-2:17, -2:24, 0:13]) } } oneOf: { [=~"^multiple1"]: matchN(1, [math.MultipleOf(3), math.MultipleOf(5)]) - multiple1Err1: 1 @test(err, code=eval, contains="does not satisfy matchN", pos=[-2:20, -2:27, 0:17]) + multiple1Err1: 1 - multiple1OK1: 3 @test(eq, 3) - multiple1OK2: 5 @test(eq, 5) + multiple1OK1: 3 + multiple1OK2: 5 - multiple1Err2: 15 @test(err, code=eval, contains="does not satisfy matchN", pos=[-7:20, -7:27, 0:17]) + multiple1Err2: 15 } anyOf: { [=~"^multiple1"]: matchN(>0, [math.MultipleOf(3), math.MultipleOf(5)]) - multiple1Err1: 1 @test(err, code=eval, contains="does not satisfy matchN", pos=[-2:20, -2:27, 0:17]) + multiple1Err1: 1 - multiple1OK1: 3 @test(eq, 3) - multiple1OK2: 5 @test(eq, 5) - multiple1OK3: 15 @test(eq, 15) + multiple1OK1: 3 + multiple1OK2: 5 + multiple1OK3: 15 } - allOf: { [=~"^multiple1"]: matchN(2, [math.MultipleOf(3), math.MultipleOf(5)]) - multiple1Err1: 1 @test(err, code=eval, contains="does not satisfy matchN", pos=[-2:20, -2:27, 0:17]) - multiple1Err2: 3 @test(err, code=eval, contains="does not satisfy matchN", pos=[-3:20, -3:27, 0:17]) - multiple1Err3: 5 @test(err, code=eval, contains="does not satisfy matchN", pos=[-4:20, -4:27, 0:17]) + multiple1Err1: 1 + multiple1Err2: 3 + multiple1Err3: 5 - multiple1OK1: 15 @test(eq, 15) + multiple1OK1: 15 } bare: { embed: t1: { a: {matchN(1, [>10])} b: {a} - - @test(eq, { - a: matchN(1, [>10]) - b: matchN(1, [>10]) - }) } embed: t2: { b: {a} a: {matchN(1, [>10])} - - @test(eq, { - b: matchN(1, [>10]) - a: matchN(1, [>10]) - }) } direct: t1: { a: matchN(1, [>10]) b: a - - @test(eq, { - a: matchN(1, [>10]) - b: matchN(1, [>10]) - }) } direct: t2: { b: a a: matchN(1, [>10]) - - @test(eq, { - b: matchN(1, [>10]) - a: matchN(1, [>10]) - }) } } @@ -189,17 +148,14 @@ required: { ok1: { x: matchN(0, [{foo!: string}]) x: bar: 2 - @test(eq, {x: {bar: 2}}) } ok2: { x: matchN(0, [{foo!: string}]) - @test(eq, {x: matchN(0, [{ foo!: string }])}) } // not matching for different reasons ok3: { x: matchN(0, [{bar!: string}]) x: bar: 2 - @test(eq, {x: {bar: 2}}) } } @@ -214,7 +170,6 @@ issue3575: { ]) x: #x x: [{a: 1}] - @test(eq, {#x: matchN(1, [[{}]]), x: [{ a: 1 }]}) } test2: { #x: matchN(1, [ @@ -222,10 +177,8 @@ issue3575: { ]) x: #x x: {a: 1} - @test(eq, {#x: matchN(1, [{}]), x: {a: 1}}) } } - -- incomplete.cue -- import "math" @@ -235,85 +188,54 @@ incomplete: { incomplete1: { x: matchN(1, [{foo!: string}]) x: bar: 2 - @test(err, code=incomplete, at=x, - suberr=(code=incomplete, contains="does not satisfy matchN", pos=[1:6, 1:13, 2:6]), - suberr=(code=incomplete, contains="field is required but not present", pos=[1:6, 1:18])) } // foo could still be provided later. incomplete2: { x: matchN(1, [{foo!: string}]) - @test(eq, {x: matchN(1, [{ - foo!: string - }])}) } // in case of doubt, we should mark an error as incomplete to be safe. incomplete3: { x: matchN(math.MultipleOf(2), [{bar!: int}, {foo!: int}]) x: bar: 2 - @test(eq, {x: {bar: 2}}) - @test(err, code=incomplete, at=x, - suberr=(code=incomplete, contains="does not satisfy matchN", pos=[1:6, 1:13, 2:6]), - suberr=(code=incomplete, contains="field is required but not present", pos=[1:6, 1:48])) } incomplete4: { x: matchN(math.MultipleOf(2), [{bar!: int}, {foo!: int}, {baz!: int}]) x: bar: 2 - @test(eq, {x: {bar: 2}}) - @test(err, code=incomplete, at=x, - suberr=(code=incomplete, contains="does not satisfy matchN", pos=[1:6, 1:13, 2:6]), - suberr=(code=incomplete, contains="field is required but not present", pos=[1:6, 1:61]), - suberr=(code=incomplete, contains="field is required but not present", pos=[1:6, 1:48])) - } incomplete5: { x: matchN(>1 & <=3, [{bar!: int}, {foo!: int}, {baz!: int}]) x: bar: 2 - @test(eq, {x: {bar: 2}}) - @test(err, code=incomplete, at=x, - suberr=(code=incomplete, contains="does not satisfy matchN", pos=[1:6, 1:13, 2:6]), - suberr=(code=incomplete, contains="field is required but not present", pos=[1:6, 1:38]), - suberr=(code=incomplete, contains="field is required but not present", pos=[1:6, 1:51])) } incomplete6: { - x: matchN(2|3, [{bar!: int}, {foo!: int}, {baz!: int}]) + x: matchN(2 | 3, [{bar!: int}, {foo!: int}, {baz!: int}]) x: bar: 2 - @test(eq, {x: {bar: 2}}) - @test(err, code=incomplete, at=x, - suberr=(code=incomplete, contains="does not satisfy matchN", pos=[1:6, 1:13, 2:6]), - suberr=(code=incomplete, contains="field is required but not present", pos=[1:6, 1:33]), - suberr=(code=incomplete, contains="field is required but not present", pos=[1:6, 1:46])) } // incorrect type cannot be corrected err1: { x: matchN(1, [{bar!: string}]) x: bar: 2 - @test(err, code=eval, at=x, contains="does not satisfy matchN", pos=[1:6, 1:13, 2:6]) } // additional incomplete matches should not be counted if they can otherwise // not satisfy the constraint. err2: { x: matchN(0, [{bar!: int}, {foo!: int}]) x: bar: 2 - @test(err, code=eval, at=x, contains="does not satisfy matchN", pos=[1:6, 1:13, 2:6]) } // additional incomplete matches should not be counted if they can otherwise // not satisfy the constraint. err3: { x: matchN(2, [{bar!: string}, {foo!: string}]) x: bar: 2 - @test(err, code=eval, at=x, contains="does not satisfy matchN", pos=[1:6, 1:13, 2:6]) } // one additional potential match cannot make up to satisfy the bound. err4: { x: matchN(>1, [{bar!: string}, {foo!: string}]) x: bar: 2 - @test(err, code=eval, at=x, contains="does not satisfy matchN", pos=[1:6, 1:13, 2:6]) } err5: { x: matchN(<1, [{bar!: int}, {foo!: int}]) x: bar: 2 - @test(err, code=eval, at=x, contains="does not satisfy matchN", pos=[1:6, 1:13, 2:6]) } } // issue3389: Tests that matchN only reports schema errors of lesser severity, @@ -323,21 +245,6 @@ issue3389: { // TODO(inline): issue converting to tests. Documented later. x: bar: 2 x: matchN(1, [{bar: 3}, {bar: 2, foo!: int}]) - - @test(debug, """ - (struct){ - x: (_|_){ - // [incomplete] issue3389.x: invalid value {bar:2} (does not satisfy matchN): 0 matched, expected 1: - // incomplete.cue:96:5 - // incomplete.cue:95:5 - // incomplete.cue:96:12 - // issue3389.x.foo: field is required but not present: - // incomplete.cue:96:5 - // incomplete.cue:96:35 - bar: (int){ 2 } - } - } - """) } -- closedness.cue -- ellipsis: ok: { @@ -346,18 +253,8 @@ ellipsis: ok: { } #Schema: { field?: #anything - #anything: matchN(1, [{ ... }]) + #anything: matchN(1, [{...}]) } - @test(eq, { - out: { - field: {shouldBeAllowed: 123} - #anything: matchN(1, [{ ... }]) - } - #Schema: { - field?: matchN(1, [{ ... }]) - #anything: matchN(1, [{ ... }]) - } - }) } // Arguments to function are not closed by enclosing definition. openArguments: ok1: { @@ -367,25 +264,18 @@ openArguments: ok1: { out: #Schema & { a: baz: "allowed" } - @test(eq, { - #Schema: {a: matchN(1, ["all", { - foo: "bar" - }])} - out: {a: {baz: "allowed"}} - }) } openArguments: err2: { #Schema: {{ - a?: matchN(1, [ //fails - null, // fail - { [string]: string }, // pass - {b: {...}}, // pass - ]) + a?: matchN(1, [//fails + null, // fail + {[string]: string}, // pass + {b: {...}}, // pass + ]) }} out: #Schema & { a: allowed: "once" } - @test(err, code=eval, at=out.a, contains="does not satisfy matchN", pos=[2:13, 2:20, 9:6]) } explicitClose: err1: { #Schema: {{ @@ -394,25 +284,24 @@ explicitClose: err1: { out: #Schema & { a: baz: "notAllowed" } - @test(err, code=eval, at=out.a, contains="does not satisfy matchN", pos=[2:6, 2:13, 5:6]) } explicitClose: ok2: { #Schema: {{ - a?: matchN(1, [ - null, // fail - close({ [string]: string }), // pass - close({b: {...}}), // fail - ]) + a?: matchN(1, [ + null, // fail + close({[string]: string}), // pass + close({b: {...}}), // fail + ]) }} out: #Schema & { a: allowed: "once" - } @test(eq, {a: {allowed: "once"}}) + } } mixed: ok3: { #Schema: { exports?: matchN(1, [ - close({ never?: _ }), // fail - #exportsObject, // pass + close({never?: _}), // fail + #exportsObject, // pass ]) #exports: matchN(1, [string, #exportsObject]) @@ -422,26 +311,6 @@ mixed: ok3: { out: #Schema & { exports: exp1: "./main-module.js" } - // TODO(inline): the errors here are legal structural cycles. We need to - // be able to print those. - @test(eq, { - #Schema: { - exports?: matchN(1, [close({ - never?: _ - }), _|_]) - #exports: matchN(1, [string, _|_]) - #exportsObject: { - exp1?: matchN(1, [string, _|_]) - } - } - out: { - exports: {exp1: "./main-module.js"} - #exports: matchN(1, [string, _|_]) - #exportsObject: { - exp1?: matchN(1, [string, _|_]) - } - } - }) } closedByDefinition: ok4: { @@ -454,24 +323,6 @@ closedByDefinition: ok4: { out: #Schema & { exports: exp1: "./main-module.js" } - // TODO(inline): the errors here are legal structural cycles. We need to - // be able to print those. - @test(eq, { - #Schema: { - exports?: matchN(1, [string, _|_]) - #exports: matchN(1, [string, _|_]) - #exportsObject: { - exp1?: matchN(1, [string, _|_]) - } - } - out: { - exports: {exp1: "./main-module.js"} - #exports: matchN(1, [string, _|_]) - #exportsObject: { - exp1?: matchN(1, [string, _|_]) - } - } - }) } closedByDefinition: err5: { #Schema: { @@ -483,9 +334,7 @@ closedByDefinition: err5: { out: #Schema & { exports: exp1: "./main-module.js" } - @test(err, code=eval, at=out.exports, contains="does not satisfy matchN", pos=[2:13, 2:20, 8:12]) } - -- issue3694.cue -- // issue3694: Tests that matchN combined with close() correctly validates schemas // requiring one of several required fields. https://cuelang.org/issue/3694 @@ -505,10 +354,6 @@ issue3694: full: { s: #step & { run: "echo hello world" } - @test(eq, { - #step: {uses?: string, run?: string} - s: {run: "echo hello world", uses?: string} - }) } issue3694: simple: { #step: matchN(1, [{ @@ -517,10 +362,7 @@ issue3694: simple: { #step: close({ uses?: string }) - @test(eq, {#step: {uses?: string}}) } -@test(err, code=incomplete, at=issue3694.full.#step, contains="does not satisfy matchN", pos=[-29:9, -29:16, -22:9]) -@test(err, code=incomplete, at=issue3694.simple.#step, contains="does not satisfy matchN", pos=[-9:9, -9:16, -6:9]) -- out/compile -- --- closedness.cue { diff --git a/internal/core/compile/testdata/sync/builtins/or.txtar b/internal/core/compile/testdata/sync/builtins/or.txtar index 247da0619..51a86c714 100644 --- a/internal/core/compile/testdata/sync/builtins/or.txtar +++ b/internal/core/compile/testdata/sync/builtins/or.txtar @@ -1,14 +1,14 @@ -- in.cue -- // unwrap into single value -unwrap: or([1, 1, 1]) @test(eq, 1) +unwrap: or([1, 1, 1]) // unique duplicate values -unique1: or([2, 1, 1, 2]) @test(eq, 2 | 1) +unique1: or([2, 1, 1, 2]) -unique2: or([{a: 1}, {a: 1}, {a: 2}]) @test(eq, {a: 1} | {a: 2}) +unique2: or([{a: 1}, {a: 1}, {a: 2}]) // do not unique embedded scalars with differing values for child definitions. -embed1: or([{2, #x: 1}, {2, #x: 2}]) @test(eq, {2, #x: 1} | {2, #x: 2}) +embed1: or([{2, #x: 1}, {2, #x: 2}]) -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/builtins/reclose.txtar b/internal/core/compile/testdata/sync/builtins/reclose.txtar index b221ddaa7..b1f3d2cab 100644 --- a/internal/core/compile/testdata/sync/builtins/reclose.txtar +++ b/internal/core/compile/testdata/sync/builtins/reclose.txtar @@ -8,15 +8,11 @@ noClose: { }) t1: ok: a & {b: 1} - @test(eq, { - foo: {a: int} - a: {a: int} - t1: {ok: {b: 1, a: int}} - }) } recursive: { - #x: { foo: int} + #x: {foo: int} + // Basic usage of __reclose - makes structs recursively closed a: __reclose({ #x... @@ -24,35 +20,33 @@ recursive: { }) // Test that extra fields are not allowed (should error) - t1: err: a & {extra: "not allowed"} @test(err, code=eval, path=extra, contains="field not allowed", pos=[0:16]) - - t2: ok: a & {nested: field2: 5} @test(eq, {nested: {field2: 5}, foo: int}) - t3: ok: a & {foo: 5} @test(eq, {foo: 5, nested: {field2: int}}) + t1: err: a & {extra: "not allowed"} + t2: ok: a & {nested: field2: 5} + t3: ok: a & {foo: 5} // Test that nested extra fields are not allowed (should error) t4: err: a & { nested: { field2: 1 - extra: "not allowed" + extra: "not allowed" } - } @test(err, code=eval, path=nested.extra, contains="field not allowed", pos=[3:4]) + } // Test with empty struct // TODO(eval): is this correct? e: __reclose({}) - t5: err: e & {extra: "not allowed"} @test(eq, {extra: "not allowed"}) + t5: err: e & {extra: "not allowed"} } - nonRecursive: { x: __reclose({ close({b: int})... c: int d: e: int }) - y: err: x & {f: int} @test(err, code=eval, path=f, contains="field not allowed", pos=[0:15]) - z: ok: x & {d: f: int} @test(eq, {d: {f: int, e: int}, c: int, b: int}) + y: err: x & {f: int} + z: ok: x & {d: f: int} } // Test that __reclose detects and restores non-recursive closing from @@ -63,9 +57,9 @@ nonRecursiveDetect: { foo... }) // Top-level field not allowed: non-recursive close restored by __reclose. - t1: err: a & {f: int} @test(err, code=eval, path=f, contains="field not allowed", pos=[0:16]) + t1: err: a & {f: int} // Nested field allowed: close was non-recursive, so b is still open. - t2: ok: a & {b: c: 1} @test(eq, {b: {c: 1}}) + t2: ok: a & {b: c: 1} } // Test that __reclose handles both recursive and non-recursive closing @@ -83,9 +77,9 @@ mixedClose: { foo... }) // Top-level extra field not allowed. - t1: err: a & {f: int} @test(err, code=eval, path=f, contains="field not allowed", pos=[0:16]) + t1: err: a & {f: int} // Allowed fields work. - t2: ok: a & {x: y: 5, b: c: 1} @test(eq, {x: {y: 5}, b: {c: 1}}) + t2: ok: a & {x: y: 5, b: c: 1} } // Test that __reclose can wrap a close() call and conditionally add @@ -97,20 +91,19 @@ recloseWrapsClose: { #def... })) // Top-level extra field not allowed (close provides non-recursive). - t1: err: a & {f: int} @test(err, code=eval, path=f, contains="field not allowed", pos=[0:16]) + t1: err: a & {f: int} // Nested extra field not allowed (__reclose detects recursive from #def). - t2: err: a & {a: c: 1} @test(err, code=eval, path=a.c, contains="field not allowed", pos=[0:19]) + t2: err: a & {a: c: 1} // Allowed nested field works. - t3: ok: a & {a: b: 5} @test(eq, {a: {b: 5}}) + t3: ok: a & {a: b: 5} } nonStructLiterals: { // Test with non-struct should error - t1: err: __reclose("not a struct") @test(err, code=eval, contains="error in call to %s", args=[__reclose], pos=[0:11]) + t1: err: __reclose("not a struct") - - #A: a: int - t4: err: __reclose(#A) @test(err, code=eval, contains="error in call to %s", args=[__reclose], pos=[0:11]) + #A: a: int + t4: err: __reclose(#A) } nonStructDefinitions: { @@ -120,20 +113,16 @@ nonStructDefinitions: { #Def... }) - t1: ok: a & 1 @test(eq, 1) + t1: ok: a & 1 // errors because of regular field + embedded scalar - t2: err: a & {b: 1} @test(err, code=eval, - contains="conflicting values %s and %s (mismatched types %s and %s)", - args=[{b:1}, 1, struct, int], pos=[-9:8, 0:11, 0:15]) + t2: err: a & {b: 1} } - -- old.cue -- retro: { // May not be used if explicitopen is not set. - t1: err: __reclose({}) @test(err, code=eval, contains="error in call to %s", args=[__reclose], pos=[0:11]) + t1: err: __reclose({}) } - -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/builtins/validators.txtar b/internal/core/compile/testdata/sync/builtins/validators.txtar index ba49e83a2..8669a6fcd 100644 --- a/internal/core/compile/testdata/sync/builtins/validators.txtar +++ b/internal/core/compile/testdata/sync/builtins/validators.txtar @@ -15,61 +15,50 @@ incompleteError1: { foo: MyType & { kv: joel: "testing" } - @test(eq, { - MyType: {kv: struct.MinFields(1)} - foo: {kv: {joel: "testing"}} - }) } incompleteError2: { MyType: { kv: [string]: string - kv: struct.MinFields(1) @test(err, code=incomplete, - contains="does not satisfy struct.MinFields(1)", pos=[0:7, -1:7, 0:24]) + kv: struct.MinFields(1) } foo: MyType & { kv: joel: "testing" - } @test(eq, { - kv: {joel: "testing"} - }) + } } incompleteError3: { t: string t: json.Validate(string) - @test(eq, {t: string & json.Validate(string)}) } uniqueConstrains1: { t: string t: json.Validate(string) t: json.Validate(string) - @test(eq, {t: json.Validate(string) & string}) } uniqueConstrains2: { t: struct.MaxFields(1) t: struct.MaxFields(1) - @test(eq, {t: struct.MaxFields(1)}) } violation: { #MyType: { kv: [string]: string - kv: struct.MinFields(1) @test(err, code=incomplete, contains="does not satisfy struct.MinFields(1)", pos=[0:7, -1:7, 0:24]) + kv: struct.MinFields(1) } foo: #MyType & { kv: joel: "testing" kv: tony: "testing" - } @test(eq, {kv: {joel: "testing", tony: "testing"}}) + } } conjuncts: { kv: struct.MinFields(1) kv: struct.MaxFields(3) - @test(eq, {kv: struct.MinFields(1) & struct.MaxFields(3)}) } // TODO: stripe off conflicting pairs @@ -83,31 +72,27 @@ conjuncts: { bareBuiltin: { a: json.Valid a: json.Valid - @test(eq, { a: json.Valid() }) } bareBuiltinCheck: { a: json.Valid a: "3" - @test(eq, {a: "3"}) } builtinValidator: { a: json.Valid() a: json.Valid() - @test(eq, {a: json.Valid()}) } builtinValidatorCheck: { a: json.Valid() a: "3" - @test(eq, {a: "3"}) } callOfCallToValidator: { a: json.Valid - b: a() @test(eq, { json.Valid() }) - e: b() @test(err, code=eval, contains="cannot call previously called validator", pos=[0:5]) + b: a() + e: b() e: "5" } @@ -115,7 +100,6 @@ validatorAsFunction: { a: json.Valid b: a("3") c: json.Valid("3") - @test(eq, {a: json.Valid(), b: true, c: true}) } // issue2098: Tests that list.MinItems() does not panic when combined with list @@ -124,43 +108,31 @@ issue2098: ok1: { _a: [1, ...] _a: list.MinItems(1) _a[0] - @test(eq, {_a: [1], 1}) } issue2098: incomplete1: { _a: [...] _a: list.MinItems(1) _a[0] - @test(err, code=incomplete, contains="index out of range", pos=[3:5]) } - -- issue3418.cue -- // issue3418: Tests that matchN correctly reports validation failures when // combined with conflicting constraints, regardless of operand order. // https://cuelang.org/issue/3418 -issue3418: t1: "foo" & matchN(1, [1&2]) & matchN(1, [_]) @test(err, code=eval, - contains="does not satisfy matchN", pos=[0:24, 0:16, 0:31, 0:35, 0:37]) +issue3418: t1: "foo" & matchN(1, [1 & 2]) & matchN(1, [_]) -issue3418: t2: "foo" & matchN(1, [_]) & matchN(1, [1&2]) @test(err, code=eval, - contains="does not satisfy matchN", pos=[0:41, 0:16, 0:48, 0:52, 0:54]) +issue3418: t2: "foo" & matchN(1, [_]) & matchN(1, [1 & 2]) issue3418: t3: { x: "foo" x: matchN(1, [_]) - x: matchN(1, [1&2]) - - @test(err, code=eval, at=x, contains="does not satisfy matchN", pos=[3:5, 1:5, 2:5, 3:12, 3:16, 3:18]) - + x: matchN(1, [1 & 2]) } issue3418: t4: { x: "foo" - x: matchN(1, [1&2]) + x: matchN(1, [1 & 2]) x: matchN(1, [_]) - - @test(err, code=eval, at=x, contains="does not satisfy matchN", pos=[2:5, 1:5, 2:12, 2:16, 2:18, 3:5]) } - - -- issue3474.cue -- import "struct" @@ -172,7 +144,6 @@ issue3474: structValidator: ok: { A: { if true {B: true} } - @test(eq, {A: {B: true}}) } issue3474: structValidator: failAfter: { // Passes only before the comprehension is evaluated. @@ -180,36 +151,34 @@ issue3474: structValidator: failAfter: { A: { C: true if true {B: true} - } @test(err, code=eval, contains="does not satisfy struct.MaxFields(1)", pos=[-1:5, -1:22, 0:5]) + } } issue3474: structValidator: incomplete: { // Passes neither before nor after the comprehension is evaluated. A: struct.MinFields(1) A: { if true {} - } @test(err, code=incomplete, contains="len(fields) < MinFields(1) (0 < 1)", pos=[-1:5, -1:22, 0:5]) + } } issue3474: structValidator: failClosed: { // Passes neither before nor after the comprehension is evaluated. #A: struct.MinFields(1) #A: { if true {} - } @test(err, code=eval, contains="does not satisfy struct.MinFields", pos=[-1:6, -1:23, 0:6]) + } } - issue3474: topValidator: ok: { A: matchN(1, [>10]) A: { if true {100} } - @test(eq, {A: 100}) } issue3474: topValidator: fail: { A: matchN(1, [>10]) A: { if true {1} - } @test(err, code=eval, contains="does not satisfy matchN", pos=[-1:5, -1:12, 0:5, 1:12]) + } } issue3474: topValidator: incomplete: { @@ -217,15 +186,13 @@ issue3474: topValidator: incomplete: { A: { if true {int} } - @test(eq, {A: matchN(1, [>10]) & int}) } issue3474: topValidator: failType: { A: matchN(1, [>10]) A: { if true {C: 1} - } @test(err, code=eval, contains="does not satisfy matchN", pos=[-1:5, -1:12, 0:5]) + } } - -- validator_is_top.cue -- // issue3639: Tests that embedding a matchN validator struct alongside direct // application does not cause "field not allowed" errors. https://cuelang.org/issue/3639 @@ -233,22 +200,14 @@ issue3639: { a: {#X} & #X a: b: 1 #X: matchN(1, [{b: int}]) - @test(eq, { - a: {b: 1} - #X: matchN(1, [{ b: int }]) - }) } // issue3661: Tests that matchN with a required field validator works when // applied via a pattern constraint. https://cuelang.org/issue/3661 issue3661: { - #X: matchN(1, [{ b!: int }]) + #X: matchN(1, [{b!: int}]) a: b: 1 - a: #X + a: #X ["a"]: #X - @test(eq, { - #X: matchN(1, [{ b!: int }]) - a: {b: 1} - }) } // issue3678: Tests that matchN with multiple required-field alternatives does not // produce spurious "field not allowed" errors. https://cuelang.org/issue/3678 @@ -264,11 +223,6 @@ issue3678: { y: #X y: x x: #X - @test(eq, { - #X: matchN(1, [{ a!: string }, { c!: string }]) - x: {c: "c"} - y: {c: "c"} - }) } // issue3981: Tests that matchN combined with close() correctly handles open // struct arguments without topological sort regressions. https://cuelang.org/issue/3981 @@ -280,9 +234,6 @@ issue3981: matchWithClose: { #openStruct: {...} } out: f1: foo: ["bar"] - @test(eq, { - out: {#openStruct: {}, f1: {foo: ["bar"]}} - }) } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/choosedefault/000_pick_first.txtar b/internal/core/compile/testdata/sync/choosedefault/000_pick_first.txtar index 4e6f9a18e..fd9dc30ce 100644 --- a/internal/core/compile/testdata/sync/choosedefault/000_pick_first.txtar +++ b/internal/core/compile/testdata/sync/choosedefault/000_pick_first.txtar @@ -1,10 +1,10 @@ -- in.cue -- -a: *5 | "a" | true @test(eq, *5 | "a" | true) +a: *5 | "a" | true b: c: *{ a: 2 } | { a: 3 -} @test(eq, *{a: 2} | {a: 3}) +} -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/choosedefault/001_simple_disambiguation_conflict.txtar b/internal/core/compile/testdata/sync/choosedefault/001_simple_disambiguation_conflict.txtar index 666f73a86..543262e18 100644 --- a/internal/core/compile/testdata/sync/choosedefault/001_simple_disambiguation_conflict.txtar +++ b/internal/core/compile/testdata/sync/choosedefault/001_simple_disambiguation_conflict.txtar @@ -1,7 +1,7 @@ -- in.cue -- -a: *"a" | "b" @test(eq, *"a" | "b") -b: *"b" | "a" @test(eq, *"b" | "a") -c: a & b @test(eq, "a" | "b") +a: *"a" | "b" +b: *"b" | "a" +c: a & b -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/choosedefault/002_associativity_of_defaults.txtar b/internal/core/compile/testdata/sync/choosedefault/002_associativity_of_defaults.txtar index 96a1c67ae..8bbdb0b19 100644 --- a/internal/core/compile/testdata/sync/choosedefault/002_associativity_of_defaults.txtar +++ b/internal/core/compile/testdata/sync/choosedefault/002_associativity_of_defaults.txtar @@ -1,21 +1,20 @@ #name: associativity of defaults #evalFull -- in.cue -- -a: *"a" | ("b" | "c") @test(eq, *"a" | "b" | "c") -b: (*"a" | "b") | "c" @test(eq, *"a" | "b" | "c") -c: *"a" | (*"b" | "c") @test(eq, *"a" | "b" | "c") -x: a & b @test(eq, *"a" | "b" | "c") -y: b & c @test(eq, *"a" | "b" | "c") +a: *"a" | ("b" | "c") +b: (*"a" | "b") | "c" +c: *"a" | (*"b" | "c") +x: a & b +y: b & c -s1: *1 | ((*2 | 3) & (2 | *3)) @test(eq, *1 | 2 | 3) -s2: *1 | ((*2 | 3) & (*2 | 3)) @test(eq, *1 | 2 | 3) -s3: *1 | ((*2 | 3) & 3) @test(eq, *1 | 3) -s4: *1 | ((*2 | 3) & 2) @test(eq, *1 | 2) -s5: *1 | *(*2 | 3) @test(eq, *1 | *2 | 3) - -e1: *(1&2) | (*"x" | string) @test(eq, "x" | string) -e2: (*"x" | string) | *(1&2) @test(eq, "x" | string) +s1: *1 | ((*2 | 3) & (2 | *3)) +s2: *1 | ((*2 | 3) & (*2 | 3)) +s3: *1 | ((*2 | 3) & 3) +s4: *1 | ((*2 | 3) & 2) +s5: *1 | *(*2 | 3) +e1: *(1 & 2) | (*"x" | string) +e2: (*"x" | string) | *(1 & 2) -- complex.cue -- // add some test cases suggested by an automated prover based on this pattern: // 1. ValK = (ValA & ValB_ND) & ValC_D \neq _|_ (the element we track must exist). @@ -26,18 +25,18 @@ e2: (*"x" | string) | *(1&2) @test(eq, "x" | string) // component that causes ValC_D to conflict with (ValA & ValB_D), // but ValC_D must *not* conflict with ValB_D on its own. t1: { - va: {a: 1, b: 2} + va: {a: 1, b: 2} vb1: {c: 3} vb2: {c: 4} - vc : {c: 4} - vd: string + vc: {c: 4} + vd: string - A: va | vd @test(eq, {a: 1, b: 2} | string) - B: *vb1 | vb2 | vd @test(eq, *{c: 3} | {c: 4} | string) - C: *vc | vd @test(eq, *{c: 4} | string) + A: va | vd + B: *vb1 | vb2 | vd + C: *vc | vd - p1: (A & B) & C @test(eq, *{a: 1, b: 2, c: 4} | string) - p2: A & (B & C) @test(eq, *{a: 1, b: 2, c: 4} | string) + p1: (A & B) & C + p2: A & (B & C) } t2: { va: 0 | 1 | 2 @@ -46,29 +45,23 @@ t2: { vc: 0 | 3 | 4 vd: string - A: va | vd @test(eq, 0 | 1 | 2 | string) - B: *vb1 | vb2 | vd @test(eq, *2 | *3 |0 | 1 | 4 | string) - C: *vc | vd @test(eq, *0 | *3 | *4 | string) + A: va | vd + B: *vb1 | vb2 | vd + C: *vc | vd - p1: (A & B) & C @test(eq, *0 | string) - p2: A & (B & C) @test(eq, *0 | string) + p1: (A & B) & C + p2: A & (B & C) } -- issue3908.cue -- // issue3908: Tests that nested defaults (e.g. null default overridden by a // string default) are handled correctly in evalv3. https://cuelang.org/issue/3908 issue3908: reduced: { - @test(permute) string | *null string | *"str" - @test(eq, *"str" | string) } issue3908: full: { - out: #Schema & { field: string | *"dataDefault" } + out: #Schema & {field: string | *"dataDefault"} #Schema: field: string | *null - @test(eq, { - out: field: *"dataDefault" | string - #Schema: field: *null | string - }) } -- out/compile -- --- complex.cue diff --git a/internal/core/compile/testdata/sync/compile/alias.txtar b/internal/core/compile/testdata/sync/compile/alias.txtar index e9bdb6b9a..dadcec6d2 100644 --- a/internal/core/compile/testdata/sync/compile/alias.txtar +++ b/internal/core/compile/testdata/sync/compile/alias.txtar @@ -1,11 +1,9 @@ -- in.cue -- dynamic: { - @test(permute, count=6) X=(a): 1 - x: X - a: "name" - @test(eq, {x: 1, a: "name", name: 1}) + x: X + a: "name" } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/compile/experiment.txtar b/internal/core/compile/testdata/sync/compile/experiment.txtar index 8e4d41f05..bccfa9224 100644 --- a/internal/core/compile/testdata/sync/compile/experiment.txtar +++ b/internal/core/compile/testdata/sync/compile/experiment.txtar @@ -2,13 +2,11 @@ module: "x.test" language: version: "v0.13.0" -- off.cue -- -off: __test_experiment("off") @test(err, code=eval, contains="testing experiment disabled", pos=[0:6]) - +off: __test_experiment("off") -- on.cue -- @experiment(testing) -on: __test_experiment("on") @test(eq, "on") - +on: __test_experiment("on") -- out/compile -- --- off.cue { diff --git a/internal/core/compile/testdata/sync/compile/fields.txtar b/internal/core/compile/testdata/sync/compile/fields.txtar index c96f0bd6d..938bb546e 100644 --- a/internal/core/compile/testdata/sync/compile/fields.txtar +++ b/internal/core/compile/testdata/sync/compile/fields.txtar @@ -1,8 +1,8 @@ -- in.cue -- -#dev: int @test(eq, int) -"#dev": int @test(eq, int) -_dev: int @test(eq, int) -_#dev: int @test(eq, int) +#dev: int +"#dev": int +_dev: int +_#dev: int -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/compile/files.txtar b/internal/core/compile/testdata/sync/compile/files.txtar index afd94d0f6..36bb81d1b 100644 --- a/internal/core/compile/testdata/sync/compile/files.txtar +++ b/internal/core/compile/testdata/sync/compile/files.txtar @@ -4,12 +4,12 @@ -- in.cue -- package repro -a: [] @test(eq, []) +a: [] -- out.cue -- package repro -x: {for a in a {}} @test(eq, {}) -y: {{{for a in a {}}}} @test(eq, {}) +x: {for a in a {}} +y: {{{for a in a {}}}} -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/compile/json.txtar b/internal/core/compile/testdata/sync/compile/json.txtar index d6017252f..2c6bf10d7 100644 --- a/internal/core/compile/testdata/sync/compile/json.txtar +++ b/internal/core/compile/testdata/sync/compile/json.txtar @@ -3,29 +3,11 @@ #noformat -- in.cue -- // allow front-style commas -a -: { "key": "value" -, "key2" -: "value2" -} - -, b: [ - 0 -, 1 -, 2 - ,3, - 4 - - , 5 +a: {"key": "value", "key2": "value2" +}, b: [ + 0, 1, 2, 3, + 4, 5, ] - -@test(eq, { - a: { - key: "value" - key2: "value2" - } - b: [0, 1, 2, 3, 4, 5] -}) -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/compile/postfixexpr.txtar b/internal/core/compile/testdata/sync/compile/postfixexpr.txtar index 2d2d43917..53e970ee6 100644 --- a/internal/core/compile/testdata/sync/compile/postfixexpr.txtar +++ b/internal/core/compile/testdata/sync/compile/postfixexpr.txtar @@ -7,29 +7,28 @@ language: version: "v0.15.0" #Base: { x: int -} @test(shareID=Base) +} // Test postfix ... operator with struct -a: #Base... @test(shareID=Base) +a: #Base... // Test with selector -b: foo.bar... @test(err, code=incomplete, contains="undefined field: bar", pos=[0:8]) +b: foo.bar... // Test with parentheses -c: (x & y)... @test(eq, _) +c: (x & y)... // Test with function call -d: fn()... @test(err, code=incomplete, contains="cannot call non-concrete value fn", pos=[0:4]) +d: fn()... // As an expression -e: #Base... & {y: int} @test(eq, {y: int, x: int}) - -foo: {} @test(eq, {}) +e: #Base... & {y: int} -x: _ @test(eq, _) -y: _ @test(eq, _) -fn: _ @test(eq, _) +foo: {} +x: _ +y: _ +fn: _ -- out/compile -- --- with_experiment.cue { diff --git a/internal/core/compile/testdata/sync/compile/scope.txtar b/internal/core/compile/testdata/sync/compile/scope.txtar index a2231306c..7b8900819 100644 --- a/internal/core/compile/testdata/sync/compile/scope.txtar +++ b/internal/core/compile/testdata/sync/compile/scope.txtar @@ -7,16 +7,16 @@ a: { e: c }} c: {} -} @test(eq, {d: {}, e: {}, c: {}}) -b: {} @test(eq, {}) -s: "foo" @test(eq, "foo") -c: s @test(eq, "foo") +} +b: {} +s: "foo" +c: s // s is technically in a new struct here so it will have a one higher count than // the one before. -d: [s]: 3 @test(eq, {["foo"]: 3}) +d: [s]: 3 -e: {} @test(eq, {}, hint="not the worst if this is not allowed") +e: {} e & { e: {} @@ -25,22 +25,13 @@ e & { p: { {X=["foo"]: b: X | null} {[Y="bar"]: b: Y} - - @test(eq, { - ["foo"]: b: null @test(final) - ["bar"]: b: string - }, incorrect) - @test(eq:todo, { - ["foo"]: b: null @test(final) - ["bar"]: b: "bar" - }) } let B = {open: int} -f: B @test(eq, {open: int}) +f: B schema: { - next: _schema_1 @test(err, code=structural_cycle) + next: _schema_1 } let _schema_1 = schema diff --git a/internal/core/compile/testdata/sync/comprehensions/015_list_comprehension.txtar b/internal/core/compile/testdata/sync/comprehensions/015_list_comprehension.txtar index 1fa1e10a8..525bdf211 100644 --- a/internal/core/compile/testdata/sync/comprehensions/015_list_comprehension.txtar +++ b/internal/core/compile/testdata/sync/comprehensions/015_list_comprehension.txtar @@ -6,12 +6,11 @@ b: { d: 4 } -a: [for k, v in b if k < "d" if v > b.a {k}] @test(eq, ["b", "c"]) +a: [for k, v in b if k < "d" if v > b.a {k}] c: { [for _, x in b for _, y in b if x < y {x}] - @test(eq, [1, 1, 1, 2, 2, 3]) } -d: [for x, _ in a {x}] @test(eq, [0, 1]) +d: [for x, _ in a {x}] -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/comprehensions/045_comprehension_and_skipped_field.txtar b/internal/core/compile/testdata/sync/comprehensions/045_comprehension_and_skipped_field.txtar index fff1e8142..27195a7bf 100644 --- a/internal/core/compile/testdata/sync/comprehensions/045_comprehension_and_skipped_field.txtar +++ b/internal/core/compile/testdata/sync/comprehensions/045_comprehension_and_skipped_field.txtar @@ -8,11 +8,10 @@ for key, value in {x: v: 1} { "\(key)": { - v: *{for pod, _ in value.v {}} | {"\(value.v)": 2} + v: *{for pod, _ in value.v {}} | {"\(value.v)": 2} _p: 3 } } -@test(eq, {x: {v: {"1": 2}, _p: 3}}) -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/comprehensions/checkdefined.txtar b/internal/core/compile/testdata/sync/comprehensions/checkdefined.txtar index 08936fed2..6821fd60d 100644 --- a/internal/core/compile/testdata/sync/comprehensions/checkdefined.txtar +++ b/internal/core/compile/testdata/sync/comprehensions/checkdefined.txtar @@ -14,40 +14,32 @@ xo: field: {} okc0: { if xc.undefined == _|_ {a: 1} - @test(eq, {a: 1}) } oko0: { if xo.undefined == _|_ {a: 1} - @test(eq, {a: 1}) } okc1: { if xc.undefined != _|_ {a: 1} - @test(eq, {}) } oko1: { if xo.undefined != _|_ {a: 1} - @test(eq, {}) } okc2: { if ({} & {s: [for y in xc.undefined {}]}) != _|_ {a: 1} - @test(eq, {}) } oko2: { if ({} & {s: [for y in xo.undefined {}]}) != _|_ {a: 1} - @test(eq, {a: 1}) } okc3: { if ({s: [for y in xc.undefined {}]}) != _|_ {a: 1} - @test(eq, {}) } oko3: { if ({s: [for y in xo.undefined {}]}) != _|_ {a: 1} - @test(eq, {a: 1}) } // Should Field s exist in okc or not? Depends on whether comparison to bottom @@ -61,7 +53,6 @@ issue1969: okc: { let Y = {} & {s: [for y in list.Range(0, X, 1) {}]} if Y != _|_ {Y} - @test(eq, {}) } issue1969: oko: { @@ -69,9 +60,6 @@ issue1969: oko: { let Y = {} & {s: [for y in list.Range(0, X, 1) {}]} if Y != _|_ {Y} - @test(eq, { - s: _|_ @test(err, code=incomplete, contains="issue1969.oko.X: undefined field: undefined", pos=[62:13]) - }) } -- issue2245.cue -- // Evaluator regression where comparing an incomplete struct to bottom in a @@ -80,20 +68,13 @@ issue1969: oko: { yo: { f: int g: f < 10 - @test(eq, { - f: int - g: _|_ @test(err, code=incomplete, contains="yo.g: non-concrete value int in operand to <", pos=[6:5, 5:5]) - }) } okyo: { if yo != _|_ {a: 1} - @test(eq, {a: 1}) } okyog: { if yo.g != _|_ {a: 1} - @test(eq, {}) } - -- incomplete.cue -- // Comparing to string is not an error. But for legacy reasons we want to still // support this. We intend to have more clean and precise behavior with the @@ -106,22 +87,19 @@ checkIncomplete: t1: { a: string } f: blah: {} - @test(eq, {f: {blah: {a: string}}}) } - -- structs.cue -- structs: { - bare: t1: ({y: 2} & {x: 3}) != _|_ @test(eq, true) - bare: f2: ({y: 2} & {x: 3}) == _|_ @test(eq, false) - bare: f3: ({x: 1, y: 2} & {x: 3}) != _|_ @test(eq, false) - bare: t4: ({x: 1, y: 2} & {x: 3}) == _|_ @test(eq, true) + bare: t1: ({y: 2} & {x: 3}) != _|_ + bare: f2: ({y: 2} & {x: 3}) == _|_ + bare: f3: ({x: 1, y: 2} & {x: 3}) != _|_ + bare: t4: ({x: 1, y: 2} & {x: 3}) == _|_ - select: t1: ({y: 2} & {x: 3}).y != _|_ @test(eq, true) - select: f2: ({y: 2} & {x: 3}).y == _|_ @test(eq, false) - select: f3: ({x: 1, y: 2} & {x: 3}).y != _|_ @test(eq, false) - select: t4: ({x: 1, y: 2} & {x: 3}).y == _|_ @test(eq, true) + select: t1: ({y: 2} & {x: 3}).y != _|_ + select: f2: ({y: 2} & {x: 3}).y == _|_ + select: f3: ({x: 1, y: 2} & {x: 3}).y != _|_ + select: t4: ({x: 1, y: 2} & {x: 3}).y == _|_ } - -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/comprehensions/closed.txtar b/internal/core/compile/testdata/sync/comprehensions/closed.txtar index 738dd049f..c16290678 100644 --- a/internal/core/compile/testdata/sync/comprehensions/closed.txtar +++ b/internal/core/compile/testdata/sync/comprehensions/closed.txtar @@ -2,7 +2,6 @@ dynamicTop: { #D: { for k, v in {foo: 123} {(k): v} - @test(eq, {foo: 123}) } } @@ -11,7 +10,6 @@ dynamicDepth1: { #D: { a: foo: 123 b: {for k, v in a {(k): v}} - @test(eq, {a: {foo: 123}, b: {foo: 123}}) } } @@ -23,7 +21,6 @@ allowed: { } vErr: #D & {d: 5} - @test(eq, {#D: {d: int}, vErr: {d: 5}}) } disallowed: { @@ -34,7 +31,6 @@ disallowed: { } vErr: #D & {d: 5} - @test(err, code=eval, at=vErr.d, contains="field not allowed", pos=[7:14]) } // Interpret comprehensions as embeddings. @@ -52,18 +48,12 @@ comprehensionIsEmbed: { x: #B & { kind: "A" } - @test(eq, { - #A: {size: *1 | int} - #B: {kind: string, size: *1 | int} - x: {kind: "A", size: *1 | int} - }) } // This comprehension is inside a definition and should still disallow b. noEraseDefinition: { #Foo: [if true {a: int}] - a: { #Foo & [{ b: 2 }] } // Error - @test(err, code=eval, at=a.0.b, contains="field not allowed", pos=[2:17]) + a: {#Foo & [{b: 2}]} // Error } // issue1956: Tests that conditional comprehensions correctly embed definitions @@ -84,11 +74,6 @@ issue1956: { x: #Thing & { kind: "KindA" } - @test(eq, { - #Details: {size: *1 | int} - #Thing: {kind: "KindA" | "KindB"} - x: {kind: "KindA", size: *1 | int} - }) } // This triggers adding the same "closedInfo" twice, potentially causing @@ -106,12 +91,7 @@ dedupTodo: { c: n: "c" // Do not combine with &, as the original issue relies on this. c: n: string } - @test(eq, { - #sub: {c: _} - out: {c: {n: "c"}, X: {test: {n: "c"}}} - }) } - -- v3issues.cue -- // issue3483: Tests that a falsy if comprehension inside a definition does not // incorrectly produce "field not allowed" in evalv3. @@ -123,10 +103,6 @@ issue3483: { schemaField: 3 } } - @test(eq, { - #Schema: {schemaField: int} - out1: {out2: {schemaField: int}} - }) } // issue3486: Tests that embedding a definition inside an if comprehension does // not produce spurious "field not allowed" errors. @@ -137,11 +113,11 @@ issue3486: { if true { out: { #schema + // This field should be allowed as #schema is embedded. extra: "foo" } } - @test(eq, {#schema: {}, out: {extra: "foo"}}) } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/comprehensions/deferfieldsetknown.txtar b/internal/core/compile/testdata/sync/comprehensions/deferfieldsetknown.txtar index d5d5b1d75..784799566 100644 --- a/internal/core/compile/testdata/sync/comprehensions/deferfieldsetknown.txtar +++ b/internal/core/compile/testdata/sync/comprehensions/deferfieldsetknown.txtar @@ -4,15 +4,15 @@ package x #PDB: {y: int} result: resources: { - if true { - x: #PDB & {y: 1} - } + if true { + x: #PDB & {y: 1} + } } out: ({ - cfg: resources: _ - out: {for n, _ in cfg.resources {(n): "x"}} -} & {cfg: result}).out @test(eq, {x: "x"}) + cfg: resources: _ + out: {for n, _ in cfg.resources {(n): "x"}} +} & {cfg: result}).out -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/comprehensions/else.txtar b/internal/core/compile/testdata/sync/comprehensions/else.txtar index c2ea89560..64893edf3 100644 --- a/internal/core/compile/testdata/sync/comprehensions/else.txtar +++ b/internal/core/compile/testdata/sync/comprehensions/else.txtar @@ -3,82 +3,69 @@ // if-else: condition true - no else ifTrue: { - if true { a: 1 } else { b: 2 } - @test(eq, {a: 1}) + if true {a: 1} else {b: 2} } // if-else: condition false - else yields ifFalse: { - if false { a: 1 } else { b: 2 } - @test(eq, {b: 2}) + if false {a: 1} else {b: 2} } // for-else: non-empty source - no else forNonEmpty: { - for x in [1, 2] { "\(x)": x } fallback { empty: true } - @test(eq, {"1": 1, "2": 2}) + for x in [1, 2] {"\(x)": x} otherwise {empty: true} } // for-else: empty source - else yields forEmpty: { - for x in [] { "\(x)": x } fallback { empty: true } - @test(eq, {empty: true}) + for x in [] {"\(x)": x} otherwise {empty: true} } // for-else with filter: filter removes all - else yields forFilteredAll: { - for x in [1, 2, 3] if x > 10 { "\(x)": x } fallback { empty: true } - @test(eq, {empty: true}) + for x in [1, 2, 3] if x > 10 {"\(x)": x} otherwise {empty: true} } // for-else with filter: filter keeps some - no else forFilteredSome: { - for x in [1, 2, 3] if x > 1 { "\(x)": x } fallback { empty: true } - @test(eq, {"2": 2, "3": 3}) + for x in [1, 2, 3] if x > 1 {"\(x)": x} otherwise {empty: true} } // if-for-fallback: if true, for empty - fallback yields ifTrueForEmpty: { - if true for x in [] { "\(x)": x } fallback { empty: true } - @test(eq, {empty: true}) + if true for x in [] {"\(x)": x} otherwise {empty: true} } // if-for-fallback: if false, for non-empty - fallback yields (if blocks iteration) ifFalseForNonEmpty: { - if false for x in [1, 2] { "\(x)": x } fallback { empty: true } - @test(eq, {empty: true}) + if false for x in [1, 2] {"\(x)": x} otherwise {empty: true} } // if-for-fallback: if true, for non-empty - no fallback ifTrueForNonEmpty: { - if true for x in [1, 2] { "\(x)": x } fallback { empty: true } - @test(eq, {"1": 1, "2": 2}) + if true for x in [1, 2] {"\(x)": x} otherwise {empty: true} } // if-if-fallback: both true - no fallback ifIfBothTrue: { - if true if true { a: 1 } fallback { b: 2 } - @test(eq, {a: 1}) + if true if true {a: 1} otherwise {b: 2} } // if-if-fallback: first false - fallback yields ifIfFirstFalse: { - if false if true { a: 1 } fallback { b: 2 } - @test(eq, {b: 2}) + if false if true {a: 1} otherwise {b: 2} } // if-if-fallback: second false - fallback yields ifIfSecondFalse: { - if true if false { a: 1 } fallback { b: 2 } - @test(eq, {b: 2}) + if true if false {a: 1} otherwise {b: 2} } // try-try-fallback: both succeed - no fallback tryTryBothSucceed: { a: 1 b: 2 - try x = a? try y = b? { result: x + y } fallback { default: 0 } - @test(eq, {a: 1, b: 2, result: 3}) + try x = a? try y = b? {result: x + y} otherwise {default: 0} } missing?: int @@ -86,103 +73,90 @@ missing?: int // try-try-fallback: first fails - fallback yields tryTryFirstFails: { b: 2 - try x = missing? try y = b? { result: x + y } fallback { default: -1 } - @test(eq, {b: 2, default: -1}) + try x = missing? try y = b? {result: x + y} otherwise {default: -1} } // try-try-fallback: second fails - fallback yields tryTrySecondFails: { a: 1 - try x = a? try y = missing? { result: x + y } fallback { default: -2 } - @test(eq, {a: 1, default: -2}) + try x = a? try y = missing? {result: x + y} otherwise {default: -2} } // list if-else: true listIfTrue: [ - if true { 1 } else { 2 } -] @test(eq, [1]) + if true {1} else {2} +] // list if-else: false listIfFalse: [ - if false { 1 } else { 2 } -] @test(eq, [2]) + if false {1} else {2} +] // list for-else: empty listForEmpty: [ - for x in [] { x } fallback { 0 } -] @test(eq, [0]) + for x in [] {x} otherwise {0} +] // list for-else: non-empty listForNonEmpty: [ - for x in [1, 2] { x * 2 } fallback { 0 } -] @test(eq, [2, 4]) + for x in [1, 2] {x * 2} otherwise {0} +] // else with multiple fields elseMultipleFields: { - if false { a: 1 } else { b: 2, c: 3 } - @test(eq, {b: 2, c: 3}) + if false {a: 1} else {b: 2, c: 3} } // else embeds into existing struct elseEmbeds: { existing: 1 - if false { added: 2 } else { fallback: 3 } - @test(eq, {existing: 1, fallback: 3}) + if false {added: 2} else {fallback: 3} } // fallback with outer scope access outerScope: { let threshold = 10 - for x in [] { x } fallback { fallbackField: threshold } - @test(eq, {fallbackField: 10}) + for x in [] {x} otherwise {fallbackField: threshold} } // if-else: nested body fields - else yields once ifNestedBody: { - if false { a: b: 1 } else { c: 2 } - @test(eq, {c: 2}) + if false {a: b: 1} else {c: 2} } // if-else: nested else fields ifNestedElse: { - if false { a: 1 } else { b: c: 2 } - @test(eq, {b: {c: 2}}) + if false {a: 1} else {b: c: 2} } // if-else: nested fields in both ifNestedBoth: { - if false { a: b: 1 } else { c: d: 2 } - @test(eq, {c: {d: 2}}) + if false {a: b: 1} else {c: d: 2} } // if-else: deeply nested fields ifDeeplyNested: { - if false { a: b: c: 1 } else { a: b: c: 2 } - @test(eq, {a: {b: {c: 2}}}) + if false {a: b: c: 1} else {a: b: c: 2} } // for-fallback: nested body fields, empty source forNestedEmpty: { - for x in [] { a: b: (x): x } fallback { a: b: none: true } - @test(eq, {a: {b: {none: true}}}) + for x in [] {a: b: (x): x} otherwise {a: b: none: true} } // for-fallback: nested body fields, non-empty source - no fallback forNestedNonEmpty: { - for x in [1] { a: b: "\(x)": x } fallback { a: b: none: true } - @test(eq, {a: {b: {"1": 1}}}) + for x in [1] {a: b: "\(x)": x} otherwise {a: b: none: true} } // nested comprehensions - outer fallback triggers nestedOuterFallback: { - for x in [] { for y in [1] { y } fallback { inner: true } } fallback { outer: true } - @test(eq, {outer: true}) + for x in [] {for y in [1] {y} otherwise {inner: true}} otherwise {outer: true} } // nested comprehensions - inner fallback triggers nestedInnerFallback: { - for x in [1] { for y in [] { y } fallback { inner: true } } fallback { outer: true } - @test(eq, {inner: true}) + for x in [1] {for y in [] {y} otherwise {inner: true}} otherwise {outer: true} } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/comprehensions/else_on_error.txtar b/internal/core/compile/testdata/sync/comprehensions/else_on_error.txtar index 7e355774e..762eaec60 100644 --- a/internal/core/compile/testdata/sync/comprehensions/else_on_error.txtar +++ b/internal/core/compile/testdata/sync/comprehensions/else_on_error.txtar @@ -6,20 +6,17 @@ // Error in for source - else should NOT trigger forSourceError: { - @test(err, code=eval, pos=[2:11], contains="cannot range") - for x in "not-a-list" { "\(x)": x } fallback { fallbackField: true } + for x in "not-a-list" {"\(x)": x} otherwise {fallbackField: true} } // Error in if condition - else should NOT trigger ifConditionError: { - @test(err, code=eval, pos=[2:6, 2:14], contains="invalid operands") - if ("not" + 1) { a: 1 } else { b: 2 } + if ("not" + 1) {a: 1} else {b: 2} } // Bottom value in for source - else should NOT trigger forSourceBottom: { - @test(err, code=user, pos=[2:11], contains="explicit error") - for x in _|_ { "\(x)": x } fallback { fallbackField: true } + for x in _|_ {"\(x)": x} otherwise {fallbackField: true} } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/comprehensions/errors.txtar b/internal/core/compile/testdata/sync/comprehensions/errors.txtar index 325751c61..3c4b28391 100644 --- a/internal/core/compile/testdata/sync/comprehensions/errors.txtar +++ b/internal/core/compile/testdata/sync/comprehensions/errors.txtar @@ -2,20 +2,14 @@ circularIf: { #list: { tail: #list | *null - if tail != null { - } - @test(eq, {tail: null}) + if tail != null {} } } circularFor: { #list: { tail: #list | *null - for x in tail != null { - } - @test(err, code=eval, - contains="cannot range over %s (found %s, want list or struct)", - args=[tail != null, bool], pos=[2:12]) + for x in tail != null {} } } @@ -23,17 +17,13 @@ circularFor: { // Issue #465 userError: { a: string | *_|_ - if a != "" { - } - @test(err, code=incomplete, contains="non-concrete value string", pos=[2:5, 1:5]) + if a != "" {} } intField: { for i, _ in [1, 2] { - (i): { - } + (i): {} } - @test(err, code=eval, contains="integer fields not supported", pos=[2:4]) } // Issue #2403 @@ -48,10 +38,6 @@ conflictRangingOverSelf: { (k): k } } - @test(err, code=eval, at=x.age, - contains="conflicting values %s and %s (mismatched types %s and %s)", - args=[int, "age", int, string], - pos=[3:9, 6:5, 7:3, 8:9]) } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/comprehensions/fields.txtar b/internal/core/compile/testdata/sync/comprehensions/fields.txtar index 9170c3354..c897e544f 100644 --- a/internal/core/compile/testdata/sync/comprehensions/fields.txtar +++ b/internal/core/compile/testdata/sync/comprehensions/fields.txtar @@ -12,7 +12,6 @@ dynamic: { (s): 1 "\(s)bar": 2 } - @test(eq, {foo: 1, foobar: 2}) } ignoreOptional: { @@ -23,17 +22,13 @@ ignoreOptional: { } y: { - for k,v in #x { + for k, v in #x { (k): "exists" } } - @test(eq, { - #x: {a?: string, b?: string, c: string} - y: {c: "exists"} - }) } -missingRequiredError: { +missingRequiredError: { // Issue #2369 #x: { a!: string @@ -42,11 +37,10 @@ missingRequiredError: { } y: { - for k,v in #x { + for k, v in #x { (k): "exists" } } - @test(err, code=incomplete, at=y, contains="missing required field", pos=[9:3, 3:3, 9:14]) } // issue560: Tests that for comprehensions over definitions with interpolated @@ -60,29 +54,13 @@ issue560: { "\(v)": string } "{a}": string - } @test(err, code=incomplete, - contains="error in call to %s", args=[strings.Split], - pos=[1:16, -1:13]) + } } user: { #User tags_str: "b {c}" } - @test(eq, { - #User: { - tags_str: string - tags_map: {"{a}": string} - } - user: { - tags_str: "b {c}" - tags_map: { - "{a}": string - b: string - "{c}": string - } - } - }) } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/comprehensions/for.txtar b/internal/core/compile/testdata/sync/comprehensions/for.txtar index d7836e251..3e6d408fb 100644 --- a/internal/core/compile/testdata/sync/comprehensions/for.txtar +++ b/internal/core/compile/testdata/sync/comprehensions/for.txtar @@ -1,15 +1,14 @@ -- in.cue -- -b: {for k, v in a {"\(k)": v + 1}} @test(eq, {b: 2, c: 3}) -a: {b: 1, c: 2} @test(eq, {b: 1, c: 2}) +b: {for k, v in a {"\(k)": v + 1}} +a: {b: 1, c: 2} -x: {for k, v in y {"\(k)": v}} @test(eq, {}) +x: {for k, v in y {"\(k)": v}} y: {} // check that empty struct after reference works. -k: {for v in e {v}} @test(err, code=eval, pos=[0:14], contains="cannot range") -e: int @test(eq, int) +k: {for v in e {v}} +e: int comprehensionBinds: { - @test(eq, {a: a: _, b: a: _}) a: {for _ in [1] {a: _}} b: {for _, _ in [1] {a: _}} } diff --git a/internal/core/compile/testdata/sync/comprehensions/iferror.txtar b/internal/core/compile/testdata/sync/comprehensions/iferror.txtar index 4c05be083..7e41e9652 100644 --- a/internal/core/compile/testdata/sync/comprehensions/iferror.txtar +++ b/internal/core/compile/testdata/sync/comprehensions/iferror.txtar @@ -5,28 +5,24 @@ wrongConcreteType: { if a.b { 2 } - @test(err, code=eval, contains="cannot use 2 (type int) as type bool", pos=[1:2, -2:8]) } wrongType: { if a.c { 2 } - @test(err, code=eval, contains="cannot use int (type int) as type bool", pos=[1:2, -9:14]) } incomplete: err1: { if a.d { 2 } - @test(err, code=incomplete, contains="undefined field: d", pos=[1:7]) } incomplete: err2: { list: [1, 2, 3] for x in list if a.d { x } - @test(err, code=incomplete, contains="undefined field: d", pos=[2:21]) } // issue809: Tests that comprehension guards using `!= _|_` work correctly @@ -49,26 +45,11 @@ useDefault: { } s: [Name=string]: #A & {a: Name} - s: bar: _ + s: bar: _ foo: [ for _, a in s if a.b != _|_ {a}, ] - - @test(eq, { - #A: { - a: string - b: string - } - s: bar: { - a: "bar" - b: *"bar" | string - } - foo: [{ - a: "bar" - b: *"bar" | string - }] - }) } } @@ -81,8 +62,7 @@ issue1972: { #patchs #someCondition: _ - if #someCondition { - } + if #someCondition {} } err1: { someCondition: _ @@ -91,18 +71,14 @@ issue1972: { if someCondition { patchs: _ } - } @test(err, code=eval, - contains="conflicting values %s and %s (mismatched types %s and %s)", - pos=[0:8, 2:11, 3:3] - ) + } err2: { #patchs: [] #patchs #someCondition: _ - if #someCondition { - } - } @test(err, code=incomplete, contains="incomplete %s: %s", args=[bool, _], pos=[]) + if #someCondition {} + } err3: { someCondition: _ patchs: [...{}] @@ -110,11 +86,6 @@ issue1972: { if someCondition { patchs: _ } - - // TODO(inline): support commas in arguments - @test(err, code=eval, contains="conflicting values %s and %s (mismatched types %s and %s)", - pos=[0:8, 2:11, 3:3] - ) } } -- out/compile -- diff --git a/internal/core/compile/testdata/sync/comprehensions/incomplete.txtar b/internal/core/compile/testdata/sync/comprehensions/incomplete.txtar index e2acd9900..628a04ddc 100644 --- a/internal/core/compile/testdata/sync/comprehensions/incomplete.txtar +++ b/internal/core/compile/testdata/sync/comprehensions/incomplete.txtar @@ -2,9 +2,9 @@ cond: bool src: {} top: _ -a: [ if cond {}] @test(err, code=incomplete, pos=[-3:7], contains="incomplete bool") -b: [for x in src.foo {}] @test(err, code=incomplete, pos=[0:18], contains="undefined field") -c: {for x in top {}} @test(err, code=incomplete, pos=[0:14], contains="cannot range") +a: [if cond {}] +b: [for x in src.foo {}] +c: {for x in top {}} -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/comprehensions/issue1732.txtar b/internal/core/compile/testdata/sync/comprehensions/issue1732.txtar index a4f14da7d..72ffd842a 100644 --- a/internal/core/compile/testdata/sync/comprehensions/issue1732.txtar +++ b/internal/core/compile/testdata/sync/comprehensions/issue1732.txtar @@ -47,7 +47,6 @@ common: { if enabled { foo: string } - @test(err, code=incomplete, contains="incomplete bool", pos=[1:12]) } } @@ -126,90 +125,6 @@ foo: { } } } -@test(eq, { - networkingv1: { - metav1: {#LabelSelector: {matchLabels: {}}} - #NetworkPolicy: {spec: {ingress: [], egress: []}} - #NetworkPolicySpec: {ingress: [], egress: []} - #NetworkPolicyIngressRule: {from: []} - #NetworkPolicyEgressRule: {to: []} - #NetworkPolicyPeer: { - namespaceSelector: null | {matchLabels: {}} - } - } - global_config: { - #GlobalConfig: {auth0: {enabled: bool}} - } - common: {#SomeConfig: {_|_, enabled: bool}} - foo: { - #Values: {global: {auth0: {enabled: bool}}} - } - #Config: { - tenant: {id: string} - auth0: {_|_, enabled: bool} - charts: { - foo: { - global: { - auth0: { - enabled: _|_ @test(err, code=incomplete, contains="#Config.auth0: incomplete bool: bool (and 1 more errors)", pos=[59:12]) - } - } - } - } - global: { - auth0: { - enabled: _|_ @test(err, code=incomplete, contains="#Config.auth0: incomplete bool: bool (and 1 more errors)", pos=[59:12]) - } - } - } - #NetworkPolicy: {spec: {ingress: [], egress: []}} - #Flux: { - charts: { - foo: {global: {auth0: {enabled: bool}}} - } - formatOutput: { - foo: {} - "ns/network": { - spec: { - ingress: [{ - from: [{ - namespaceSelector: {matchLabels: {tenant: string}} - }] - }] - egress: [{ - to: [{ - namespaceSelector: {matchLabels: {tenant: string}} - }] - }] - } - } - } - _outputs$config: { - foo: {} - "ns/network": { - spec: { - ingress: [{ - from: [{ - namespaceSelector: {matchLabels: {tenant: string}} - }] - }] - egress: [{ - to: [{ - namespaceSelector: {matchLabels: {tenant: string}} - }] - }] - } - } - } - tenant: {id: string} - auth0: {_|_, enabled: bool} - global: { - auth0: { - enabled: _|_ @test(err, code=incomplete, contains="#Flux.auth0: incomplete bool: bool (and 1 more errors)", pos=[59:12]) - } - } - } -}) -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/comprehensions/issue2171.txtar b/internal/core/compile/testdata/sync/comprehensions/issue2171.txtar index 4c794d116..5f35555d5 100644 --- a/internal/core/compile/testdata/sync/comprehensions/issue2171.txtar +++ b/internal/core/compile/testdata/sync/comprehensions/issue2171.txtar @@ -3,12 +3,10 @@ package x do: { - hello: { - } + hello: {} } for k, v in do {do: (k): v} -@test(eq, {do: hello: {}}) -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/comprehensions/issue2481.txtar b/internal/core/compile/testdata/sync/comprehensions/issue2481.txtar index 3c639c3ef..4517427bb 100644 --- a/internal/core/compile/testdata/sync/comprehensions/issue2481.txtar +++ b/internal/core/compile/testdata/sync/comprehensions/issue2481.txtar @@ -11,14 +11,13 @@ // TODO: fix out: { for k in keys { - if values[k] != _|_ { + if values[k] != _|_ { val: k if val != _|_ { k } } } - @test(err, code=eval, hint="string with struct") } // multiple lets are mapped to the same location and will conflict. This is @@ -27,27 +26,25 @@ out: { // TODO: fix multiLets: { for k in keys { - if values[k] != _|_ { + if values[k] != _|_ { let val = k if val != _|_ { k } } } - @test(eq, "b") } keys: [ // order matters "a", "b", -] @test(eq, ["a", "b"]) +] values: { // order does not matter "b": "member" "c": "foo" - @test(eq, {b: "member", c: "foo"}) } full: { @@ -78,7 +75,6 @@ full: { "role": "member" "username": "foo" } - @test(eq, {out: {role: "member"}, #github_team_membership: {team_id: string, role: string}, values: {role: "member", username: "foo"}}) } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/comprehensions/issue287.txtar b/internal/core/compile/testdata/sync/comprehensions/issue287.txtar index 027fb24ed..3749d364a 100644 --- a/internal/core/compile/testdata/sync/comprehensions/issue287.txtar +++ b/internal/core/compile/testdata/sync/comprehensions/issue287.txtar @@ -7,8 +7,8 @@ if #E["y"] != _|_ { } #E: [_]: bool #E: x: true -#E: _ @test(eq, {y: true, x: true}) -z: _ @test(eq, true) +#E: _ +z: _ -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/comprehensions/issue293.txtar b/internal/core/compile/testdata/sync/comprehensions/issue293.txtar index 6fa23bfd3..bb642a66a 100644 --- a/internal/core/compile/testdata/sync/comprehensions/issue293.txtar +++ b/internal/core/compile/testdata/sync/comprehensions/issue293.txtar @@ -11,37 +11,34 @@ }) } x: _ -// All tests here should pass and the result of the okcN tests should be -// identical to those of the okoN tests. -// Should Field s exist in okc or not? Depends on whether comparison to bottom -// is recursive or not. It probably should not. -// TODO: fix for new evaluator. But possibly address this with new builtins. + // All tests here should pass and the result of the okcN tests should be + // identical to those of the okoN tests. + // Should Field s exist in okc or not? Depends on whether comparison to bottom + // is recursive or not. It probably should not. + // TODO: fix for new evaluator. But possibly address this with new builtins. } z: #T & { x: { f1: 99 f2: "i want to disallow this" } -} @test(err, code=eval, at=x.f2, contains="field not allowed", pos=[3:3]) - +} -t: #C @test(eq, {p: "foo"}) +t: #C #C: { if true { p: _ -// Comparing to string is not an error. But for legacy reasons we want to still -// support this. We intend to have more clean and precise behavior with the -// builtins isdefined, isvalid, and isconcrete. + // Comparing to string is not an error. But for legacy reasons we want to still + // support this. We intend to have more clean and precise behavior with the + // builtins isdefined, isvalid, and isconcrete. } } t: p: "foo" - -- variant1.cue -- #V1: { - x: close({ f1: int }) - x: f2: 2 @test(err, code=eval, contains="field not allowed", pos=[0:5]) + x: close({f1: int}) + x: f2: 2 } - -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/comprehensions/issue3762.txtar b/internal/core/compile/testdata/sync/comprehensions/issue3762.txtar index 79fd4e3b9..8aa3ac435 100644 --- a/internal/core/compile/testdata/sync/comprehensions/issue3762.txtar +++ b/internal/core/compile/testdata/sync/comprehensions/issue3762.txtar @@ -21,29 +21,8 @@ full: { x: 5 } - _a: [ID=_]: vms: [{ name: "hello" }] - _b: [ID=_]: vms: [{ name: "again" }] - @test(eq, { - kube: node: n1: { - _CL: "l" - _cs: l: { - opts: {} - _ba?: string - vms: [{ - name: "hello" - }] - } - } - _a: l: { - _ba?: string - opts: {} - vms: [{ - name: "hello" - }] - } - x: 5 - _b: {} - }) + _a: [ID=_]: vms: [{name: "hello"}] + _b: [ID=_]: vms: [{name: "again"}] } reduced: p1: { _cs: _a.l & { @@ -65,14 +44,6 @@ reduced: p1: { for k, _ in _a & _b { x: 5 } - @test(eq, { - _cs: {opts: {}, _ba?: string, vms: "hello"} - _a: { - l: {_ba?: string, opts: {}, vms: "hello"} - } - _b: {l: {vms: "again"}} - x: 5 - }) } reduced: p2: { for k, _ in _a & _b { @@ -94,14 +65,6 @@ reduced: p2: { } _b: l: vms: "again" - @test(eq, { - x: 5 - _cs: {opts: {}, _ba?: string, vms: "hello"} - _a: { - l: {_ba?: string, opts: {}, vms: "hello"} - } - _b: {l: {vms: "again"}} - }) } reference: { _x: { @@ -115,11 +78,6 @@ reference: { for k, _ in _x & _y { ok: true } - @test(eq, { - _x: {f: true} - _y: {f: false} - ok: true - }) } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/comprehensions/issue3763.txtar b/internal/core/compile/testdata/sync/comprehensions/issue3763.txtar index 6cfbd807c..bc30bf2ab 100644 --- a/internal/core/compile/testdata/sync/comprehensions/issue3763.txtar +++ b/internal/core/compile/testdata/sync/comprehensions/issue3763.txtar @@ -8,16 +8,8 @@ reduced: { if true { let Z = [for _, x in A {x}] - B: [for z in Z if z.y != _|_ { b: 1 }] + B: [for z in Z if z.y != _|_ {b: 1}] } - @test(eq, { - A: { - x1: {y?: int} - x2: {y?: int} - x3: {y?: int} - } - B: [] - }) } -- full.cue -- full: { @@ -27,8 +19,6 @@ full: { cp: int32 } } - - @test(shareID=L, at=k.n.n1._cs.l) k: n: n1: { _CL: "l" } @@ -57,45 +47,7 @@ full: { }] } - _cl: l: {} @test(shareID=L) - @test(eq, { - _core_v1: #cp: { - hostPort?: >=-2147483648 & <=2147483647 & int - cp: >=-2147483648 & <=2147483647 & int - } - k: n: n1: { - _CL: "l" - _cs: l: _ports: { - "1": { - hostPort?: >=-2147483648 & <=2147483647 & int - cp: >=-2147483648 & <=2147483647 & int - } - "2": { - hostPort?: >=-2147483648 & <=2147483647 & int - cp: >=-2147483648 & <=2147483647 & int - } - "3": { - hostPort?: >=-2147483648 & <=2147483647 & int - cp: >=-2147483648 & <=2147483647 & int - } - } - } - _cl: l: _ports: { - "1": { - hostPort?: >=-2147483648 & <=2147483647 & int - cp: >=-2147483648 & <=2147483647 & int - } - "2": { - hostPort?: >=-2147483648 & <=2147483647 & int - cp: >=-2147483648 & <=2147483647 & int - } - "3": { - hostPort?: >=-2147483648 & <=2147483647 & int - cp: >=-2147483648 & <=2147483647 & int - } - } - ports: [] - }) + _cl: l: {} } -- out/compile -- --- full.cue diff --git a/internal/core/compile/testdata/sync/comprehensions/issue3929.txtar b/internal/core/compile/testdata/sync/comprehensions/issue3929.txtar index 2b7b56935..2c9ed12c6 100644 --- a/internal/core/compile/testdata/sync/comprehensions/issue3929.txtar +++ b/internal/core/compile/testdata/sync/comprehensions/issue3929.txtar @@ -12,9 +12,8 @@ import "strings" reduced: { #Input: { - @test(shareID=reducedInput) - name: string - age: "one" | "two" + name: string + age: "one" | "two" if name != _|_ { if true { age: "one" @@ -33,62 +32,27 @@ reduced: { } #def3: { - _in: #Input @test(shareID=reducedInput) + _in: #Input def3: _in.age } in: name: "foobar" out: (#def1 & {_in: in}).def1 - @test(eq, { - #Input: {name: string, age: "one" | "two"} - #def1: { - _in$main: _ - def1: { - _in$main: _ - def2: { - _in$main: {name: string, age: "one" | "two"} - def3: "one" | "two" - } - } - } - #def2: { - _in$main: _ - def2: { - _in$main: {name: string, age: "one" | "two"} - def3: "one" | "two" - } - } - #def3: { - _in$main: {name: string, age: "one" | "two"} - def3: "one" | "two" - } - in: {name: "foobar"} - out: { - _in$main: {name: "foobar"} - def2: { - _in$main: {name: "foobar", age: "one"} - def3: "one" - } - } - }) } full: { cronjob: [string]: #CronjobConfig #CronjobConfig: { - @test(shareID=cronjobConfig) #PodConfig } #PodConfig: { - @test(shareID=podConfig) #ContainerConfig } #ContainerConfig: { - @test(shareID=containerConfig) image: string imagePullPolicy: "IfNotPresent" | "Always" | "Never" if image != _|_ { @@ -102,13 +66,13 @@ full: { } _#cronjob: { - c=_config: #CronjobConfig @test(shareID=cronjobConfig) + c=_config: #CronjobConfig out: spec: jobTemplate: spec: template: _#pod & {_config: c} } _#pod: { - c=_config: #PodConfig @test(shareID=podConfig) + c=_config: #PodConfig spec: containers: [{ _#container & { @@ -118,7 +82,7 @@ full: { } _#container: { - c=_config: #ContainerConfig @test(shareID=containerConfig) + c=_config: #ContainerConfig imagePullPolicy: c.imagePullPolicy } @@ -128,69 +92,6 @@ full: { for k, v in cronjob { objects: cronjob: "\(k)": (_#cronjob & {_config: v}).out } - @test(eq, hint="update this once todo is fixed", { - cronjob: foobar: { - image: "foobar:latest" - imagePullPolicy: *"Always" | "IfNotPresent" | "Never" - } - #CronjobConfig: { - image: string - imagePullPolicy: "IfNotPresent" | "Always" | "Never" - } - #PodConfig: { - image: string - imagePullPolicy: "IfNotPresent" | "Always" | "Never" - } - #ContainerConfig: { - image: string - imagePullPolicy: "IfNotPresent" | "Always" | "Never" - } - _#cronjob$main: { - _config$main: { - image: string - imagePullPolicy: "IfNotPresent" | "Always" | "Never" - } - out: spec: jobTemplate: spec: template: { - _config$main: { - image: string - imagePullPolicy: "IfNotPresent" | "Always" | "Never" - } - spec: containers: [{ - _config$main: _ @test(ignore) - imagePullPolicy: "IfNotPresent" | "Always" | "Never" - }] - } - } - _#pod$main: { - _config$main: { - image: string - imagePullPolicy: "IfNotPresent" | "Always" | "Never" - } - spec: containers: [{ - _config$main: _ @test(ignore) - imagePullPolicy: "IfNotPresent" | "Always" | "Never" - }] - } - _#container$main: { - _config$main: { - image: string - imagePullPolicy: "IfNotPresent" | "Always" | "Never" - } - imagePullPolicy: "IfNotPresent" | "Always" | "Never" - } - objects: cronjob: foobar: spec: jobTemplate: spec: template: { - _config$main: { - image: "foobar:latest" - imagePullPolicy: *"Always" | "IfNotPresent" | "Never" - } - spec: containers: [{ - _config$main: _ @test(ignore) - imagePullPolicy: *"Always" | "IfNotPresent" | "Never" - }] - } - }) - // TODO(inline) support at for closed. - // @test(closed, at=full.objects.cronjob.foobar) } -- out/compile -- diff --git a/internal/core/compile/testdata/sync/comprehensions/issue4091.txtar b/internal/core/compile/testdata/sync/comprehensions/issue4091.txtar index 59b02835b..37ffbfda6 100644 --- a/internal/core/compile/testdata/sync/comprehensions/issue4091.txtar +++ b/internal/core/compile/testdata/sync/comprehensions/issue4091.txtar @@ -4,13 +4,7 @@ # via {_input: _obj}. # https://cuelang.org/issue/4091 -- in.cue -- -output: (_Generator & {_input: _obj})._output @test(eq, { - genID: "id1" - _id: "id1" - volumeMounts: [{name: "mount1"}] - _volumes: {mount1: {name: "mount1"}} - volumes: {mount1: {name: "mount1"}} -}) +output: (_Generator & {_input: _obj})._output _obj: spec: { _id: "id1" diff --git a/internal/core/compile/testdata/sync/comprehensions/issue4094.txtar b/internal/core/compile/testdata/sync/comprehensions/issue4094.txtar index 6f1559254..25be0e47c 100644 --- a/internal/core/compile/testdata/sync/comprehensions/issue4094.txtar +++ b/internal/core/compile/testdata/sync/comprehensions/issue4094.txtar @@ -32,10 +32,7 @@ _libexport: { } export: _libexport & { _IMPORTS: [_imported] -} @test(eq, at=objects, [ - {_neverTrue: false, alwaysSet: "foo", name: "name1", spec: {image: "image1"}}, - {generated: true}, -]) +} _imported: { export: _libexport & { diff --git a/internal/core/compile/testdata/sync/comprehensions/issue4174.txtar b/internal/core/compile/testdata/sync/comprehensions/issue4174.txtar index 8d90cfaed..0b012ce07 100644 --- a/internal/core/compile/testdata/sync/comprehensions/issue4174.txtar +++ b/internal/core/compile/testdata/sync/comprehensions/issue4174.txtar @@ -14,7 +14,7 @@ if false { a: neverAdded: {} } -a: _ @test(eq, {}) +a: _ -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/comprehensions/issue436.txtar b/internal/core/compile/testdata/sync/comprehensions/issue436.txtar index 5773037c8..e6b24c61b 100644 --- a/internal/core/compile/testdata/sync/comprehensions/issue436.txtar +++ b/internal/core/compile/testdata/sync/comprehensions/issue436.txtar @@ -6,7 +6,6 @@ #a: { val: string result: string - @test(closed) } a: #a & { @@ -15,15 +14,15 @@ a: #a & { if (val == "match") { result: "matched" } -} @test(eq, {val: *"default" | string, result: *"not-matched" | string}) @test(closed) +} match: a & { val: "match" -} @test(eq, {val: "match", result: "matched"}) @test(closed) +} not: a & { val: "other" -} @test(eq, {val: "other", result: *"not-matched" | string}) @test(closed) +} -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/comprehensions/issue507.txtar b/internal/core/compile/testdata/sync/comprehensions/issue507.txtar index 24f54819e..3ec55f517 100644 --- a/internal/core/compile/testdata/sync/comprehensions/issue507.txtar +++ b/internal/core/compile/testdata/sync/comprehensions/issue507.txtar @@ -11,22 +11,22 @@ foo: [ for e in somelist { "hello foo: \(e)" }, -] @test(eq, []) +] -otherlist: ["something"] @test(eq, ["something"]) +otherlist: ["something"] // Works fine as well z: [ for e in otherlist { "hello z: \(e)" }, -] @test(eq, ["hello z: something"]) +] extlist: [...string] | *["something"] bar: [ for e in extlist { "hello bar: \(e)" }, -] @test(eq, ["hello bar: something"]) +] -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/comprehensions/issue837.txtar b/internal/core/compile/testdata/sync/comprehensions/issue837.txtar index b2c383735..fbc8adb7c 100644 --- a/internal/core/compile/testdata/sync/comprehensions/issue837.txtar +++ b/internal/core/compile/testdata/sync/comprehensions/issue837.txtar @@ -5,9 +5,7 @@ #Manifest: { ref: #ManifestRef - description: #KumoriKinds[ref.kind] @test(err, code=incomplete, - contains="unresolved disjunction %v (type %s)", - args=["service" | "deployment", string], pos=[0:15]) + description: #KumoriKinds[ref.kind] } #ManifestRef: kind: #KindsNames @@ -25,8 +23,6 @@ service: (#Configure & { _params: hsize: dep.hsize }).service - @test(err, at=service.description.role, code=incomplete, - contains="undefined field: %s", args=[role], pos=[24:19]) } } } @@ -44,8 +40,7 @@ role: "admin" }).out - role: configed.role @test(err, code=incomplete, - contains="undefined field: %s", args=[role], pos=[0:19]) + role: configed.role } } } @@ -56,11 +51,9 @@ } out: { - labstr: $p.label @test(err, code=eval, - contains="undefined field: %s", args=[label], pos=[0:14]) - + labstr: $p.label } -} @test(err, code=eval) +} #RoleSize: { $_instances: >=0 | *1 @@ -72,9 +65,6 @@ } #ServiceManifest: #Manifest & {ref: kind: "service"} -@test(err, at=#ServiceManifest.description, code=incomplete, - contains="undefined field: %s", args=[service], pos=[-67:28]) - -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/comprehensions/issue843.txtar b/internal/core/compile/testdata/sync/comprehensions/issue843.txtar index 9934c3622..188e477f8 100644 --- a/internal/core/compile/testdata/sync/comprehensions/issue843.txtar +++ b/internal/core/compile/testdata/sync/comprehensions/issue843.txtar @@ -13,13 +13,6 @@ import "list" "as": list.Concat([["go"], as]) }, ] - @test(eq, { - as: [] - #c: [{ - do: "f1" - as: ["go"] - }] - }) } #d2: { @@ -32,27 +25,12 @@ import "list" } }, ] - // TODO(inline): generatign this value is broken: hand-spun. - @test(eq, { - p: *"." | string - #c: [{ - do: "f2" - from: { - as: [*"."| string] - #c: [{ - do: "f1" - as: ["go", *"."| string] - }] - } - }] - }) } #c1: { #c: [...#o] _ ... - @test(eq, {_, #c: []}) } #o: #f1 | #f2 @@ -60,15 +38,10 @@ import "list" #f1: { do: "f1" as: [...string] - @test(eq, {do: "f1", as: []}) } - -@test(shareID=C1, at=#c1) -@test(shareID=C1, at=#f2.from) #f2: { do: "f2" from: #c1 - @test(eq, {do: "f2", from: {_, #c: []}}) } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/comprehensions/lists.txtar b/internal/core/compile/testdata/sync/comprehensions/lists.txtar index 5ea0936af..26f74382c 100644 --- a/internal/core/compile/testdata/sync/comprehensions/lists.txtar +++ b/internal/core/compile/testdata/sync/comprehensions/lists.txtar @@ -1,7 +1,7 @@ -- in.cue -- -a: [{a: 1}, {b: 2 & 3}] @test(err, code=eval, pos=[0:17, 0:21], contains="conflicting values") +a: [{a: 1}, {b: 2 & 3}] -b: [for x in a {x}] @test(err, code=eval, pos=[-2:17, -2:21], contains="conflicting values") +b: [for x in a {x}] -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/comprehensions/multi.txtar b/internal/core/compile/testdata/sync/comprehensions/multi.txtar index 7598086dc..f53bb77ee 100644 --- a/internal/core/compile/testdata/sync/comprehensions/multi.txtar +++ b/internal/core/compile/testdata/sync/comprehensions/multi.txtar @@ -1,7 +1,7 @@ -- in.cue -- -list: [2, 3] @test(eq, [2, 3]) -a: [ 3, for x in list {x}, for x in list {x}] @test(eq, [3, 2, 3, 2, 3]) -b: [ 3, if true {3}, for x in list if x > 2 {x}] @test(eq, [3, 3, 3]) +list: [2, 3] +a: [3, for x in list {x}, for x in list {x}] +b: [3, if true {3}, for x in list if x > 2 {x}] // issue574: Tests that if and for comprehensions inside list literals // correctly include or exclude elements based on conditions. @@ -23,12 +23,6 @@ issue574: { "bye" }, ] - @test(eq, { - greet: true - bye: true - message1: ["hello", "how are you doing?", "bye"] - message2: ["how are you doing?", "bye"] - }) } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/comprehensions/nested.txtar b/internal/core/compile/testdata/sync/comprehensions/nested.txtar index 31980d92e..db9159278 100644 --- a/internal/core/compile/testdata/sync/comprehensions/nested.txtar +++ b/internal/core/compile/testdata/sync/comprehensions/nested.txtar @@ -23,17 +23,6 @@ deployment: "node-exporter": { }] } } - @test(eq, { - spec: template: spec: containers: [{ - ports: [{ - _export$kube: _ @test(ignore) - containerPort: 9100 - name: "scrape" - }] - name: string - }] - _name$kube: string - }) } service: [ID=string]: { spec: { @@ -71,36 +60,6 @@ for k, v in deployment { ] } } -@test(eq, { - service: "node-exporter": spec: { - ports: [{ - name: "metrics" - port: 9100 - protocol: "TCP" - targetPort: *9100 | int - }] - selector: _|_ @test(err, code=incomplete, contains="service.\"node-exporter\".spec.selector: undefined field: metadata", pos=[59:35]) - } - deployment: "node-exporter": { - spec: template: spec: containers: [{ - ports: [{ - containerPort: 9100 - name: "scrape" - _export$kube: *true | false - }] - name: string - }] - _name$kube: string - } - _spec$kube: { - _name$kube: string - spec: template: spec: containers: [{ - name: string - ports: [] - }] - } -}) - -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/comprehensions/nested2.txtar b/internal/core/compile/testdata/sync/comprehensions/nested2.txtar index 6dd72df5a..09b2d125d 100644 --- a/internal/core/compile/testdata/sync/comprehensions/nested2.txtar +++ b/internal/core/compile/testdata/sync/comprehensions/nested2.txtar @@ -2,7 +2,6 @@ given: { INC: USD: 2.0 USD: GBP: 3.0 - @test(eq, {INC: {USD: 2.0}, USD: {GBP: 3.0}}) } hydrated: { for k, v in given { @@ -13,11 +12,6 @@ hydrated: { "\(k1)": "\(k)": number } } - @test(eq, { - INC: {INC: 1.0, USD: 2.0} - USD: {USD: 1.0, INC: number, GBP: 3.0} - GBP: {GBP: 1.0, USD: number} - }) } foo: { @@ -27,7 +21,6 @@ foo: { b: 20 } } - @test(eq, {a: 10, b: 20}) } indirectlyNested: { @@ -39,25 +32,20 @@ indirectlyNested: { } } } - @test(eq, {a: true, b: true}) } directlyNestedEmpty: { a: true if true { - if a { - } + if a {} } - @test(eq, {a: true}) } directlyDoublyNestedEmpty: { a: true if true { - if a { - } + if a {} } - @test(eq, {a: true}) } indirectlyDoublyNestedEmpty: { @@ -74,7 +62,6 @@ indirectlyDoublyNestedEmpty: { } } } - @test(eq, {a: true, b: true}) } indirectlyDoublyNested: { @@ -89,7 +76,6 @@ indirectlyDoublyNested: { c: 1 } } - @test(eq, {a: true, c: 1, b: 1}) } // This case used to trigger an over-aggressive deduplication. @@ -107,24 +93,19 @@ issue1974: { "\(k)": "\(vk)": vv } } - @test(eq, { - X: {foo: {bar: "", baz: ""}} - out: {foo: {bar: "", baz: ""}} - }) } -- pending.cue -- // Trigger notification while an arc is still pending. -T: int @test(eq, 1) +T: int for C in Y { let X = C.M - T: X.V + T: X.V } Y: x: { M: V: 1 for _ in M { - if true { M: {} } + if true {M: {}} } - @test(eq, {M: {V: 1}}) } -- issue3940.cue -- // issue3940: Tests that chained comprehension clauses do not trigger spurious @@ -133,81 +114,32 @@ Y: x: { issue3940: reduced1: { X a: b: X - a: b: a: b: {y: X @test(shareID=reduced1X)} + a: b: a: b: {y: X} X: { - @test(shareID=reduced1X) a: {} objects: { for v in a - for _ in ({} & v).objects { - } + for _ in ({} & v).objects {} } } - - // The eq:todo value is now the correct result: the pushdown fix - // properly handles chained comprehension clauses, unifying a.b - // into a single struct. - @test(eq, { - a: { - b: { - a: {b: {y: {a: {}, objects: {}}}} - objects: _|_ @test(err, code=incomplete, contains="issue3940.reduced1.a.b.objects: undefined field: objects", pos=[15:22]) - } - } - X: {a: {}, objects: {}} - objects: {} - }) - @test(eq:todo, { - a: b: { - a: {b: {y: {a: {}, objects: {}}}} - objects: {} - } - X: {a: {}, objects: {}} - objects: {} - }) } // Test nested comprehensions (with braces) - should work as before issue3940: reduced2: { X a: b: X - a: b: a: b: {y: X @test(shareID=reduced2X)} + a: b: a: b: {y: X} X: { - @test(shareID=reduced2X) a: {} objects: { for v in a - for _ in ({} & v).objects { - } + for _ in ({} & v).objects {} } } - // The pushdown fix resolves the spurious "undefined field" error - // on objects: reduced2 is structurally identical to reduced1 and - // should produce the same result. - @test(eq, { - a: { - b: { - a: {b: {y: {a: {}, objects: {}}}} - objects: _|_ - } - } - X: {a: {}, objects: {}} - objects: {} - }) - @test(eq:todo, { - a: { - b: { - a: {b: {y: {a: {}, objects: {}}}} - objects: {} - } - } - X: {a: {}, objects: {}} - objects: {} - }) } issue3940: reduced3: { a: E @@ -217,13 +149,6 @@ issue3940: reduced3: { i: {} o: [for m in i for v in ({} & m).o {}] } - @test(eq, { - a: { - i: {x: {i: {x: {i: {}, o: []}}, o: []}} - o: [] - } - E: {i: {}, o: []} - }) } issue3940: reduced4: { @@ -231,7 +156,7 @@ issue3940: reduced4: { _imports: [{ objects: {...} #export: Exporter & { - _imports: [{ #export: Exporter }] + _imports: [{#export: Exporter}] } }] } @@ -244,39 +169,19 @@ issue3940: reduced4: { }, ] } - @test(eq, { - out: { - _imports: [{ - objects: {} - #export: { - _imports: [{ - #export: { - _imports: [] - objects: [] - } - }] - objects: [] - } - }] - objects: [] - } - Exporter: {_imports: [], objects: []} - }) } issue3940: let: { X a: b: X - a: b: a: b: {y: X @test(shareID=letX)} + a: b: a: b: {y: X} X: { - @test(shareID=letX) a: {} objects: { for v in a let x = ({} & v) - for _ in x.objects { - } + for _ in x.objects {} } } } @@ -324,85 +229,6 @@ issue3940: full: { }, ] } - @test(eq, at=out, { - _imports: [{ - objects: branch: { - #conf: _ @test(ignore) - region: _|_ @test(err, code=incomplete, contains="undefined field: global") - } - imports: [{ - objects: leaf: { - #conf: _ @test(ignore) - region: _|_ @test(err, code=incomplete, contains="undefined field: global") - } - #export: { - _objects: leaf: { - #conf: _ @test(ignore) - region: _|_ @test(err, code=incomplete, contains="undefined field: global") - } - #conf: _ @test(ignore) - _imports: [] - objects: [{ - leaf: { - #conf: _ @test(ignore) - region: _|_ @test(err, code=incomplete, contains="undefined field: global") - } - }] - } - }] - #export: { - _objects: branch: { - #conf: _ @test(ignore) - region: _|_ @test(err, code=incomplete, contains="undefined field: global") - } - _imports: [{ - objects: leaf: { - #conf: _ @test(ignore) - region: _|_ @test(err, code=incomplete, contains="undefined field: global") - } - #export: { - _objects: leaf: { - #conf: _ @test(ignore) - region: _|_ @test(err, code=incomplete, contains="undefined field: global") - } - #conf: _ @test(ignore) - _imports: [] - objects: [{ - leaf: { - #conf: _ @test(ignore) - region: _|_ @test(err, code=incomplete, contains="undefined field: global") - } - }] - } - }] - #conf: _ @test(ignore) - objects: [{ - branch: { - #conf: _ @test(ignore) - region: _|_ @test(err, code=incomplete, contains="undefined field: global") - } - }, { - leaf: { - #conf: _ @test(ignore) - region: _|_ @test(err, code=incomplete, contains="undefined field: global") - } - }] - } - }] - #conf: {global: {region: "Europe"}} - _objects: {} - objects: [{ - branch: { - #conf: {global: {region: "Europe"}} - region: "Europe" - } - }, { - leaf: { - #conf: {global: {region: "Europe"}} - region: "Europe" - } - }] - }) } -- issue3990.cue -- // issue3990: Tests that nested comprehensions within struct definitions do not @@ -424,7 +250,7 @@ issue3990: { } for import in _imports - for _, obj in ({extra: "unused"} & import).exportObjs {(import.name): obj}, + for _, obj in ({extra: "unused"} & import).exportObjs {(import.name): obj} _Deployment: this={ _names: { @@ -437,44 +263,6 @@ issue3990: { volumeNames: [for _, v in _names {v}] } } - @test(eq, { - _imports: [{ - name: "noVolumes" - exportObjs: deployment: {volumes: [], _names: {}} - }, { - name: "someVolumes" - exportObjs: deployment: { - _names: {data: "data"} - volumeNames: ["data"] - volumes: [{ - name: "data" - }] - } - }] - _noVolumes: { - name: "noVolumes" - exportObjs: {deployment: {volumes: [], _names: {}}} - } - _someVolumes: { - name: "someVolumes" - exportObjs: { - deployment: { - volumes: [{ name: "data" }] - _names: {data: "data"} - volumeNames: ["data"] - } - } - } - _Deployment: { - _names: _|_ @test(err, code=incomplete) - } - someVolumes: { - volumes: [{ name: "data" }] - _names: {data: "data"} - volumeNames: ["data"] - } - noVolumes: {volumes: [], _names: {}} - }) } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/comprehensions/nestembed.txtar b/internal/core/compile/testdata/sync/comprehensions/nestembed.txtar index 9ee9fe486..04000ba16 100644 --- a/internal/core/compile/testdata/sync/comprehensions/nestembed.txtar +++ b/internal/core/compile/testdata/sync/comprehensions/nestembed.txtar @@ -4,13 +4,12 @@ Issue #556 -- in.cue -- import "list" -DeleteThis: ["this", "that"] @test(eq, ["this", "that"]) +DeleteThis: ["this", "that"] useful_infra: { gcp: cluters: 10 aws: clusters: 20 this: clusters: 1 that: clusters: 2 - @test(eq, {gcp: {cluters: 10}, aws: {clusters: 20}, this: {clusters: 1}, that: {clusters: 2}}) } New_infra: { for k, v in useful_infra { @@ -18,7 +17,6 @@ New_infra: { "\(k)": v } } - @test(eq, {gcp: {cluters: 10}, aws: {clusters: 20}}) } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/comprehensions/open_iter_writeback.txtar b/internal/core/compile/testdata/sync/comprehensions/open_iter_writeback.txtar index 0511ecc66..1bb43fc75 100644 --- a/internal/core/compile/testdata/sync/comprehensions/open_iter_writeback.txtar +++ b/internal/core/compile/testdata/sync/comprehensions/open_iter_writeback.txtar @@ -18,27 +18,18 @@ openIter: { a: 1 b: 2 ... - if true { c: 3 } + if true {c: 3} } - keys: [for k, _ in src { k }] - @test(eq, { - src: {a: 1, b: 2, c: 3, ...} - keys: ["a", "b", "c"] - }) + keys: [for k, _ in src {k}] } defOpen: { #T: { [string]: int - if true { a: 1 } + if true {a: 1} } - inst: #T & { b: 2 } - keys: [for k, _ in inst { k }] - @test(eq, { - #T: {[string]: int, a: 1} - inst: {a: 1, b: 2} - keys: ["b", "a"] - }) + inst: #T & {b: 2} + keys: [for k, _ in inst {k}] } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/comprehensions/optional_ref_yield.txtar b/internal/core/compile/testdata/sync/comprehensions/optional_ref_yield.txtar index c009b0202..6156c8f97 100644 --- a/internal/core/compile/testdata/sync/comprehensions/optional_ref_yield.txtar +++ b/internal/core/compile/testdata/sync/comprehensions/optional_ref_yield.txtar @@ -27,7 +27,7 @@ optionalUpgradesViaSiblingComp: { foo: 5 } } - x: bar: int @test(eq, 5) + x: bar: int } // Test B: a self-reference to an optional field that stays optional @@ -38,7 +38,7 @@ optionalStaysOptional: { bar: x.foo foo?: int } - x: bar: _ @test(err, code=incomplete, contains="cannot reference optional field") + x: bar: _ } // Test C: regression for the original ArcPending case — a self-reference @@ -51,7 +51,7 @@ pendingBecomesMember: { foo: 5 } } - x: bar: int @test(eq, 5) + x: bar: int } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/comprehensions/pushdown.txtar b/internal/core/compile/testdata/sync/comprehensions/pushdown.txtar index 503ce15d9..d026bba14 100644 --- a/internal/core/compile/testdata/sync/comprehensions/pushdown.txtar +++ b/internal/core/compile/testdata/sync/comprehensions/pushdown.txtar @@ -21,21 +21,6 @@ linkChildren: { } } } - @test(eq, { - w: 1 - v: { - x: 1 - y: 1 - z: 1 - rw: 1 - rx: 1 - ry: 1 - rz: 1 - n1a: {na: [1, 1, 1, 1]} - n2a: {n1a: {na: [1, 1, 1, 1]}} - n2z: {n1z: {nz: 1}} - } - }) } fail: { @@ -48,11 +33,11 @@ fail: { if a.b == _|_ { b: 1 } - } @test(err, code=incomplete|cycle) + } } embed: { - fail1: #C1 @test(err, code=eval, path=p, contains="field not allowed") + fail1: #C1 #C1: { // TODO(errors): don't include all positions of p in the normal list of // positions, or rather categorize the positions to show: @@ -66,8 +51,7 @@ embed: { } fail1: p: "foo" // this should fail, as p is not present. - - success2: #C2 @test(eq, {p: "foo"}) + success2: #C2 #C2: { if true { p: _ @@ -75,7 +59,7 @@ embed: { } success2: p: "foo" // this succeeds as p is present. - success3: #C3 @test(eq, {}) + success3: #C3 #C3: {} success3: { if false { @@ -86,7 +70,7 @@ embed: { success4: { #X: y: string - x: y: string + x: y: string x: { for _ in ["iter-once"] { #X @@ -95,7 +79,7 @@ embed: { } } } - } @test(eq, {#X: {y: string}, x: {y: string}}) + } fail4: #C4 #C4: {} @@ -104,14 +88,14 @@ embed: { // error as p is not allowed in fail4 p: q: 1 } - } @test(err, code=eval, path=p, contains="field not allowed", pos=[3:4]) + } incomplete5: { a: bool if a { p: q: 1 } - } @test(err, code=incomplete, contains="incomplete %s: %s", args=[bool, bool], pos=[1:6]) + } incomplete6: { if false { @@ -119,21 +103,14 @@ embed: { } p: q + 1 q: int - } @test(eq, { - p: _|_ @test(err, code=incomplete, contains="embed.incomplete6.p: non-concrete value int in operand to +", pos=[117:6, 118:6]) - q: int - }) + } incomplete7: { p: q + 1 q: int if false { q: 1 // do not inadvertently pick up a void arc. } - } @test(eq, { - p: _|_ @test(err, code=incomplete, contains="non-concrete value int") - // TODO(inline): do not fail on todo with position mismatch. @test(err:todo, pos=[124:6, 125:6, 126:3]) - q: int - }) + } } // Mix of both dynamic and static fields. @@ -141,21 +118,20 @@ mixedFieldsSuccess: { a: { for _, s in ["foo"] { "\(s)": 1 - X: 1 + X: 1 } } b: #Def: { for _, s in ["foo"] { "\(s)": 1 - X: 1 + X: 1 } } b: x: b.#Def - b: x: X: _ + b: x: X: _ b: x: foo: _ - c: #Def: { X: int foo: int @@ -164,20 +140,9 @@ mixedFieldsSuccess: { c: x: { for _, s in ["foo"] { "\(s)": 1 - X: 1 + X: 1 } } - @test(eq, { - a: {X: 1, foo: 1} - b: { - #Def: {X: 1, foo: 1} - x: {X: 1, foo: 1} - } - c: { - #Def: {X: int, foo: int} - x: {X: 1, foo: 1} - } - }) } // fieldMismatch tests that an embedded scalar cannot be mixed with regular @@ -189,7 +154,6 @@ fieldMismatch: { x: 3 } } - @test(err, code=eval, at=a, hint="int with struct") } // b12aStructCycle presents a case that can easily lead to stack overflow in @@ -210,10 +174,8 @@ noStackOverflowStructCycle: { sum: tail.sum } } - @test(err, code=structural_cycle, at="#list.tail", contains="structural cycle", pos=[]) } - // #a is incomplete, but the missing values are provided by x. provideIncompleteSuccess: { t1: { @@ -225,11 +187,6 @@ provideIncompleteSuccess: { } x: (#a & {b: true}) & {c: 4} y: x - @test(eq, { - #a: {_|_, b: bool} - x: {b: true, c: 4} - y: {b: true, c: 4} - }) } t2: { @@ -239,7 +196,7 @@ provideIncompleteSuccess: { c: 4 } b: true - } @test(eq, {c: 4, b: true}) + } #c: {} a: { @@ -249,7 +206,7 @@ provideIncompleteSuccess: { b: true // d is disallowed, even though it is added by embedding. // TODO: this seems right, but it may be good to clarify why. - c: #c @test(err, code=eval, at=d, contains="field not allowed", pos=[-5:8]) + c: #c } } } @@ -282,24 +239,13 @@ voidArcs: { } } } - @test(eq, { - scopes: { - x: 1 - a: {y: 2, b: 1, c: {d: 1}, e: 2, f: {g: 2}} - } - drop: {x: 1, a: {y: 2}} - }) } cyclicError: { a: { - // With pushdown, x and y remain bool (incomplete) rather than - // erroring: the if guards cannot resolve bool to a concrete - // value, so the comprehension bodies simply do not fire. - @test(err, code=incomplete) x: bool y: bool - if a.x { + if a.x { y: true } if a.y { @@ -310,15 +256,7 @@ cyclicError: { // With pushdown, evaluating a.b no longer forces a cycle error // because the comprehension dependencies are pushed down to the // individual fields rather than blocking the parent. - c: a.b @test(err, code=incomplete|cycle) - @test(eq, { - a: { - x: _|_ - y: _|_ - b: {} - } - c: _|_ - }) + c: a.b } midwayReferences: { @@ -331,12 +269,6 @@ midwayReferences: { b: a.x c: a.x.y d: a.x.y.z - @test(eq, { - a: {x: {y: {z: {a: 1, b: 2}}}} - b: {y: {z: {a: 1, b: 2}}} - c: {z: {a: 1, b: 2}} - d: {a: 1, b: 2} - }) } // Ensure first closedness check is done after evaluation of @@ -355,10 +287,6 @@ closedCheck: success1: { d: "d" e: "ok" } - @test(eq, { - a: {b: {c: {d: "d", e: "ok"}}} - #D: {d: string} - }) } closedCheck: success2: { @@ -367,7 +295,7 @@ closedCheck: success2: { #D: { d: string if d != "c" { - ("foo"+"bar"): string + ("foo" + "bar"): string } } @@ -375,10 +303,6 @@ closedCheck: success2: { d: "d" foobar: "ok" } - @test(eq, { - a: {b: {c: {d: "d", foobar: "ok"}}} - #D: {d: string} - }) } closedCheck: success3: { @@ -390,7 +314,6 @@ closedCheck: success3: { if d != "c" { string } - @test(err, code=incomplete, contains="non-concrete value", pos=[1:7, -1:6]) } } @@ -398,26 +321,14 @@ closedCheck: success3: { d: "d" e: "ok" } - @test(eq, { - a: {b: {c: {d: "d", e: "ok"}}} - #D: { - d: string - e: _|_ - } - }) } emptyComprehensionIncomplete: { a: {} b: { // b should be an incomplete error - if a.b { - } - } @test(err, code=incomplete, contains="undefined field: %s", args=[b], pos=[2:8]) - @test(eq, { - a: {} - b: _|_ - }) + if a.b {} + } } // voidEliminationSuccess tests that "conditional" or "void" arcs are eliminated @@ -430,7 +341,6 @@ voidEliminationSuccess: t1: { if false { a: b: true } - @test(eq, {}) } voidEliminationSuccess: t2: { @@ -460,14 +370,6 @@ voidEliminationSuccess: t2: { components: sinks: blah: { kind: "source" } - @test(eq, { - components: { - sinks: { - blah: {kind: "source", configuration: {}} - } - #C: {kind: string, configuration: {}} - } - }) } voidEliminationSuccess: derefRef1: { @@ -481,15 +383,8 @@ voidEliminationSuccess: derefRef1: { E: { e: bool - f: !e @test(err, code=incomplete, contains="not concrete", pos=[0:7]) + f: !e } - @test(eq, { - a: {b: {c: {}}} - E: { - e: bool - f: _|_ - } - }) } voidEliminationSuccess: derefRef2: { @@ -504,19 +399,8 @@ voidEliminationSuccess: derefRef2: { E: #F #F: { e: bool - f: !e @test(err, code=incomplete, contains="not concrete", pos=[0:7]) + f: !e } - @test(eq, { - a: {b: {c: {}}} - E: { - e: bool - f: _|_ - } - #F: { - e: bool - f: _|_ @test(err, code=incomplete) - } - }) } voidEliminationSuccess: derefDisj1: { @@ -535,10 +419,6 @@ voidEliminationSuccess: derefDisj1: { g: bool h: !g } - @test(eq, { - a: {b: {c: {}}} - E: _|_ @test(err, code=incomplete, contains="voidEliminationSuccess.derefDisj1.E: 2 errors in empty disjunction: (and 2 more errors)", pos=[]) - }) } voidEliminationSuccess: derefDisj2: { @@ -557,10 +437,6 @@ voidEliminationSuccess: derefDisj2: { g: bool h: !g } - @test(eq, { - a: {b: {c: {}}} - E: _|_ @test(err, code=incomplete, contains="voidEliminationSuccess.derefDisj2.E: 2 errors in empty disjunction: (and 2 more errors)", pos=[]) - }) } voidEliminationSuccess: bulk1: { @@ -574,7 +450,6 @@ voidEliminationSuccess: bulk1: { } d: c.e } - @test(eq, {a: {b: {c: {e: string}, d: string}}}) } voidEliminationSuccess: opt1: { @@ -588,7 +463,6 @@ voidEliminationSuccess: opt1: { } d: c.e } - @test(eq, {a: {b: {c: {e: string}, d: string}}}) } voidEliminationSuccess: noCycle1: { @@ -602,7 +476,6 @@ voidEliminationSuccess: noCycle1: { if false {g: _} } } - @test(eq, {_x: {}, a: {c: {h: "stream"}, b: {}}}) } voidEliminationSuccess: noCycle2: { @@ -616,7 +489,6 @@ voidEliminationSuccess: noCycle2: { } } _x: a.b - @test(eq, {a: {c: {h: "stream"}, b: {}}, _x: {}}) } voidLookup: { @@ -630,7 +502,7 @@ voidLookup: { a: [string]: { c: { for k, v in z { - (k): null // don't add this arc anywhere + (k): null // don't add this arc anywhere } } z: { @@ -639,35 +511,16 @@ voidLookup: { } } } - @test(eq, { - a: { - x: { - z: _|_ - c: _|_ - } - y: {c: _, z: {}} - } - }) - @test(err, at=a.x.z, code=incomplete, - contains="undefined field: %s", args=[void], pos=[1:17]) - @test(err, at=a.x.c, code=incomplete, - path=voidLookup.a.x.z, contains="undefined field: %s", args=[void], pos=[1:17]) } - // Eliminate the top value even if there is an error (especially incomplete // errors). topElimination: { a: int _ if true { - x: a+1 + x: a + 1 } - @test(eq, { - a: int - x: _|_ - }) - @test(err, at=x, code=incomplete, contains="non-concrete value %v in operand to %s", args=[int, +], pos=[4:6, 1:5]) } voidEliminationSuccess: drop1: { @@ -681,10 +534,6 @@ voidEliminationSuccess: drop1: { s: t & { #ok: false } - @test(eq, { - t: {#ok: *true | bool, x: int} - s: {#ok: false} - }) } // should be error @@ -692,9 +541,7 @@ voidEliminationSuccess: drop1: { explicitDefaultError: { a: string | *_|_ - if a != "" { - } - @test(err, code=incomplete, contains="non-concrete value string", pos=[3:5, 1:5]) + if a != "" {} } // Remove arcs for with no for comprehension results. @@ -709,7 +556,6 @@ allArcsSuccess: p1: { x: {} } } - @test(eq, {x: {}, y: {}}) } allArcsSuccess: p2: { @@ -723,7 +569,6 @@ allArcsSuccess: p2: { (k): null } } - @test(eq, {y: {}, x: {}}) } structShare: ok1: { @@ -735,7 +580,6 @@ structShare: ok1: { d: e: true // resolves } } - @test(eq, {a: {d: {e: true}}, E: {}}) } structShare: err1: { @@ -744,9 +588,7 @@ structShare: err1: { if true { x: d: e: true } - @test(err, code=eval, at=x.d.e, contains="field not allowed", pos=[4:9]) } - -- issue2208.cue -- // Regression where definitions that compiled correctly with 0.4.3 failed to // compile with 0.5.0-beta.2 due to incorrect handling of void errors. @@ -754,8 +596,7 @@ structShare: err1: { voidErrorIncomplete: { #Schema: [string]: { required: bool - if !required { - } + if !required {} } root: #Schema @@ -764,7 +605,6 @@ voidErrorIncomplete: { child: required: false } } - @test(eq, {#Schema: {}, root: {}}) } // TODO: should these always be errors, or only for cue vet? @@ -789,8 +629,6 @@ voidErrorIncomplete: { // } // } // } - - -- issue1759.cue -- // Tests that len() and comprehensions correctly see the full struct/list value. // https://cuelang.org/issue/1759 @@ -812,7 +650,7 @@ unity: success1: { } envs: "e1": #Env & { - configurations: c1: #Config + configurations: c1: #Config } envs: [string]: configurations: [string]: { @@ -823,17 +661,6 @@ unity: success1: { } } } - @test(eq, { - #Config: {name: string, type: string} - #AnyConfig: {name: string, type: string} - #Env: {name: string, configurations: {}} - envs: { - e1: { - configurations: {c1: {type: "foo", name: string}} - name: string - } - } - }) } // issue1759: Tests that len() correctly sees the full struct value when @@ -846,22 +673,16 @@ issue1759: { if true { _ports_map: a: {port: "80"} } - @test(eq, { - _ports_map: {a: {port: "80"}} - port: "80" - }) } arcAlignment: t1: { - [string]: { - if true { } + [string]: { + if true {} } if false { c: _ } - @test(eq, {}) } - -- issue2111.cue -- // Evaluator regression where circular dependency in evaluation of conditionals // caused incorrect results. All arc types, not just regular fields, should be pushed down. @@ -872,13 +693,10 @@ letPushdown: { a: { for k, v in _c { let x = v - if x != _|_ { - } + if x != _|_ {} } } - @test(eq, {_c: {y: 1}, a: {}}) } - -- issue2113.cue -- // Evaluator regression where a nested comprehension caused "was already used" // errors when the enclosing value was not yet fully evaluated. @@ -890,11 +708,9 @@ nestedWithEmbeddingOK: { a: { for k, v in c { {x: 1} - if a.x != _|_ { - } + if a.x != _|_ {} } } - @test(eq, {c: [1], a: {x: 1}}) } nestedWithDynamicFieldOK: { @@ -902,26 +718,22 @@ nestedWithDynamicFieldOK: { a: { for k, v in _c { - if x != _|_ { - } + if x != _|_ {} x="\(k)": 1 } } - @test(eq, {_c: {y: 1}, a: {y: 1}}) } // Errors in nested comprehensions should also be reported. errorPropagation: { deployment: _ for k, v in deployment { - for k1, v2 in v.env2 { // Report this error. - deployment: (k): x1: 1 + for k1, v2 in v.env2 { + deployment: (k): x1: 1 // Report this error. } } - for id in ["elem"] { deployment: (id): x2: 2 } - @test(err, code=incomplete, contains="undefined field: env2", pos=[3:19]) + for id in ["elem"] {deployment: (id): x2: 2} } - -- issue2131.cue -- // issue2131: Tests that chained for comprehensions correctly produce output // fields when iterating over nested structs. https://cuelang.org/issue/2131 @@ -935,13 +747,6 @@ issue2131: tests: { for os, examples in tests for k, v in examples { (os): (k): out: "test" } - @test(eq, { - windows: { - eg1: {in: "c:\\d", out: "test"} - eg2: {in: "c:\\test", out: "test"} - eg3: {in: "c:\\test\\d", out: "test"} - } - }) } -- issue3533.cue -- // issue3533: Tests that fields under two levels of comprehensions are not @@ -958,12 +763,6 @@ issue3533: { } } out: metadata: namespace: *"default" | string - @test(eq, { - #ObjectMeta: {namespace?: string} - out: { - metadata: {namespace: *"default" | string} - } - }) } -- issue3535.cue -- // issue3535: Tests that hidden fields inside if comprehensions do not @@ -981,10 +780,6 @@ issue3535: hidden: { } } foo: kind: "foo" - @test(eq, { - #X: {kind: string, output: {}} - foo: {kind: "foo", _hidden: {}, output: {}} - }) } issue3535: regular: { #X: { @@ -998,7 +793,6 @@ issue3535: regular: { } } foo: kind: "foo" - @test(err, code=eval, at=foo.regular, contains="field not allowed", pos=[8:4]) } issue3535: def: { #X: { @@ -1012,36 +806,25 @@ issue3535: def: { } } foo: kind: "foo" - @test(eq, { - #X: {kind: string, output: {}} - foo: {kind: "foo", #def: {}, output: {}} - }) } -- reflect.cue -- import "encoding/json" - unifyDynamicReflectSuccess: { for _, s in ["foo"] { X: {...} "\(s)": { X: {...} // cannot be _ - Y: json.Marshal(X) // cannot be yaml, X cannot be literal + Y: json.Marshal(X) // cannot be yaml, X cannot be literal } } [string]: X: { - if true {// must be there + if true { x: y: {} // at least 2 nestings needed to expose problem + // must be there } } - @test(eq, { - X: {X: {x: {y: {}}}} - foo: { - X: {x: {y: {}}} - Y: "{\"x\":{\"y\":{}}}" - } - }) } -- issue3621.cue -- // issue3621: evalv3 regression producing false "cyclic reference" errors for @@ -1055,7 +838,6 @@ issue3621: reduced: t1: { a: b1.b2.b3 b1: b2: b3: "Foo" } - @test(eq, {a: "Foo", b1: {b2: {b3: "Foo"}}}) } issue3621: reduced: t2: { outer: {} @@ -1063,10 +845,6 @@ issue3621: reduced: t2: { inner: inner2: name: "Foo" outer: b: inner.inner2.name } - @test(eq, { - outer: {b: "Foo"} - inner: {inner2: {name: "Foo"}} - }) } issue3621: full: { hello: "world" @@ -1082,20 +860,6 @@ issue3621: full: { bar: (inner.inner2.name) } } - @test(eq, { - hello: "world" - outer: { - outer2: {bar: "Employees", name: "outer2"} - } - inner: { - inner2: { - name: "Employees" - description: "All employees" - privacy: "secret" - create_default: false - } - } - }) } -- issue3708.cue -- // issue3708: evalv3 regression reporting a cyclic reference error when fields are @@ -1114,10 +878,6 @@ issue3708: { if true { people: bob: name: "Bob" } - @test(eq, { - out: "person" - people: {bob: {name: "Bob", kind: "person"}} - }) } -- issue3729.cue -- // issue3729: evalv3 incorrectly reports "incomplete value null" for fields typed @@ -1129,24 +889,18 @@ issue3729: withDisjunction: { if true { root: sub1?: #sub2: true } - @test(eq, { - #Root: {sub1?: {#sub2?: bool}} - root: {sub1?: {#sub2: true}} - }) } issue3729: withoutDisjunction: { root?: null if true { root: #sub1?: #sub2: true } - @test(err, code=eval, contains="conflicting values null", pos=[0:32, 1:9, 2:2, 3:9]) } issue3729: withoutDisjunctionWithEmbed: { root?: null if true { root: {_, #sub1?: #sub2: true} } - @test(eq, {root: {null, #sub1?: {#sub2: true}}}) } issue3729: definitionsOnly: { #Root: #sub1?: #sub2?: bool @@ -1154,10 +908,6 @@ issue3729: definitionsOnly: { if true { root: #sub1?: #sub2: true } - @test(eq, { - #Root: {#sub1?: {#sub2?: bool}} - root: {#sub1?: {#sub2: true}} - }) } issue3729: withEmbed: incomplete: { #Root: #sub1?: #sub2?: bool @@ -1165,15 +915,11 @@ issue3729: withEmbed: incomplete: { if true { root: {_, #sub1?: #sub2: true} } - @test(eq, { - #Root: {#sub1?: {#sub2?: bool}} - root: {null, #sub1?: {#sub2: true}} | {#sub1?: {#sub2: true}} - }) } issue3729: full: { - #Application: spec: #ApplicationSpec + #Application: spec: #ApplicationSpec #ApplicationSpec: syncPolicy?: null | #SyncPolicy - #SyncPolicy: automated?: null | #SyncPolicyAutomated + #SyncPolicy: automated?: null | #SyncPolicyAutomated #SyncPolicyAutomated: { prune?: bool selfHeal?: bool @@ -1189,28 +935,6 @@ issue3729: full: { } } argoApp: spec: _syncpolicy: "selfhealprune" - @test(eq, { - #Application: { - spec: { - syncPolicy?: null | {automated?: null | {prune?: bool, selfHeal?: bool}} - } - } - #ApplicationSpec: { - syncPolicy?: null | {automated?: null | {prune?: bool, selfHeal?: bool}} - } - #SyncPolicy: { - automated?: null | {prune?: bool, selfHeal?: bool} - } - #SyncPolicyAutomated: {prune?: bool, selfHeal?: bool} - argoApp: { - spec: { - syncPolicy: { - automated: {prune: true, selfHeal: true} - } - _syncpolicy: "selfhealprune" - } - } - }) } -- pending.cue -- // resolving comprehensions arcs across disjunctions. @@ -1221,20 +945,17 @@ arcTypeAcrossTwo: { if true { a: b: c: d: true } - @test(eq, {a: {b: {c: {d: true}}}}) } // issue3894: evalv3 regression where an if comprehension affecting an optional // field with a disjunction returns an incorrect result instead of the properly // constrained value. https://cuelang.org/issue/3894 issue3894: reduced: p1: { {a: string} | {b: value: string} - if true { b: value: "true" } - @test(eq, {b: {value: "true"}, a: string} | {b: {value: "true"}}) + if true {b: value: "true"} } issue3894: reduced: p2: { {b: value: string} | {a: string} - if true { b: value: "true" } - @test(eq, {b: {value: "true"}} | {b: {value: "true"}, a: string}) + if true {b: value: "true"} } issue3894: full: { #Output: {a?: string} | {b?: {value: string}} @@ -1244,10 +965,6 @@ issue3894: full: { b: {value: "true"} } } - @test(eq, { - #Output: {a?: string} | {b?: {value: string}} - out: {b: {value: "true"}} - }) } -- issue3935.cue -- // issue3935: evalv3 incorrectly reports "field not allowed" when a schema defined @@ -1265,14 +982,6 @@ issue3935: reduced: { } y!: x!: _ } - @test(eq, { - out: {y: {x: "bar"}, x: "bar"} - #A: {y: {other: int}} - #B: { - x: _|_ @test(err, code=incomplete, contains="issue3935.reduced.#B.x: required field missing: y", pos=[12:7]) - y!: {x!: _} - } - }) } issue3935: full: { out: #SchemaOther | #SchemaSelected @@ -1291,7 +1000,7 @@ issue3935: full: { } #SchemaSelected: { spec!: { - name!: string + name!: string config!: _ } @@ -1301,28 +1010,6 @@ issue3935: full: { _specConfig: spec.config } - @test(eq, { - out: { - spec: { - name: "foo" - config: {namespace: "bar"} - } - namespace: "bar" - _specConfig: {namespace: "bar"} - } - #SchemaOther: { - spec: { - otherOptional?: int - otherRegular: int - otherRequired!: int - } - } - #SchemaSelected: { - spec!: {name!: string, config!: _} - namespace: _|_ @test(err, code=incomplete, contains="issue3935.full.#SchemaSelected.namespace: undefined field: namespace", pos=[47:27]) - _specConfig: _|_ @test(err, code=incomplete, contains="issue3935.full.#SchemaSelected._specConfig: required field missing: spec", pos=[50:16]) - } - }) } -- rework.cue -- regression1: { @@ -1341,10 +1028,7 @@ regression1: { spec: command: ["a"] patch: {} } - out: #Rollout & {_X: x} @test(eq, at=out,{ - _Y: {spec: {command: ["a"]}, patch: {}} - command: ["a"] - }) + out: #Rollout & {_X: x} } regression2: { #Primary: { @@ -1361,10 +1045,7 @@ regression2: { spec: command: ["a"] patch: {} } - out: #Rollout & {_X: x} @test(eq, at=out,{ - _Y: {spec: {command: ["a"]}, patch: {}} - command: ["a"] - }) + out: #Rollout & {_X: x} } letCycleSelf: { #X: X={ @@ -1376,8 +1057,6 @@ letCycleSelf: { x: [string]: #X x: a: {} - - @test(eq, {#X: {hosts: {}}, x: {a: {hosts: {}}}}) } -- rework2.cue -- @experiment(aliasv2) @@ -1390,12 +1069,6 @@ letCycleSelfKeyword: { } env: #E & {hosts: h1: x: "k"} - - @test(eq, { - #E: _|_ @test(err, code=incomplete, path=letCycleSelf2.#E, - contains="cannot range over s.hosts (incomplete type _)", pos=[7:13]) - env: {hosts: {h1: {x: "k"}}, out: {k: "a"}} - }) } letCycleSelfKeyword2: { #E: { @@ -1408,19 +1081,9 @@ letCycleSelfKeyword2: { } env: #E & { - hosts: h1: 1 + hosts: h1: 1 networks: n1: "x" } - - @test(eq, { - #E: _|_ @test(err, code=incomplete, path=regression_let3.#E, - contains="cannot range over s.hosts (incomplete)", pos=[22:13]) - env: { - hosts: {h1: 1} - networks: {n1: "x"} - a: {n1: "x"} - } - }) } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/comprehensions/try.txtar b/internal/core/compile/testdata/sync/comprehensions/try.txtar index 46ab04092..0fbfa4962 100644 --- a/internal/core/compile/testdata/sync/comprehensions/try.txtar +++ b/internal/core/compile/testdata/sync/comprehensions/try.txtar @@ -5,22 +5,20 @@ // Basic try with successful evaluation // ============================================================================= -a: 1 @test(eq, 1) -b: 2 @test(eq, 2) -c?: int // undefined optional field +a: 1 +b: 2 +c?: int // undefined optional field incomplete: int // Try with successful optional references (both defined) success: { - try { result: a? + b? } - @test(eq, {result: 3}) + try {result: a? + b?} } // Try with single optional reference single: { - x: 5 - try { y: x? * 2 } - @test(eq, {x: 5, y: 10}) + x: 5 + try {y: x? * 2} } // ============================================================================= @@ -30,21 +28,18 @@ single: { // Else NOT triggered when try succeeds (value is defined) fallbackDef: 42 elseNotTriggered: { - try { v: fallbackDef? } else { fallback: 0 } - @test(eq, {v: 42}) + try {v: fallbackDef?} else {fallback: 0} } // Else triggered when try fails (optional field undefined) // Note: else uses different field name to avoid merge conflicts with trial evaluation elseTriggered: { - try { v: c? } else { fallback: -1 } - @test(eq, {fallback: -1}) + try {v: c?} else {fallback: -1} } // Else with different field names (avoids conflict with trial evaluation) elseMultiField: { - try { x: c?, y: c? } else { fallback: true } - @test(eq, {fallback: true}) + try {x: c?, y: c?} else {fallback: true} } // ============================================================================= @@ -53,25 +48,21 @@ elseMultiField: { // Try produces empty struct when optional fails (no else) emptyOnFail: { - try { z: c? + 1 } - @test(eq, {}) + try {z: c? + 1} } // Try with mix of defined and undefined - all must succeed mixedRefs: { - try { x: a?, y: c? } else { fallback: true } - @test(eq, {fallback: true}) + try {x: a?, y: c?} else {fallback: true} } incompleteOK: { - try { x: incomplete? } else { fallback: 23 } - @test(eq, {x: int}) + try {x: incomplete?} else {fallback: 23} } // Nested struct in try body with incomplete value incompleteNestedBody: { - try { x: y: incomplete? } else { fallback: 23 } - @test(eq, {x: {y: int}}) + try {x: y: incomplete?} else {fallback: 23} } // ============================================================================= @@ -81,29 +72,20 @@ incompleteNestedBody: { // Unfilled required field triggers else requiredUnfilled: { a!: _ - try { x: a? } else { fallback: 23 } - @test(eq, { - a!: _ - x: _|_ @test(err, code=incomplete, contains="requiredUnfilled.x: required field missing: a", pos=[83:11]) - }) + try {x: a?} else {fallback: 23} } // Filled required field succeeds requiredFilled: { a!: _ - a: 5 - try { x: a? } else { fallback: 23 } - @test(eq, {a: 5, x: 5}) + a: 5 + try {x: a?} else {fallback: 23} } // Required field with type constraint triggers else requiredWithType: { a!: int - try { x: a? } else { fallback: 23 } - @test(eq, { - a!: int - x: _|_ @test(err, code=incomplete, contains="requiredWithType.x: required field missing: a", pos=[101:11]) - }) + try {x: a?} else {fallback: 23} } // ============================================================================= @@ -112,14 +94,12 @@ requiredWithType: { // For with optional source that exists forWithDefinedSource: { - try { for x in [b?] { val: x } } - @test(eq, {val: 2}) + try {for x in [b?] {val: x}} } // For with optional source that's undefined forWithUndefinedSource: { - try { for x in [c?] { val: x } } else { empty: true } - @test(eq, {empty: true}) + try {for x in [c?] {val: x}} else {empty: true} } // ============================================================================= @@ -129,15 +109,13 @@ forWithUndefinedSource: { nested: { // Try inside struct outer: { - try { inner: a? } - @test(eq, {inner: 1}) + try {inner: a?} } // Multiple try clauses in same struct multi: { - try { first: a? } - try { second: b? } - @test(eq, {first: 1, second: 2}) + try {first: a?} + try {second: b?} } // Try with nested struct in body @@ -147,7 +125,6 @@ nested: { level2: a? } } - @test(eq, {level1: {level2: 1}}) } } @@ -158,14 +135,12 @@ nested: { complexExpr: { // Binary operations binOp: { - try { sum: a? + b?, prod: a? * b? } - @test(eq, {sum: 3, prod: 2}) + try {sum: a? + b?, prod: a? * b?} } // Conditional with optional list: { - try { items: [a?, b?, a? + b?] } - @test(eq, {items: [1, 2, 3]}) + try {items: [a?, b?, a? + b?]} } } @@ -173,7 +148,7 @@ complexExpr: { // Selector expressions with optional // ============================================================================= - selectorTests: { +selectorTests: { data: { nested: { value: 100 @@ -182,15 +157,8 @@ complexExpr: { // Selector on defined path definedSelector: { - try { v: data.nested.value? } + try {v: data.nested.value?} } - - @test(eq, { - data: {nested: {value: 100}} - definedSelector: {v: 100} - }) - - // Note: selector on undefined path would be compile error } // ============================================================================= @@ -202,20 +170,16 @@ closedness: { d: #Def exists: { - try { v: #Def.f? } - @test(eq, {v: int}) + try {v: #Def.f?} } notExistsDef: { - try { v: #Def.g? } - @test(err, code=eval, path=v, contains="undefined field: %s", args=[g], pos=[1:17]) + try {v: #Def.g?} } notExistsValue: { - try { v: d.g? } - @test(err, code=eval, path=v, contains="undefined field: %s", args=[g], pos=[1:14]) + try {v: d.g?} } } - // ============================================================================= // Index expressions with optional // ============================================================================= @@ -226,44 +190,37 @@ indexTests: { // Index on defined position (closed list) definedIndex: { - try { v: closedList[0]? } - @test(eq, {v: 10}) + try {v: closedList[0]?} } // Index on defined position (middle) middleIndex: { - try { v: closedList[1]? } - @test(eq, {v: 20}) + try {v: closedList[1]?} } // Index out of range on CLOSED list - should ERROR (can never be satisfied) outOfRangeClosed: { - try { v: closedList[10]? } else { fallback: -1 } - @test(err, code=eval, path=v, contains="index out of range [%d] with length %d", args=[10, 3], pos=[1:23]) + try {v: closedList[10]?} else {fallback: -1} } // Index out of range on CLOSED list without else - should ERROR outOfRangeClosedNoElse: { - try { v: closedList[100]? } - @test(err, code=eval, path=v, contains="index out of range [%d] with length %d", args=[100, 3], pos=[1:23]) + try {v: closedList[100]?} } // Index out of range on OPEN list - should trigger else (list might grow) outOfRangeOpen: { - try { v: openList[10]? } else { fallback: -1 } - @test(eq, {fallback: -1}) + try {v: openList[10]?} else {fallback: -1} } // Index out of range on OPEN list without else - empty struct outOfRangeOpenNoElse: { - try { v: openList[100]? } - @test(eq, {}) + try {v: openList[100]?} } // Multiple index accesses on closed list multipleIndex: { - try { x: closedList[0]?, y: closedList[1]?, z: closedList[2]? } - @test(eq, {x: 10, y: 20, z: 30}) + try {x: closedList[0]?, y: closedList[1]?, z: closedList[2]?} } } @@ -274,26 +231,22 @@ indexTests: { edgeCases: { // Empty try body (should produce empty struct) emptyBody: { - try { } - @test(eq, {}) + try {} } // Try with only literal (no optional refs) - should always succeed literalOnly: { - try { x: 42 } - @test(eq, {x: 42}) + try {x: 42} } // Multiple optional refs, first fails firstFails: { - try { x: c?, y: a? } else { skipped: true } - @test(eq, {skipped: true}) + try {x: c?, y: a?} else {skipped: true} } // Multiple optional refs, second fails secondFails: { - try { x: a?, y: c? } else { skipped: true } - @test(eq, {skipped: true}) + try {x: a?, y: c?} else {skipped: true} } referenceError: { @@ -301,17 +254,13 @@ edgeCases: { a: _b: 2 direct: { - try { v: a? } else { skipped: true } - @test(err, code=eval, path=edgeCases.referenceError.a, contains="failed arithmetic: %v", args=[division by zero], pos=[-3:6]) - // v shares the error from a + try {v: a?} else {skipped: true} } dontSkipError1: { - try { a._b? } else { skipped: true } - @test(err, code=eval, path=edgeCases.referenceError.a, contains="failed arithmetic: %v", args=[division by zero], pos=[-8:6]) + try {a._b?} else {skipped: true} } dontSkipError2: { - try { a?._b? } else { skipped: true } - @test(err, code=eval, path=edgeCases.referenceError.a, contains="failed arithmetic: %v", args=[division by zero], pos=[-12:6]) + try {a?._b?} else {skipped: true} } } } @@ -326,52 +275,41 @@ edgeCases: { refIntoTry: { // Try that succeeds - inner fields are accessible source: { - try { val: a? } - @test(eq, {val: 1}) + try {val: a?} } // Reference into successful try result (no ? needed) - ref: source.val @test(eq, 1) // Should resolve to 1 + ref: source.val // Should resolve to 1 // Nested try - outer succeeds, inner may or may not nestedSource: { try { inner: { - try { deep: b? } + try {deep: b?} } } - @test(eq, {inner: {deep: 2}}) } // Reference into nested try result (no ? needed) - nestedRef: nestedSource.inner.deep @test(eq, 2) // Should resolve to 2 + nestedRef: nestedSource.inner.deep // Should resolve to 2 // Try that fails - struct is empty, reference fails - nestedSkipped?: { try { c? } } @test(err, code=incomplete, path=refIntoTry, contains="field not found: %v", args=[nestedSkipped], pos=[]) + nestedSkipped?: { try {c?}} mixedSource: { - try { foo: nestedSkipped? } + try {foo: nestedSkipped?} bar?: 1 - baz: 1 - @test(eq, {bar?: 1, baz: 1}) + baz: 1 } // Reference into failed try - use try to handle the missing field skippedRef: { - try { v: mixedSource.foo? } else { missing: true } - @test(eq, {missing: true}) + try {v: mixedSource.foo?} else {missing: true} } failedRef1: { - try { v: mixedSource.foo } else { missing: true } - @test(eq, { - v: _|_ @test(err, code=incomplete, contains="refIntoTry.failedRef1.v: undefined field: foo", pos=[360:24]) - }) + try {v: mixedSource.foo} else {missing: true} } failedRef2: { - try { v: mixedSource.foo } else { missing: true } - @test(eq, { - v: _|_ @test(err, code=incomplete, contains="refIntoTry.failedRef2.v: undefined field: foo", pos=[366:24]) - }) + try {v: mixedSource.foo} else {missing: true} } successRef: { - try { v: mixedSource.baz? } else { missing: true } - @test(eq, {v: 1}) + try {v: mixedSource.baz?} else {missing: true} } } @@ -382,53 +320,41 @@ refIntoTry: { errorPrecedence: { // Type error with optional that exists - should error typeErrorDefined: { - try { v: a? + "string" } else { fallback: "ok" } - @test(err, code=eval, path=v, - contains="invalid operands %s and %s to '%s' (type %s and %s)", - args=[1, "string", +, int, string], pos=[1:12, -376:4, 1:17]) + try {v: a? + "string"} else {fallback: "ok"} } // Type error AND undefined optional - depends on evaluation order // If c? is evaluated first and fails, the type error is never reached typeErrorUndefined: { - try { v: c? + "string" } else { fallback: "ok" } - @test(eq, {fallback: "ok"}) + try {v: c? + "string"} else {fallback: "ok"} } // Division by zero with optional divByZero: { - try { v: a? / 0 } else { fallback: "ok" } - @test(err, code=eval, path=v, contains="failed arithmetic: %v", - args=[division by zero], pos=[1:12]) + try {v: a? / 0} else {fallback: "ok"} } // Error from conflicting values conflictError: { - try { v: a? & "notanint" } else { fallback: "ok" } - @test(err, code=eval, path=v, - contains="conflicting values %s and %s (mismatched types %s and %s)", - args=["notanint", 1, string, int], - pos=[-398:4, 0:17, 1:3, 1:12, 1:17]) + try {v: a? & "notanint"} else {fallback: "ok"} } // Mixed case: OptionalUndefined in one field, real error in another // The real error should still propagate mixedError: { try { - x: c? // undefined - y: 1 / 0 // real error (independent) - } else { fallback: "ok" } - @test(eq, {fallback: "ok"}) + x: c? // undefined + y: 1 / 0 // real error (independent) + } else {fallback: "ok"} } // Mixed case 2: multiple optionals, one undefined, one with error mixedErrorMultiple: { try { - x: a? // defined (1) - y: c? // undefined - z: a? / 0 // real error - } else { fallback: "ok" } - @test(eq, {fallback: "ok"}) + x: a? // defined (1) + y: c? // undefined + z: a? / 0 // real error + } else {fallback: "ok"} } } @@ -439,104 +365,86 @@ errorPrecedence: { assignmentForm: { // Basic assignment with defined value basicDefined: { - try x = a? { result: x } - @test(eq, {result: 1}) + try x = a? {result: x} } // Assignment with undefined optional - should trigger else basicUndefined: { - try x = c? { result: x } else { fallback: 0 } - @test(eq, {fallback: 0}) + try x = c? {result: x} else {fallback: 0} } // Assignment without else - should produce empty struct noElseUndefined: { - try x = c? { result: x } - @test(eq, {}) + try x = c? {result: x} } // Assignment with expression withExpression: { - try sum = a? + b? { result: sum } - @test(eq, {result: 3}) + try sum = a? + b? {result: sum} } // Assignment with failing expression - triggers else withFailingExpr: { - try sum = a? + c? { result: sum } else { fallback: -1 } - @test(eq, {fallback: -1}) + try sum = a? + c? {result: sum} else {fallback: -1} } // Chained assignments chained: { - try x = a? try y = b? { result: x + y } - @test(eq, {result: 3}) + try x = a? try y = b? {result: x + y} } // Assignment with selector withSelector: { - data: { inner: 42 } - try v = data.inner? { result: v } - @test(eq, {data: {inner: 42}, result: 42}) + data: {inner: 42} + try v = data.inner? {result: v} } // Assignment with index withIndex: { list: [10, 20, 30] - try v = list[1]? { result: v } - @test(eq, {list: [10, 20, 30], result: 20}) + try v = list[1]? {result: v} } // Assignment with out-of-range index on closed list - should ERROR withOutOfRangeIndex: { list: [10, 20, 30] - try v = list[10]? { result: v } else { fallback: -1 } - @test(err, code=eval, path=result, - contains="index out of range [%d] with length %d", args=[10, 3], pos=[2:16]) + try v = list[10]? {result: v} else {fallback: -1} } // Assignment with out-of-range index on open list - should trigger else withOutOfRangeIndexOpen: { list: [10, 20, 30, ...] - try v = list[10]? { result: v } else { fallback: -1 } - @test(eq, {list: [10, 20, 30], fallback: -1}) + try v = list[10]? {result: v} else {fallback: -1} } // Assignment used in nested expression nestedUse: { - try x = a? { inner: { value: x * 2 } } - @test(eq, {inner: {value: 2}}) + try x = a? {inner: {value: x * 2}} } // Multiple chained try assignments with one failing chainedOneFails: { - try x = a? try y = c? { result: x + y } - @test(eq, {}) + try x = a? try y = c? {result: x + y} } // Assignment with real error - should propagate withRealError: { - try x = a? / 0 { result: x } else { fallback: "ok" } - @test(err, code=eval, path=result, - contains="failed arithmetic: %v", args=[division by zero], pos=[1:11]) + try x = a? / 0 {result: x} else {fallback: "ok"} } // Assignment combined with for withFor: { - try x = b? for i, v in [1, 2] { "\(i)": x + v } - @test(eq, {"0": 3, "1": 4}) + try x = b? for i, v in [1, 2] {"\(i)": x + v} } // Assignment combined with if withIf: { - try x = a? if x > 0 { positive: x } - @test(eq, {positive: 1}) + try x = a? if x > 0 {positive: x} } // Assignment combined with let withLet: { - try x = a? let y = x * 2 { doubled: y } - @test(eq, {doubled: 2}) + try x = a? let y = x * 2 {doubled: y} } } @@ -544,10 +452,9 @@ assignmentForm: { // Original recursive tests // ============================================================================= -recursive: t1: { try { for x in [b?] { x } } } @test(eq, 2) -recursive: t2: { try { {x: b?, y: c?} } } @test(eq, {}) -recursive: t3: { try { {x: b?, y: c?} } else { z: 23 }} @test(eq, {z: 23}) - +recursive: t1: { try {for x in [b?] {x}}} +recursive: t2: { try {{x: b?, y: c?}}} +recursive: t3: { try {{x: b?, y: c?}} else {z: 23}} -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/cycle/015_reference_across_tuples_and_back.txtar b/internal/core/compile/testdata/sync/cycle/015_reference_across_tuples_and_back.txtar index f73a200e2..1fc23ee06 100644 --- a/internal/core/compile/testdata/sync/cycle/015_reference_across_tuples_and_back.txtar +++ b/internal/core/compile/testdata/sync/cycle/015_reference_across_tuples_and_back.txtar @@ -1,11 +1,7 @@ -- in.cue -- t1: { - a: {c: b.e, d: b.f} - b: {e: 3, f: a.c} - @test(eq, { - a: {c: 3, d: 3} - b: {e: 3, f: 3} - }) + a: {c: b.e, d: b.f} + b: {e: 3, f: a.c} } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/cycle/021_delayed_constraint_failure.txtar b/internal/core/compile/testdata/sync/cycle/021_delayed_constraint_failure.txtar index 50cb46c19..eeb32d416 100644 --- a/internal/core/compile/testdata/sync/cycle/021_delayed_constraint_failure.txtar +++ b/internal/core/compile/testdata/sync/cycle/021_delayed_constraint_failure.txtar @@ -3,12 +3,12 @@ # Tests that cycles resolved by defaults produce correct values, while # conflicting constraints on the same field produce errors. -- in.cue -- -a: b - 100 @test(eq, 100) // Okay to have no error here, as long as there is an error with b. +a: b - 100 // Okay to have no error here, as long as there is an error with b. b: a + 110 -b: 200 @test(err, code=eval, pos=[-1:4, 0:4]) +b: 200 x: 100 -x: x + 1 @test(err, code=eval, pos=[-1:4, 0:4]) +x: x + 1 -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/cycle/023_reentrance.txtar b/internal/core/compile/testdata/sync/cycle/023_reentrance.txtar index ca898f25d..2ca0b5b21 100644 --- a/internal/core/compile/testdata/sync/cycle/023_reentrance.txtar +++ b/internal/core/compile/testdata/sync/cycle/023_reentrance.txtar @@ -4,9 +4,8 @@ // This indirection is needed to avoid binding references to fib // within fib to the instantiated version. fibRec: { - nn: int + nn: int out: (fib & {n: nn}).out - @test(err, code=incomplete, at=out) } fib: { n: int @@ -17,14 +16,12 @@ fib: { if n < 2 { out: n } - @test(err, code=incomplete) } -fib1: (fib & {n: 1}).out @test(eq, 1) // MAY NOT be an error -fib2: (fib & {n: 2}).out @test(eq, 1) // MAY be an error -fib3: (fib & {n: 3}).out @test(err, code=structural_cycle) // SHOULD be an error -fib7: (fib & {n: 7}).out @test(err, code=structural_cycle) // Error -fib12: (fib & {n: 12}).out @test(err, code=structural_cycle) // Error - +fib1: (fib & {n: 1}).out // MAY NOT be an error +fib2: (fib & {n: 2}).out // MAY be an error +fib3: (fib & {n: 3}).out // SHOULD be an error +fib7: (fib & {n: 7}).out // Error +fib12: (fib & {n: 12}).out // Error -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/cycle/025_cannot_resolve_references_that_would_be_ambiguous.txtar b/internal/core/compile/testdata/sync/cycle/025_cannot_resolve_references_that_would_be_ambiguous.txtar index 2e08b475e..ea826ff6f 100644 --- a/internal/core/compile/testdata/sync/cycle/025_cannot_resolve_references_that_would_be_ambiguous.txtar +++ b/internal/core/compile/testdata/sync/cycle/025_cannot_resolve_references_that_would_be_ambiguous.txtar @@ -2,16 +2,16 @@ #evalFull -- in.cue -- a1: *0 | 1 -a1: a3 - a2 @test(err, code=cycle, pos=[2:10]) +a1: a3 - a2 a2: *0 | 1 -a2: a3 - a1 @test(err, code=cycle, pos=[0:10]) -a3: 1 @test(eq, 1) +a2: a3 - a1 +a3: 1 -b1: (*0 | 1) & b2 @test(eq, 0|1) -b2: (0 | *1) & b1 @test(eq, 0|1) +b1: (*0 | 1) & b2 +b2: (0 | *1) & b1 -c1: (*{a: 1} | {b: 1}) & c2 @test(eq, {a: 1, b: 2} | {b: 1, a: 2}) -c2: (*{a: 2} | {b: 2}) & c1 @test(eq, {a: 2, b: 1} | {b: 2, a: 1}) +c1: (*{a: 1} | {b: 1}) & c2 +c2: (*{a: 2} | {b: 2}) & c1 -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/cycle/049_self-reference_cycles_conflicts_with_strings.txtar b/internal/core/compile/testdata/sync/cycle/049_self-reference_cycles_conflicts_with_strings.txtar index 8fb86a6aa..7fed50893 100644 --- a/internal/core/compile/testdata/sync/cycle/049_self-reference_cycles_conflicts_with_strings.txtar +++ b/internal/core/compile/testdata/sync/cycle/049_self-reference_cycles_conflicts_with_strings.txtar @@ -3,9 +3,9 @@ -- in.cue -- a: { x: y + "?" - y: x + "!" @test(eq, "hey!") + y: x + "!" } -a: x: "hey" @test(err, code=eval, contains="conflicting values", pos=[-3:5, 0:7]) +a: x: "hey" -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/cycle/050_resolved_self-reference_cycles_with_disjunctions.txtar b/internal/core/compile/testdata/sync/cycle/050_resolved_self-reference_cycles_with_disjunctions.txtar index aeee608b7..a21d7d880 100644 --- a/internal/core/compile/testdata/sync/cycle/050_resolved_self-reference_cycles_with_disjunctions.txtar +++ b/internal/core/compile/testdata/sync/cycle/050_resolved_self-reference_cycles_with_disjunctions.txtar @@ -1,15 +1,9 @@ #name: resolved self-reference cycles with disjunctions #evalPartial -- in.cue -- -a: b & {x: 1} | {y: 1} // {x:1,y:3,z:2} | {y:1} -b: {x: 2} | c & {z: 2} // {x:2} | {x:1,y:3,z:2} -c: a & {y: 3} | {z: 3} // {x:1,y:3,z:2} | {z:3} - -@test(eq, { - a: {x: 1, z: 2, y: 3} | {y: 1} - b: {x: 2} | {z: 2, y: 3, x: 1} - c: {y: 3, x: 1, z: 2} | {z: 3} -}) +a: b & {x: 1} | {y: 1} // {x:1,y:3,z:2} | {y:1} +b: {x: 2} | c & {z: 2} // {x:2} | {x:1,y:3,z:2} +c: a & {y: 3} | {z: 3} // {x:1,y:3,z:2} | {z:3} -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/cycle/051_resolved_self-reference_cycles_with_disjunction.txtar b/internal/core/compile/testdata/sync/cycle/051_resolved_self-reference_cycles_with_disjunction.txtar index c6dc31469..198157e2c 100644 --- a/internal/core/compile/testdata/sync/cycle/051_resolved_self-reference_cycles_with_disjunction.txtar +++ b/internal/core/compile/testdata/sync/cycle/051_resolved_self-reference_cycles_with_disjunction.txtar @@ -24,67 +24,54 @@ // ((6 + 2) + 2) & 9 // 6 == xa1-2 // 10 & 9 => _|_ // The remaining values resolve. -xa1: (xa2 & 8) | (xa4 & 9) @test(eq, 8) -xa2: xa3 + 2 @test(eq, 8) -xa3: 6 & xa1-2 @test(eq, 6) -xa4: xa2 + 2 @test(eq, 10) +xa1: (xa2 & 8) | (xa4 & 9) +xa2: xa3 + 2 +xa3: 6 & xa1-2 +xa4: xa2 + 2 // TODO(inline): make positions work here. -xb1: (xb2 & 8) | (xb4 & 9) @test(err, code=cycle, - suberr=(code=cycle, path=xb2, contains="unresolved disjunction: %v", args=[xb3]), - suberr=(code=cycle, path=xb3, contains="%d errors in empty disjunction:", args=[3]), - suberr=(code=cycle, path=xb3, contains="unresolved disjunction: %v", args=[xb1]), - suberr=(code=cycle, path=xb3, contains="cycle with field: %v", args=[xb2])) -xb2: xb3 + 2 @test(err, code=cycle, - suberr=(code=cycle, contains="unresolved disjunction: %v", args=[xb3]), - suberr=(code=cycle, path=xb3, contains="cycle with field: %v", args=[xb2])) -xb3: (6 & (xb1 - 2)) | (xb4 & 9) @test(err, code=cycle, - suberr=(code=cycle, path=xb2, contains="unresolved disjunction: %v", args=[xb3]), - suberr=(code=cycle, contains="unresolved disjunction: %v", args=[xb1]), - suberr=(code=cycle, contains="cycle with field: %v", args=[xb2])) -xb4: xb2 + 2 @test(err, code=cycle, - suberr=(code=cycle, path=xb2, contains="unresolved disjunction: %v", args=[xb3]), - suberr=(code=cycle, path=xb3, contains="cycle with field: %v", args=[xb2])) +xb1: (xb2 & 8) | (xb4 & 9) +xb2: xb3 + 2 +xb3: (6 & (xb1 - 2)) | (xb4 & 9) +xb4: xb2 + 2 // Another variant with more disjunctions. xc1 remains with two // possibilities. Technically, only the first value is valid. // However, to fully determine that, all options of the remaining // disjunction will have to be evaluated algebraically, which is // not done. -xc1: xc2 & 8 | xc4 & 9 | xc5 & 9 @test(eq, 8|9) -xc2: xc3 + 2 @test(eq, 8) -xc3: 6 & xc1-2 @test(err, code=incomplete, - contains="unresolved disjunction %v (type %s)", args=[8 | 9, int], pos=[0:10]) -xc4: xc2 + 1 @test(eq, 9) -xc5: xc2 + 2 @test(eq, 10) +xc1: xc2 & 8 | xc4 & 9 | xc5 & 9 +xc2: xc3 + 2 +xc3: 6 & xc1-2 +xc4: xc2 + 1 +xc5: xc2 + 2 // The below is resolved by setting xd1 explicitly. -xd1: xd2 & 8 | xd4 & 9 | xd5 & 9 // 8 see below -xd2: xd3 + 2 @test(eq, 8) -xd3: 6 & xd1-2 @test(eq, 6) -xd4: xd2 + 1 @test(eq, 9) -xd5: xd2 + 2 @test(eq, 10) -xd1: 8 @test(eq, 8) +xd1: xd2 & 8 | xd4 & 9 | xd5 & 9 // 8 see below +xd2: xd3 + 2 +xd3: 6 & xd1-2 +xd4: xd2 + 1 +xd5: xd2 + 2 +xd1: 8 // The below is resolved by setting xd1 explicitly to the wrong // value, resulting in an error. xe1: xe2 & 8 | xe4 & 9 | xe5 & 9 -xe2: xe3 + 2 @test(eq, 8) -xe3: 6 & xe1-2 @test(err, code=eval, pos=[0:6, 0:10]) -xe4: xe2 + 1 @test(eq, 9) -xe5: xe2 + 2 @test(eq, 10) -xe1: 9 @test(eq, 9) +xe2: xe3 + 2 +xe3: 6 & xe1-2 +xe4: xe2 + 1 +xe5: xe2 + 2 +xe1: 9 -xf1: xf2 & 8 | xf4 & 9 @test(err, code=cycle, pos=[]) -xf2: xf3 + 2 @test(err, code=cycle, pos=[0:6]) -xf3: 6 & xf1-2 | xf4 & 9 @test(err, code=cycle, pos=[-1:6]) -xf4: xf2 + 2 @test(err, code=cycle, pos=[-2:6]) +xf1: xf2 & 8 | xf4 & 9 +xf2: xf3 + 2 +xf3: 6 & xf1-2 | xf4 & 9 +xf4: xf2 + 2 -z1: z2+1 | z3+5 @test(eq, 11|13) // +3 for fun -z2: z3 + 2 @test(eq, 10) +z1: z2+1 | z3+5 // +3 for fun +z2: z3 + 2 z3: z1 - 3 -z3: 8 @test(err, code=incomplete, - contains="unresolved disjunction %v (type %s)", args=[11 | 13, int], pos=[-1:5]) +z3: 8 -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/cycle/052_resolved_self-reference_cycles_with_disjunction_with_defaults.txtar b/internal/core/compile/testdata/sync/cycle/052_resolved_self-reference_cycles_with_disjunction_with_defaults.txtar index f9a636594..be55a9b9c 100644 --- a/internal/core/compile/testdata/sync/cycle/052_resolved_self-reference_cycles_with_disjunction_with_defaults.txtar +++ b/internal/core/compile/testdata/sync/cycle/052_resolved_self-reference_cycles_with_disjunction_with_defaults.txtar @@ -3,59 +3,48 @@ -- in.cue -- // The disjunction in xa could be resolved, but as disjunctions // are not resolved for expression, it remains unresolved. -xa1: (xa2 & 8) | *(xa4 & 9) @test(eq, 8) -xa2: xa3 + 2 @test(eq, 8) -xa3: 6 & xa1-2 @test(eq, 6) -xa4: xa2 + 2 @test(eq, 10) +xa1: (xa2 & 8) | *(xa4 & 9) +xa2: xa3 + 2 +xa3: 6 & xa1-2 +xa4: xa2 + 2 // TODO(inline): make positions work here. -xb1: *(xb2 & 8) | (xb4 & 9) @test(err, code=cycle, pos=[], - suberr=(code=cycle, path=xb2, contains="unresolved disjunction: %v", args=[xb3]), - suberr=(code=cycle, path=xb3, contains="%d errors in empty disjunction:", args=[3]), - suberr=(code=cycle, path=xb3, contains="unresolved disjunction: %v", args=[xb1],), - suberr=(code=cycle, path=xb3, contains="cycle with field: %v", args=[xb2])) -xb2: xb3 + 2 @test(err, code=cycle, - suberr=(code=cycle, contains="unresolved disjunction: %v", args=[xb3]), - suberr=(code=cycle, path=xb3, contains="cycle with field: %v", args=[xb2])) -xb3: *(6 & (xb1 - 2)) | (xb4 & 9) @test(err, code=cycle, - suberr=(code=cycle, path=xb2, contains="unresolved disjunction: %v", args=[xb3]), - suberr=(code=cycle, contains="unresolved disjunction: %v", args=[xb1]), - suberr=(code=cycle, contains="cycle with field: %v", args=[xb2])) -xb4: xb2 + 2 @test(err, code=cycle, - suberr=(code=cycle, path=xb2, contains="unresolved disjunction: %v", args=[xb3]), - suberr=(code=cycle, path=xb3, contains="cycle with field: %v", args=[xb2])) +xb1: *(xb2 & 8) | (xb4 & 9) +xb2: xb3 + 2 +xb3: *(6 & (xb1 - 2)) | (xb4 & 9) +xb4: xb2 + 2 // Another variant with more disjunctions. xc1 remains with two // possibilities. Technically, only the first value is valid. // However, to fully determine that, all options of the remaining // disjunction will have to be evaluated algebraically, which is // not done. -xc1: *(xc2 & 8) | (xc4 & 9) | (xc5 & 9) @test(eq, *8|9) -xc2: xc3 + 2 @test(eq, 8) -xc3: 6 & xc1-2 @test(eq, 6) -xc4: xc2 + 1 @test(eq, 9) -xc5: xc2 + 2 @test(eq, 10) +xc1: *(xc2 & 8) | (xc4 & 9) | (xc5 & 9) +xc2: xc3 + 2 +xc3: 6 & xc1-2 +xc4: xc2 + 1 +xc5: xc2 + 2 // The above is resolved by setting xd1 explicitly. -xd1: *(xd2 & 8) | xd4 & 9 | xd5 & 9 @test(eq, *8|9) -xd2: xd3 + 2 @test(eq, 8) -xd3: 6 & xd1-2 @test(eq, 6) -xd4: xd2 + 1 @test(eq, 9) -xd5: xd2 + 2 @test(eq, 10) +xd1: *(xd2 & 8) | xd4 & 9 | xd5 & 9 +xd2: xd3 + 2 +xd3: 6 & xd1-2 +xd4: xd2 + 1 +xd5: xd2 + 2 // The above is resolved by setting xd1 explicitly to the wrong // value, resulting in an error. xe1: *(xe2 & 8) | xe4 & 9 | xe5 & 9 -xe2: xe3 + 2 @test(eq, 8) -xe3: 6 & xe1-2 @test(err, code=eval, pos=[0:6, 0:10]) -xe4: xe2 + 1 @test(eq, 9) -xe5: xe2 + 2 @test(eq, 10) -xe1: 9 @test(eq, 9) +xe2: xe3 + 2 +xe3: 6 & xe1-2 +xe4: xe2 + 1 +xe5: xe2 + 2 +xe1: 9 -z1: *(z2 + 1) | z3+5 @test(eq, *11|13) -z2: z3 + 2 @test(eq, 10) +z1: *(z2 + 1) | z3+5 +z2: z3 + 2 z3: z1 - 3 -z3: 8 @test(eq, 8) +z3: 8 -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/cycle/builtins.txtar b/internal/core/compile/testdata/sync/cycle/builtins.txtar index c8d945c21..dd26f4185 100644 --- a/internal/core/compile/testdata/sync/cycle/builtins.txtar +++ b/internal/core/compile/testdata/sync/cycle/builtins.txtar @@ -10,7 +10,6 @@ import "regexp" // by a builtin, effectively the entire struct needs to be evaluated and special // care should be taking to not evaluate too early. builtinCyclePerm: { - @test(permute, count=6) X: "mod.test" Y: { @@ -19,14 +18,6 @@ builtinCyclePerm: { } X: Y.host - - @test(eq, { - X: "mod.test" - Y: { - #components: {host: "mod.test"} - host: "mod.test" - } - }) } -- matchn.cue -- // This should not be a structural cycle, as the list type is "optional". @@ -35,21 +26,12 @@ issue3410: { _s: { #x: matchN(1, [_s, [..._s]]) } - // TODO(inline): inline test outputs references in calls. This was crafted - // by hand. - @test(eq, { - _s: {#x: matchN(1, [_|_, []])} - #x: matchN(1, [_|_, []]) - }) } issue3420: { matches1: { #S: matchN(1, [_, _|_]) s: 2 } - @test(eq, { - matches1: {#S: matchN(1, [_, _|_]), s: 2} - }) } issue3443: { matchIf: { @@ -94,13 +76,12 @@ issue3443: { // cycle1.cycle. fail: #S: matchN(1, [{n: #S}]) & {n: n: n: _} } - @test(err, pos=[2:7]) } issue3633: final: { // With nested matchNs as below, the schema will become an incomplete error // as a value of the root vertex. Make sure this edge case is properly // handled. - data: {} & #s @test(err, code=incomplete, pos=[1:6, 0:8, 1:13]) + data: {} & #s #s: matchN(1, [matchN(1, [{a!: _}])]) } issue3842: reduced: { @@ -109,7 +90,6 @@ issue3842: reduced: { }, #recursive, _) & { source?: string }] - @test(eq, {#recursive: []}) } -- cycle.cue -- import "strconv" @@ -118,9 +98,8 @@ noCycle: t1: { _s _s: { #x: matchN(1, [_s]) - #x: {} // insert concrete value to trigger application of validator. + #x: {} // insert concrete value to trigger application of validator. } - @test(err, pos=[3:7, 3:14, 4:13]) } issue3649: noCycle: t1: { data: #c @@ -130,25 +109,6 @@ issue3649: noCycle: t1: { b?: string a?: matchN(1, [#c]) } - // Cannot use @test(eq) with self-referential #c in expected value. - @test(eq, "foo", at=data.a.b) - @test(debug, """ - (struct){ - data: (#struct){ - a: (#struct){ - b: (string){ "foo" } - } - b?: (string){ string } - } - #c: (#struct){ - b?: (string){ string } - a?: (_){ matchN(1, (#list){ - 0: (_|_){// 〈2;#c〉 - } - }) } - } - } - """) } // Same as above, but with longer paths. issue3649: noCycle: t2: { @@ -158,33 +118,6 @@ issue3649: noCycle: t2: { b?: string y: a?: matchN(1, [{d: c}]) } - // Cannot use @test(eq) with self-referential c in expected value. - @test(eq, {a: {d: {b: "foo"}}}, at=x.y) - @test(debug, """ - (struct){ - x: (struct){ - y: (struct){ - a: (struct){ - d: (struct){ - b: (string){ "foo" } - } - } - } - b?: (string){ string } - } - c: (struct){ - b?: (string){ string } - y: (struct){ - a?: (_){ matchN(1, (#list){ - 0: (_|_){// { - // d: 〈4;c〉 - // } - } - }) } - } - } - } - """) } issue3649: cycle: t1: { data: #c @@ -193,14 +126,12 @@ issue3649: cycle: t1: { b: string a: matchN(1, [#c]) } - @test(err, pos=[5:6, 2:11, 5:13]) } // This used to cause a stack overflow. issue4037: cycle: { _intlike: x=matchN(1, [strconv.Atoi(x)]) - f: "1233" & _intlike - @test(err, pos=[1:14, 1:21, 2:5]) + f: "1233" & _intlike } -- yamlcycle.cue -- import "encoding/yaml" @@ -208,39 +139,26 @@ import "encoding/yaml" yamlNoCycle: { // the validator is invoked recursively and also unifies with a concrete // value. This should nonetheless not result in a cycle error. - #c: { - b?: string - a?: yaml.Validate(#c) - } - data: #c - data: a: #"{a: "b: foo"}"# - @test(eq, { - #c: { - b?: string - a?: yaml.Validate({ + #c: { b?: string - a?: _ - }) - } - data: {a: "{a: \"b: foo\"}", b?: string} - }) + a?: yaml.Validate(#c) + } + data: #c + data: a: #"{a: "b: foo"}"# } selfCycle: t1: { c: matchN(1, [{d: c}]) c: d: {} - @test(err, pos=[1:5, 1:12, 2:5]) } selfCycle: t2: { // Even though only part of the path is unified with concrete data, this // should still result in a cycle error. c: matchN(1, [{d: c}]) c: {} - @test(eq, {c: {}}) } selfCycle: yamlVal: t1: { x: y: yaml.Validate(x) x: y: "{}" - @test(err, pos=[1:8, 2:8]) } selfCycle: yamlVal: t2: { // Duplicating validators can cause some tricky code paths, like finalizing @@ -249,22 +167,18 @@ selfCycle: yamlVal: t2: { x: y: "{}" x: y: yaml.Validate(x) x: y: "{}" - @test(err, pos=[3:8, 4:8, 5:8, 6:8]) } -selfCycle: yamlFun: t1:{ +selfCycle: yamlFun: t1: { x: y?: yaml.Validate("{}", x) - @test(eq, {x: {y?: true}}) } selfCycle: yamlFun: t2: { z: x & __no_sharing z: y: "{}" x: y: yaml.Validate("{}", x) - @test(err, pos=[3:8]) } selfCycle: yamlValidatePartial: { x: y: yaml.ValidatePartial(x) x: y: "{}" - @test(err, pos=[1:8, 2:8]) } -- jsoncycle.cue -- import "encoding/json" @@ -272,7 +186,6 @@ import "encoding/json" jsonCycle: t1: { x: y: json.Validate(x) x: y: "{}" - @test(err, pos=[1:8, 2:8]) } -- listmatchncycle.cue -- import "list" @@ -280,27 +193,11 @@ import "list" listMatchN: structCycle: { x: y: list.MatchN(1, x) x: y: [{}] - @test(err, pos=[1:8, 1:5, 1:20, 2:5, 2:8]) } listMatchN: ok: { x: y?: list.MatchN(1, x) - z: x + z: x z: y: [{}] - // x.y? is non-concrete (list.MatchN validator); only check z.y which is concrete. - @test(eq, [{}], at=z.y) - @test(debug, """ - (struct){ - x: (struct){ - y?: (list){ list.MatchN(1, listMatchN.ok.x) } - } - z: (struct){ - y: (#list){ - 0: (struct){ - } - } - } - } - """) } -- issue3634.cue -- // evalv3 structural cycle regression: using `len(...)` with a `#Schema` @@ -319,26 +216,13 @@ issue3634: full: { #Schema // removing this fixes the bug! properties: foo: required: ["bar", "baz"] }], 3)) - - @test(eq, { - #Schema: {required?: [], properties?: {}} - out: 3 - }) } issue3634: reduced: { #D: { b?: int a?: #D } - out: len(#D & list.Repeat([#D & { a: b: 1 }], 1)[0]) - - @test(eq, { - #D: { - b?: int - a?: _|_ @test(err, code=structural_cycle, contains="issue3634.reduced.#D.a: structural cycle", pos=[]) - } - out: 1 - }) + out: len(#D & list.Repeat([#D & {a: b: 1}], 1)[0]) } -- issue3743.cue -- // Passing a cyclic value to `yaml.MarshalStream` caused a stack overflow @@ -348,21 +232,15 @@ import "encoding/yaml" issue3743: { #transform: { - in: _ - out: [ - if false {out}, // note that this is a cycle - in, - ] + in: _ + out: [ + if false {out}, // note that this is a cycle + in, + ] } - docs: [ (#transform & {in: "x"}).out ] + docs: [(#transform & {in: "x"}).out] out: yaml.MarshalStream(docs) - - @test(eq, { - #transform: {in: _, out: [_]} - docs: [["x"]] - out: "- x\n" - }) } -- out/compile -- --- cycle.cue diff --git a/internal/core/compile/testdata/sync/cycle/chain.txtar b/internal/core/compile/testdata/sync/cycle/chain.txtar index b88cb62e9..288614a73 100644 --- a/internal/core/compile/testdata/sync/cycle/chain.txtar +++ b/internal/core/compile/testdata/sync/cycle/chain.txtar @@ -6,7 +6,6 @@ import "list" // The following just chains existing fields and should NOT trigger a cycle // detection error. - chain: t1: { #maxiter: 2 @@ -21,17 +20,10 @@ chain: t1: { a: x2: null - #DepthF: { #in: _ #out: {} } - @test(eq, { - #maxiter: 2 - x: {} - a: {x2: null, x0: {}, x1: {}} - #DepthF: {#in: _, #out: {}} - }) } chain: t2: p1: { @@ -45,7 +37,6 @@ chain: t2: p1: { x: _ x.x0 - @test(eq, {X: 1, x: {x0: {}, x1: {}}}) } chain: t2: p2: { @@ -59,7 +50,6 @@ chain: t2: p2: { x.x0 X: 1 - @test(eq, {x: {x0: {}, x1: {}}, X: 1}) } chain: t3: p1: { @@ -84,9 +74,7 @@ chain: t3: p1: { x.x0 X: 1 - @test(eq, {X: 1, x: {x0: {}}}) } - -- issue2052.cue -- // Bounded recursion regression: a pattern that evaluated correctly in v0.4.3 // began failing in v0.5.0-alpha.1 with spurious unbounded recursion errors. @@ -95,6 +83,7 @@ import ( "list" "math" ) + issue2052: reduced: t1: { A: a: _ Depth: { @@ -105,14 +94,6 @@ issue2052: reduced: t1: { funcs: {} funcs["0"] } - @test(eq, { - A: {a: _} - Depth: { - #maxiter: 1 - funcs: {"0": {a: _}} - a: _ - } - }) } issue2052: reduced: t2: { A: a: _ @@ -124,10 +105,6 @@ issue2052: reduced: t2: { funcs: {} funcs["0"] } - @test(eq, { - A: {a: _} - Depth: {maxiter: 1, funcs: {"0": {a: _}}, a: _} - }) } issue2052: medium: t1: { #Depth: { @@ -159,40 +136,6 @@ issue2052: medium: t1: { tree: "bar" d: #Depth & {#in: tree} - - @test(eq, { - #Depth: { - #maxiter: 4 - #funcs: { - "4": null - "0": {#in: _, #basic: string | null, out: 1} - "1": {#in: _, #basic: string | null, out: 1} - "2": {#in: _, #basic: string | null, out: 1} - "3": {#in: _, #basic: string | null, out: 1} - } - #in: _ - #basic: string | null - out: 1 - } - #DepthF: { - #next: _ - #func: {#in: _, #basic: string | null, out: 1} - } - tree: "bar" - d: { - #in: "bar" - #maxiter: 4 - #funcs: { - "4": null - "0": {#in: _, #basic: string | null, out: 1} - "1": {#in: _, #basic: string | null, out: 1} - "2": {#in: _, #basic: string | null, out: 1} - "3": {#in: _, #basic: string | null, out: 1} - } - #basic: string | null - out: 1 - } - }) } issue2052: medium: t2: { @@ -203,9 +146,9 @@ issue2052: medium: t2: { #funcs: "\(k)": (#DepthF & {#next: #funcs["\(k+1)"]}).#func } - #funcs:{ + #funcs: { for k, v in list.Range(0, #maxiter, 1) { - "\(k)": (#DepthF & {#next: #funcs["\(k+1)"]}).#func + "\(k)": (#DepthF & {#next: #funcs["\(k+1)"]}).#func } } @@ -231,39 +174,6 @@ issue2052: medium: t2: { tree: "bar" d: #Depth & {#in: tree} - @test(eq, { - #Depth: { - #maxiter: 4 - #funcs: { - "4": null - "0": {#in: _, #basic: string | null, out: 1} - "1": {#in: _, #basic: string | null, out: 1} - "2": {#in: _, #basic: string | null, out: 1} - "3": {#in: _, #basic: string | null, out: 1} - } - #in: _ - #basic: string | null - out: 1 - } - #DepthF: { - #next: _ - #func: {#in: _, #basic: string | null, out: 1} - } - tree: "bar" - d: { - #in: "bar" - #maxiter: 4 - #funcs: { - "4": null - "0": {#in: _, #basic: string | null, out: 1} - "1": {#in: _, #basic: string | null, out: 1} - "2": {#in: _, #basic: string | null, out: 1} - "3": {#in: _, #basic: string | null, out: 1} - } - #basic: string | null - out: 1 - } - }) } issue2052: full: { @@ -322,178 +232,6 @@ issue2052: full: { } d: #Depth & {#in: tree} - @test(eq, { - #RecurseN: { - #maxiter: *4 | >=0 & int - #funcFactory: {#next: _, #func: _} - #funcs: { - "4": null - "0": _ - "1": _ - "2": _ - "3": _ - } - } - #DepthF: { - #next: _ - #func: { - #in: _ - #basic: int | number | string | bytes | null - out: {1} - } - } - #Depth: { - #maxiter: 11 - #funcFactory: { - #next: _ - #func: { - #in: _ - #basic: int | number | string | bytes | null - out: {1} - } - } - #funcs: { - "11": null - "0": { - #in: _ - #basic: int | number | string | bytes | null - out: {1} - } - "1": { - #in: _ - #basic: int | number | string | bytes | null - out: {1} - } - "2": { - #in: _ - #basic: int | number | string | bytes | null - out: {1} - } - "3": { - #in: _ - #basic: int | number | string | bytes | null - out: {1} - } - "4": { - #in: _ - #basic: int | number | string | bytes | null - out: {1} - } - "5": { - #in: _ - #basic: int | number | string | bytes | null - out: {1} - } - "6": { - #in: _ - #basic: int | number | string | bytes | null - out: {1} - } - "7": { - #in: _ - #basic: int | number | string | bytes | null - out: {1} - } - "8": { - #in: _ - #basic: int | number | string | bytes | null - out: {1} - } - "9": { - #in: _ - #basic: int | number | string | bytes | null - out: {1} - } - "10": { - #in: _ - #basic: int | number | string | bytes | null - out: {1} - } - } - #in: _ - #basic: int | number | string | bytes | null - out: {1} - } - tree: { - a: {foo: "bar", a: {b: {c: "d"}}} - cow: "moo" - } - d: { - #in: { - a: {foo: "bar", a: {b: {c: "d"}}} - cow: "moo" - } - #maxiter: 11 - #funcFactory: { - #next: _ - #func: { - #in: _ - #basic: int | number | string | bytes | null - out: {1} - } - } - #funcs: { - "11": null - "0": { - #in: _ - #basic: int | number | string | bytes | null - out: {1} - } - "1": { - #in: _ - #basic: int | number | string | bytes | null - out: {1} - } - "2": { - #in: _ - #basic: int | number | string | bytes | null - out: {1} - } - "3": { - #in: _ - #basic: int | number | string | bytes | null - out: {1} - } - "4": { - #in: _ - #basic: int | number | string | bytes | null - out: {1} - } - "5": { - #in: _ - #basic: int | number | string | bytes | null - out: {1} - } - "6": { - #in: _ - #basic: int | number | string | bytes | null - out: {1} - } - "7": { - #in: _ - #basic: int | number | string | bytes | null - out: {1} - } - "8": { - #in: _ - #basic: int | number | string | bytes | null - out: {1} - } - "9": { - #in: _ - #basic: int | number | string | bytes | null - out: {1} - } - "10": { - #in: _ - #basic: int | number | string | bytes | null - out: {1} - } - } - #basic: int | number | string | bytes | null - out: {5} - } - }) } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/cycle/compbottom.txtar b/internal/core/compile/testdata/sync/cycle/compbottom.txtar index eddb316a6..521db27da 100644 --- a/internal/core/compile/testdata/sync/cycle/compbottom.txtar +++ b/internal/core/compile/testdata/sync/cycle/compbottom.txtar @@ -30,7 +30,6 @@ simple: { #message: #"^(message: (?P.*))?$"# p1: { - @test(permute, count=24) X: "message: hello" #aux: { @@ -44,11 +43,6 @@ simple: { Y: regexp.FindNamedSubmatch(#message, X) X: #aux.message - @test(eq, { - X: "message: hello" - #aux: {message: "message: hello"} - Y: {message: "hello"} - }) } } @@ -56,7 +50,6 @@ medium: { #userHostPort: #"^((?P[[:alnum:]]*)@)?(?P[[:alnum:].]+)$"# p1: { - @test(permute, count=120) Y: { userinfo: "user" @@ -92,12 +85,6 @@ medium: { } #Y: regexp.FindNamedSubmatch(#userHostPort, X) - @test(eq, { - Y: {userinfo: "user", host: "mod.test"} - X: "user@mod.test" - #X: {userinfo: "user@", host: "mod.test"} - #Y: {host: "mod.test", userinfo: "user"} - }) } } -- out/compile -- diff --git a/internal/core/compile/testdata/sync/cycle/compbottom2.txtar b/internal/core/compile/testdata/sync/cycle/compbottom2.txtar index 4c74c6ff1..28a603573 100644 --- a/internal/core/compile/testdata/sync/cycle/compbottom2.txtar +++ b/internal/core/compile/testdata/sync/cycle/compbottom2.txtar @@ -7,30 +7,26 @@ self: { if a.b == _|_ { b: 1 } - @test(err, code=incomplete|cycle) } } // This is an incomplete error, as it may succeed when the user // explicitly specifies a value for a.b. - isConcreteFail: t1:{ + isConcreteFail: t1: { a: { if a.b == _|_ { b: 1 } b: int - @test(eq, {b: 1}) } } - isConcreteFail: t2:{ + isConcreteFail: t2: { a: { if a.b == _|_ { b: 1 } b?: int - @test(err, code=cycle, - contains="circular dependency in evaluation of conditionals: %v changed after evaluation", args=[a.b], pos=[1:7]) } } @@ -46,7 +42,6 @@ self: { b: 1 } b: int - @test(eq, {b: int}) } } isNotConcrete: t2: { @@ -55,60 +50,49 @@ self: { b: 1 } b?: int - @test(eq, {b?: int}) } } } - -- mutual.cue -- mutual: { noConflicts: { a: {if b.foo == _|_ {new: ""}} b: {if a.bar == _|_ {new: ""}} - @test(eq, {a: {new: ""}, b: {new: ""}}) } mutualCycleFail: { b: { if a.bar == _|_ {foo: ""} - @test(err, code=incomplete|cycle) } a: { if b.foo == _|_ {bar: ""} - @test(err, code=incomplete|cycle) } } brokenCycleSuccess: { - a: { if b.foo == _|_ { foo: "" } } - b: { if a.bar == _|_ { bar: "" } } + a: {if b.foo == _|_ {foo: ""}} + b: {if a.bar == _|_ {bar: ""}} a: bar: "" - @test(eq, {a: {foo: "", bar: ""}, b: {}}) } allowOneDirectionalDependency: { p1: { - a: { if b.foo == _|_ { bar: "" } } // added - b: { if a.bar == _|_ { new: "" } } // not added - @test(eq, {a: {bar: ""}, b: {}}) + a: {if b.foo == _|_ {bar: ""}} // added + b: {if a.bar == _|_ {new: ""}} // not added } p2: { - a: { if b.foo == _|_ { new: "" } } - b: { if a.bar == _|_ { foo: "" } } - @test(eq, {a: {}, b: {foo: ""}}) + a: {if b.foo == _|_ {new: ""}} + b: {if a.bar == _|_ {foo: ""}} } } oneDirectionalBrokenConflictSuccess: { - @test(permute, count=6) b: foo: "" - a: { if b.foo == _|_ { bar: "" } } - b: { if a.bar == _|_ { new: "" } } - @test(eq, {b: {foo: "", new: ""}, a: {}}) + a: {if b.foo == _|_ {bar: ""}} + b: {if a.bar == _|_ {new: ""}} } } - -- mutualsamestruct.cue -- sameStruct: { chainSuccess: a: { @@ -120,7 +104,6 @@ sameStruct: { if ret != _|_ { foo: a: 1 } - @test(eq, {raises?: {}, ret: {a: 1}, foo: {a: 1}}) } chainSuccess: b: { @@ -132,7 +115,6 @@ sameStruct: { ret: a: 1 } ret?: {} - @test(eq, {foo: {a: 1}, raises?: {}, ret: {a: 1}}) } cycleFail: t1: p1: { @@ -144,7 +126,6 @@ sameStruct: { if ret != _|_ { raises: a: 1 } - @test(err, code=cycle|incomplete, any, contains="circular dependency in evaluation of conditionals: %v changed after evaluation", args=[raises]) } cycleFail: t1: p2: { @@ -156,7 +137,6 @@ sameStruct: { if raises == _|_ { ret: a: 1 } - @test(err, code=cycle, contains="circular dependency in evaluation of conditionals: %v changed after evaluation", args=[ret], pos=[2:6]) } // This test should fail with a cycle error. Even though raises and ret are @@ -179,7 +159,6 @@ sameStruct: { if ret != _|_ { raises: a: 1 } - @test(err, any, code=cycle|incomplete) } // Pushdown improvement: with this ordering, ret != _|_ fires first @@ -194,7 +173,6 @@ sameStruct: { if raises == _|_ { ret: a: 1 } - @test(err, any, code=cycle|incomplete) } // Pushdown improvement: raises is _ (top), raises == _|_ is false, @@ -210,7 +188,6 @@ sameStruct: { if ret != _|_ { raises: a: 1 } - @test(err, any, code=cycle|incomplete) } // Pushdown improvement: different ordering gives different result. @@ -224,7 +201,6 @@ sameStruct: { if raises == _|_ { ret: a: 1 } - @test(err, any, code=cycle|incomplete) } defCloseSuccess: { @@ -241,13 +217,8 @@ sameStruct: { expr: #Example & { ret: 2 } - @test(eq, { - #Example: {raises?: {runtime?: string}, ret?: _} - expr: {ret: 2, raises?: {runtime?: string}} - }) } } - -- nestedchain.cue -- // Issue nestedChain: { @@ -258,7 +229,6 @@ nestedChain: { if #E.y == _|_ { #E: x: true } - @test(err, code=incomplete|cycle) #E: [_]: bool } @@ -271,7 +241,6 @@ nestedChain: { } #E: [_]: bool #E: x: true - @test(eq, {#E: {y: true, x: true}}) } doubleAddfail: { @@ -282,7 +251,6 @@ nestedChain: { #E: x: true } #E: [_]: bool - @test(err, code=incomplete|cycle) } trippleSuccess: { @@ -293,7 +261,6 @@ nestedChain: { z: true } #E: x: true - @test(eq, {#E: {y: true, x: true}, z: true}) } } -- issue3836.cue -- @@ -311,13 +278,6 @@ issue3836: hidden: { out: [if bar != _|_ {"bar is set"}] } _Value.out - // Pushdown improvement: the comprehension guard (foo|bar) == _|_ now - // correctly fires and sets bar, where previously (without pushdown) the - // guard saw a spurious non-bottom value and did not fire. - @test(eq, { - _Value: {foo?: _, bar: type: "bar", out: ["bar is set"]} - ["bar is set"] - }) } issue3836: exposed: { foo?: _ @@ -326,7 +286,6 @@ issue3836: exposed: { bar: type: "bar" } out: [if bar != _|_ {"bar is set"}] - @test(err, code=cycle, contains="circular dependency in evaluation of conditionals: %v changed after evaluation", args=[(foo|bar)], pos=[3:6]) } -- issue3838.cue -- // evalv3 regression: `if in.opt != _|_` inside a list expression stopped @@ -359,16 +318,6 @@ issue3838: { (#T & { _test: assert: invoke: "foo" }).results - @test(eq, { - true - #T: { - subject: {in: {opt?: {foo: int}}, out: 0} - _test: { - assert: {pass: false, notOk: _} | {pass: true, invoke: _, res: 0} - } - results: _|_ @test(err, code=incomplete, contains="issue3838.#T.results: unresolved disjunction {pass:false,notOk:_} | {pass:true,invoke:_,res:0} (type struct)", pos=[26:12]) - } - }) } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/cycle/compbottomnofinal.txtar b/internal/core/compile/testdata/sync/cycle/compbottomnofinal.txtar index 05b6c7b2e..e7af516c4 100644 --- a/internal/core/compile/testdata/sync/cycle/compbottomnofinal.txtar +++ b/internal/core/compile/testdata/sync/cycle/compbottomnofinal.txtar @@ -14,16 +14,12 @@ minimal: { if b.port == _|_ { port: "" } - // Pushdown produces cycle error instead of incomplete. - @test(err, code=cycle|incomplete) } b: { if a.port == _|_ { port: "" } - // Pushdown produces cycle error instead of incomplete. - @test(err, code=cycle|incomplete) } } @@ -31,7 +27,6 @@ small: { #userHostPort: #"^(:(?P\d+))?$"# p1: { - @test(permute, count=2) #Y: regexp.FindNamedSubmatch(#userHostPort, #X.port) #X: { @@ -42,13 +37,6 @@ small: { port: ":" + strconv.FormatInt(#Y.port, 10) } } - // Yield-on-running heuristic: the comp's referenced node - // #Y is not currently being processed (only scheduled), so - // the comp does not yield and instead reports a cycle error. - @test(eq, { - #Y: _|_ @test(err, code=cycle|incomplete) - #X: _|_ @test(err, code=cycle|incomplete) - }) } } @@ -56,9 +44,8 @@ medium: { #userHostPort: #"^(:(?P\d+))?$"# p1: { - @test(permute, count=6) - #Y: regexp.FindNamedSubmatch(#userHostPort, #X.port) @test(err, code=incomplete|cycle) + #Y: regexp.FindNamedSubmatch(#userHostPort, #X.port) // Yield-on-running heuristic: the comp's referenced node Y // is not currently being processed, so the comp does not @@ -68,7 +55,7 @@ medium: { if #Y.port != _|_ { port: strconv.Atoi(#Y.port) } - } @test(err, code=incomplete|cycle) + } #X: { // Can never determine whether Y.port exists as its resolution @@ -80,7 +67,7 @@ medium: { if Y.port != _|_ { port: ":" + strconv.FormatInt(Y.port, 10) } - } @test(err, code=incomplete|cycle) + } } } @@ -88,17 +75,13 @@ large: { #userHostPort: #"^((?P[[:alnum:]]*)@)?(?P[[:alnum:].]+)(:(?P\d+))?$"# p1: { - @test(permute, count=120) - // Pushdown improvement: #Y, #X, and X now resolve successfully. - // Y gets a cycle error because #Y.port changed after evaluation. - // Permute disabled: pushdown introduces ordering sensitivity. Y: { userinfo: "user" host: "mod.test" } - X: #X.userinfo + #X.host + #X.port @test(err, any, code=incomplete|cycle) + X: #X.userinfo + #X.host + #X.port #X: { if Y.userinfo == _|_ { @@ -116,7 +99,7 @@ large: { if Y.port != _|_ { port: ":" + strconv.FormatInt(Y.port, 10) } - } @test(err, any, code=incomplete|cycle) + } Y: { if #Y.userinfo != _|_ { @@ -128,9 +111,9 @@ large: { if #Y.port != _|_ { port: strconv.Atoi(#Y.port) } - } @test(err, any, code=incomplete|cycle) + } - #Y: regexp.FindNamedSubmatch(#userHostPort, X) @test(err, any, code=incomplete|cycle) + #Y: regexp.FindNamedSubmatch(#userHostPort, X) } } -- out/compile -- diff --git a/internal/core/compile/testdata/sync/cycle/comprehension.txtar b/internal/core/compile/testdata/sync/cycle/comprehension.txtar index 274af9980..19c48eb3b 100644 --- a/internal/core/compile/testdata/sync/cycle/comprehension.txtar +++ b/internal/core/compile/testdata/sync/cycle/comprehension.txtar @@ -10,11 +10,11 @@ A: { a: { parent: "" children: [for k, v in A if v.parent == k {k}] - } @test(eq, {parent: "", children: []}) + } b: { parent: "a" children: [for k, v in A if v.parent == k {k}] - } @test(eq, {parent: "a", children: []}) + } } // This should result in an incomplete error (a reference cycle error classifies @@ -23,10 +23,7 @@ B: { a: { parent: "" children: [for k, v in B for _, w in v.children {k}] - } @test(eq, { - parent: "" - children: _|_ @test(err, code=incomplete, contains="B.a.children: cannot range over v.children (incomplete type list)", pos=[24:40]) - }) + } } // Issue #486: stack overflow in v0.3.0 when evaluating parametric fields with @@ -56,13 +53,6 @@ Issue486: { }, ] } - @test(eq, { - A: { - a: {parent: "", children: ["b"]} - b: {parent: "a", children: ["c"]} - c: {parent: "b", children: []} - } - }) } // Issue #1666: evaluator hangs indefinitely when combining disjunctions with @@ -84,14 +74,6 @@ issue1666: { } } } - @test(eq, { - #E: {f1: {}, f2: {}} - _e: {f2: {a: {t: {f1: {}, f2: {}}}}, f1: {}} - e: { - f1: {a: {f1: {}, f2: {}}} - f2: {a: {t: {f1: {}, f2: {}}}} - } - }) } // Issue #779: for comprehension incorrectly rejected valid bidirectional @@ -108,14 +90,9 @@ issue779: { } } } - Y: STATE & { message: X } + Y: STATE & {message: X} X: "test" - STATE: { code: 101 } - @test(eq, { - X: "test" - STATE: {code: 101} - Y: {message: "test", code: 101} - }) + STATE: {code: 101} } // Issue #1934: regression in v0.4.1 where nested comprehensions referencing @@ -131,10 +108,6 @@ selfReferential: T1: { for s, v in S for t, _ in T { T: (t): S: (s): v } - @test(eq, { - S: {d: "bar"} - T: {e: {S: {a: "foo", d: "bar"}}} - }) } // selfReferential comprehension for list. @@ -146,7 +119,6 @@ selfReferential: list: { } ] panels: [{}, {}, {}] - @test(eq, {panels: [{id: 0}, {id: 1}, {id: 2}]}) } selfReferential: insertionError: { @@ -158,33 +130,23 @@ selfReferential: insertionError: { // defined. ("foo3"): 1 } - @test(err, code=eval, contains="adding field foo3 not allowed as field set was already referenced", pos=[6:14]) } } // A comprehension should not recursively evaluated arcs, so that a // structural cycle can be avoided when unnecessary. selfReferential: acrossOr: t1: p1: { - o: #Output & { retry: reject: "ok" } + o: #Output & {retry: reject: "ok"} #AllOutputs: { reject: string resource: string - retry: #Output + retry: #Output } #Output: or([for name, config in #AllOutputs { (name): config }]) - @test(eq, { - o: {retry: {reject: "ok"}} - #AllOutputs: { - reject: string - resource: string - retry: {reject: string} | {resource: string} - } - #Output: {reject: string} | {resource: string} - }) } selfReferential: acrossOr: t1: p2: { @@ -192,22 +154,13 @@ selfReferential: acrossOr: t1: p2: { (name): config }]) - o: #Output & { retry: reject: "ok" } + o: #Output & {retry: reject: "ok"} #AllOutputs: { reject: string resource: string - retry: #Output + retry: #Output } - @test(eq, { - #Output: {reject: string} | {resource: string} - o: {retry: {reject: "ok"}} - #AllOutputs: { - reject: string - resource: string - retry: {reject: string} | {resource: string} - } - }) } selfReferential: acrossOr: t1: p3: { @@ -218,83 +171,47 @@ selfReferential: acrossOr: t1: p3: { #AllOutputs: { reject: string resource: string - retry: #Output + retry: #Output } - o: #Output & { retry: reject: "ok" } - @test(eq, { - #Output: {reject: string} | {resource: string} - #AllOutputs: { - reject: string - resource: string - retry: {reject: string} | {resource: string} - } - o: {retry: {reject: "ok"}} - }) + o: #Output & {retry: reject: "ok"} } selfReferential: acrossOr: t2: p1: { - d: or([for x, y in #A { y }]) - o: d & { b: 2 } + d: or([for x, y in #A {y}]) + o: d & {b: 2} #A: { d1: int d2: string d3: b: d } - @test(eq, { - d: int | string - o: {b: 2} - #A: { - d1: int - d2: string - d3: {b: int | string} - } - }) } selfReferential: acrossOr: t2: p2: { - o: d & { b: 2 } - d: or([for x, y in #A { y }]) + o: d & {b: 2} + d: or([for x, y in #A {y}]) #A: { d1: int d2: string d3: b: d } - @test(eq, { - o: {b: 2} - d: int | string - #A: { - d1: int - d2: string - d3: {b: int | string} - } - }) } selfReferential: acrossOr: t2: p3: { - o: d & { b: 2 } + o: d & {b: 2} #A: { d1: int d2: string d3: b: d } - d: or([for x, y in #A { y }]) - @test(eq, { - o: {b: 2} - #A: { - d1: int - d2: string - d3: {b: int | string} - } - d: int | string - }) + d: or([for x, y in #A {y}]) } // Issue #1881: evaluator required the source of a for comprehension to be // fully evaluated before iterating, causing false structural cycle errors. // https://cuelang.org/issue/1881 issue1881: p1: { - o: #Output & { retry: output: reject: "ok" } + o: #Output & {retry: output: reject: "ok"} #AllOutputs: { reject: string @@ -305,17 +222,6 @@ issue1881: p1: { #Output: or([for name, config in #AllOutputs { (name): config }]) - @test(eq, { - o: {retry: {output: {reject: "ok"}}} - #AllOutputs: { - reject: string - resource: string - retry: { - output: {reject: string} | {resource: string} - } - } - #Output: {reject: string} | {resource: string} - }) } issue1881: p2: { @@ -325,22 +231,11 @@ issue1881: p2: { retry: output: #Output } - o: #Output & { retry: output: reject: "ok" } + o: #Output & {retry: output: reject: "ok"} #Output: or([for name, config in #AllOutputs { (name): config }]) - @test(eq, { - #AllOutputs: { - reject: string - resource: string - retry: { - output: {reject: string} | {resource: string} - } - } - o: {retry: {output: {reject: "ok"}}} - #Output: {reject: string} | {resource: string} - }) } issue1881: p3: { @@ -354,18 +249,7 @@ issue1881: p3: { (name): config }]) - o: #Output & { retry: output: reject: "ok" } - @test(eq, { - #AllOutputs: { - reject: string - resource: string - retry: { - output: {reject: string} | {resource: string} - } - } - #Output: {reject: string} | {resource: string} - o: {retry: {output: {reject: "ok"}}} - }) + o: #Output & {retry: output: reject: "ok"} } siblingInsertion: t1: p1: { @@ -380,15 +264,6 @@ siblingInsertion: t1: p1: { for id, v in D { deployment: (id): env2: ENV: "True" } - @test(eq, { - D: {logging: _} - deployment: { - logging: { - env2: {ENV: "True"} - env: {ENV: "True"} - } - } - }) } siblingInsertion: t1: p2: { @@ -403,15 +278,6 @@ siblingInsertion: t1: p2: { for k1, v2 in v.env2 { deployment: (k): env: (k1): v2 } - @test(eq, { - D: {logging: _} - deployment: { - logging: { - env2: {ENV: "True"} - env: {ENV: "True"} - } - } - }) } siblingInsertion: t2: p1: { @@ -427,15 +293,6 @@ siblingInsertion: t2: p1: { for id, v in D { deployment: (id): env2: ENV: "True" } - @test(eq, { - D: {logging: _} - deployment: { - logging: { - env2: {ENV: "True"} - env: {ENV: "True"} - } - } - }) } siblingInsertion: t2: p2: { @@ -451,15 +308,6 @@ siblingInsertion: t2: p2: { for id, v in D { deployment: (id): env2: ENV: "True" } - @test(eq, { - D: {logging: _} - deployment: { - logging: { - env2: {ENV: "True"} - env: {ENV: "True"} - } - } - }) } // Issue #1407: cue export produced a misleading, location-free "cycle error" @@ -469,9 +317,7 @@ siblingInsertion: t2: p2: { selfReferential: fail: { a: {} b: a.x != "" - if b { - } - @test(err, code=incomplete, contains="undefined field: x", pos=[2:7]) + if b {} } // Issue #2367: stack overflow triggered by a comprehension that inserts into @@ -481,7 +327,6 @@ selfReferential: fail: { issue2367: { a: _ for x in [a] {a: x} - @test(eq, {a: _}) } // Issue #2310: evalv2 incorrectly reported a structural cycle when a @@ -509,79 +354,6 @@ issue2310: original: { #s & {#_2: "c", #_3: "d", _}, #s & {#_2: "e", #_3: "f", _}, ] - @test(eq, { - #s: { - _|_ - #_1: string - #_2: string - #_3: string - } - #sub: { - _|_ - #a: string - _#X: [string, - {_|_, #_1: string, #_2: "a", #_3: "b"}, - { - _|_ - #_1: {_|_, #_1: string, #_2: "a", #_3: "b"} - #_2: "c" - #_3: "d" - }, - { - _|_ - #_1: { - _|_ - #_1: {_|_, #_1: string, #_2: "a", #_3: "b"} - #_2: "c" - #_3: "d" - } - #_2: "e" - #_3: "f" - }] - #_1: { - _|_ - #_1: {_|_, #_1: string, #_2: "a", #_3: "b"} - #_2: "c" - #_3: "d" - } - #_2: "e" - #_3: "f" - } - res: { - "bbb" - #a: "aaa" - _#X: ["aaa", - {"bbb", #_1: "aaa", #_2: "a", #_3: "b"}, - { - "bbb" - #_1: {"bbb", #_1: "aaa", #_2: "a", #_3: "b"} - #_2: "c" - #_3: "d" - }, - { - "bbb" - #_1: { - "bbb" - #_1: {"bbb", #_1: "aaa", #_2: "a", #_3: "b"} - #_2: "c" - #_3: "d" - } - #_2: "e" - #_3: "f" - }] - #_1: { - "bbb" - #_1: {"bbb", #_1: "aaa", #_2: "a", #_3: "b"} - #_2: "c" - #_3: "d" - } - #_2: "e" - #_3: "f" - } - #subs: [{_|_, #_2: "a", #_3: "b", #_1: string}, - {_|_, #_2: "c", #_3: "d", #_1: string}, - {_|_, #_2: "e", #_3: "f", #_1: string}] - }) } issue2310: reduced: { res: { @@ -593,23 +365,7 @@ issue2310: reduced: { #s: {#str: string, #str + "a"} #subs: [0, 1, 2] - @test(eq, { - res: { - "Xaaa" - #X: ["X", - {"Xa", #str: "X"}, - {"Xaa", #str: {"Xa", #str: "X"}}, - { - "Xaaa" - #str: {"Xaa", #str: {"Xa", #str: "X"}} - }] - #str: {"Xaa", #str: {"Xa", #str: "X"}} - } - #s: {_|_, #str: string} - #subs: [0, 1, 2] - }) } - -- issue3903.cue -- // evalv3 structural cycle regression: a schema with `_deps` and comprehensions // over those deps triggered a spurious structural cycle error that exported @@ -628,13 +384,6 @@ issue3903: reduced: { } ] } - @test(eq, { - s1: { - _deps: [{_deps: [], objs: []}] - objs: [] - } - #Schema: {_deps: [], objs: []} - }) } issue3903: full: { s1: #Schema & { @@ -650,7 +399,7 @@ issue3903: full: { _deps: [...] objs: [ - for obj in _local { obj }, + for obj in _local {obj}, for dep in _deps for obj in (dep & {}).objs { @@ -658,23 +407,6 @@ issue3903: full: { }, ] } - @test(eq, { - s1: { - _deps: [{ - _local: ["s2 local"] - _deps: [] - objs: ["s2 local"] - }] - _local: ["s1 local"] - objs: ["s1 local", "s2 local"] - } - s2: { - _local: ["s2 local"] - _deps: [] - objs: ["s2 local"] - } - #Schema: {_local: [], _deps: [], objs: []} - }) } -- issue2405.cue -- // A recursive disjunction type (`#Copy` with struct/list/scalar alternatives) @@ -703,13 +435,6 @@ issue2405: { foo: #Copy foo: param: a: [{b: 134}] - @test(eq, { - #Copy: {param: {}, result: {}} | {param: [], result: []} | {param: number, result: number} - foo: { - param: {a: [{b: 134}]} - result: {a: [{b: 134}]} - } - }) } -- issue3941.cue -- // evalv3 regression: a comprehension iterating over a pattern-constrained field @@ -717,7 +442,7 @@ issue2405: { // already referenced" error that evalv2 did not emit. // https://cuelang.org/issue/3941 issue3941: full: { - #Metadata: name: string + #Metadata: name: string #Resource: metadata: #Metadata out: { @@ -732,17 +457,6 @@ issue3941: full: { } } } - @test(eq, { - #Metadata: {name: string} - #Resource: {metadata: {name: string}} - out: { - _metadata: {name: "foo"} - resource: { - level1: {foo: {metadata: {name: "foo"}}} - } - _names: ["foo"] - } - }) } -- issue2229.cue -- // A list comprehension whose result was unified back into the same list caused @@ -752,20 +466,12 @@ issue2229: full_ok: X={ build: bool | *true test: bool | *true - make: [ for k, v in X if (v & true) != _|_ { k } ] -} @test(eq, { - build: *true | bool - test: *true | bool - make: ["build", "test"] -}) + make: [for k, v in X if (v & true) != _|_ {k}] +} issue2229: reduced_fail: X={ x: true - y: [ for _, v in X if v & true { _ } ] -} @test(err, code=eval, - suberr=(code=eval, contains="conflicting values", pos=[2:5, 2:24, 2:28]), - suberr=(code=eval, contains="conflicting values", pos=[2:5, 2:24, 2:28]), - suberr=(code=eval, contains="structural cycle", pos=[2:24]), -) + y: [for _, v in X if v & true {_}] +} -- issue4100.cue -- // Segmentation fault in `adt.(*OpContext).freeNodeContext` in v0.14.1, // triggered by a let binding inside a conditional that feeds into a for loop. @@ -778,7 +484,6 @@ issue4100: { } } for _ in a {} - @test(eq, {a: [0]}) } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/cycle/constraints.txtar b/internal/core/compile/testdata/sync/cycle/constraints.txtar index eacb13aa3..7d3b54bcd 100644 --- a/internal/core/compile/testdata/sync/cycle/constraints.txtar +++ b/internal/core/compile/testdata/sync/cycle/constraints.txtar @@ -7,10 +7,6 @@ safeCycle: simple2: { y: [string]: b: c: y x: y x: c: y - @test(eq, { - y: {} - x: {c: {b: {c: {}, b: {c: {}}}}} - }) } // Not a cycle: the structure in x (c) only triggers one further @@ -19,10 +15,6 @@ safeCycle: long1: { y: [string]: b: y x: y x: c: b: e: b: c: _ - @test(eq, { - y: {} - x: {c: {b: {e: {b: {c: {b: {}}}}}}} - }) } // Not a cycle: the structure in x (c) only triggers one further @@ -31,10 +23,6 @@ safeCycle: long2: { a: [string]: b: a x: a x: c: b: c: b: c: {} - @test(eq, { - a: {} - x: {c: {b: {c: {b: {c: {b: {}}}}}}} - }) } // noCyclePattern is similar to the above cases, but involving more patterns @@ -46,7 +34,6 @@ noCyclePattern: t1: { a: {} [string]: #D [string]: b: c: {} - @test(eq, {#D: {}, a: {b: {c: {}}}}) } noCyclePattern: t2: { @@ -54,20 +41,14 @@ noCyclePattern: t2: { a: {} [string]: #D [string]: b: x: c: {} - @test(eq, {#D: {}, a: {b: {x: {c: {x: {}}}}}}) } noCyclePattern: t3: { _D: [string]: _T - _T: x: _D + _T: x: _D [string]: _D [string]: b: x: c: {} a: {} - @test(eq, { - _D: {} - _T: {x: {}} - a: {b: {x: {c: {x: {}}}}} - }) } noCyclePattern: t4: { @@ -76,11 +57,6 @@ noCyclePattern: t4: { [string]: _D [string]: b: x: {} a: {} - @test(eq, { - _D: {} - _T: {y: {}} - a: {b: {x: {y: {}}}} - }) } noCyclePattern: t5: { @@ -89,11 +65,6 @@ noCyclePattern: t5: { [string]: _D [string]: b: x: y: c: x: {} a: {} - @test(eq, { - _D: {} - _T: {y: {}} - a: {b: {x: {y: {c: {x: {y: {}}}}}}} - }) } // This example also has an embedding, in which case it should still behave @@ -104,29 +75,13 @@ noCyclePattern: t6: { #E: t: #T #T: { - { object: #S } + {object: #S} } - #S: y: #D + #S: y: #D [string]: x: #D - [string]: x: r: t: object: y: foo: t: object: { - } + [string]: x: r: t: object: y: foo: t: object: {} bar: {} - @test(eq, { - #D: {} - #E: {t: {object: {y: {}}}} - #T: {object: {y: {}}} - #S: {y: {}} - bar: { - x: { - r: { - t: { - object: {y: {foo: {t: {object: {y: {}}}}}} - } - } - } - } - }) } // Cycle: x cyclic. The pattern constraint should not be seen as @@ -134,11 +89,9 @@ noCyclePattern: t6: { noCancelSelfInvoke: t1: { y: [string]: b: y x: y - x: c: x @test(err, at=b.b, code=structural_cycle) @test(err, at=c, code=structural_cycle) - @test(err, code=structural_cycle) + x: c: x } - // Even though these cycles cross pattern boundaries, they are still structural // cycles as the reference includes a field that triggers the pattern. selfTriggerCycle: _ @@ -147,11 +100,11 @@ selfTriggerCycle: _ // However, upon investigation this error is present in the tree. Either way, // the error only needs to be reported once, so this is not a huge problem. selfTriggerCycle: t1: { - a: #T @test(shareID=T) + a: #T #T: { [string]: #T - b: {} @test(err, at=b, code=structural_cycle) - } @test(shareID=T) + b: {} + } } selfTriggerCycle: t2: { @@ -159,16 +112,15 @@ selfTriggerCycle: t2: { a: X } b: #T - b: c: {} @test(err, at=a, code=structural_cycle) + b: c: {} } selfTriggerCycle: long1: { // The long string of nested fields will initially exempt the structural // cycle, but they will eventually run out, causing the cycle to be // triggered. - a: [string]: b: a // -> record conjunct from pattern per field. - a: c: b: c: b: c: {} // -> track if any of the fields is not a cycle. - @test(err, at=a.c.b.c.b.c.b, code=structural_cycle) + a: [string]: b: a // -> record conjunct from pattern per field. + a: c: b: c: b: c: {} // -> track if any of the fields is not a cycle. } // TODO: see comment at selfTriggerCycle.t1 @@ -180,10 +132,6 @@ selfTriggerCycle: issue1503: { a: [string]: link: #T a: b: {} } - @test(err, at=#T.a.b.link, code=structural_cycle) - @test(err, at=a.a.b.link, code=structural_cycle) - @test(err, at=a.a.one.link.a.b.link, code=structural_cycle) - @test(err, at=a.a.one.link.a.two.link, code=structural_cycle) } mutuallyTriggeringCycle: t1: { @@ -193,7 +141,6 @@ mutuallyTriggeringCycle: t1: { y: [string]: b: y x: y x: c: y - @test(err, at=x.c.b.b.b.b.b, code=structural_cycle) } -- ring.cue -- brokenRing: t1: { @@ -203,48 +150,29 @@ brokenRing: t1: { // TODO: it would be nicer, though, if the representation were consistent. p1: { D: a?: T - T: b: D - @test(err, code=structural_cycle) - // @test(debug) + T: b: D } p2: { // TODO(eval): fix permute or eval: error messages differ based on path in the two cases. // @test(permute, count=2) - T: b: D + T: b: D D: a?: T - @test(eq, { - T: { - b: { - a?: _|_ @test(err, code=structural_cycle, contains="structural cycle", pos=[]) - } - } - D: { - a?: _|_ @test(err, code=structural_cycle, contains="structural cycle", pos=[]) - } - }) } } brokenRing: t2: p1: { D: [string]: T - T: b: D - @test(eq, {D: {}, T: {b: {}}}) + T: b: D } brokenRing: t2: p2: { - T: b: D + T: b: D D: [string]: T - @test(eq, {T: {b: {}}, D: {}}) } cyclicRing: t1: { D: a: T T: b: D - @test(err, at=T.b, code=structural_cycle) - @test(err, at=D.a.b, code=structural_cycle) - // TODO(inline): fix shareID here. - // @test(shareID=T, at=D.a) - // @test(shareID=T, at=T) } -- issue3476.cue -- // `cue def -e '#a'` causes a stack overflow. The definition #a selects a @@ -253,12 +181,11 @@ cyclicRing: t1: { // exporter to recurse infinitely instead of detecting the cycle. // https://cuelang.org/issue/3476 issue3476: { - #a: (#b & {x: _}).x + #a: (#b & {x: _}).x #b: { x?: #c #c: [string]: #c } - @test(eq, {#a: {}, #b: {x?: {}, #c: {}}}) } -- issue3509.cue -- // evalv3 causes infinite work and OOM panic where evalv2 is fast. A @@ -277,16 +204,6 @@ issue3509: { #matrixConfig: [...#matrixConfig] | string matrix?: [string]: [...#matrixConfig] } - - @test(eq, { - out: "foo" - #job: {step: string} - #Workflow: { - job: {step: string} - #matrixConfig: [] | string - matrix?: {} - } - }) } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/cycle/cycle_with_bounds.txtar b/internal/core/compile/testdata/sync/cycle/cycle_with_bounds.txtar index 8a20d4b3c..4ba436c7e 100644 --- a/internal/core/compile/testdata/sync/cycle/cycle_with_bounds.txtar +++ b/internal/core/compile/testdata/sync/cycle/cycle_with_bounds.txtar @@ -6,8 +6,8 @@ foo: !=bar bar: #Value bar: !=foo -bar: 0 @test(eq, 0) -foo: 1 @test(eq, 1) +bar: 0 +foo: 1 -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/cycle/disjunction.txtar b/internal/core/compile/testdata/sync/cycle/disjunction.txtar index 55ab5b02f..9433deb78 100644 --- a/internal/core/compile/testdata/sync/cycle/disjunction.txtar +++ b/internal/core/compile/testdata/sync/cycle/disjunction.txtar @@ -1,69 +1,58 @@ -- in.cue -- // cycle is a structural cycle -cycle: a: cycle @test(err, code=structural_cycle, pos=[]) +cycle: a: cycle // reference to outside structural cycle -r1a: cycle | int @test(eq, int) -r1b: int | cycle @test(eq, int) +r1a: cycle | int +r1b: int | cycle -r2a: cycle | 1 @test(eq, 1) -r2b: 1 | cycle @test(eq, 1) +r2a: cycle | 1 +r2b: 1 | cycle -r3a: cycle | null @test(eq, null) -r3b: null | cycle @test(eq, null) +r3a: cycle | null +r3b: null | cycle -r4a: cycle | {} @test(eq, {}) -r4b: {} | cycle @test(eq, {}) +r4a: cycle | {} +r4b: {} | cycle -r5a: cycle | [] @test(eq, []) -r5b: [] | cycle @test(eq, []) +r5a: cycle | [] +r5b: [] | cycle // reference to ancestor node s1a: { x: s1a | int - @test(eq, {x: int}) } s1b: { x: int | s1b - @test(eq, {x: int}) } s2a: { x: s2a | 1 - @test(eq, {x: 1}) } s2b: { x: 1 | s2b - @test(eq, {x: 1}) } s3a: { x: s3a | null - @test(eq, {x: null}) } s3b: { x: null | s3b - @test(eq, {x: null}) } s4a: { x: s4a | {} - @test(eq, {x: {}}) } s4b: { x: {} | s4b - @test(eq, {x: {}}) } s5a: { x: s5a | [] - @test(eq, {x: []}) } s5b: { x: [] | s5b - @test(eq, {x: []}) } - -- issue3042.cue -- // Array element validation not being enforced for elements nested inside // a struct: invalid values passed validation without error. @@ -81,10 +70,6 @@ issue3042: { ] } } - @test(err, code=eval, - suberr=(code=eval, path=data, contains="conflicting values %s and %s (mismatched types %s and %s)", args=[{secret:{infra:[{name:"bar1"}]}}, [...#nesting], struct, list], pos=[4:57, 6:8, 6:19]), - suberr=(code=eval, path=data, contains="conflicting values %s and %s (mismatched types %s and %s)", args=[{secret:{infra:[{name:"bar1"}]}}, string, struct, string], pos=[4:12, 6:8, 6:19]), - ) } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/cycle/evaluate.txtar b/internal/core/compile/testdata/sync/cycle/evaluate.txtar index 7abc7c3ad..dd741b3e8 100644 --- a/internal/core/compile/testdata/sync/cycle/evaluate.txtar +++ b/internal/core/compile/testdata/sync/cycle/evaluate.txtar @@ -14,7 +14,6 @@ letCycleOK: t1: { b: c let X = b c: X - @test(eq, {b: _, c: _}) } // The let has structural cycle, but it is only used in a way that the @@ -25,7 +24,6 @@ letCycleOK: t2: { let X = a c: X.b } - @test(eq, {a: {b: 1, c: 1}}) } // Ensure that the cycle exemption algorithm does not bypass actual structural @@ -36,7 +34,6 @@ letCycleFail: t1: { let X = a c: X } - @test(err, code=structural_cycle, path=a.c, contains="structural cycle", pos=[]) } // Cycles should also be detected in evaluation paths that descend into @@ -44,88 +41,62 @@ letCycleFail: t1: { letCycleFail: t2: { a: { let X = a - if X == _|_ { } + if X == _|_ {} x: y: "" } - @test(eq, {a: {x: {y: ""}}}) - // TODO(eval): not sure if it really should fail here, so this may be okay. - @test(debug, """ - (struct){ - a: (struct){ - let X#4 = (_|_){ - // [structural_cycle] letCycleFail.t2.a.X: structural cycle - } - x: (struct){ - y: (string){ "" } - } - } - } - """) } listCycleOK: { a: b b: and([c]) c: a - @test(eq, {a: _, b: _, c: _}) } disjunctionCycle: { a: b b: and(1 | c) c: a - @test(err, code=eval, path=b, - hint="This probably should be a totally different error message.", - contains="cannot use %s (type %s) as %s in argument %d to %v", - args=[1, int, list, 1, and], pos=[2:9]) } forCycle: { #A: a: #B // TODO(errors): Correct error position, or at all. - #B: or([for x in #A { b: x }]) - @test(err, code=structural_cycle, path=#B.b, contains="structural cycle", pos=[]) + #B: or([for x in #A {b: x}]) } letCycleWithAnd: { a: d: b - b: and([for x in a let y = x { y }]) + b: and([for x in a let y = x {y}]) c: a - @test(eq, {a: {d: {}}, b: {}, c: {d: {}}}) } closeCycle: { a: b b: close({d: c}) c: a - @test(err, code=structural_cycle, path=c, contains="structural cycle", pos=[]) } structCycle: { a: b b: and([{d: c}]) c: a - @test(err, code=structural_cycle, path=c, contains="structural cycle", pos=[]) } embedCycle: { a: b b: close({c}) c: a - @test(eq, {a: {}, b: {}, c: {}}) } listAddCycle: { a: b b: list.Concat([[c], [c]]) c: a - @test(err, code=structural_cycle, path=b, contains="error in call to %s", args=[list.Concat], pos=[2:5]) } listMulCycle: { a: b b: list.Repeat([{a: b: c}], 3) c: a - @test(err, code=structural_cycle, path=b, contains="error in call to %s", args=[list.Repeat], pos=[2:5]) } // consult the correct closeness info in the face of it being passed down @@ -133,26 +104,21 @@ listMulCycle: { closeFail: { #T: [_]: _ #T: close({"a": string}) - x: #T + x: #T x: b: "foo" - @test(err, code=eval, path=x.b, contains="field not allowed", pos=[1:6, 4:5]) } printCycle: { a: { X: a - if X { - } + if X {} } - @test(err, code=structural_cycle, path=a.X, contains="structural cycle", pos=[]) } -- self.cue -- issue3978: { a: self={ - if self.missing != _|_ { - } + if self.missing != _|_ {} } - @test(eq, {a: {}}) } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/cycle/expression.txtar b/internal/core/compile/testdata/sync/cycle/expression.txtar index ef740832a..4ef00c935 100644 --- a/internal/core/compile/testdata/sync/cycle/expression.txtar +++ b/internal/core/compile/testdata/sync/cycle/expression.txtar @@ -1,27 +1,26 @@ -- in.cue -- t1: a: { - a1: a0 + 2 @test(eq, 7.0) - b1: a1 - 2 @test(eq, 5.0) - a0: X @test(eq, 5.0) - X: b1 @test(eq, 5.0) + a1: a0 + 2 + b1: a1 - 2 + a0: X + X: b1 X: 5.0 } t1: b: { - X: 5.0 @test(eq, 5.0) - a1: a0 + 2 @test(eq, 7.0) - b1: a1 - 2 @test(eq, 5.0) - a0: X @test(eq, 5.0) + X: 5.0 + a1: a0 + 2 + b1: a1 - 2 + a0: X X: b1 - @test(eq, {X: 5.0, a1: 7.0, b1: 5.0, a0: 5.0}) } // TODO: did we really mean to have 3 times c? t1: c: { - a1: a0 + 2 @test(eq, 7.0) - b1: a1 - 2 @test(eq, 5.0) - X: 5.0 @test(eq, 5.0) - a0: X @test(eq, 5.0) + a1: a0 + 2 + b1: a1 - 2 + X: 5.0 + a0: X X: b1 } @@ -39,12 +38,10 @@ t1: c: { a1: a0 + 2 a0: X X: b1 - @test(eq, {a1: 7.0, b1: 5.0, X: 5.0, a0: 5.0}) } t1total: { for _, v in t1 {v} - @test(eq, {a1: 7.0, b1: 5.0, a0: 5.0, X: 5.0}) } // Issue #622 @@ -54,60 +51,55 @@ t1total: { // // TODO: are these meant to be permutations? If so use @test(permute) t2: a: { - a0: X @test(eq, 5.0) - a1: a0 * 2 @test(eq, 10.0) - Y: a1 @test(eq, 10.0) + a0: X + a1: a0 * 2 + Y: a1 - b0: Y @test(eq, 10.0) - b1: b0 / 2 @test(eq, 5.0) - X: b1 @test(eq, 5.0) + b0: Y + b1: b0 / 2 + X: b1 X: 5.0 - @test(eq, {a0: 5.0, a1: 10.0, Y: 10.0, b0: 10.0, b1: 5.0, X: 5.0}) } t2: b: { - b0: Y @test(eq, 10.0) - b1: b0 / 2 @test(eq, 5.0) - X: b1 @test(eq, 5.0) + b0: Y + b1: b0 / 2 + X: b1 - a0: X @test(eq, 5.0) - a1: a0 * 2 @test(eq, 10.0) - Y: a1 @test(eq, 10.0) + a0: X + a1: a0 * 2 + Y: a1 X: 5.0 - @test(eq, {b0: 10.0, b1: 5.0, X: 5.0, a0: 5.0, a1: 10.0, Y: 10.0}) } t2: c: { - b0: Y @test(eq, 10.0) - b1: b0 / 2 @test(eq, 5.0) - X: b1 @test(eq, 5.0) + b0: Y + b1: b0 / 2 + X: b1 - X: 5.0 @test(eq, 5.0) + X: 5.0 - a0: X @test(eq, 5.0) - a1: a0 * 2 @test(eq, 10.0) - Y: a1 @test(eq, 10.0) - @test(eq, {b0: 10.0, b1: 5.0, X: 5.0, a0: 5.0, a1: 10.0, Y: 10.0}) + a0: X + a1: a0 * 2 + Y: a1 } t2: d: { - b0: Y @test(eq, 10.0) - b1: b0 / 2 @test(eq, 5.0) - X: b1 @test(eq, 5.0) + b0: Y + b1: b0 / 2 + X: b1 - a0: X @test(eq, 5.0) - a1: a0 * 2 @test(eq, 10.0) - Y: a1 @test(eq, 10.0) + a0: X + a1: a0 * 2 + Y: a1 X: 5.0 - @test(eq, {b0: 10.0, b1: 5.0, X: 5.0, a0: 5.0, a1: 10.0, Y: 10.0}) } t2total: { for _, v in t2 {v} - @test(eq, {a0: 5.0, a1: 10.0, Y: 10.0, b0: 10.0, b1: 5.0, X: 5.0}) } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/cycle/freeze.txtar b/internal/core/compile/testdata/sync/cycle/freeze.txtar index daa9fb157..e84229047 100644 --- a/internal/core/compile/testdata/sync/cycle/freeze.txtar +++ b/internal/core/compile/testdata/sync/cycle/freeze.txtar @@ -6,35 +6,30 @@ freezing: t1: ok: { #a: x: "a" len(#a) // 1 - @test(eq, {1, #a: {x: "a"}}) } - -- comprehension.cue -- // This should be an incomplete error, as z is inserted in x, over which the // comprehension loops. Adding a field z to x would fix this. // This test would fail in the old evaluator, depending on ordering. comprehension: t1: _ -comprehension: t1: ok:{ - @test(permute, count=) +comprehension: t1: ok: { x: y: {} // order of comprehensions matter in old evaluator. for _ in x { - if true { x: z: a: {} } + if true {x: z: a: {}} } if true { - if true { x: z: a: {} } + if true {x: z: a: {}} } - @test(eq, {x: {y: {}, z: {a: {}}}}) } comprehension: t2: err: { a: { x: 1 for k, v in a { - (k+"q"): v // This increases the set of fields in a. + (k + "q"): v // This increases the set of fields in a. } - @test(err, code=eval, contains="adding field %v not allowed as field set was already referenced", args=[xq], pos=[3:13]) } } @@ -44,17 +39,13 @@ comprehension: t3: err: { b: y: 1 a: { for k, v in b { - (k+"q"): v + (k + "q"): v } - @test(err, code=eval, - suberr=(code=eval, contains="adding field %v not allowed as field set was already referenced", args=[yq], pos=[2:13]), - suberr=(code=eval, contains="adding field %v not allowed as field set was already referenced", args=[xq], pos=[2:13])) } b: { for k, v in a { (k): v } - @test(eq, {y: 1, x: 1}) } } @@ -62,9 +53,8 @@ comprehension: t4: ok: { // It is okay to make x more specific as long as no fields are added. x: y: {} for _ in x { - if true { x: y: a: {} } + if true {x: y: a: {}} } - @test(eq, {x: {y: {a: {}}}}) } comprehension: moreSpecific: ok: { @@ -73,7 +63,6 @@ comprehension: moreSpecific: ok: { for k, v in a { (k): 1 } - @test(eq, {x: 1}) } } @@ -84,8 +73,6 @@ comprehension: moreSpecific: err: { for k, v in a if len(v) > 0 { (k): {z: 1} } - @test(err, code=eval, path=x, - contains="adding field %v not allowed as field set was already referenced", args=[z], pos=[4:9]) } } -- issue3178.cue -- @@ -97,14 +84,12 @@ issue3178: { // - second comprehension runs // - in order to satisfy, first comprehension must run // - first comprehension runs and completes - input: [ "Value" ] + input: ["Value"] output: {...} for name in input { - output: "\(name)": true - } - for name, v in output { + output: "\(name)": true } - @test(eq, {input: ["Value"], output: {Value: true}}) + for name, v in output {} } -- out/compile -- --- comprehension.cue diff --git a/internal/core/compile/testdata/sync/cycle/inline.txtar b/internal/core/compile/testdata/sync/cycle/inline.txtar index ba40b7a1b..652bcdfda 100644 --- a/internal/core/compile/testdata/sync/cycle/inline.txtar +++ b/internal/core/compile/testdata/sync/cycle/inline.txtar @@ -4,23 +4,22 @@ inline: small: { f: { n: int - out: (f & {"n": n - 1}).out @test(err, code=structural_cycle, contains="structural cycle", pos=[0:9]) + out: (f & {"n": n - 1}).out } } inline: medium: { - f2: (f & {n: 2}).out @test(err, code=structural_cycle, contains="structural cycle", pos=[1:24]) + f2: (f & {n: 2}).out fRec: {nn: int, out: (f & {n: nn}).out} - @test(err, at=fRec.out, code=structural_cycle, contains="structural cycle", pos=[6:9]) f: { n: int - out: (fRec & {nn: n - 1}).out @test(err, code=structural_cycle, contains="structural cycle", pos=[0:9]) + out: (fRec & {nn: n - 1}).out } } inline: patterns: { f: n: (f & {n: {}}).n - f: n: {} @test(err, code=structural_cycle, contains="structural cycle", pos=[-1:9]) + f: n: {} [string]: {n: {}} f: [string]: {} f: {} @@ -38,16 +37,6 @@ inline: acrossFields: fail1: { // invalid recursion is here. k10: (f & {in: k30}).out - @test(eq, { - f: { - in: number - out: _|_ @test(err, code=incomplete, contains="inline.acrossFields.fail1.f.out: non-concrete value number in operand to +", pos=[31:8, 30:8]) - } - k00: 0 - k10: _|_ @test(err, code=incomplete, contains="in: non-concrete value number in operand to +", pos=[31:8, 30:8, 36:17]) - k20: _|_ @test(err, code=incomplete, contains="in: non-concrete value number in operand to +", pos=[31:8, 30:8, 39:17]) - k30: _|_ @test(err, code=incomplete, contains="in: non-concrete value number in operand to +", pos=[31:8, 30:8, 35:17]) - }) } // Issue #2163 @@ -64,13 +53,6 @@ inline: acrossFields: ok1: { // TODO: what is correct behavior here. // This is borderline okay. k10: (f & {in: k30}).out - @test(eq, { - f: {in: number, out: number} - k00: 0 - k10: 0 - k20: 0 - k30: 0 - }, hint="might be okay to fail") } -- inlineexpand.cue -- inlined: { @@ -79,10 +61,6 @@ inlined: { output: input.a } root: a: (X & {input: root}).output - @test(eq, { - X: {input: {a: _}, output: _} - root: {a: _} - }) } expanded1: hasCycle: { X: { @@ -93,7 +71,6 @@ expanded1: hasCycle: { a: _a.output _a: X & {input: root} } - @test(err, code=structural_cycle, at=root._a.input._a.input, contains="structural cycle", pos=[]) } expanded2: noCycle: { X: { @@ -102,17 +79,12 @@ expanded2: noCycle: { } root: a: _a.output _a: X & {input: root} - @test(eq, { - X: {input: {a: _}, output: _} - root: {a: _} - _a: {input: {a: _}, output: _} - }) } issue3731: reduced: { #lookup: { input: {...} output: [ - for _, v in input if v.show != _|_ { v }, + for _, v in input if v.show != _|_ {v}, ] } @@ -120,19 +92,12 @@ issue3731: reduced: { self: show: true others: (#lookup & {input: root}).output } - @test(eq, { - #lookup: {input: {}, output: []} - root: { - self: {show: true} - others: [{show: true}] - } - }) } issue3731: expanded: { #lookup: { input: {...} output: [ - for _, v in input if v.show != _|_ { v }, + for _, v in input if v.show != _|_ {v}, ] } @@ -141,7 +106,6 @@ issue3731: expanded: { others: _others.output _others: #lookup & {input: root} } - @test(err, code=structural_cycle, at=root._others.input._others.input, contains="structural cycle", pos=[]) } issue3731: full: { #Workspace: { @@ -158,61 +122,31 @@ issue3731: full: { #AccountConfig workspaces: "workspaceA": {} } - + #AccountConfigSub2: { #AccountConfig workspaces: "workspaceB": {} } - + tree: env1: { "region1": { - "env1-r1-account-sub1": #AccountConfigSub1 + "env1-r1-account-sub1": #AccountConfigSub1 "env1-r1-account-sub2-1": #AccountConfigSub2 } } - + #lookupSiblings: { envtree: {...} out: [ for region, v in envtree for account, config in v - if config.workspaces."workspaceB" != _|_ { account }, + if config.workspaces."workspaceB" != _|_ {account}, ] } - + tree: ENVTREE=env1: [_]: [_]: #AccountConfig & { siblings: (#lookupSiblings & {envtree: ENVTREE}).out } - @test(eq, { - #Workspace: {workspaceA?: {}, workspaceB?: {}} - #AccountConfig: { - workspaces: {workspaceA?: {}, workspaceB?: {}} - siblings?: [] - } - #AccountConfigSub1: { - workspaces: {workspaceA: {}, workspaceB?: {}} - siblings?: [] - } - #AccountConfigSub2: { - workspaces: {workspaceB: {}, workspaceA?: {}} - siblings?: [] - } - tree: { - env1: { - region1: { - "env1-r1-account-sub1": { - siblings: ["env1-r1-account-sub2-1"] - workspaces: {workspaceA: {}, workspaceB?: {}} - } - "env1-r1-account-sub2-1": { - siblings: ["env1-r1-account-sub2-1"] - workspaces: {workspaceB: {}, workspaceA?: {}} - } - } - } - } - #lookupSiblings: {envtree: {}, out: []} - }) } -- out/compile -- --- inlineexpand.cue diff --git a/internal/core/compile/testdata/sync/cycle/inline_non_recursive.txtar b/internal/core/compile/testdata/sync/cycle/inline_non_recursive.txtar index b681e8e67..867de213b 100644 --- a/internal/core/compile/testdata/sync/cycle/inline_non_recursive.txtar +++ b/internal/core/compile/testdata/sync/cycle/inline_non_recursive.txtar @@ -11,13 +11,6 @@ ok1: { k10: (f & {in: k00}).out k20: (f & {in: k10}).out k30: (f & {in: k20}).out - @test(eq, { - f: {in: number, out: number} - k00: 0 - k10: 0 - k20: 0 - k30: 0 - }) } ok2: { @@ -29,13 +22,6 @@ ok2: { k10: {(f & {in: k00}).out} k20: {(f & {in: k10}).out} k30: {(f & {in: k20}).out} - @test(eq, { - f: {in: number, out: number} - k00: 0 - k10: 0 - k20: 0 - k30: 0 - }) } ok3: { @@ -47,13 +33,6 @@ ok3: { k10: {close((f & {in: k00})).out} k20: {close((f & {in: k10})).out} k30: {close((f & {in: k20})).out} - @test(eq, { - f: {in: number, out: number} - k00: 0 - k10: 0 - k20: 0 - k30: 0 - }) } ok4: { @@ -65,13 +44,6 @@ ok4: { k10: {out: {(f & {in: k00}).out}}.out k20: {out: {(f & {in: k10}).out}}.out k30: {out: {(f & {in: k20}).out}}.out - @test(eq, { - f: {in: number, out: number} - k00: 0 - k10: 0 - k20: 0 - k30: 0 - }) } // Issue #1708: nested indirect selectors on a definition instantiated more than @@ -82,30 +54,13 @@ ok4: { issue1708: { #add10: { in: number - a10: { i: in, o: i + 10 } + a10: {i: in, o: i + 10} out: a10.o } k00: 0 k10: (#add10 & {in: k00}).out k20: (#add10 & {in: k10}).out k30: (#add10 & {in: k20}).out - - // TODO(inline): the generation of this value is broken, had to hand-adjust. - // TODO(inline): file positions are absolute instead of relative to the definition. - @test(eq, { - #add10: { - in: number - a10: { - i: number - o: _|_ @test(err, code=incomplete, contains="non-concrete value number in operand to +", pos=[84:20, 83:7]) - } - out: _|_ @test(err) - } - k00: 0 - k10: 10 - k20: 20 - k30: _|_ @test(err, code=incomplete, contains="undefined field: out", pos=[88:28]) - }) } -- issue3182.cue -- // evalv3 regression: references under projections (e.g. `{ a: x }.a`) were @@ -113,26 +68,22 @@ issue1708: { // https://cuelang.org/issue/3182 issue3182: { first: t1: { - x: { a: x }.a - @test(eq, {x: _}) + x: {a: x}.a } first: t2: { - x: { a: b: x }.a - @test(err, code=structural_cycle) + x: {a: b: x}.a } second: { - { t: x }.t.y + {t: x}.t.y x: y: x: y: a: 1 - @test(eq, {x: {y: {x: {y: {a: 1}}, a: 1}}, a: 1}) } third: { { p: { - x: p - y: 1 + x: p + y: 1 } }.p.x.y - @test(eq, 1) } } -- select.cue -- @@ -140,16 +91,10 @@ issue3182: { select: direct: { #Step: (#Job & {opt: _}).opt #Job: matchN(1, [#NormalJob]) - // TODO(inline): broken generation: retains reference. - @test(eq, { - #Step: _ - #Job: matchN(1, [{req!: int, opt?: {run?: string}}]) - }) } select: indirect: { #Step: #Job.opt #Job: matchN(1, [#NormalJob]) & {opt: _} - @test(eq, {#Step: _, #Job: {_|_, opt: _}}) } #NormalJob: { req!: int diff --git a/internal/core/compile/testdata/sync/cycle/issue241.txtar b/internal/core/compile/testdata/sync/cycle/issue241.txtar index c0941b73c..dd2a2998d 100644 --- a/internal/core/compile/testdata/sync/cycle/issue241.txtar +++ b/internal/core/compile/testdata/sync/cycle/issue241.txtar @@ -5,16 +5,16 @@ -- in.cue -- #Value: 0 | 1 -foo: #Value @test(err, code=cycle|incomplete, args=[bar], pos=[-2:13, 2:6, 3:6]) +foo: #Value foo: !=bar -bar: #Value @test(eq, 0 | 1) -bar: !=foo @test(err:todo, code=cycle|incomplete) +bar: #Value +bar: !=foo #Value: 0 | 1 -Foo: #Value @test(eq, 1) +Foo: #Value Foo: !=Bar -Bar: #Value @test(eq, 0) +Bar: #Value Bar: !=Foo Bar: 0 @@ -22,11 +22,11 @@ cell: a: 0 | 1 cell: a: !=cell.b cell: b: 0 | 1 cell: b: !=cell.a -cell: a: 0 @test(eq, 0) -cell: b: _ @test(eq, 1) +cell: a: 0 +cell: b: _ -a: cell.a @test(eq, 0) -b: cell.b @test(eq, 1) +a: cell.a +b: cell.b -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/cycle/issue242.txtar b/internal/core/compile/testdata/sync/cycle/issue242.txtar index 5a79f358b..a54e95bed 100644 --- a/internal/core/compile/testdata/sync/cycle/issue242.txtar +++ b/internal/core/compile/testdata/sync/cycle/issue242.txtar @@ -3,7 +3,7 @@ # must differ from its neighbors). # https://cuelang.org/issue/242 -- in.cue -- -#size: 2 +#size: 2 #CellValue: 0 | 1 | 2 | 3 cell: "0": "0": #CellValue cell: "0": "0": !=cell["0"]["1"] @@ -29,10 +29,6 @@ cell: "0": "0": 0 cell: "0": "1": 1 cell: "1": "0": 2 cell: "1": "1": 3 -@test(eq, { - "0": {"0": 0, "1": 1} - "1": {"0": 2, "1": 3} -}, at=cell) cell2: a: 0 | 1 cell2: a: !=cell2.b @@ -42,7 +38,6 @@ cell2: b: !=cell2.a cell2: a: _ cell2: b: 1 -@test(eq, {a: 0, b: 1}, at=cell2) cell3: a: 0 | 1 cell3: a: !=cell3.b @@ -52,7 +47,6 @@ cell3: b: !=cell3.a cell3: a: 0 cell3: b: _ -@test(eq, {a: 0, b: 1}, at=cell3) cell4: a: 0 | 1 cell4: a: !=cell4.b diff --git a/internal/core/compile/testdata/sync/cycle/issue2526.txtar b/internal/core/compile/testdata/sync/cycle/issue2526.txtar index a2eb4ac79..a73c0cbd1 100644 --- a/internal/core/compile/testdata/sync/cycle/issue2526.txtar +++ b/internal/core/compile/testdata/sync/cycle/issue2526.txtar @@ -7,7 +7,6 @@ x: { y y: x } -@test(err, code=structural_cycle, path=x.y, contains="structural cycle", pos=[]) -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/cycle/issue306.txtar b/internal/core/compile/testdata/sync/cycle/issue306.txtar index edd973df9..e4426d9aa 100644 --- a/internal/core/compile/testdata/sync/cycle/issue306.txtar +++ b/internal/core/compile/testdata/sync/cycle/issue306.txtar @@ -2,10 +2,10 @@ # values with cyclic field dependencies. # https://cuelang.org/issue/306 -- in.cue -- -a: 12 @test(eq, 12) +a: 12 #Controller: settings: { controller: #Controller -} @test(err, code=structural_cycle, path=controller, contains="structural cycle", pos=[]) +} -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/cycle/issue3118.txtar b/internal/core/compile/testdata/sync/cycle/issue3118.txtar index 8930de850..b0f46ceb4 100644 --- a/internal/core/compile/testdata/sync/cycle/issue3118.txtar +++ b/internal/core/compile/testdata/sync/cycle/issue3118.txtar @@ -17,27 +17,16 @@ examples: [string]: #TimeSpan examples: eg1: { - start: 10.0 - duration: 2.1 - @test(eq, {start: 10.0, duration: 2.1, end: 12.1}) + start: 10.0 + duration: 2.1 } examples: eg2: { - start: 10.0 - @test(eq, { - start: _|_ @test(err, code=incomplete, pos=[6:12, 4:12, 8:12]) - duration: _|_ @test(err, code=incomplete, pos=[7:12, 4:12, 8:12]) - end: _|_ @test(err, code=incomplete, pos=[7:12, 4:12, 8:12]) -}) + start: 10.0 } examples: eg3: { - end: 10.0 - @test(eq, { - end: _|_ @test(err, code=incomplete, pos=[8:12, 2:12, 6:12, 10:9]) - start: _|_ @test(err, code=incomplete, pos=[7:12, 2:12, 6:12, 10:9]) - duration: _|_ @test(err, code=incomplete, pos=[7:12, 2:12, 6:12, 10:9]) -}) + end: 10.0 } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/cycle/issue3527.txtar b/internal/core/compile/testdata/sync/cycle/issue3527.txtar index de3f5aefd..10ee110f0 100644 --- a/internal/core/compile/testdata/sync/cycle/issue3527.txtar +++ b/internal/core/compile/testdata/sync/cycle/issue3527.txtar @@ -21,24 +21,6 @@ subject: { #computeF1040: in: #ReturnData #ReturnData: taxPayer?: #TaxPayer #TaxPayer: self?: _ - -@test(eq, { - _taxPayer$p: {self: {}} - assert: { - invoke: {taxPayer: {self: {}}} - res: { - in: {taxPayer: {self: {}}} - _computed$p: {in: {taxPayer: {self: {}}}} - } - } - subject: { - in: {taxPayer?: {self?: _}} - _computed$p: {in: {taxPayer?: {self?: _}}} - } - #computeF1040: {in: {taxPayer?: {self?: _}}} - #ReturnData: {taxPayer?: {self?: _}} - #TaxPayer: {self?: _} -}) -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/cycle/issue3570.txtar b/internal/core/compile/testdata/sync/cycle/issue3570.txtar index 93dd792d7..40dc84bda 100644 --- a/internal/core/compile/testdata/sync/cycle/issue3570.txtar +++ b/internal/core/compile/testdata/sync/cycle/issue3570.txtar @@ -4,7 +4,7 @@ -- in.cue -- foo: foo: 25 | 44 foo -foo: foo @test(eq, {foo: _}) +foo: foo -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/cycle/issue3571.txtar b/internal/core/compile/testdata/sync/cycle/issue3571.txtar index 8d1a55634..367af913e 100644 --- a/internal/core/compile/testdata/sync/cycle/issue3571.txtar +++ b/internal/core/compile/testdata/sync/cycle/issue3571.txtar @@ -6,19 +6,13 @@ simplified: { #T in: _ - x: #T + x: #T x: x: #T #T: { in: x - x: _ + x: _ } - - @test(eq, { - in: {x: {in: _, x: _}, in: {in: _, x: _}} - x: {x: {in: _, x: _}, in: {in: _, x: _}} - #T: {in: _, x: _} - }) } issue3571: { @@ -35,26 +29,6 @@ issue3571: { in: #in #in: _ } - - @test(eq, { - a: { - in: { - f: true - g: { - #in: {f: {#in: {x: true}, in: {x: true}}} - in: {f: {#in: {x: true}, in: {x: true}}} - } - } - #in: { - g: { - #in: {f: {#in: {x: true}, in: {x: true}}} - in: {f: {#in: {x: true}, in: {x: true}}} - } - f?: _ - } - } - #T: {in: _, #in: _} - }) } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/cycle/issue3827.txtar b/internal/core/compile/testdata/sync/cycle/issue3827.txtar index 73dc57233..2064ea8cc 100644 --- a/internal/core/compile/testdata/sync/cycle/issue3827.txtar +++ b/internal/core/compile/testdata/sync/cycle/issue3827.txtar @@ -5,8 +5,7 @@ -- in.cue -- reduced: { A: b: (A.c & {}).x - A: null | { c: x: 1 } - @test(eq, {A: {b: 1, c: {x: 1}}}) + A: null | {c: x: 1} } full: { @@ -26,16 +25,6 @@ full: { with?: [string]: string } } - @test(eq, { - out: { - uses: "actions/upload-artifact@v3" - with: {name: "foo", path: "bar"} - } - #Workflow: { - #Step: {uses?: string, with?: {}} - steps: {} - } - }) } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/cycle/issue4203.txtar b/internal/core/compile/testdata/sync/cycle/issue4203.txtar index e021688ce..7e3dad8bc 100644 --- a/internal/core/compile/testdata/sync/cycle/issue4203.txtar +++ b/internal/core/compile/testdata/sync/cycle/issue4203.txtar @@ -26,29 +26,6 @@ if true { output: _input[0].variable } -@test(eq, { - _listBuilder: { - kind: "kind1" - _deps: [] - _kindJoin: {_objs: [], _out: ""} - _depKinds: "" - variable: "{}" - } - output: "{kind1}" - _input: [{ - _deps: [{ - kind: "kind1" - _deps: [] - _kindJoin: {_objs: [], _out: ""} - _depKinds: "" - variable: "{}" - }] - kind: "kind1" - _kindJoin: {_objs: [], _out: ""} - _depKinds: "kind1" - variable: "{kind1}" - }] -}) -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/cycle/issue4210.txtar b/internal/core/compile/testdata/sync/cycle/issue4210.txtar index 050f6a635..b64c4f39b 100644 --- a/internal/core/compile/testdata/sync/cycle/issue4210.txtar +++ b/internal/core/compile/testdata/sync/cycle/issue4210.txtar @@ -7,20 +7,16 @@ -- in.cue -- t1: { a: b: c: {a}.b - @test(err, code=structural_cycle, contains="structural cycle", pos=[]) } t2: { a: b: c: {a & _}.b - @test(err, code=structural_cycle, contains="structural cycle", pos=[]) } t3: { a: b: c: d: {a.b}.c - @test(err, code=structural_cycle, contains="structural cycle", pos=[]) } t4: { x: y: z: {a}.y a: x - @test(err, code=structural_cycle, contains="structural cycle", pos=[]) } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/cycle/issue4228.txtar b/internal/core/compile/testdata/sync/cycle/issue4228.txtar index 4ffbdc4b7..bc6db5c8d 100644 --- a/internal/core/compile/testdata/sync/cycle/issue4228.txtar +++ b/internal/core/compile/testdata/sync/cycle/issue4228.txtar @@ -23,10 +23,10 @@ _allValuesAreValidStructs: [_]: self={ _setTypeMeta: self={ #apiVersion!: string - #kind!: string + #kind!: string #template: k8s: { apiVersion: self.#apiVersion - kind: self.#kind + kind: self.#kind } } @@ -53,7 +53,7 @@ _namespacedResourceKinds: { app: { #apiVersion: "argoproj.io/v1alpha1" - #kind: "Application" + #kind: "Application" #resourceSchema: { spec?: revisionHistoryLimit?: int } @@ -68,8 +68,7 @@ _namespacedResourceKinds: { // Usage argocd: _namespacedResourceKinds & { app: apps: {} -} @test(err, code=eval) - +} -- export.cue -- @experiment(aliasv2) @@ -92,8 +91,6 @@ let _globalScope = self } #manifests: {#export, #entries: [_globalScope]}.yamlStream - -@test(err, code=eval) -- out/compile -- --- export.cue { diff --git a/internal/core/compile/testdata/sync/cycle/issue4230.txtar b/internal/core/compile/testdata/sync/cycle/issue4230.txtar index b04c574ee..cf03bbb4d 100644 --- a/internal/core/compile/testdata/sync/cycle/issue4230.txtar +++ b/internal/core/compile/testdata/sync/cycle/issue4230.txtar @@ -17,10 +17,7 @@ x: X={ regions: (#transform & {_input: X})._output app: region: or(["west", "east"]) & "west" -} @test(eq, { - regions: ["west"] - app: {region: "west"} -}) +} -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/cycle/issue4244.txtar b/internal/core/compile/testdata/sync/cycle/issue4244.txtar index 1e16239c3..65b1f666c 100644 --- a/internal/core/compile/testdata/sync/cycle/issue4244.txtar +++ b/internal/core/compile/testdata/sync/cycle/issue4244.txtar @@ -9,32 +9,22 @@ import "strings" let splits = strings.Split(id, "_never_") let prefix = splits[0] - #ID: =~"^\(prefix)$" @test(err, code=incomplete, contains="invalid interpolation", pos=[0:12, -2:22]) - #SubID: =~"^\(prefix):sub$" @test(err, code=incomplete, contains="invalid interpolation", pos=[0:12, -3:22]) + #ID: =~"^\(prefix)$" + #SubID: =~"^\(prefix):sub$" - id: #ID @test(err, code=incomplete, contains="invalid interpolation", pos=[-3:12, -5:22]) - subid: #SubID @test(err, code=incomplete, contains="invalid interpolation", pos=[-3:12, -6:22]) + id: #ID + subid: #SubID } case1: #schema & { id: "foo" subid: "foo:sub" -} @test(eq, { - id: "foo" - subid: "foo:sub" - #ID: =~"^foo$" - #SubID: =~"^foo:sub$" -}) +} case2: #schema & { subid: "foo:sub" id: "foo" -} @test(eq, { - subid: "foo:sub" - id: "foo" - #ID: =~"^foo$" - #SubID: =~"^foo:sub$" -}) +} -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/cycle/issue4253.txtar b/internal/core/compile/testdata/sync/cycle/issue4253.txtar index dd54161e8..e7fd2d172 100644 --- a/internal/core/compile/testdata/sync/cycle/issue4253.txtar +++ b/internal/core/compile/testdata/sync/cycle/issue4253.txtar @@ -23,7 +23,7 @@ x: { } gateway: whoami2: {} -} @test(eq, at=gateway.whoami2, {foo: 1, k8s: {foo: 1}}) +} -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/cycle/issue429.txtar b/internal/core/compile/testdata/sync/cycle/issue429.txtar index 4ca318b3d..d144ba392 100644 --- a/internal/core/compile/testdata/sync/cycle/issue429.txtar +++ b/internal/core/compile/testdata/sync/cycle/issue429.txtar @@ -14,39 +14,23 @@ max: >min | *min } -s0: #Size & {res: 1} @test(eq, { - res: 1 - min: *2 | >1 - max: *2 | >1 | >2 -}) +s0: #Size & {res: 1} // This discards the default for max. This is correct, but unfortunate. // TODO: is there a tweak to the default mechanism possible that would fix that? // Tread very carefully, though! Perhaps we could have a builtin that // discards any default, so that we can at least manually override this // behavior. -s1: #Size & {min: 5} @test(eq, { - min: 5 - res: *0 | >=0 & int - max: *5 | >5 -}) -s2: #Size & {max: 5} @test(eq, { - max: 5 - res: *0 | >=0 & int - min: *1 | >0 -}) +s1: #Size & {min: 5} +s2: #Size & {max: 5} s3: #Size & { min: 5 max: 10 -} @test(eq, {min: 5, max: 10, res: *0 | >=0 & int}) +} es3: #Size & { min: 10 max: 5 -} @test(err, code=eval, - suberr=(code=eval, path=max, contains="%d errors in empty disjunction:", args=[2], pos=[]), - suberr=(code=eval, path=max, contains="conflicting values %s and %s", args=[1, 5], pos=[-29:16, -28:15, 0:6, 2:7]), - suberr=(code=eval, path=max, contains="conflicting values %s and %s", args=[10, 5], pos=[-28:15, 0:6, 1:7, 2:7]), - suberr=(code=eval, path=max, contains="invalid value %v (out of bound %s)", args=[5, >10], pos=[-28:7, 2:7])) +} // Disjunctions with cycles // TODO: improve error message here. Logic is correct, though. @@ -57,25 +41,19 @@ es3: #Size & { } r1: #nonEmptyRange & { min: 3 -} @test(eq, { - min: _|_ @test(err, code=incomplete, contains="r1.min: non-concrete value max for bound < (and 2 more errors)", pos=[46:8]) - max: >3 -}) +} r2: #nonEmptyRange & { max: 5 -} @test(eq, {max: 5, min: *1 | <5 & int}) +} r3: #nonEmptyRange & { min: 3 max: 6 -} @test(eq, {min: 3, max: 6}) +} er3: #nonEmptyRange & { min: 5 max: 5 -} @test(err, code=eval, - suberr=(code=eval, path=min, contains="conflicting values %s and %s", args=[1, 5], pos=[-18:8, 0:6, 1:7]), - suberr=(code=eval, path=min, contains="invalid value %v (out of bound %s)", args=[5, <5], pos=[-17:7, 1:7]), - suberr=(code=eval, path=min, contains="invalid value %v (out of bound %s)", args=[5, <5], pos=[-17:7, 1:7])) +} -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/cycle/issue494.txtar b/internal/core/compile/testdata/sync/cycle/issue494.txtar index 69132d1b1..483bd59ff 100644 --- a/internal/core/compile/testdata/sync/cycle/issue494.txtar +++ b/internal/core/compile/testdata/sync/cycle/issue494.txtar @@ -8,27 +8,27 @@ _Q: [{pos: 0}, {pos: 1}] a: [rn=string]: _Q[0:len(a[rn])] -a: ben: [{}] @test(eq, [{pos: 0}]) +a: ben: [{}] b: [rn=string]: _Q[0:1] -b: ben: [{}] @test(eq, [{pos: 0}]) +b: ben: [{}] c: [rn=string]: [...{l: len(a[rn])}] -c: ben: [{}] @test(eq, [{l: 1}]) +c: ben: [{}] #d: [rn=string]: [...{pos: uint}] & _Q[0:len(#d[rn])] -#d: ben: [{}] @test(eq, [{pos: 0}]) +#d: ben: [{}] -d: #d @test(eq, {ben: [{pos: 0}]}) +d: #d e: [rn=string]: _Q[0 : len(a[rn])+1] -e: ben: [{}, ...] @test(eq, [{pos: 0}, {pos: 1}]) +e: ben: [{}, ...] f: [rn=string]: _Q[0 : len(a[rn])+1] -f: ben: [{}] @test(err, code=eval, contains="incompatible list lengths", pos=[]) +f: ben: [{}] g: [rn=string]: _Q[0:len(a[rn])] -g: ben: [{}, {}] @test(err, code=eval, contains="incompatible list lengths", pos=[]) +g: ben: [{}, {}] -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/cycle/issue502.txtar b/internal/core/compile/testdata/sync/cycle/issue502.txtar index 8776364d9..1c058291d 100644 --- a/internal/core/compile/testdata/sync/cycle/issue502.txtar +++ b/internal/core/compile/testdata/sync/cycle/issue502.txtar @@ -11,7 +11,7 @@ mas: [string]: { cfg: _ _link: #T - link: _link & {config: cfg} + link: _link & {config: cfg} } } @@ -34,31 +34,7 @@ } } -a: #a & {config: a: 34} @test(eq, { - config: {a: 34} - body: 34 - mas: one: { - cfg: {b: 34} - _link: { - config: {b: int} - body: int - mas: two: { - cfg: {c: int} - _link: {config: {c: int}, body: int, mas: {}} - link: {config: {c: int}, body: int, mas: {}} - } - } - link: { - config: {b: 34} - body: 34 - mas: two: { - cfg: {c: 34} - _link: {config: {c: int}, body: int, mas: {}} - link: {config: {c: 34}, body: 34, mas: {}} - } - } - } -}) +a: #a & {config: a: 34} -- reduced.cue -- reduced: t1: { #T: x: y?: { @@ -67,28 +43,6 @@ reduced: t1: { } a: #T a: x: y: V: x: y: V: {} - - @test(eq, { - #T: x: y?: { - V: _ - z: x: y?: { - _|_ - V: _ - z: _|_ @test(err, code=structural_cycle, contains="reduced.t1.#T.x.y.z.x.y.z: structural cycle", pos=[]) - } - } - a: x: y: { - V: x: y: V: {} - z: x: y: { - V: {} - z: x: y?: { - _|_ - V: _ - z: _|_ @test(err, code=structural_cycle, contains="reduced.t1.a.x.y.z.x.y.z.x.y.z: structural cycle", pos=[]) - } - } - } - }) } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/cycle/issue990.txtar b/internal/core/compile/testdata/sync/cycle/issue990.txtar index cf4934fc8..bf5b0a673 100644 --- a/internal/core/compile/testdata/sync/cycle/issue990.txtar +++ b/internal/core/compile/testdata/sync/cycle/issue990.txtar @@ -51,11 +51,10 @@ _test: { n: "c1" } - s3: #AS s3: d: { n: "s3" - r: r1: a:c1 + r: r1: a: c1 } s2: #AS @@ -80,114 +79,6 @@ _test: { // Test out: #sub & {#p: _test.s1} - -// TODO(fmt): can we improve this? -@test(eq, { - #AC: {k: "simple", d: {n: string}} - #AS: {k: "complex", d: {n: string, r: {}}} - #R: { - a: {k: "simple", d: {n: string}} | {k: "complex", d: {n: string, r: {}}} - } - #S: {n: string, r: {}} - #C: {n: string} - #sub: { - #p: {k: "complex", d: {n: string, r: {}}} - dict: {} - } - _test: { - c1: {d: {n: "c1"}, k: "simple"} - s3: { - d: { - n: "s3" - r: {r1: {a: {d: {n: "c1"}, k: "simple"}}} - } - k: "complex" - } - s2: { - d: { - n: "s2" - r: { - r1: {a: {d: {n: "c1"}, k: "simple"}} - r2: { - a: { - d: { - n: "s3" - r: {r1: {a: {d: {n: "c1"}, k: "simple"}}} - } - k: "complex" - } - } - } - } - k: "complex" - } - s1: { - d: { - n: "s1" - r: { - r1: {a: {d: {n: "c1"}, k: "simple"}} - r2: { - a: { - d: { - n: "s2" - r: { - r1: {a: {d: {n: "c1"}, k: "simple"}} - r2: { - a: { - d: { - n: "s3" - r: {r1: {a: {d: {n: "c1"}, k: "simple"}}} - } - k: "complex" - } - } - } - } - k: "complex" - } - } - } - } - k: "complex" - } - } - out: { - #p: { - d: { - n: "s1" - r: { - r1: {a: {d: {n: "c1"}, k: "simple"}} - r2: { - a: { - d: { - n: "s2" - r: { - r1: {a: {d: {n: "c1"}, k: "simple"}} - r2: { - a: { - d: { - n: "s3" - r: {r1: {a: {d: {n: "c1"}, k: "simple"}}} - } - k: "complex" - } - } - } - } - k: "complex" - } - } - } - } - k: "complex" - } - dict: { - r1: {a: {d: {n: "c1"}, k: "simple"}} - r2_r1: {a: {d: {n: "c1"}, k: "simple"}} - r2_r2_r1: {a: {d: {n: "c1"}, k: "simple"}} - } - } -}) -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/cycle/patterns.txtar b/internal/core/compile/testdata/sync/cycle/patterns.txtar index 1eaa3a300..a4ad2b901 100644 --- a/internal/core/compile/testdata/sync/cycle/patterns.txtar +++ b/internal/core/compile/testdata/sync/cycle/patterns.txtar @@ -7,10 +7,9 @@ a: b b: [string]: int c: a: int [string]: c -a: b @test(eq, {a: int}) +a: b b: [string]: int -c: a: int @test(eq, int) - +c: a: int -- issue3326.cue -- // https://cuelang.org/issue/3326 issue3326: { @@ -23,7 +22,6 @@ issue3326: { _self: x: [...and(x)] _self x: [1] - @test(eq, {_self: {x: []}, x: [1], a: int}) } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/cycle/self.txtar b/internal/core/compile/testdata/sync/cycle/self.txtar index 2d66eeaa3..c910af174 100644 --- a/internal/core/compile/testdata/sync/cycle/self.txtar +++ b/internal/core/compile/testdata/sync/cycle/self.txtar @@ -6,114 +6,95 @@ import "list" expr: error1: { a: 3 a: a + 1 - @test(err, code=eval, path=a, contains="conflicting values %s and %s", args=[4, 3], pos=[1:5, 2:5]) } expr: error2: { a: a + 1 a: 3 - @test(err, code=eval, path=a, contains="conflicting values %s and %s", args=[4, 3], pos=[1:5, 2:5]) } listConcat: error1: { a: ["1", "2"] a: list.Concat([a, ["3"]]) - @test(err, code=structural_cycle, path=a, contains="error in call to %s", args=[list.Concat], pos=[2:5]) } listConcat: error2: { a: list.Concat([["3"], a]) a: ["1", "2"] - @test(err, code=structural_cycle, path=a, contains="error in call to %s", args=[list.Concat], pos=[1:5]) } selfEmbed: ok1: { a: x Y: x x: {Y} - @test(eq, {a: {}, Y: {}, x: {}}) } selfEmbed: ok2: { Y: x.b a: x x: b: {Y} - @test(eq, {Y: {}, a: {b: {}}, x: {b: {}}}) } selfEmbed: ok3: { Y: x a: x x: {Y} - @test(eq, {Y: {}, a: {}, x: {}}) } selfEmbed: ok4: { a: x x: {Y} Y: x - @test(eq, {a: {}, x: {}, Y: {}}) } selfEmbed: ok5: { x: {Y} a: x Y: x - @test(eq, {x: {}, a: {}, Y: {}}) } selfEmbed: ok6: { x: b: {Y} Y: x.b a: x - @test(eq, {x: {b: {}}, Y: {}, a: {b: {}}}) } - disjSelf: ok1: { #A: string | #A - x: #A - @test(eq, {#A: string | _, x: string | _}) + x: #A } disjSelf: ok2: { - x: #A + x: #A #A: string | #A - @test(eq, {x: string | _, #A: string | _}) } disjSelf: ok3: { #A: #A | string - x: #A - @test(eq, {#A: _ | string, x: _ | string}) + x: #A } disjSelf: ok4: { - x: #A + x: #A #A: #A | string - @test(eq, {x: _ | string, #A: _ | string}) } disjEmbed: ok1: { #A: string | {#A} x: #A - @test(eq, {#A: string | {}, x: string | {}}) } disjEmbed: ok2: { x: #A #A: string | {#A} - @test(eq, {x: string | {}, #A: string | {}}) } disjEmbed: ok3: { #A: {#A} | string x: #A - @test(eq, {#A: {} | string, x: {} | string}) } disjEmbed: ok4: { x: #A #A: {#A} | string - @test(eq, {x: {} | string, #A: {} | string}) } // x and #A should yield the same result. @@ -124,79 +105,62 @@ disjList: ok1: { y: x y: [[[[string]]]] - @test(eq, { - #A: string - x: string - y: [[[[string]]]] - }) } disjList: ok2: { x: #A #A: string | [#A] - @test(eq, {x: string, #A: string}) } disjList: ok3: { #A: [#A] | string x: #A - @test(eq, {#A: string, x: string}) } disjList: ok4: { x: #A #A: [#A] | string - @test(eq, {x: string, #A: string}) } - -- old.cue -- name: "foo" dynamicSelf: ok1: { X=(name): string | X - x: X - @test(eq, {x: string | _, foo: string | _}) + x: X } dynamicSelf: ok2: { - x: X + x: X X=(name): string | X - @test(eq, {x: string | _, foo: string | _}) } dynamicSelf: ok3: { X=(name): X | string - x: X - @test(eq, {x: _ | string, foo: _ | string}) + x: X } dynamicSelf: ok4: { - x: X + x: X X=(name): X | string - @test(eq, {x: _ | string, foo: _ | string}) } dynamicEmbed: ok1: { X=(name): string | {X} x: X - @test(eq, {x: string | {}, foo: string | {}}) } dynamicEmbed: ok2: { x: X X=(name): string | {X} - @test(eq, {x: string | {}, foo: string | {}}) } dynamicEmbed: ok3: { X=(name): {X} | string x: X - @test(eq, {x: {} | string, foo: {} | string}) } dynamicEmbed: ok4: { x: X X=(name): {X} | string - @test(eq, {x: {} | string, foo: {} | string}) } dynamicList: _ @@ -206,156 +170,124 @@ dynamicList: ok1: { y: x y: [[[[string]]]] - @test(eq, { - x: string - y: [[[[string]]]] - foo: string - }) } dynamicList: ok2: { x: X X=(name): string | [X] - @test(eq, {x: string, foo: string}) } dynamicList: ok3: { X=(name): [X] | string x: X - @test(eq, {x: string, foo: string}) } dynamicList: ok4: { x: X X=(name): [X] | string - @test(eq, {x: string, foo: string}) } dynamicPatternSelf: ok1: { X=[string]: string | X - @test(eq, {}) } dynamicPatternSelf: ok2: { X=[string]: X | string - @test(eq, {}) } dynamicPatternEmbed: ok1: { X=[string]: string | {X} - @test(eq, {}) } dynamicPatternEmbed: ok2: { X=[string]: {X} | string - @test(eq, {}) } dynamicPatternList: ok1: { X=[string]: string | [X] - @test(eq, {}) } dynamicPatternList: ok2: { X=[string]: [X] | string - @test(eq, {}) } valueSelf: ok1: { y: X={string | X} x: y - @test(eq, {y: string | {}, x: string | {}}) } valueSelf: ok2: { x: y y: X={string | X} - @test(eq, {x: string | {}, y: string | {}}) } valueSelf: ok3: { y: X={X | string} x: y - @test(eq, {y: {} | string, x: {} | string}) } valueSelf: ok4: { x: y y: X={X | string} - @test(eq, {x: {} | string, y: {} | string}) } valueEmbed: ok1: { y: X={string | {X}} x: y - @test(eq, {y: string | {}, x: string | {}}) } valueEmbed: ok2: { x: y y: X={string | {X}} - @test(eq, {x: string | {}, y: string | {}}) } valueEmbed: ok3: { y: X={{X} | string} x: y - @test(eq, {y: {} | string, x: {} | string}) } valueEmbed: ok4: { x: y y: X={{X} | string} - @test(eq, {x: {} | string, y: {} | string}) } valueList: ok1: { y: X={string | [X]} x: y - @test(eq, {y: string, x: string}) } valueList: ok2: { x: y y: X={string | [X]} - @test(eq, {x: string, y: string}) } valueList: ok3: { y: X={[X] | string} x: y - @test(eq, {y: string, x: string}) } valueList: ok4: { x: y y: X={[X] | string} - @test(eq, {x: string, y: string}) } // Issue #1729 issue1729: t1: { - #x: { #x | {} } + #x: {#x | {}} x: #x & {} - @test(eq, {#x: {}, x: {}}) } issue1729: t2: { x: #x & {} - #x: { #x | {} } - @test(eq, {x: {}, #x: {}}) + #x: {#x | {}} } - -- selfnew.cue -- @experiment(aliasv2) issue4125: t1_self: { let Root = self a: Root.a - @test(eq, {a: _}) } -- selfold.cue -- issue4125: t2_alias: X={ let Y = X b: Y.b - @test(eq, {b: _}) } - -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/cycle/structural.txtar b/internal/core/compile/testdata/sync/cycle/structural.txtar index df812a883..39b3fc4d2 100644 --- a/internal/core/compile/testdata/sync/cycle/structural.txtar +++ b/internal/core/compile/testdata/sync/cycle/structural.txtar @@ -3,32 +3,26 @@ import "list" a1: { f: [f] - @test(err, code=structural_cycle, path=f.0, contains="structural cycle", pos=[]) } a2: { f: f - @test(eq, {f: _}) } a3: { f: {g: f} - @test(err, code=structural_cycle, path=f.g, contains="structural cycle", pos=[]) } a4: { a: [a | int] - @test(eq, {a: [int]}) } a5: { a: b: a | int - @test(eq, {a: {b: int}}) } a6: { a: a | int - @test(eq, {a: _ | int}) } a7: { @@ -41,48 +35,38 @@ a7: { x: b.y y: 3 } - @test(eq, { - a: "foo" - b: {x: {x: "foo", y: 3}, y: "foo"} - c: {x: "foo", y: 3} - }) } b1: { b: a & [1] a: [a | int] - @test(eq, {b: [1], a: [int]}) } b2: { a: [a | int] b: a & [1] - @test(eq, {a: [int], b: [1]}) } b3: { x: a: [a | int] b: x & {a: [1]} - @test(eq, {x: {a: [int]}, b: {a: [1]}}) } b4: { b: x.y & [1] x: y: [y] - @test(err, code=eval, path=b.0, contains="conflicting values %s and %s (mismatched types %s and %s)", args=[1, [y], int, list], pos=[1:5, 1:12, 2:8, 2:9]) } // Ensure that the cycle error is not blindly copied to a referring field, // as the cycle may not persist. b4: cond1: { - b: x.y & { _z: false, [1] } + b: x.y & {_z: false, [1]} x: y: { _z: *true | bool if _z { [y] } } - @test(err, code=structural_cycle, path=x.y.0, contains="structural cycle", pos=[]) } // This reports a structural cycle at b4.cond2.b, because the value it refers @@ -99,28 +83,22 @@ b4: cond2: { [y] } } - b: x.y & { _z: false, [1] } - @test(err, code=structural_cycle, path=x.y.0, contains="structural cycle", pos=[]) + b: x.y & {_z: false, [1]} } b5: { b: x.y & {a: [1]} x: y: a: [a | int] - @test(eq, {b: {a: [1]}, x: {y: {a: [int]}}}) } b6: { b: x & {a: [1]} x: a: [a] - @test(err, code=eval, path=b.a.0, contains="conflicting values %s and %s (mismatched types %s and %s)", - args=[1, [1], int, list], pos=[1:5, 1:13, 1:14, 2:9]) } b7: { b: a & [[1]] a: [a] - @test(err, code=eval, path=b.0.0, contains="conflicting values %s and %s (mismatched types %s and %s)", - args=[1, [a], int, list], pos=[1:5, 1:11, 2:5, 2:6]) } // Issue #555 @@ -128,11 +106,6 @@ b8: { x: a a: f: b b: a | string - @test(eq, { - x: {f: string} - a: {f: string} - b: string - }) } // Issue #555 @@ -143,18 +116,6 @@ b9: { } #ref: ref: string x: #b | #ref - @test(eq, { - #a: string | {ref: string} - #b: { - c: [string | {ref: string}, - string | {ref: string}, - string | {ref: string}] - } - #ref: {ref: string} - x: {c: [string | {ref: string}, - string | {ref: string}, - string | {ref: string}]} | {ref: string} - }) } // Issue #534 @@ -171,23 +132,14 @@ b10: { }) d: d: b: string - @test(eq, { - a: {b: string | {d: string}} - c: { - d: string | {b: string | {b: string | {b: string}}} - } - d: {d: {b: string}} - }) } // Issue #509 -- with comprehension b11: { #list: { tail: #list | *null - if tail != null { - } + if tail != null {} } - @test(eq, {#list: {tail: null}}) } // Issue #509 -- with comprehension @@ -216,26 +168,6 @@ b12: { } } } - @test(eq, { - #list: {value: int, tail: null, sum: int} - list1: { - value: 1 - tail: { - value: 2 - tail: { - value: 3 - tail: { - value: 4 - tail: *null | {value: int, tail: null, sum: int} - sum: 4 - } - sum: 7 - } - sum: 9 - } - sum: 10 - } - }) } // More trigger happy on stack overflows. @@ -246,13 +178,12 @@ b12b: { if tail != null { sum: tail.sum } - } @test(err, code=structural_cycle, path=tail, contains="structural cycle", pos=[]) + } - list1: #list @test(err, code=structural_cycle, path=b12b.#list.tail, contains="structural cycle", pos=[]) + list1: #list list1: { tail: { - tail: { - } + tail: {} } } } @@ -260,7 +191,6 @@ b12b: { // Issue #587 b13: { root: a: [for x in root {x}] - @test(err, code=structural_cycle, path=root.a.0.0, contains="structural cycle", pos=[]) } // Issue #587 @@ -276,14 +206,12 @@ b14: { b: [for x in root {x}] } - @test(err, code=structural_cycle, path=root.b.1.1, contains="structural cycle", pos=[]) } // This is okay // Issue #587 b15: { root: a: {for x in root {x}} - @test(eq, {root: {a: {}}}) } // Issue #502 -- unused bulk constraints are not cyclic @@ -295,14 +223,6 @@ p1: { a: #T & { a: one: link: a: two: {} } - @test(eq, { - #T: {a: {}} - a: { - a: { - one: {link: {a: {two: {link: {a: {}}}}}} - } - } - }) } // Issue #502 -- but they are if it is invoked within the struct. @@ -315,8 +235,6 @@ p2: { a: #T & { a: one: link: a: two: {} } - @test(eq, {one: {link: {a: {two: {}}}}}, at=a.a) - @test(err, code=structural_cycle, path=#T.a.b.link, contains="structural cycle", pos=[]) } // Issue #502 -- or added later. @@ -328,11 +246,11 @@ p3: { #U: { #S #T: a: b: {} - } @test(err, code=structural_cycle, path=#T.a.b.link, contains="structural cycle", pos=[]) + } a: #U.#T & { a: one: link: a: two: {} - } @test(err, code=structural_cycle, path=p3.#U.#T.a.b.link, contains="structural cycle", pos=[]) + } } // Issue #502 -- unused bulk constraints are not cyclic @@ -344,10 +262,6 @@ p4: { a: #T & { a: [{link: a: [{}]}] } - @test(eq, { - #T: {a: []} - a: {a: [{link: {a: [{link: {a: []}}]}}]} - }) } // Issue #502 -- but they are if it is invoked within the struct. @@ -360,8 +274,6 @@ p5: { a: #T & { a: [{link: a: [{}]}] } - @test(err, code=structural_cycle, path=#T.a.0.link, contains="structural cycle", pos=[]) - @test(eq, [{link: {a: [{}]}}], at=a.a) } // Issue #502 -- or added later. @@ -373,11 +285,11 @@ p6: { #U: { #S #T: a: [{}] - } @test(err, code=structural_cycle, path=#T.a.0.link, contains="structural cycle", pos=[]) + } a: #U.#T & { a: [{link: a: [{}]}] - } @test(err, code=structural_cycle, path=p6.#U.#T.a.0.link, contains="structural cycle", pos=[]) + } } c1: { @@ -385,26 +297,21 @@ c1: { b: {} c: a & b } - @test(err, code=structural_cycle, path=a.c.c, contains="structural cycle", pos=[]) } // indirection d1: { a: b: c: d: {h: int, t: r} - @test(err, at=a.b.c.d.t, code=structural_cycle, path=d1.r, contains="structural cycle", pos=[]) - r: a.b @test(err, code=structural_cycle, contains="structural cycle", pos=[]) + r: a.b x: a.b.c - } d2: { - x: a.b.c @test(shareID=X) - @test(shareID=X, at=a.b.c) + x: a.b.c - r: a.b @test(shareID=R) - @test(shareID=R, at=a.b) + r: a.b a: b: c: d: {h: int, t: r} } @@ -413,16 +320,9 @@ d3: { config: { a: b: c: indirect indirect: [a.b, null][i] - i: int | *1 + i: int | *1 } x: config & {i: 0} - @test(err, at=x.indirect, code=structural_cycle, contains="structural cycle", pos=[]) - @test(err, at=x.a.b.c, code=structural_cycle, contains="structural cycle", pos=[]) - @test(eq, at=config, { - a: {b: {c: null}} - indirect: null - i: *1 | int - }) } // Ensure that the cycles here fail early. @@ -435,21 +335,18 @@ shortPathFail: doubleRef: { // result to be longer than perhaps expected. a: #List #List: Next: #List | *null - @test(eq, {a: {Next: null}, #List: {Next: null}}) } shortPathFail: elipsis: { // Avoid this: the elipsis causes `_` to be mixed in with the #Foo // reference, causing the first cycle to be discounted. t1: { - #Foo: ref: null | #Foo - #Foo: { ... } - @test(eq, {#Foo: {ref: null}}) + #Foo: ref: null | #Foo + #Foo: {...} } t2: { - Foo: ref: Foo + Foo: ref: Foo Foo: {...} - @test(err, code=structural_cycle, at=Foo.ref, contains="structural cycle", pos=[]) } } @@ -460,22 +357,18 @@ shortPathFail: elipsis: { patternFail: issue2374: { r=[string]: {b: r} a: {r: 0} - @test(err, code=structural_cycle, at=a.b, contains="structural cycle", pos=[]) } shortPathFail: comprehension: { #list: { tail: #list | *null - if tail != null { - } + if tail != null {} } - @test(eq, {#list: {tail: null}}) } withLetFail: { - schema: next: _schema_1 + schema: next: _schema_1 let _schema_1 = schema - @test(err, code=structural_cycle, at=schema.next, contains="structural cycle", pos=[]) } // Issue #3310: `list.Sum` called with a comprehension iterating over the @@ -489,31 +382,14 @@ fieldsSumInfinite: issue3310: { sprite: 1.00 total: list.Sum([for _, v in issue3310 {v}]) - @test(err, code=structural_cycle, at=total, contains="error in call to %s", args=[list.Sum], pos=[5:9]) } listOptOK: { list: { - head: int + head: int tail?: list } a: list & {head: 3, tail: head: 2} - @test(eq, { - list: { - head: int - tail?: _|_ @test(err, code=structural_cycle, contains="list.tail: structural cycle", pos=[]) - } - a: { - head: 3 - tail: { - head: 2 - tail?: { - head: int - tail?: _|_ @test(err, code=structural_cycle, contains="list.tail: structural cycle", pos=[]) - } - } - } - }) } // The cyclic definitions below used to work OK on old versions of evalv2, @@ -526,12 +402,6 @@ issue2545: { #B: { A: #A } - @test(err, code=structural_cycle, - hint="the comment says this should succeed since the optional field breaks the cycle, but it still errors in both v2 and v3") - @test(eq:todo, { - #A: {B?: _ @test(ignore)} - #B: {A: {B?: _|_}} - }) } // combining structural with reference cycles @@ -541,8 +411,6 @@ e1: { b: c: b b: b - @test(err, code=structural_cycle, at=a.c, contains="structural cycle", pos=[]) - @test(err, code=structural_cycle, at=b.c, contains="structural cycle", pos=[]) } e2: { @@ -551,15 +419,13 @@ e2: { b: c: b b: {b} - @test(err, code=structural_cycle, at=a.c, contains="structural cycle", pos=[]) - @test(err, code=structural_cycle, at=b.c, contains="structural cycle", pos=[]) } e3: { - a: [a] @test(err, code=eval, contains="conflicting values %s and %s (mismatched types %s and %s)", args=[[a], {c:a}, list, struct], pos=[0:5, 1:5]) - a: c: a @test(err, code=structural_cycle, contains="structural cycle", pos=[]) + a: [a] + a: c: a - b: [b] @test(err, code=eval, contains="conflicting values %s and %s (mismatched types %s and %s)", args=[[b], {c:b}, list, struct], pos=[0:5, 1:5]) + b: [b] b: c: b } @@ -569,9 +435,6 @@ e4: { b: [[{c: 1}]] b: [b | {}] - @test(err, code=eval, - suberr=(code=eval, path=a.0, contains="conflicting values %s and %s (mismatched types %s and %s)", args=[[{c:1}], {}, list, struct], pos=[1:10, 2:6]), - suberr=(code=eval, path=a.0.0, contains="conflicting values %s and %s (mismatched types %s and %s)", args=[{c:1}, [{c:1}], struct, list], pos=[1:6, 2:6, 2:7])) } e5: { @@ -580,7 +443,6 @@ e5: { b: b | int b: c: b | int - @test(eq, {a: {c: int}, b: {c: int}}) } // validating values @@ -588,33 +450,21 @@ nestedList: { v1e: { x: [x | int, 1] y: x & [[[2], 1], 1] - @test(err, code=eval, - suberr=(code=eval, path=y.0, contains="conflicting values %s and %s (mismatched types %s and %s)", pos=[1:11, 2:6, 2:11]), - suberr=(code=eval, path=y.0.0, contains="%d errors in empty disjunction:", args=[2], pos=[]), - suberr=(code=eval, path=y.0.0, contains="conflicting values %s and %s (mismatched types %s and %s)", pos=[1:7, 1:11, 2:6, 2:12]), - suberr=(code=eval, path=y.0.0, contains="incompatible list lengths (%d and %d)", args=[1, 2], pos=[1:6])) } v2e: { y: x & [[[2], 1], 1] x: [x | int, 1] - @test(err, code=eval, - suberr=(code=eval, path=y.0, contains="conflicting values %s and %s (mismatched types %s and %s)", pos=[1:6, 1:11, 2:11]), - suberr=(code=eval, path=y.0.0, contains="%d errors in empty disjunction:", args=[2], pos=[]), - suberr=(code=eval, path=y.0.0, contains="conflicting values %s and %s (mismatched types %s and %s)", pos=[1:6, 1:12, 2:7, 2:11]), - suberr=(code=eval, path=y.0.0, contains="incompatible list lengths (%d and %d)", args=[1, 2], pos=[2:6])) } v1: { x: [x | int, 1] y: x & [[[2, 1], 1], 1] - @test(eq, {x: [int, 1], y: [[[2, 1], 1], 1]}) } v2: { y: x & [[[2, 1], 1], 1] x: [x | int, 1] - @test(eq, {y: [[[2, 1], 1], 1], x: [int, 1]}) } } @@ -634,19 +484,6 @@ v3: { } } } - @test(eq, { - list: {head: int, tail: null} - myList: { - head: 2 - tail: { - head: 3 - tail: { - head: 4 - tail: {head: int, tail: null} | null - } - } - } - }) } v4: { @@ -660,16 +497,6 @@ v4: { head: 2 tail: head: 3 } - @test(eq, { - list: {head: int, tail: 1} - myList: { - head: 2 - tail: { - head: 3 - tail: {head: int, tail: 1} | 1 - } - } - }) } v5: { @@ -683,13 +510,6 @@ v5: { head: 2 tail: head: 3 } - @test(eq, { - list: {head: int, tail: {}} - myList: { - head: 2 - tail: {head: 3, tail: {head: int, tail: {}} | {}} | {head: 3} - } - }) } // Example from "The Logic of Type Feature Structures" (Bob Carpenter)/ @@ -703,7 +523,6 @@ z1: { g: f } z: x & y - @test(err, code=structural_cycle, path=z.g, contains="structural cycle", pos=[]) } // Cross references. Here there is no cycle, but the repeated instantiations @@ -716,11 +535,7 @@ crossRefNoCycle: t1: { x: _ y: x } - C: { x: T } & T - @test(eq, { - T: {x: _, y: _} - C: {x: {x: _, y: _}, y: {x: _, y: _}} - }) + C: {x: T} & T } crossRefNoCycle: t2: { @@ -728,11 +543,7 @@ crossRefNoCycle: t2: { x: _ y: x } - C: T & { x: T } - @test(eq, { - T: {x: _, y: _} - C: {x: {x: _, y: _}, y: {x: _, y: _}} - }) + C: T & {x: T} } crossRefNoCycle: t3: { @@ -741,15 +552,7 @@ crossRefNoCycle: t3: { y: x z: y } - C: T & { x: T } - @test(eq, { - T: {x: _, y: _, z: _} - C: { - x: {x: _, y: _, z: _} - y: {x: _, y: _, z: _} - z: {x: _, y: _, z: _} - } - }) + C: T & {x: T} } crossRefNoCycle: t4: { @@ -758,63 +561,27 @@ crossRefNoCycle: t4: { y: x z: y } - C: T & { x: T & { x: T } } - @test(eq, { - T: {x: _, y: _, z: _} - C: { - x: { - x: {x: _, y: _, z: _} - y: {x: _, y: _, z: _} - z: {x: _, y: _, z: _} - } - y: { - x: {x: _, y: _, z: _} - y: {x: _, y: _, z: _} - z: {x: _, y: _, z: _} - } - z: { - x: {x: _, y: _, z: _} - y: {x: _, y: _, z: _} - z: {x: _, y: _, z: _} - } - } - }) + C: T & {x: T & {x: T}} } crossRefNoCycle: t5: { T: X={ y: X.x } - C: T & { x: T } - @test(eq, { - T: { - y: _|_ @test(err, code=incomplete, contains="crossRefNoCycle.t5.T.y: undefined field: x", pos=[785:8]) - } - C: { - x: { - y: _|_ @test(err, code=incomplete, contains="crossRefNoCycle.t5.T.y: undefined field: x", pos=[785:8]) - } - y: { - y: _|_ @test(err, code=incomplete, contains="crossRefNoCycle.t5.T.y: undefined field: x", pos=[785:8]) - } - } - }) + C: T & {x: T} } // Ensure these are NOT treated as structural errors. n1: { a: b: int - @test(eq, {a: {b: int}}) } n2: { n1 a: n1 - @test(eq, {a: {b: int, a: {b: int}}}) } n3: { n1 - @test(eq, {a: {b: int}}) } n4: { n1 @@ -825,21 +592,17 @@ n4: { z: int } } - @test(eq, { - x: {y: {z: int, a: {b: int}}, a: {b: int}} - a: {b: int} - }) } -- edge.cue -- // TODO(eval): notice the difference, not a huge deal, but still. resolveToAncestor: { t1: X: { - a: b.a @test(eq, _) @test(err:todo, code=structural_cycle) - b: X @test(err, code=structural_cycle, contains="structural cycle", pos=[]) + a: b.a + b: X } t2: X: { - b: X @test(err, code=structural_cycle, contains="structural cycle", pos=[]) - a: b.a @test(err, code=structural_cycle, path=resolveToAncestor.t2.X.b, contains="structural cycle", pos=[]) + b: X + a: b.a } } -- out/compile -- diff --git a/internal/core/compile/testdata/sync/cycle/with_defaults.txtar b/internal/core/compile/testdata/sync/cycle/with_defaults.txtar index 4a344457b..c31c23253 100644 --- a/internal/core/compile/testdata/sync/cycle/with_defaults.txtar +++ b/internal/core/compile/testdata/sync/cycle/with_defaults.txtar @@ -4,18 +4,15 @@ range1: { min: *1 | int range: >min range: 8 - @test(eq, {min: *1 | int, range: 8}) } range2: { min: *1 | int max: int & >min - @test(eq, {min: *1 | int, max: >1 & int}) } rg: range2 rg: { // min: 1 max: 8 - @test(eq, {max: 8, min: *1 | int}) } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/definitions/026_combined_definitions.txtar b/internal/core/compile/testdata/sync/definitions/026_combined_definitions.txtar index 35fa385fc..c1052b23f 100644 --- a/internal/core/compile/testdata/sync/definitions/026_combined_definitions.txtar +++ b/internal/core/compile/testdata/sync/definitions/026_combined_definitions.txtar @@ -8,22 +8,22 @@ #def: {a: "A"} #def: {b: "B"} } -d1: #D1 & {env: c: "C" } @test(err, at=env.c, code=eval, contains="field not allowed", pos=[0:17]) +d1: #D1 & {env: c: "C"} #D2: { a: int } #D2: { b: int -} @test(eq, {a: int, b: int}) +} #D3: { env: a: "A" } #D3: { env: b: "B" -} @test(eq, { env: { a: "A", b: "B" } }) +} #D4: { env: #DC - env: b: int @test(err, code=eval, contains="field not allowed", pos=[0:7]) + env: b: int } #DC: {a: int} -- out/compile -- diff --git a/internal/core/compile/testdata/sync/definitions/028_recursive_closing_starting_at_non-definition.txtar b/internal/core/compile/testdata/sync/definitions/028_recursive_closing_starting_at_non-definition.txtar index ef6b30d5d..84077fbef 100644 --- a/internal/core/compile/testdata/sync/definitions/028_recursive_closing_starting_at_non-definition.txtar +++ b/internal/core/compile/testdata/sync/definitions/028_recursive_closing_starting_at_non-definition.txtar @@ -8,7 +8,7 @@ z: a: { c: f: 1 } } -A: z & {a: {#B: {c: e: 2}}} @test(eq, {a: #B: c: {e: 2, d: 1, f: 1}}) +A: z & {a: {#B: {c: e: 2}}} -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/definitions/032_definitions_with_embedding.txtar b/internal/core/compile/testdata/sync/definitions/032_definitions_with_embedding.txtar index 6be6dfd0a..cc1cc4e15 100644 --- a/internal/core/compile/testdata/sync/definitions/032_definitions_with_embedding.txtar +++ b/internal/core/compile/testdata/sync/definitions/032_definitions_with_embedding.txtar @@ -7,17 +7,13 @@ #E a: {c: int} b: 3 -} @test(eq, { - a: {b: int, c: int} - b: 3 -}) +} // adding a field to a nested struct that is closed. -#e1: #S & {a: d: 4} @test(err, at=a.d, code=eval, - contains="field not allowed", pos=[0:15]) +#e1: #S & {a: d: 4} // literal struct not closed until after unification. -#v1: #S & {a: c: 4} @test(eq, {a: {b: int, c: 4}, b: 3}) +#v1: #S & {a: c: 4} -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/definitions/033_Issue_#153.txtar b/internal/core/compile/testdata/sync/definitions/033_Issue_#153.txtar index 21eb1a714..b4ebefe27 100644 --- a/internal/core/compile/testdata/sync/definitions/033_Issue_#153.txtar +++ b/internal/core/compile/testdata/sync/definitions/033_Issue_#153.txtar @@ -13,7 +13,7 @@ Foo: { } Junk: { - b: 2 @test(eq, 2) + b: 2 } Foo & { @@ -23,14 +23,6 @@ Foo & { } }] } -@test(eq, { - Foo: listOfCloseds: [] - #Closed: a: int | *0 - Junk: b: 2 - listOfCloseds: _|_ @test(err, at=0.b, code=eval, - hint="considerably more positions could be useful", - contains="field not allowed", pos=[16:4]) -}) -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/definitions/036_closing_with_failed_optional.txtar b/internal/core/compile/testdata/sync/definitions/036_closing_with_failed_optional.txtar index 1bf7ec5e2..b652e17f5 100644 --- a/internal/core/compile/testdata/sync/definitions/036_closing_with_failed_optional.txtar +++ b/internal/core/compile/testdata/sync/definitions/036_closing_with_failed_optional.txtar @@ -1,33 +1,17 @@ -- in.cue -- -#k1: {a: int, b?: int} & #A @test(eq, {a: int}) @test(closed) +#k1: {a: int, b?: int} & #A -#k2: #A & {a: int, b?: int} @test(eq, {a: int}) @test(closed) +#k2: #A & {a: int, b?: int} -o1: {a?: 3} & {a?: 4} @test(eq, {a?: _|_}) @test(closed=false) +o1: {a?: 3} & {a?: 4} // Optional fields with error values can be eliminated when closing -#o2: {a?: 3} & {a?: 4} @test(eq, {}) @test(closed) +#o2: {a?: 3} & {a?: 4} -#d1: {a?: 2, b: 4} | {a?: 3, c: 5} @test(closed) @test(eq, { - a?: 2 - b: 4 - } | { - a?: 3 - c: 5 - }) +#d1: {a?: 2, b: 4} | {a?: 3, c: 5} // Note: a? can be discarded safely. -v1: #d1 & {a?: 3, b: 4} @test(closed) @test(eq, {b: 4}) @test(debug, """ - (#struct){ - a?: (_|_){ - // [eval] v1.a: conflicting values 2 and 3: - // in.cue:10:11 - // in.cue:19:5 - // in.cue:19:16 - } - b: (int){ 4 } - } - """) +v1: #d1 & {a?: 3, b: 4} #A: {a: int} -- out/compile -- diff --git a/internal/core/compile/testdata/sync/definitions/036_optionals_in_open_structs.txtar b/internal/core/compile/testdata/sync/definitions/036_optionals_in_open_structs.txtar index ad442fed1..652881bab 100644 --- a/internal/core/compile/testdata/sync/definitions/036_optionals_in_open_structs.txtar +++ b/internal/core/compile/testdata/sync/definitions/036_optionals_in_open_structs.txtar @@ -6,11 +6,7 @@ B: { [=~"^[m-z]*$"]: int } #C: {A & B} -c: #C & {aaa: 3} @test(eq, { - [=~"^[a-s]*$"]: int - [=~"^[m-z]*$"]: int - aaa: 3 -}) +c: #C & {aaa: 3} -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/definitions/037_closing_with_comprehensions.txtar b/internal/core/compile/testdata/sync/definitions/037_closing_with_comprehensions.txtar index 6c4d4c14c..55f4e2412 100644 --- a/internal/core/compile/testdata/sync/definitions/037_closing_with_comprehensions.txtar +++ b/internal/core/compile/testdata/sync/definitions/037_closing_with_comprehensions.txtar @@ -1,38 +1,37 @@ #name: closing with comprehensions #evalPartial -- in.cue -- -#A: {f1: int, f2: int} @test(eq, {f1: int, f2: int}) @test(closed) +#A: {f1: int, f2: int} for k, v in {f3: int} { a: #A & {"\(k)": v} } -@test(err, at=a.f3, code=eval, contains="field not allowed", pos=[-2:11]) #B: { for k, v in {f1: int} { "\(k)": v } -} @test(eq, { f1: int }) +} #C: { f1: _ for k, v in {f1: int} { "\(k)": v } -} @test(eq, { f1: int }) @test(closed) @test(allows=false, string) +} #D: { for k, v in {f1: int} { "\(k)": v } ... -} @test(eq, { f1: int }) @test(closed) @test(allows, string) +} #E: #A & { for k, v in {f3: int} { "\(k)": v } -} @test(err, at=f3, code=eval, contains="field not allowed", pos=[2:3]) +} -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/definitions/037_conjunction_of_optional_sets.txtar b/internal/core/compile/testdata/sync/definitions/037_conjunction_of_optional_sets.txtar index 0ab4749dc..ce52a7f40 100644 --- a/internal/core/compile/testdata/sync/definitions/037_conjunction_of_optional_sets.txtar +++ b/internal/core/compile/testdata/sync/definitions/037_conjunction_of_optional_sets.txtar @@ -6,20 +6,13 @@ [=~"^[m-z]*$"]: int } -#C: #A & #B @test(allows, moo) @test(allows=false, QQQ) @test(eq, { - [=~"^[a-s]*$"]: int - [=~"^[m-z]*$"]: int -}) -c: #C -c: {aaa: 3 } @test(err, code=eval, at=aaa, - hint="positions missing", - contains="field not allowed", pos=[in.cue:2:2, 0:5]) +#C: #A & #B +c: #C +c: {aaa: 3} #D: {#A & #B} d: #D -d: {aaa: 3 } @test(err, code=eval, at=aaa, - hint="positions missing", - contains="field not allowed", pos=[in.cue:2:2, 0:5]) +d: {aaa: 3} -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/definitions/038_continue_recursive_closing_for_optionals.txtar b/internal/core/compile/testdata/sync/definitions/038_continue_recursive_closing_for_optionals.txtar index 0edaccd92..3725ffa25 100644 --- a/internal/core/compile/testdata/sync/definitions/038_continue_recursive_closing_for_optionals.txtar +++ b/internal/core/compile/testdata/sync/definitions/038_continue_recursive_closing_for_optionals.txtar @@ -4,7 +4,7 @@ } a: #S & { v: {b: int} -} @test(err, at=v.b, code=eval, contains="field not allowed", pos=[1:6]) +} -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/definitions/039_augment_closed_optionals.txtar b/internal/core/compile/testdata/sync/definitions/039_augment_closed_optionals.txtar index 8cd25e05e..4f14a3d9e 100644 --- a/internal/core/compile/testdata/sync/definitions/039_augment_closed_optionals.txtar +++ b/internal/core/compile/testdata/sync/definitions/039_augment_closed_optionals.txtar @@ -8,14 +8,15 @@ #C: { #A & #B {[=~"^Q*$"]: int} -} @test(allows, moo) @test(allows, Qoo) @test(allows=false, string) +} + // TODO: What should this be? @test(allows=false, zoo) -c: #C & {QQ: 3} @test(eq, {QQ: 3}) +c: #C & {QQ: 3} #D: { #A #B } -d: #D & {aaa: 4} @test(eq, {aaa: 4}) +d: #D & {aaa: 4} -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/definitions/comprehensions.txtar b/internal/core/compile/testdata/sync/definitions/comprehensions.txtar index 1232b9b67..76be85dd3 100644 --- a/internal/core/compile/testdata/sync/definitions/comprehensions.txtar +++ b/internal/core/compile/testdata/sync/definitions/comprehensions.txtar @@ -12,7 +12,6 @@ issue595: { for cfg in #cfgs { files: cfg.nam } - @test(err, code=eval, at=files, contains="undefined field: nam", pos=[8:14]) } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/definitions/defembed.txtar b/internal/core/compile/testdata/sync/definitions/defembed.txtar index 02e5540b5..6343e6741 100644 --- a/internal/core/compile/testdata/sync/definitions/defembed.txtar +++ b/internal/core/compile/testdata/sync/definitions/defembed.txtar @@ -3,22 +3,15 @@ a: { #A } -a: c: 1 @test(err, code=eval, contains="field not allowed", pos=[0:4]) +a: c: 1 #A: b: 1 b: { #A - leaf: "leaf value" - interpolation: "more \(leaf_ref)" - leaf_ref: leaf - - @test(eq, { - b: 1 - leaf: "leaf value" - interpolation: "more leaf value" - leaf_ref: "leaf value" - }) + leaf: "leaf value" + interpolation: "more \(leaf_ref)" + leaf_ref: leaf } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/definitions/dynamic.txtar b/internal/core/compile/testdata/sync/definitions/dynamic.txtar index 8dca6a3ae..736b8d738 100644 --- a/internal/core/compile/testdata/sync/definitions/dynamic.txtar +++ b/internal/core/compile/testdata/sync/definitions/dynamic.txtar @@ -2,45 +2,25 @@ #A: { a: "foo" "\(a)": 3 - - @test(eq, { - a: "foo" - foo: 3 - }) } #B: a: b: { c: string d: 2 -} @test(eq, { - c: string - d: 2 -}) +} #C: a: b: { - c: *"d" | string + c: *"d" | string (c): 2 -} @test(eq, { - c: *"d" | string - d: 2 -}) - -x: #B & #C @test(eq, { - a: b: { - c: *"d" | string - d: 2 - } -}) +} +x: #B & #C -- evalv3regress.cue -- chained: x: { // TODO: add this once the todo is fixed. // @test(permute) - (a.b): "foo" + (a.b): "foo" (x.hello): "true" a: b: "hello" - - @test(eq, {a: b: "hello", hello: "foo"}, incorrect, hint="shouldn't foo be in here?") - @test(eq:todo, {a: b: "hello", hello: "foo", foo: "true"}) } -- out/compile -- --- evalv3regress.cue diff --git a/internal/core/compile/testdata/sync/definitions/embed.txtar b/internal/core/compile/testdata/sync/definitions/embed.txtar index b26869efc..c5db8f8cf 100644 --- a/internal/core/compile/testdata/sync/definitions/embed.txtar +++ b/internal/core/compile/testdata/sync/definitions/embed.txtar @@ -3,11 +3,6 @@ deployment: [string]: #Deployment deployment: foo: spec: replicas: 1 -@test(eq, { - [string]: spec: replicas: int - foo: spec: replicas: 1 -}, at=deployment) - #Deployment: { #TypeMeta @@ -20,7 +15,7 @@ deployment: foo: spec: replicas: 1 recloseSimple: { #foo: {} - a: {#foo} & {b: int} @test(err, at=b, code=eval, contains="field not allowed", pos=[0:15]) + a: {#foo} & {b: int} } // Reclosing @@ -37,7 +32,7 @@ reclose1: { } z: #a.b - z: d: 3 @test(err, code=eval, contains="field not allowed", pos=[0:5]) + z: d: 3 } reclose2: { @@ -52,7 +47,7 @@ reclose2: { } } - z: a.b @test(eq, { c: int, d: 3 }) + z: a.b z: d: 3 } @@ -76,7 +71,7 @@ reclose3: { x: #A & { Name: "a" Something: 4 - } @test(eq, {Name: "a", Something: 4}) + } } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/definitions/exclude.txtar b/internal/core/compile/testdata/sync/definitions/exclude.txtar index bdead3fd9..a9a0ada2d 100644 --- a/internal/core/compile/testdata/sync/definitions/exclude.txtar +++ b/internal/core/compile/testdata/sync/definitions/exclude.txtar @@ -3,65 +3,37 @@ package p excludeLet: { // Two lets with the same name should not unify and checked by definition. - #D: { let X = {}, #foo: X, f: _ } + #D: { let X = {}, #foo: X, f: _} a: #D - a: { let X = { a: 1 }, f: X } @test(debugCheck, """ - (#struct){ - let X#2 = (struct){ - a: (int){ 1 } - } - f: (#struct){ - a: (int){ 1 } - } - let X#1 = (#struct){ - } - #foo: (#struct){ - } - } - """) - - @test(eq, { - #D: { - #foo: {} - f: _ - } - a: { - #foo: {} - f: a: 1 - } - }) + a: { let X = {a: 1}, f: X} } definition: { // Check a definition only if it s contained withing a definition. err1: { - #D: { #foo: a: int } + #D: {#foo: a: int} a: #D - a: { #foo: b: int @test(err, code=eval, contains="field not allowed", pos=[0:14]) } + a: {#foo: b: int} } ok1: { #D: {} a: #D - a: { #foo: b: int } - @test(eq, { - #D: {} - a: #foo: b: int - }) + a: {#foo: b: int} } } hidden: { // Check a hidden field only if it s contained withing a definition. err1: { - #D: { _foo: a: int } + #D: {_foo: a: int} a: #D - a: { _foo: b: int } @test(err, code=eval, at=_foo$p, contains="field not allowed", pos=[0:14]) + a: {_foo: b: int} } ok1: { #D: {} a: #D - a: { _foo: b: int } - } @test(eq, {#D: {}, a: {_foo$p: {b: int}}}) + a: {_foo: b: int} + } } -- regress.cue -- package p @@ -70,11 +42,11 @@ import "encoding/json" definition: ok2: { #Tree: { - #Leaf: leaf: string + #Leaf: leaf: string #Branch: branch?: #Leaf root: #Branch } - out: json.Marshal(#Tree & {root: {}}) @test(eq, #"{"root":{}}"#) + out: json.Marshal(#Tree & {root: {}}) } hidden: ok2: { @@ -83,17 +55,10 @@ hidden: ok2: { run: "foo bar" } } - #Workflow: { - } + #Workflow: {} #step: matchN(1, [{ "run"!: _ }]) - - @test(eq, { - out: _hidden$p: run: "foo bar" - #Workflow: {} - #step: matchN(1, [{ run!: _ }]) - }) } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/definitions/explicitopen.txtar b/internal/core/compile/testdata/sync/definitions/explicitopen.txtar index 089879954..880325504 100644 --- a/internal/core/compile/testdata/sync/definitions/explicitopen.txtar +++ b/internal/core/compile/testdata/sync/definitions/explicitopen.txtar @@ -9,7 +9,6 @@ language: version: "v0.15.0" -- old.cue -- package foo -@test(shareID=AOpen2, at=#A) #A: a: 1 Old1: { { @@ -26,70 +25,68 @@ Old1: { } useNewClosed1: { - t1: err: NewClosed1 & {c: 3} @test(err, code=eval, contains="field not allowed", pos=[0:25]) - t2: ok: {NewClosed1, c: 3} @test(eq, { a: 1, c: 3 }) + t1: err: NewClosed1 & {c: 3} + t2: ok: {NewClosed1, c: 3} } useNewClosed2: { - t1: err: #NewClosed2 & {c: 3} @test(err, code=eval, contains="field not allowed", pos=[0:26]) - t2: ok: {#NewClosed2, c: 3} @test(eq, { a: 1, b: 1, c: 3 }) + t1: err: #NewClosed2 & {c: 3} + t2: ok: {#NewClosed2, c: 3} } useNewOpen1: { - t1: ok: NewOpen1 & {c: 3} @test(eq, { a: 1, b: 1, c: 3 }) - t2: ok: {NewOpen1, c: 3} @test(eq, { a: 1, b: 1, c: 3 }) + t1: ok: NewOpen1 & {c: 3} + t2: ok: {NewOpen1, c: 3} } useNewOpen2: { - t1: ok: NewOpen2 & {c: 3} @test(eq, { a: 1, c: 3 }) - t2: ok: {NewOpen2, c: 3} @test(eq, { a: 1, c: 3 }) + t1: ok: NewOpen2 & {c: 3} + t2: ok: {NewOpen2, c: 3} } combineold: { // all {a: 1} - a0: ok: #A & NewClosed1 @test(eq, { a: 1 }) - a1: ok: {#A, NewClosed1} @test(eq, { a: 1 }) + a0: ok: #A & NewClosed1 + a1: ok: {#A, NewClosed1} - a2: ok: NewClosed1 & NewOpen2 @test(eq, { a: 1 }) - a3: ok: {NewClosed1, NewOpen2} @test(eq, { a: 1 }) + a2: ok: NewClosed1 & NewOpen2 + a3: ok: {NewClosed1, NewOpen2} // all {a: 1, b: 2} - b0: ok: Old1 & #NewClosed2 @test(eq, { a: 1, b: 1 }) - b1: ok: #Old2 & #NewClosed2 @test(eq, { a: 1, b: 1 }) + b0: ok: Old1 & #NewClosed2 + b1: ok: #Old2 & #NewClosed2 - c1: ok: {#NewClosed2, Old1} @test(eq, { a: 1, b: 1 }) - c2: ok: {#NewClosed2, #Old2} @test(eq, { a: 1, b: 1 }) + c1: ok: {#NewClosed2, Old1} + c2: ok: {#NewClosed2, #Old2} // {a: 1} and {a: 1, b: 2} - e0: err: #A & Old1 @test(err, code=eval, contains="field not allowed", pos=[-47:3]) - e1: err: #A & #Old2 @test(err, code=eval, contains="field not allowed", pos=[-41:3]) - e2: err: #A & #NewClosed2 @test(err, code=eval, contains="field not allowed", pos=[new.cue:12:2]) - e3: err: #A & NewOpen1 @test(err, code=eval, contains="field not allowed", pos=[new.cue:17:2]) - - e4: ok: {#A, Old1} @test(eq, { a: 1, b: 1 }) - e5: ok: {#A, #Old2} @test(eq, { a: 1, b: 1 }) - e6: ok: {#A, #NewClosed2} @test(eq, { a: 1, b: 1 }) - e7: ok: {#A, NewOpen1} @test(eq, { a: 1, b: 1 }) - - f0: err: NewClosed1 & Old1 @test(err, code=eval, contains="field not allowed", pos=[-57:3]) - f1: err: NewClosed1 & #Old2 @test(err, code=eval, contains="field not allowed", pos=[-51:3]) - f2: err: NewClosed1 & #NewClosed2 @test(err, code=eval, contains="field not allowed", pos=[new.cue:12:2]) - f3: err: NewClosed1 & NewOpen1 @test(err, code=eval, contains="field not allowed", pos=[new.cue:17:2]) - - f4: ok: {NewClosed1, Old1} @test(eq, { a: 1, b: 1 }) - f5: ok: {NewClosed1, #Old2} @test(eq, { a: 1, b: 1 }) - f6: ok: {NewClosed1, NewClosed1} @test(eq, { a: 1 }) - f7: ok: {NewClosed1, #NewClosed2} @test(eq, { a: 1, b: 1 }) - f8: ok: {NewClosed1, NewOpen1} @test(eq, { a: 1, b: 1 }) + e0: err: #A & Old1 + e1: err: #A & #Old2 + e2: err: #A & #NewClosed2 + e3: err: #A & NewOpen1 + + e4: ok: {#A, Old1} + e5: ok: {#A, #Old2} + e6: ok: {#A, #NewClosed2} + e7: ok: {#A, NewOpen1} + + f0: err: NewClosed1 & Old1 + f1: err: NewClosed1 & #Old2 + f2: err: NewClosed1 & #NewClosed2 + f3: err: NewClosed1 & NewOpen1 + + f4: ok: {NewClosed1, Old1} + f5: ok: {NewClosed1, #Old2} + f6: ok: {NewClosed1, NewClosed1} + f7: ok: {NewClosed1, #NewClosed2} + f8: ok: {NewClosed1, NewOpen1} } - -- new.cue -- @experiment(explicitopen) package foo NewClosed1: { - @test(shareID=NC1) #A } @@ -103,100 +100,101 @@ NewOpen1: { b: 1 } -NewOpen2: #A... @test(shareID=AOpen2) +NewOpen2: #A... useOld1: { - t1: err: Old1 & {c: 3} @test(err, code=eval, contains="field not allowed", pos=[0:19]) - t2: err: {Old1, c: 3} @test(err, code=eval, contains="field not allowed", pos=[0:18]) // TODO - t3: ok: {Old1..., c: 3} @test(eq, {a: 1, b: 1, c: 3}) + t1: err: Old1 & {c: 3} + t2: err: {Old1, c: 3} // TODO + t3: ok: {Old1..., c: 3} } useOld2: { - t1: err: #Old2 & {c: 3} @test(err, code=eval, contains="field not allowed", pos=[0:20]) - t2: err: {#Old2, c: 3} @test(err, code=eval, contains="field not allowed", pos=[0:19]) - t3: ok: {#Old2..., c: 3} @test(eq, {a: 1, b: 1, c: 3}) + t1: err: #Old2 & {c: 3} + t2: err: {#Old2, c: 3} + t3: ok: {#Old2..., c: 3} } combinenew: { // all {a: 1} - a0: ok: #A & NewClosed1 @test(eq, {a: 1}) - a1: ok: {#A, NewClosed1} @test(eq, {a: 1}) + a0: ok: #A & NewClosed1 + a1: ok: {#A, NewClosed1} - a2: ok: NewClosed1 & NewOpen2 @test(eq, {a: 1}) - a3: ok: {NewClosed1, NewOpen2} @test(eq, {a: 1}) - a4: ok: {NewClosed1..., NewOpen2} @test(eq, {a: 1}) + a2: ok: NewClosed1 & NewOpen2 + a3: ok: {NewClosed1, NewOpen2} + a4: ok: {NewClosed1..., NewOpen2} - a5: ok: NewOpen2 & NewClosed1 @test(eq, {a: 1}) - a6: ok: {NewOpen2, NewClosed1} @test(eq, {a: 1}) - a7: ok: {NewOpen2..., NewClosed1} @test(eq, {a: 1}) + a5: ok: NewOpen2 & NewClosed1 + a6: ok: {NewOpen2, NewClosed1} + a7: ok: {NewOpen2..., NewClosed1} // all {a: 1, b: 2} - b0: ok: Old1 & #NewClosed2 @test(eq, {a: 1, b: 1}) - b1: ok: #Old2 & #NewClosed2 @test(eq, {a: 1, b: 1}) - b2: ok: #NewClosed2 & Old1 @test(eq, {a: 1, b: 1}) - b3: ok: #NewClosed2 & #Old2 @test(eq, {a: 1, b: 1}) - - c1: ok: {#NewClosed2, Old1} @test(eq, {a: 1, b: 1}) - c2: ok: {#NewClosed2, #Old2} @test(eq, {a: 1, b: 1}) - c3: ok: {Old1, #NewClosed2} @test(eq, {a: 1, b: 1}) - c4: ok: {#Old2, #NewClosed2} @test(eq, {a: 1, b: 1}) - - d0: ok: {#NewClosed2, Old1...} @test(eq, {a: 1, b: 1}) - d1: ok: {#NewClosed2, #Old2...} @test(eq, {a: 1, b: 1}) - d2: ok: {#NewClosed2..., Old1} @test(eq, {a: 1, b: 1}) - d3: ok: {#NewClosed2..., #Old2} @test(eq, {a: 1, b: 1}) - d4: ok: {#NewClosed2..., Old1...} @test(eq, {a: 1, b: 1}) - d5: ok: {#NewClosed2..., #Old2...} @test(eq, {a: 1, b: 1}) - - d6: ok: {Old1..., #NewClosed2} @test(eq, {a: 1, b: 1}) - d7: ok: {#Old2..., #NewClosed2} @test(eq, {a: 1, b: 1}) - d8: ok: {Old1, #NewClosed2...,} @test(eq, {a: 1, b: 1}) - d9: ok: {#Old2, #NewClosed2...,} @test(eq, {a: 1, b: 1}) - d10: ok: {Old1..., #NewClosed2...,} @test(eq, {a: 1, b: 1}) - d11: ok: {#Old2..., #NewClosed2...,} @test(eq, {a: 1, b: 1}) + b0: ok: Old1 & #NewClosed2 + b1: ok: #Old2 & #NewClosed2 + b2: ok: #NewClosed2 & Old1 + b3: ok: #NewClosed2 & #Old2 + + c1: ok: {#NewClosed2, Old1} + c2: ok: {#NewClosed2, #Old2} + c3: ok: {Old1, #NewClosed2} + c4: ok: {#Old2, #NewClosed2} + + d0: ok: {#NewClosed2, Old1...} + d1: ok: {#NewClosed2, #Old2...} + d2: ok: {#NewClosed2..., Old1} + d3: ok: {#NewClosed2..., #Old2} + d4: ok: {#NewClosed2..., Old1...} + d5: ok: {#NewClosed2..., #Old2...} + + d6: ok: {Old1..., #NewClosed2} + d7: ok: {#Old2..., #NewClosed2} + d8: ok: {Old1, #NewClosed2...} + d9: ok: {#Old2, #NewClosed2...} + d10: ok: {Old1..., #NewClosed2...} + d11: ok: {#Old2..., #NewClosed2...} // {a: 1} and {a: 1, b: 2} - e0: err: #A & Old1 @test(err, code=eval, contains="field not allowed", pos=[old.cue:8:3]) - e1: err: #A & #Old2 @test(err, code=eval, contains="field not allowed", pos=[old.cue:15:3]) - e2: err: #A & #NewClosed2 @test(err, code=eval, contains="field not allowed", pos=[-63:2]) - e3: err: #A & NewOpen1 @test(err, code=eval, contains="field not allowed", pos=[-59:2]) - - e4: err: {#A, Old1} @test(err, code=eval, contains="field not allowed", pos=[old.cue:8:3]) - e5: err: {#A, #Old2} @test(err, code=eval, contains="field not allowed", pos=[old.cue:15:3]) - e6: err: {#A, #NewClosed2} @test(err, code=eval, contains="field not allowed", pos=[-68:2]) - e7: err: {#A, NewOpen1} @test(err, code=eval, contains="field not allowed", pos=[-64:2]) - - e8: ok: {#A..., Old1} @test(eq, {a: 1, b: 1}) - e9: ok: {#A..., #Old2} @test(eq, {a: 1, b: 1}) - e10: ok: {#A..., #NewClosed2} @test(eq, {a: 1, b: 1}) - e11: ok: {#A..., NewOpen1} @test(eq, {a: 1, b: 1}) - - f0: err: NewClosed1 & Old1 @test(err, code=eval, contains="field not allowed", pos=[old.cue:8:3]) - f1: err: NewClosed1 & #Old2 @test(err, code=eval, contains="field not allowed", pos=[old.cue:15:3]) - f2: err: NewClosed1 & #NewClosed2 @test(err, code=eval, contains="field not allowed", pos=[-78:2]) - f3: err: NewClosed1 & NewOpen1 @test(err, code=eval, contains="field not allowed", pos=[-74:2]) - f4: ok: NewClosed1 & NewClosed1 @test(eq, {a: 1}) @test(shareID=NC1) - - f5: err: {NewClosed1, Old1} @test(err, code=eval, contains="field not allowed", pos=[old.cue:8:3]) - f6: err: {NewClosed1, #Old2} @test(err, code=eval, contains="field not allowed", pos=[old.cue:15:3]) - f7: err: {NewClosed1, #NewClosed2} @test(err, code=eval, contains="field not allowed", pos=[-84:2]) - f8: err: {NewClosed1, NewOpen1} @test(err, code=eval, contains="field not allowed", pos=[-80:2]) - f9: ok: {NewClosed1, NewClosed1} @test(err) - - f9: ok: {NewClosed1..., Old1} @test(err, code=eval, contains="field not allowed", pos=[old.cue:8:3], hint="see todo") - f10: ok: {NewClosed1..., #Old2} @test(eq, {a: 1, b: 1}) - f11: ok: {NewClosed1..., NewClosed1} @test(eq, {a: 1}) - f12: ok: {NewClosed1..., #NewClosed2} @test(eq, {a: 1, b: 1}) - f13: ok: {NewClosed1..., NewOpen1} @test(eq, {a: 1, b: 1}) - - f14: err: Old1 & NewClosed1 @test(eq, {a: 1, b: 1}, hint="see todo") - f15: err: #Old2 & NewClosed1 @test(eq, {a: 1, b: 1}, hint="see todo") - f16: err: #NewClosed2 & NewClosed1 @test(err, code=eval, contains="field not allowed", pos=[-96:2]) - f17: err: NewOpen1 & NewClosed1 @test(err, code=eval, contains="field not allowed", pos=[-92:2]) - f18: ok: NewClosed1 & NewClosed1 @test(eq, {a: 1}) @test(shareID=NC1) + e0: err: #A & Old1 + e1: err: #A & #Old2 + e2: err: #A & #NewClosed2 + e3: err: #A & NewOpen1 + + e4: err: {#A, Old1} + e5: err: {#A, #Old2} + e6: err: {#A, #NewClosed2} + e7: err: {#A, NewOpen1} + + e8: ok: {#A..., Old1} + e9: ok: {#A..., #Old2} + e10: ok: {#A..., #NewClosed2} + e11: ok: {#A..., NewOpen1} + + f0: err: NewClosed1 & Old1 + f1: err: NewClosed1 & #Old2 + f2: err: NewClosed1 & #NewClosed2 + f3: err: NewClosed1 & NewOpen1 + f4: ok: NewClosed1 & NewClosed1 + + f5: err: {NewClosed1, Old1} + f6: err: {NewClosed1, #Old2} + f7: err: {NewClosed1, #NewClosed2} + f8: err: {NewClosed1, NewOpen1} + f9: ok: {NewClosed1, NewClosed1} + + f9: ok: {NewClosed1..., Old1} + f10: ok: {NewClosed1..., #Old2} + f11: ok: {NewClosed1..., NewClosed1} + f12: ok: {NewClosed1..., #NewClosed2} + f13: ok: {NewClosed1..., NewOpen1} + + f14: err: Old1 & NewClosed1 + f15: err: #Old2 & NewClosed1 + f16: err: #NewClosed2 & NewClosed1 + f17: err: NewOpen1 & NewClosed1 + f18: ok: NewClosed1 & NewClosed1 } -- issues.cue -- @experiment(explicitopen) + // explicitopen experiment: postfix `...` spread cannot directly combine with // `&`; tests open-struct spread behavior and non-struct operand tolerance. // https://cuelang.org/issue/4150 @@ -204,13 +202,13 @@ issue4150: { #Def: a: int x: #Def... & { - a: 42 - b: 42 - } @test(eq, {a: 42, b: 42}) @test(closed) + a: 42 + b: 42 + } foo: {a: int} bar: {b: int} - y: foo... & bar... @test(eq, {a: int, b: int}) + y: foo... & bar... // NOTE: we allow this, even though it doesn't mean anything. The benefit // of this is that code doesn't become brittle using the spread operator @@ -222,7 +220,7 @@ issue4150: { // // Not allowing ... on any expression would mean #foo... may or may not be // erroneous, depending on the value foo is set to. - z: 1... @test(eq, 1) + z: 1... } -- out/compile -- --- issues.cue diff --git a/internal/core/compile/testdata/sync/definitions/fields.txtar b/internal/core/compile/testdata/sync/definitions/fields.txtar index 3444974f2..720dad968 100644 --- a/internal/core/compile/testdata/sync/definitions/fields.txtar +++ b/internal/core/compile/testdata/sync/definitions/fields.txtar @@ -7,53 +7,29 @@ ok: t1: { c: #R - c: [{b: int}] @test(allows=false, int) - #R: [...] @test(allows, int) - - @test(eq, { - c: [{b: int}] - #R: [] - }) + c: [{b: int}] + #R: [...] } ok: t2: { #A: _ - l: #A + l: #A l: f: "hi" - - @test(eq, { - #A: _ - l: f: "hi" - }) } ok: t3: { #A: f: {...} - #A1: { #A } + #A1: {#A} s: [string]: #A1 s: foo: f: d: foo: 1 - - @test(eq, { - #A: f: {} - #A1: f: {} - s: foo: f: d: foo: 1 - }) } ok: t4: { - #T: { a: b: 1 } + #T: {a: b: 1} W: { {#T} b: c: 2 } - - @test(eq, { - #T: a: b: 1 - W: { - a: b: 1 - b: c: 2 - } - }) } ok: t5: { @@ -62,11 +38,9 @@ ok: t5: { Common _ } - Common: { } + Common: {} x: #A - x: c: int @test(err, code=eval, - hint="not sure if this is actually correct", - contains="field not allowed", pos=[0:5]) + x: c: int } ok: t6: { @@ -74,37 +48,21 @@ ok: t6: { Common ... } - Common: { } - x: #A @test(allows, string) + Common: {} + x: #A x: c: int - - @test(eq, { - #A: {} - Common: {} - x: c: int - }) } ok: t7: { a: {#A, #B} #A: b: f: 1 #B: b: g: 1 - - @test(eq, { - a: b: { - f: 1 - g: 1 - } - #A: b: f: 1 - #B: b: g: 1 - }) } ok: t8: { // TODO: this should pass - foo: #X @test(shareID=ok_t8_foox) + foo: #X #X: { - @test(shareID=ok_t8_foox) a: b: c: C: 1 for k, _ in a { @@ -113,72 +71,35 @@ ok: t8: { a: (k): c: D: 2 } } - - @test(eq, { - foo: a: b: c: { - C: 1 - D: 2 - } - #X: a: b: c: { - C: 1 - D: 2 - } - }) } ok: t9: { c: #R c: [{b: int}] #R: [...] - - @test(eq, { - c: [{ - b: int - }] - #R: [] - }) } ok: t10: { #A: _ // top should allow everything - l: #A + l: #A l: f: "hi" - - @test(eq, { - #A: _ - l: f: "hi" - }) } ok: t11: { // indirections #A: f: {...} - #A1: { #A } + #A1: {#A} s: [string]: #A1 s: foo: f: d: foo: "bar" // should pass - - @test(eq, { - #A: f: {} - #A1: f: {} - s: foo: f: d: foo: "bar" - }) } ok: t12: { // nested embedding - #T: { a: b: 1 } + #T: {a: b: 1} W: { {#T} b: c: 2 } - - @test(eq, { - #T: { a: b: 1 } - W: { - a: b: 1 - b: c: 2 - } - }) } ok: t13: { @@ -189,15 +110,9 @@ ok: t13: { Common _ } - Common: { } + Common: {} x: #A - x: c: int @test(err, code=eval, contains="field not allowed", pos=[0:5]) - - @test(eq, { - #A: {} - Common: {} - x: c: _|_ - }) + x: c: int } ok: t14: { @@ -206,15 +121,9 @@ ok: t14: { Common ... } - Common: { } + Common: {} x: #A x: c: int - - @test(eq, { - #A: {} - Common: {} - x: c: int - }) } // TODO: move this test to "ok": _ means any and implicitly defines all fields @@ -224,51 +133,45 @@ ok: t14: { // either allow for an error variant that only "allows" all fields but does not // define them as optional top, or rethink the closedness model altogether. err: t1: { - @test(permute, count=6) #D: _ & {a: 2} a: #D - a: disallowed: 1 @test(err, code=eval, contains="field not allowed", pos=[0:5]) + a: disallowed: 1 } err: t2: { - @test(permute) - #S: { { c: d: 1 } } + #S: {{c: d: 1}} V: #S - V: { c: e: 1 @test(err, code=eval, contains="field not allowed", pos=[0:10]) } + V: {c: e: 1} } err: t3: { - @test(permute) #D: {} a: #D - a: c: "C" @test(err, code=eval, contains="field not allowed", pos=[0:5]) + a: c: "C" } err: t4: { - @test(permute) a: #A #A: b: f: 1 - a: b: h: 1 @test(err, code=eval, contains="field not allowed", pos=[0:8]) + a: b: h: 1 } err: t5: { - @test(permute) // TODO: this should fail a: {#A, #B} #A: b: f: 1 #B: b: g: 1 b: a - b: b: h: 1 @test(err, code=eval, contains="field not allowed", pos=[0:8]) + b: b: h: 1 } err: t6: { - @test(permute) // TODO: this should fail a: {#A, #B} #A: b: c: d: e: f: 1 #B: b: c: d: e: g: 1 b: a - b: b: c: d: e: h: 1 @test(err, code=eval, contains="field not allowed", pos=[0:17]) + b: b: c: d: e: h: 1 } // TODO: move this test to "ok": _ means any and implicitly defines all fields @@ -278,18 +181,16 @@ err: t6: { // either allow for an error variant that only "allows" all fields but does not // define them as optional top, or rethink the closedness model altogether. err: t7: { - @test(permute) #D: _ & {a: 2} a: #D - a: b: 1 @test(err, code=eval, contains="field not allowed", pos=[0:5]) + a: b: 1 } err: t8: { - @test(permute) // nested embedding - #S: { { c: d: 1 } } + #S: {{c: d: 1}} V: #S - V: { c: e: 1 @test(err, code=eval, contains="field not allowed", pos=[0:10]) } + V: {c: e: 1} } -- validators.cue -- import "struct" @@ -306,18 +207,6 @@ validator: open: { } data: trailingComma: "all" data: #Schema - - @test(eq, { - #Schema: { - matchN(1, [{trailingComma: "all"}]) - #x: trailingComma?: "all" - } - data: { - // TODO: why is the matchN dropped here? - trailingComma: "all" - #x: trailingComma?: "all" - } - }) } validator: keepClosed: { @@ -327,7 +216,7 @@ validator: keepClosed: { b?: int } x: #X - x: c: 1 @test(err, code=eval, contains="field not allowed", pos=[-5:3, 0:5]) + x: c: 1 } -- issue1830.cue -- // Closedness was not applied when accessing optional fields through a selector; @@ -346,14 +235,11 @@ issue1830: { x1: (#x & {y: z: _}).y.z & { name: "blah" age1: 5 - } @test(closed) @test(eq, { name: "blah", age1: 5 }, incorrect) + } x2: (#x.y & {z: _}).z & { name: "blah" age2: 5 - } @test(closed) @test(eq, { name: "blah", age2: 5 }, incorrect) - - @test(err:todo, at=x1.age1, code=eval, contains="field not allowed") - @test(err:todo, at=x2.age2, code=eval, contains="field not allowed") + } } } -- issue3491.cue -- @@ -364,20 +250,11 @@ issue3491: { #Schema: field?: {} a: #Schema & { - field: {} + field: {} } a: b b: #Extra: {} - - @test(eq, { - #Schema: field?: {} - a: { - field: {} - #Extra: {} - } - b: #Extra: {} - }) } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/definitions/files.txtar b/internal/core/compile/testdata/sync/definitions/files.txtar index 549e10c43..af87e35d0 100644 --- a/internal/core/compile/testdata/sync/definitions/files.txtar +++ b/internal/core/compile/testdata/sync/definitions/files.txtar @@ -11,27 +11,22 @@ package foo dark: #theme & { color: "dark" ctermbg: "239" -} @test(eq, {color: "dark", ctermbg: "239"}) +} light: #theme & { color: "light" ctermbg: "254" -} @test(eq, {color: "light", ctermbg: "254"}) +} #Config: { console: dark | *light -} @test(eq, { - console: *{color: "light", ctermbg: "254"} | {color: "dark", ctermbg: "239"} -}) +} -- box.cue -- package foo #Config & { console: dark } - -@test(eq, {color: "dark", ctermbg: "239"}, at=console) - -- out/compile -- --- box.cue { diff --git a/internal/core/compile/testdata/sync/definitions/hidden.txtar b/internal/core/compile/testdata/sync/definitions/hidden.txtar index dd8d9b241..edfbcbf05 100644 --- a/internal/core/compile/testdata/sync/definitions/hidden.txtar +++ b/internal/core/compile/testdata/sync/definitions/hidden.txtar @@ -22,20 +22,11 @@ e: pkg.#D & #def & { // This should not fail, as this is a different _val _val: g: int -} @test(err, code=eval, at=_name$foo.c, contains="field not allowed", pos=[3:9]) +} -f: pkg.#D & {_val: f: 4} @test(debugCheck, """ - (#struct){ - _val(:foo): (struct){ - f: (int){ 4 } - } - _val(mod.test/pkg): (#struct){ - f: (int){ 3 } - } - } - """) +f: pkg.#D & {_val: f: 4} -g: f._val @test(eq, {f: 4}) +g: f._val -- pkg/bar.cue -- package pkg diff --git a/internal/core/compile/testdata/sync/definitions/issue271.txtar b/internal/core/compile/testdata/sync/definitions/issue271.txtar index a87b33597..4945944ed 100644 --- a/internal/core/compile/testdata/sync/definitions/issue271.txtar +++ b/internal/core/compile/testdata/sync/definitions/issue271.txtar @@ -5,10 +5,10 @@ -- in.cue -- #T: [_]: _ #T: close({"a": string}) -x: #T +x: #T x: { - a: "hello" @test(eq, "hello") - b: "foo" @test(err, code=eval, contains="field not allowed", pos=[-5:5, 0:2]) + a: "hello" + b: "foo" } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/definitions/issue317.txtar b/internal/core/compile/testdata/sync/definitions/issue317.txtar index 51a853472..586f53d68 100644 --- a/internal/core/compile/testdata/sync/definitions/issue317.txtar +++ b/internal/core/compile/testdata/sync/definitions/issue317.txtar @@ -17,16 +17,7 @@ s: #T & { foo: otherField: string } concrete: foo: otherField: "hello" -} @test(closed) @test(eq, { - #Schema: foo: { - fieldWithDefault: *0 | int - otherField: string - } - concrete: foo: { - fieldWithDefault: *0 | int - otherField: "hello" - } -}) +} #Container: { Env: [Name=string]: { name: string @@ -44,20 +35,7 @@ Something: { "a thing": Env: foobar: value: "foo" } } -x: Something & #Deployment @test(closed) @test(eq, { - #Containers: { - "a thing": Env: foobar: { - value: "foo" - name: string - } - } - containers: [{ - Env: foobar: { - name: string - value: "foo" - } - }] -}) +x: Something & #Deployment -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/definitions/issue320.txtar b/internal/core/compile/testdata/sync/definitions/issue320.txtar index 94a32c67f..ad013135b 100644 --- a/internal/core/compile/testdata/sync/definitions/issue320.txtar +++ b/internal/core/compile/testdata/sync/definitions/issue320.txtar @@ -13,10 +13,7 @@ foo: #Foo & { x: "hello" y: "goodbye" -} @test(err, at=y, code=eval, - hint="could use more positions, like in v2", - contains="field not allowed", - pos=[in.cue:10:2]) +} -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/definitions/issue342.txtar b/internal/core/compile/testdata/sync/definitions/issue342.txtar index d6b09d3e7..457977ec1 100644 --- a/internal/core/compile/testdata/sync/definitions/issue342.txtar +++ b/internal/core/compile/testdata/sync/definitions/issue342.txtar @@ -5,7 +5,7 @@ X: { #Simple: { ref: string - } @test(shareID=SIMPLE) + } #Complex: { { @@ -13,31 +13,23 @@ X: { } | { local: string } - } @test(eq, {ref: string} | {local: string}) @test(shareID=COMPLEX) - + } var: "bar" // Validate(concrete) after Fill() on Complex.ref from a "static" key will succeed - "test_1": #Complex @test(shareID=COMPLEX) @test(eq, { - ref: string - } | { - local: string - }) + "test_1": #Complex // Validate(concrete) after Fill() on "#Simple.ref" from a "dynamic" key will succeed "test_2_\(var)": #Simple - @test(shareID=SIMPLE, at=test_2_bar) - @test(eq, at=test_2_bar, { ref: string }) // Validate(concrete) after Fill() on Complex.ref from a "dynamic" key will fail "test_3_\(var)": #Complex test_3_bar: ref: "FOO" - @test(eq, at=test_3_bar, { ref: "FOO" }) } -Z: X.test_3_bar.ref @test(eq, "FOO") +Z: X.test_3_bar.ref -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/definitions/issue359.txtar b/internal/core/compile/testdata/sync/definitions/issue359.txtar index 98dce7df6..9b84c327c 100644 --- a/internal/core/compile/testdata/sync/definitions/issue359.txtar +++ b/internal/core/compile/testdata/sync/definitions/issue359.txtar @@ -10,7 +10,7 @@ // Second struct is not considered closed, as expected good: #simple & { peso: 4 -} @test(eq, {peso: 4, edad: *2 | int}) +} #complex: { things: [string]: #simple @@ -20,67 +20,23 @@ good: #simple & { #many: #complex & { things: hola: peso: 2 things: sol: peso: 3 -} @test(eq, { - things: { - hola: { - peso: 2 - edad: *2 | int - } - sol: { - peso: 3 - edad: *2 | int - } - } -}) +} // Inner struct in second struct IS considered closed: why? bad: #many & { things: hola: peso: 2 -} @test(eq, { - things: { - hola: { - peso: 2 - edad: *2 | int - } - sol: { - peso: 3 - edad: *2 | int - } - } -}) +} // non-definition equivalent many: #complex & { things: hola: peso: 2 things: sol: peso: 3 -} @test(eq, { - things: { - hola: { - peso: 2 - edad: *2 | int - } - sol: { - peso: 3 - edad: *2 | int - } - } -}) +} // Now inner struct on second struct is NOT considered closed notbad: many & { things: hola: peso: 2 -} @test(eq, { - things: { - hola: { - peso: 2 - edad: *2 | int - } - sol: { - peso: 3 - edad: *2 | int - } - } -}) +} -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/definitions/issue367.txtar b/internal/core/compile/testdata/sync/definitions/issue367.txtar index 6f870ee7c..45b5b13ce 100644 --- a/internal/core/compile/testdata/sync/definitions/issue367.txtar +++ b/internal/core/compile/testdata/sync/definitions/issue367.txtar @@ -1,12 +1,7 @@ -- in.cue -- #def1: l1: ["l2"]: {l3: int, l4: 26} -#special1: #def1 & {l1: l2: l3: <100} @test(eq, { - l1: l2: { - l3: int & <100 - l4: 26 - } -}) -instance: #special1 & {l1: l2: l3: 34} @test(eq, {l1: {l2: {l3: 34, l4: 26}}}) +#special1: #def1 & {l1: l2: l3: <100} +instance: #special1 & {l1: l2: l3: 34} -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/definitions/issue370.txtar b/internal/core/compile/testdata/sync/definitions/issue370.txtar index 09e783f1a..25386619d 100644 --- a/internal/core/compile/testdata/sync/definitions/issue370.txtar +++ b/internal/core/compile/testdata/sync/definitions/issue370.txtar @@ -15,12 +15,12 @@ package x c1: #C1 & { name: "cueckoo" -} @test(eq, {name: "cueckoo"}) +} c2: #C2 & { c1 age: 5 -} @test(eq, {age: 5, name: "cueckoo"}) +} -- out/compile -- --- x.cue { diff --git a/internal/core/compile/testdata/sync/definitions/issue3834.txtar b/internal/core/compile/testdata/sync/definitions/issue3834.txtar index 06ec9472d..c4a3a2596 100644 --- a/internal/core/compile/testdata/sync/definitions/issue3834.txtar +++ b/internal/core/compile/testdata/sync/definitions/issue3834.txtar @@ -9,26 +9,10 @@ X: { _a: _ | close({y!: z?: _}) _b: _a & {y: {}} concrete: _b.y - isTrue: concrete != _|_ @test(eq, true) + isTrue: concrete != _|_ } {X} -@test(eq, { - X: { - _a: {foo: true} - _b: {y: {}, foo: true} - concrete: {} - isTrue: true - } - _a: {foo: true} - _b: {y: {}, foo: true} - concrete: {} - isTrue: true - - sub: _ @test(ignore) - full: _ @test(ignore) -}) - sub: t1: { X: { _a: foo: true @@ -37,91 +21,33 @@ sub: t1: { concrete: _b.y } {X} - - @test(eq, { - X: { - _a: {foo: true} - _b: {y: {}, foo: true} - concrete: {} - } - _a: {foo: true} - _b: {y: {}, foo: true} - concrete: {} - }) } sub: t2: { X: { _a: foo: true _a: _ | close({y!: z?: _}) _b: _a & {y: {}} - concrete: _b.y @test(eq, {}) + concrete: _b.y } X - - @test(eq, { - X: { - _a: {foo: true} - _b: {y: {}, foo: true} - concrete: {} - } - _a: {foo: true} - _b: {y: {}, foo: true} - concrete: {} - }) } sub: t3: { #X: { _a: foo: true _a: _ | close({y!: z?: _}) _b: _a & {y: {}} - concrete: _b.y @test(eq, {}) + concrete: _b.y } {#X} - - @test(eq, { - #X: { - _a: {foo: true} - _b: {y: {}, foo: true} - concrete: {} - } - _a: {foo: true} - _b: {y: {}, foo: true} - concrete: {} - }) } sub: t4: { #X: { _a: foo: true _a: _ | close({y!: z?: _}) _b: _a & {y: {}} - concrete: _b.y @test(eq, {}) - @test(debug, """ - (#struct){ - _a: (#struct){ - foo: (bool){ true } - } - _b: (#struct){ - y: (#struct){ - } - foo: (bool){ true } - } - concrete: (#struct){ - } - } - """) + concrete: _b.y } #X - - @test(eq, { - #X: { - _a: {foo: true} - _b: {y: {}, foo: true} - concrete: {} - } - _a: {foo: true} - _b: {y: {}, foo: true} - concrete: {} - }) } full: { @@ -131,21 +57,10 @@ full: { _dataWithExtra: _data & {Extra: {}} - out: _dataWithExtra.Extra != _|_ @test(eq, true) + out: _dataWithExtra.Extra != _|_ } {#Foo} - - @test(eq, { - #Foo: { - _data: {Foo: true} - _dataWithExtra: {Extra: {}, Foo: true} - out: true - } - _data: {Foo: true} - _dataWithExtra: {Extra: {}, Foo: true} - out: true - }) } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/definitions/issue3851.txtar b/internal/core/compile/testdata/sync/definitions/issue3851.txtar index a0e0f71c6..eb5eec3ec 100644 --- a/internal/core/compile/testdata/sync/definitions/issue3851.txtar +++ b/internal/core/compile/testdata/sync/definitions/issue3851.txtar @@ -6,7 +6,7 @@ name?: string sub1?: sub2?: null | _ } -#Output: null | #App @test(eq, null | {name?: string, sub1?: {sub2?: null | _}}) +#Output: null | #App out: #Output & { name: "foo" sub1: sub2: {} | _ @@ -16,7 +16,7 @@ out: #Output & { foo: _let } } -} @test(eq, {name: "foo", sub1: {sub2: {sub3: {foo: "bar"}}}}) +} -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/definitions/issue4000.txtar b/internal/core/compile/testdata/sync/definitions/issue4000.txtar index 193369e69..e3d177792 100644 --- a/internal/core/compile/testdata/sync/definitions/issue4000.txtar +++ b/internal/core/compile/testdata/sync/definitions/issue4000.txtar @@ -4,32 +4,15 @@ import "list" items: list.Sort(#List.items, { - x: {} - y: {} + x: {} + y: {} less: x.kind < y.kind -}) @test(eq, [{ - spec: [{rules: [{expr: "x"}]}] - kind: *"default" | string - - @test(shareID=L0) - },{ - spec: [{rules: [{expr: "y"}]}] - kind: *"default" | string - - @test(shareID=L1) - }] -) +}) #List: items: list.Concat(_items) _items: [#VMRuleList] -// This is an alternative way of writing sharing. -@test(shareID=L0, at=items.0) -@test(shareID=L1, at=items.1) -@test(shareID=L0, at=#VMRuleList.0) -@test(shareID=L1, at=#VMRuleList.1) - #VMRuleList: [...null | #VMRule] & [{ spec: [{ rules: [{expr: "x"}] @@ -38,29 +21,11 @@ _items: [#VMRuleList] spec: [{ rules: [{expr: "y"}] }] -}] @test(eq, [{ - @test(shareID=L0) - - kind: *"default" | string - spec: [{ - rules: [{ - expr: "x" - }] - }] -}, { - @test(shareID=L1) - - kind: *"default" | string - spec: [{ - rules: [{ - expr: "y" - }] - }] -}]) +}] #RuleGroup: rules: [...#Rule] -#Rule: expr: string @test(eq, string) +#Rule: expr: string #VMRule: { #TypeMeta diff --git a/internal/core/compile/testdata/sync/definitions/issue419.txtar b/internal/core/compile/testdata/sync/definitions/issue419.txtar index 7ab628bc4..c780248ad 100644 --- a/internal/core/compile/testdata/sync/definitions/issue419.txtar +++ b/internal/core/compile/testdata/sync/definitions/issue419.txtar @@ -17,13 +17,6 @@ l: [...#X] l: [ {b: "bar"}, ] - -@test(eq, { - #A: {a: string} - #B: {b: string} - #X: {a: string} | {b: string} - l: [{ b: "bar" }] -}) -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/definitions/issue471.txtar b/internal/core/compile/testdata/sync/definitions/issue471.txtar index 39cb9ae4c..eb540b469 100644 --- a/internal/core/compile/testdata/sync/definitions/issue471.txtar +++ b/internal/core/compile/testdata/sync/definitions/issue471.txtar @@ -25,14 +25,6 @@ package x name: string address: string } - -@test(eq, { - #a: {name: string, age: int} | {name: string, address: string} - #a1: {name: string, age: int} - #a2: {name: string, address: string} - #c: {name: string, age: int} - #d: {name: string, address: string} -}) -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/definitions/issue483.txtar b/internal/core/compile/testdata/sync/definitions/issue483.txtar index 42a4c1b4e..833d2e4af 100644 --- a/internal/core/compile/testdata/sync/definitions/issue483.txtar +++ b/internal/core/compile/testdata/sync/definitions/issue483.txtar @@ -4,11 +4,11 @@ -- in.cue -- out: { instance -} @test(eq, {alpha: bravo: charlie: true}) +} instance: #Type & { alpha: bravo: charlie: true -} @test(eq, {alpha: bravo: charlie: true}) +} #Type: #Root & { alpha?: bravo?: charlie?: bool diff --git a/internal/core/compile/testdata/sync/definitions/issue491.txtar b/internal/core/compile/testdata/sync/definitions/issue491.txtar index c30a512f7..0ab4d7967 100644 --- a/internal/core/compile/testdata/sync/definitions/issue491.txtar +++ b/internal/core/compile/testdata/sync/definitions/issue491.txtar @@ -24,11 +24,11 @@ package x x: [...#Repo] x: [{ Var: "REPO1" -}] @test(eq, [{Var: "REPO1", Pattern: *"*" | string}]) +}] y: #Repo & { Var: "REPO1" -} @test(eq, {Var: "REPO1", Pattern: *"*" | string}) +} z: #PrestepNewUser & { Args: { @@ -36,7 +36,7 @@ z: #PrestepNewUser & { Var: "REPO1" }] } -} @test(eq, {Args: {Repos: [{Var: "REPO1", Pattern: *"*" | string}]}}) +} -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/definitions/issue493.txtar b/internal/core/compile/testdata/sync/definitions/issue493.txtar index 2f22748ef..a68bb615e 100644 --- a/internal/core/compile/testdata/sync/definitions/issue493.txtar +++ b/internal/core/compile/testdata/sync/definitions/issue493.txtar @@ -5,14 +5,14 @@ #Artifact: { body: _ other: [string]: int -} @test(shareID=appAtom) +} -#App: #Artifact @test(shareID=appAtom) -#Atom: #Artifact @test(shareID=appAtom) +#App: #Artifact +#Atom: #Artifact #Both: #App | #Atom -t1: #Both & {body: 3} @test(eq, {body: 3, other: {}}) +t1: #Both & {body: 3} -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/definitions/issue496.txtar b/internal/core/compile/testdata/sync/definitions/issue496.txtar index 307a2c519..ed6266e5e 100644 --- a/internal/core/compile/testdata/sync/definitions/issue496.txtar +++ b/internal/core/compile/testdata/sync/definitions/issue496.txtar @@ -8,9 +8,9 @@ _E: { name: "hello" } -} @test(shareID=lN) +} -l: #N @test(shareID=lN) +l: #N -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/definitions/issue497.txtar b/internal/core/compile/testdata/sync/definitions/issue497.txtar index 08336fdf2..b9d1457a4 100644 --- a/internal/core/compile/testdata/sync/definitions/issue497.txtar +++ b/internal/core/compile/testdata/sync/definitions/issue497.txtar @@ -8,9 +8,9 @@ f: j: { n: "hi" } -} @test(shareID=lN) @test(eq, {f: {j: {n: "hi"}}}) +} -l: #N @test(shareID=lN) +l: #N -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/definitions/issue533.txtar b/internal/core/compile/testdata/sync/definitions/issue533.txtar index 64523bee1..9f19779d7 100644 --- a/internal/core/compile/testdata/sync/definitions/issue533.txtar +++ b/internal/core/compile/testdata/sync/definitions/issue533.txtar @@ -15,12 +15,12 @@ _#x: { x1: #x & { Name: "hello" Age: 50 -} @test(err, code=eval, at=Age, contains="field not allowed", pos=[2:2]) +} x2: _#x & { Name: "hello" Age: 50 -} @test(err, code=eval, at=Age, contains="field not allowed", pos=[2:2]) +} -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/definitions/issue539.txtar b/internal/core/compile/testdata/sync/definitions/issue539.txtar index 0dd6b797e..0733d98b0 100644 --- a/internal/core/compile/testdata/sync/definitions/issue539.txtar +++ b/internal/core/compile/testdata/sync/definitions/issue539.txtar @@ -14,10 +14,7 @@ Component: { } } -hello: #Schema & Component @test(closed) @test(eq, { - hostname: *"localhost" | string - _#foo: {hello: "world"} -}) +hello: #Schema & Component -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/definitions/list.txtar b/internal/core/compile/testdata/sync/definitions/list.txtar index 55ac34c5b..f821a3ba7 100644 --- a/internal/core/compile/testdata/sync/definitions/list.txtar +++ b/internal/core/compile/testdata/sync/definitions/list.txtar @@ -1,7 +1,7 @@ -- in.cue -- c: #R & { w: [{}, {b: int}] -} @test(eq, {w: [{}, {b: int}]}) +} #R: { w: [{}, ...] } diff --git a/internal/core/compile/testdata/sync/definitions/root1.txtar b/internal/core/compile/testdata/sync/definitions/root1.txtar index 72e79b3c4..974765ce7 100644 --- a/internal/core/compile/testdata/sync/definitions/root1.txtar +++ b/internal/core/compile/testdata/sync/definitions/root1.txtar @@ -2,13 +2,7 @@ // Test embedding at root of file root1: 1 #Root1: x: {} -#Root1 & { } - -@test(eq, { - root1: 1 - #Root1: x: {} - x: {} -}) +#Root1 & {} -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/definitions/root2.txtar b/internal/core/compile/testdata/sync/definitions/root2.txtar index d8d389ed4..b42dec439 100644 --- a/internal/core/compile/testdata/sync/definitions/root2.txtar +++ b/internal/core/compile/testdata/sync/definitions/root2.txtar @@ -2,11 +2,6 @@ root2: 1 #Root2: {} #Root2 - -@test(eq, { - root2: 1 - #Root2: {} -}) -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/definitions/root3.txtar b/internal/core/compile/testdata/sync/definitions/root3.txtar index c98a89292..9f53d5822 100644 --- a/internal/core/compile/testdata/sync/definitions/root3.txtar +++ b/internal/core/compile/testdata/sync/definitions/root3.txtar @@ -1,13 +1,7 @@ -- in.cue -- x: _ #D: b: x -#D & { b: _ } - -@test(eq, { - x: _ - #D: b: _ - b: _ -}) +#D & {b: _} -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/definitions/root4.txtar b/internal/core/compile/testdata/sync/definitions/root4.txtar index f9a03d22a..03aaf0361 100644 --- a/internal/core/compile/testdata/sync/definitions/root4.txtar +++ b/internal/core/compile/testdata/sync/definitions/root4.txtar @@ -2,22 +2,10 @@ #schema: a!: bool _hidden & #schema // must fail here, but not elsewhere _hidden: { - "a": true, + "a": true notAllowed: true } allowed: true - -@test(eq, { - a: true - #schema: a!: bool - _hidden: { - a: true - notAllowed: true - } - allowed: true - notAllowed: _|_ -}) -@test(err, code=eval, contains="field not allowed", pos=[in.cue:5:2]) -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/definitions/root5.txtar b/internal/core/compile/testdata/sync/definitions/root5.txtar index 700f85573..b83cff27b 100644 --- a/internal/core/compile/testdata/sync/definitions/root5.txtar +++ b/internal/core/compile/testdata/sync/definitions/root5.txtar @@ -1,64 +1,21 @@ -- in.cue -- _schema // embed schema through indirections -_schema: #Schema @test(shareID=topSchema) +_schema: #Schema #Schema: { - @test(shareID=topSchema) a?: b?: string } a: b: "foo" c: "foo" - x: { _schema // embed schema through indirections - _schema: #Schema @test(shareID=xSchema) + _schema: #Schema #Schema: { - @test(shareID=xSchema) a?: b?: string } a: b: "foo" c: "foo" } - -@test(eq, { - a: b: "foo" - _schema: a?: b?: string - #Schema: a?: b?: string - c: "foo" - x: { - a: b: "foo" - _schema: a?: b?: string - #Schema: a?: b?: string - c: "foo" - } -}) -// TODO(inline): fix sharing detection across hidden fields. -@test(debug, """ - (#struct){ - _schema: ~(#Schema) - #Schema: (#struct){ - a?: (#struct){ - b?: (string){ string } - } - } - a: (#struct){ - b: (string){ "foo" } - } - c: (string){ "foo" } - x: (#struct){ - _schema: ~(x.#Schema) - #Schema: (#struct){ - a?: (#struct){ - b?: (string){ string } - } - } - a: (#struct){ - b: (string){ "foo" } - } - c: (string){ "foo" } - } - } - """) -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/definitions/root6.txtar b/internal/core/compile/testdata/sync/definitions/root6.txtar index 6279bd9b2..c08622157 100644 --- a/internal/core/compile/testdata/sync/definitions/root6.txtar +++ b/internal/core/compile/testdata/sync/definitions/root6.txtar @@ -2,25 +2,14 @@ c: "foo" a: b: int #Schema -#Schema: close({ a: b: int}) @test(closed) +#Schema: close({a: b: int}) x: { c: "foo" a: b: int #Schema - #Schema: close({ a: b: int}) -} @test(closed) - -@test(eq, { - a: b: int - c: "foo" - #Schema: { a: b: int } - x: { - a: b: int - c: "foo" - #Schema: a: b: int - } -}) + #Schema: close({a: b: int}) +} -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/definitions/root7.txtar b/internal/core/compile/testdata/sync/definitions/root7.txtar index dae529416..40f06eb70 100644 --- a/internal/core/compile/testdata/sync/definitions/root7.txtar +++ b/internal/core/compile/testdata/sync/definitions/root7.txtar @@ -1,8 +1,6 @@ -- in.cue -- root: input: #deps: root: {} {root.input.#deps} - -@test(eq, { root: input: #deps: root: {} }) -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/definitions/root8.txtar b/internal/core/compile/testdata/sync/definitions/root8.txtar index 87358ab09..0a725558f 100644 --- a/internal/core/compile/testdata/sync/definitions/root8.txtar +++ b/internal/core/compile/testdata/sync/definitions/root8.txtar @@ -1,21 +1,12 @@ -- in.cue -- root: input: foo: { - metadata: name: *"foo" | string - id: "id-\(metadata.name)" - #deps: [string]: _ - #deps: root: {} - spec: replicas: 1 + metadata: name: *"foo" | string + id: "id-\(metadata.name)" + #deps: [string]: _ + #deps: root: {} + spec: replicas: 1 } {root.input.foo.#deps} - -@test(eq, { - root: input: foo: { - metadata: name: *"foo" | string - id: "id-foo" - #deps: root: {} - spec: replicas: 1 - } -}) -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/definitions/typocheck.txtar b/internal/core/compile/testdata/sync/definitions/typocheck.txtar index 11c7c8269..2ee0b334f 100644 --- a/internal/core/compile/testdata/sync/definitions/typocheck.txtar +++ b/internal/core/compile/testdata/sync/definitions/typocheck.txtar @@ -1,62 +1,43 @@ -- in.cue -- embed: simple: { #A: b: 1 - a: { #A } - a: err: 1 @test(err, code=eval, contains="field not allowed", pos=[0:5]) + a: {#A} + a: err: 1 } embed: andInStruct: { #Foo: a: int - a: { #Foo & { err: 2 } } - - @test(err, at=a.err, code=eval, contains="field not allowed", pos=[2:16]) + a: {#Foo & {err: 2}} } embed: embedDefWithEmbedding: { #Foo: {{a: int}} - a: { #Foo & { err: 2 } } // not allowed - - @test(err, at=a.err, code=eval, contains="field not allowed", pos=[2:16]) + a: {#Foo & {err: 2}} // not allowed } embed: embedComprehension: { #Foo: {if true {a: int}} - a: { #Foo & { err: 2 } } // not allowed - - @test(err, at=a.err, code=eval, contains="field not allowed", pos=[2:16]) + a: {#Foo & {err: 2}} // not allowed } embed: fieldWithAnd: { #A: {} - { a: #A & {err: 3 } } - - @test(err, at=a.err, code=eval, contains="field not allowed", pos=[2:13]) + {a: #A & {err: 3}} } embed: embedAndRecursive: { #A: a: int - B: x: #A - B & { x: err: 2 } - - @test(err, at=x.err, code=eval, contains="field not allowed", pos=[3:11]) + B: x: #A + B & {x: err: 2} } embed: andEmbed: { #A: b: int #B: b: int #D: {#A & #B} d: #D & {err: 3} - - @test(err, at=d.err, code=eval, contains="field not allowed", pos=[4:11]) } and: transitive: ok: { - Z: {a: string} @test(shareID:todo=Z) - #Y: Z @test(shareID:todo=Z) + Z: {a: string} + #Y: Z #X: #Y & Z out: #X & { a: "foo" } - - @test(eq, { - Z: {a: string} - #Y: {a: string} - #X: {a: string} - out: {a: "foo"} - }) } and: transitive: err: { Z: a: string @@ -64,7 +45,7 @@ and: transitive: err: { #X: #Y & Z out: #X & { err: "foo" - } @test(err, at=err, code=eval, contains="field not allowed", pos=[1:3]) + } } and: transitiveWithEmbed: ok: { Z: a: string @@ -73,13 +54,6 @@ and: transitiveWithEmbed: ok: { out: #X & { a: "foo" } - - @test(eq, { - Z: {a: string} - #X: {a: string} - #Y: {a: string} - out: {a: "foo"} - }) } and: transitiveWithEmbed: err: { Z: a: string @@ -88,47 +62,30 @@ and: transitiveWithEmbed: err: { out: #X & { err: "foo" } - - @test(err, at=out.err, code=eval, contains="field not allowed", pos=[5:3]) } embed: nonDef: t1: { X: a: string #Y: #Z & X #Z: { X - b?: string + b?: string } - - @test(eq, { - X: {a: string} - #Y: {b?: string, a: string} - #Z: {b?: string, a: string} - }) } embed: defAndHidden: full: { _stepCommon: Name: string #Step: #Command & _stepCommon #Command: { _stepCommon - Path?: string + Path?: string } out: #Step & { Name: "foo" } - - @test(eq, { - _stepCommon: {Name: string} - #Step: {Path?: string, Name: string} - #Command: {Path?: string, Name: string} - out: {Name: "foo", Path?: string} - }) } embed: withIndirect: { A: #B #B: b: int - A & { err: 2 } // not allowed - - @test(err, at=err, code=eval, contains="field not allowed", pos=[3:8]) + A & {err: 2} // not allowed } -- validators.cue -- import ( @@ -143,7 +100,7 @@ embed: normalValidator: { b?: int } x: #X - x: err: 1 @test(err, code=eval, contains="field not allowed", pos=[-5:3, 0:5]) + x: err: 1 } embed: openValidator: t1: { #X: { @@ -153,19 +110,12 @@ embed: openValidator: t1: { } x: #X x: err: 1 - - @test(eq, { - #X: {matchN(0, []), a?: int, b?: int} - x: {err: 1, a?: int, b?: int} - }) } embed: openValidator: t2: { Y: matchN(1, [X]) X: b?: Y a: X - a: b: 1 @test(err, suberr=(code=eval, contains="conflicting values"), - suberr=(code=eval, contains="does not satisfy matchN", pos=[-3:5, -3:12, -2:9, 0:8]), - ) + a: b: 1 } disjunction: withErr: t1: { params: {} @@ -174,13 +124,6 @@ disjunction: withErr: t1: { } #Schema1: b1?: null | #Schema2 #Schema2: b2?: null | {b3?: string} - - @test(eq, { - params: {} - out: {b1: {b2: {b3: _}}} - #Schema1: {b1?: null | {b2?: null | {b3?: string}}} - #Schema2: {b2?: null | {b3?: string}} - }) } embed: nestedValidator: { #types: z?: list.UniqueItems @@ -190,30 +133,19 @@ embed: nestedValidator: { y?: #types } #def: {} - - @test(eq, { - #types: _ @test(ignore) - x: {y: {z: [1]}} - #def: {} - }) } -- inline.cue -- embedInline: { #Schema: { a: "hello" // do not close outer struct of 'b', as inlined value is not a schema. - b: { {x: c: "foo"}.x } + b: {{x: c: "foo"}.x} b: { c: string d: "never printed" } } out: #Schema & __no_sharing - - @test(eq, { - #Schema: {a: "hello", b: {c: "foo", d: "never printed"}} - out: {a: "hello", b: {c: "foo", d: "never printed"}} - }) } // evalv3 "field not allowed" regression involving embeddings and selectors; // accessing a field via selector on an embedded definition should stay open. @@ -222,18 +154,13 @@ issue3853: { #Schema: { a: "hello" // do not close outer struct of 'b', as inlined value is not a schema. - b: { {x: c: "foo"}.x } + b: {{x: c: "foo"}.x} b: { c: string d: "never printed" } } out: {x: (#Schema & {}).a}.x - - @test(eq, { - #Schema: {a: "hello", b: {c: "foo", d: "never printed"}} - out: "hello" - }) } -- disjunction.cue -- import "list" @@ -242,9 +169,9 @@ import "list" // are present; disallowed fields in a default disjunct should still be caught. // https://cuelang.org/issue/3947 issue3947: full: { - #Schema: allowed?: string + #Schema: allowed?: string _defaults: disallowed: _ | *"default value" - out: #Schema & _defaults @test(err, code=eval, at=disallowed, contains="field not allowed", pos=[-1:13]) + out: #Schema & _defaults } // evalv3 regression: #oneOf pattern disjunction; unifying a closed definition // disjunction with a default string field caused incorrect field-not-allowed errors. @@ -253,18 +180,11 @@ issue3957: reduced: { c: a: "bar" c: #B & {a: string | *"foo"} #B: b?: string - - @test(err, at=c.a, code=eval, contains="field not allowed", pos=[1:5, 2:11]) } issue3957: full: { #oneof: {a: string} | {b?: [...string]} c: #oneof & {a: string | *"foo"} c: a: "bar" - - @test(eq, { - #oneof: {a: string} | {b?: []} - c: {a: "bar"} - }) } issue3957: derived: t1: { #Schema: { @@ -272,11 +192,6 @@ issue3957: derived: t1: { out: list.FlattenN([in], 1) } x: #Schema & {in: "foo"} - - @test(eq, { - #Schema: {in: string | [], out: [string | []]} - x: {in: "foo", out: ["foo"]} - }) } issue3957: derived: t2: { #Schema: { @@ -285,18 +200,13 @@ issue3957: derived: t2: { out: _flat } out: #Schema & {in: "foo"} - - @test(eq, { - #Schema: {in: string | [], out: [string | []]} - out: {in: "foo", out: ["foo"]} - }) } -- issue3833.cue -- // evalv3 "field not allowed" regression with embeddings; combining a definition // that has an open field with another definition via embedding should be allowed. // https://cuelang.org/issue/3833 issue3833: ok: { - out: { #A & { a: #B } } + out: {#A & {a: #B}} #A: { a: {b: string, ...} ... @@ -306,16 +216,9 @@ issue3833: ok: { #C & {c: "foo"} b: "foo" } - - @test(eq, { - out: {a: {b: "foo", c: "foo"}} - #A: {a: {b: string}} - #C: {c: string} - #B: {c: "foo", b: "foo"} - }) -} -issue3833: evalv2Issue:{ - out: { #A & { a: #B } } +} +issue3833: evalv2Issue: { + out: {#A & {a: #B}} #A: { a: b: string ... @@ -325,11 +228,6 @@ issue3833: evalv2Issue:{ #C & {c: "foo"} b: "foo" } - - @test(err, at=out.a.c, code=eval, - contains="field not allowed", pos=[6:6, 8:9], - hint="key positions are missing", - ) } -- issue3837.cue -- // evalv3 regression with embeddings, disjunctions, and extra fields; a struct @@ -340,14 +238,8 @@ issue3837: reduced: { #Embed extra: "foo" } - out: {{ x: A & __no_sharing }} + out: {{x: A & __no_sharing}} #Embed: {} - - @test(eq, { - A: {extra: "foo"} - out: {x: {extra: "foo"}} - #Embed: {} - }) } issue3837: full: { #Embed: {} @@ -363,14 +255,6 @@ issue3837: full: { #def: (#A & __no_sharing) } } - - @test(eq, { - #Embed: {} - #A: {extra: "foo"} - #B: {bar: string} | {} - #C: {bar: string} - out: {bar: "baz", #def: {extra: "foo"}} - }) } -- issue3832.cue -- // evalv3 "field not allowed" regression with a disjunction and a let field; @@ -381,7 +265,7 @@ issue3832: { #T: { _subject: { - in: _ + in: _ out: { let self = in.self outFirstName: self.firstName @@ -395,47 +279,26 @@ issue3832: { invoke!: _ // TODO: here, the let from _subject.out gets converted to a // permanent error,instead of incomplete. - pass: (_subject & {in: invoke}).out + pass: (_subject & {in: invoke}).out } results: _assert.pass } #T & { _assert: invoke: _person } - - @test(eq, { - _person: {self: {firstName: "Sam"}} - #T: _ @test(ignore) - _assert: { - invoke: {self: {firstName: "Sam"}} - pass: {outFirstName: "Sam"} - } - _subject: _ @test(ignore) - results: {outFirstName: "Sam"} - }) } -- issue3839.cue -- // evalv3 closedness regression with embeddings and definitions; embedding a // definition with an ellipsis inside a non-definition should remain open. // https://cuelang.org/issue/3839 issue3839: reduced: { - x: { A & __no_sharing } + x: {A & __no_sharing} x: y: 1 - #B: { - // Note: true with both old semantics and explicitopen - @test(closed) - @test(allows=false, string) - } + #B: {} A: { #B ... - - // Note: true with both old semantics and explicitopen - @test(closed) - @test(allows, string) } - - @test(eq, {x: {y: 1}, #B: {}, A: {}}) } issue3839: full: { _globals: glb: globalField: "" @@ -463,15 +326,6 @@ issue3839: full: { #Embed ... } - - @test(eq, { - _globals: {glb: {globalField: ""}} - #GlobalContext: {globalField: string} - #Context: {glb: {globalField: string}, out: {globalField: string}} - out: {ingress: {#def: {globalField: ""}, foo: 1234, bar: "http"}} - #Embed: {#def: {}} - #Ingress: {#def: {}} - }) } -- chaineddef.cue -- // evalv3 "field not allowed" regression when embedding a chain of definitions; @@ -485,25 +339,15 @@ issue3920: { } #A: a?: #B #B: c?: string - - @test(eq, { - out: {a: {b: "out", c?: string}} - #A: {a?: {c?: string}} - #B: {c?: string} - }) } onlyCloseDirectStruct: { #foo: {} x: {y: {{a: #foo}}} x: y: b: 1 - - @test(eq, {#foo: {}, x: {y: {a: {}, b: 1}}}) } closeInEmbed: { x: {close({{["d"]: f: int}})} x: d: e: 1 - - @test(eq, {x: {d: {e: 1, f: int}}}) } -- embedelim.cue -- // evalv3 "field not allowed" regression with nested definitions; eliminating @@ -514,20 +358,12 @@ issue3921: top: { #A: b: string #B: _ a: {#A & {}} - - @test(eq, {#A: {b: string}, #B: _, a: {b: string}}) } issue3921: hidden: { #A: #B #A: _hidden: b: string #B: {} - a: { #A & { _hidden: {} }} - - @test(eq, { - #A: {_hidden: {b: string}} - #B: {} - a: {_hidden: {b: string}} - }) + a: {#A & {_hidden: {}}} } issue3921: full: { out: #templateList & #defineMap @@ -544,35 +380,9 @@ issue3921: full: { } #Step: #StepInner & { image: string - #config: version: string + #config: version: string } #StepInner: image: string - - @test(eq, { - out: { - #stepMap: {foo: { - image: "bar" - #config: {version: string} - }} - stepList: [{ - image: "bar" - #config: {version: string} - }] - } - #templateList: {#stepMap: {}, stepList: []} - #defineMap: { - #stepMap: {foo: { - image: "bar" - #config: {version: string}} - } - stepList: _ - } - #Step: { - image: string - #config: {version: string} - } - #StepInner: {image: string} - }) } -- issue3843.cue -- // evalv3 "field not allowed" regression when a definition is reused at @@ -585,14 +395,8 @@ dedupPattern: t1: p1: { x: #Z x: y: z: 1 } - B: A & __no_sharing + B: A & __no_sharing out: A.#Z & B.x - - @test(eq, { - A: {#Z: {}, x: {y: {z: 1}}} - B: {#Z: {}, x: {y: {z: 1}}} - out: {y: {z: 1}} - }) } dedupPattern: t1: p2: { A: { @@ -600,14 +404,8 @@ dedupPattern: t1: p2: { x: #Z x: y: z: 1 } - B: A & __no_sharing + B: A & __no_sharing out: B.x & A.#Z - - @test(eq, { - A: {#Z: {}, x: {y: {z: 1}}} - B: {#Z: {}, x: {y: {z: 1}}} - out: {y: {z: 1}} - }) } -- issue3858.cue -- // evalv3 "field not allowed" regression with embeddings where a definition @@ -624,54 +422,34 @@ orig: t1: { #Job: { image: string vcs: "git" - args: [...string] - env: [string]: string + args: [...string] + env: [string]: string } #Output: { - _in: _ - out: (_in & {}) + _in: _ + out: (_in & {}) } #Output & { _in: (#JobConfig & {}).job } - - @test(eq, { - #Image: {embed: {image: "foo:v1"}} - #JobConfig: { - image: {embed: {image: "foo:v1"}} - job: {image: "foo:v1", vcs: "git", args: [], env: {}} - } - #Job: {image: string, vcs: "git", args: [], env: {}} - #Output: {_in: _, out: {}} - _in: {image: "foo:v1", vcs: "git", args: [], env: {}} - out: {image: "foo:v1", vcs: "git", args: [], env: {}} - }) } reduced: t1: { Y: { a: e: "foo" - b: X & { a } + b: X & {a} } X: { e: string f: 1 // fails in `out` } #Z: { - _in: _ - out: _in & __no_sharing + _in: _ + out: _in & __no_sharing } #Z & { _in: Y } - - @test(eq, { - Y: {a: {e: "foo"}, b: {e: "foo", f: 1}} - X: {e: string, f: 1} - #Z: {_in: _, out: _} - _in: {a: {e: "foo"}, b: {e: "foo", f: 1}} - out: {a: {e: "foo"}, b: {e: "foo", f: 1}} - }) } orig: t2: { #JobConfig: { @@ -691,45 +469,21 @@ orig: t2: { out: #Output & { in: input: (#JobConfig & {}).job } - - @test(eq, { - #JobConfig: { - image: {spec: {image: "someimage"}} - job: {image: "someimage", env: "FOO"} - } - #Job: {image: string, env: "FOO"} - #Output: { - in: _ - out: _ @test(ignore) - } - out: { - in: {input: {image: "someimage", env: "FOO"}} - out: {image: "someimage", env: "FOO"} - } - }) } reduced: t2: { Y: { a: e: "foo" - b: X & { a } + b: X & {a} } X: { e: string f: 1 // fails } #Z: { - _in: _ - out: _in + _in: _ + out: _in } - #Z & { _in: Y } - - @test(eq, { - Y: {a: {e: "foo"}, b: {e: "foo", f: 1}} - X: {e: string, f: 1} - #Z: {_in: _, out: _} - _in: {a: {e: "foo"}, b: {e: "foo", f: 1}} - out: {a: {e: "foo"}, b: {e: "foo", f: 1}} - }) + #Z & {_in: Y} } -- issue3934.cue -- // evalv3 "field not allowed" regression with disjunctions and a comprehension; @@ -745,15 +499,9 @@ issue3934: { } #Foo: foo?: null | #Bar | *{bar: 3} #Bar: { - bar?: int + bar?: int extra?: null | {...} } - - @test(eq, { - out: {foo: *{bar: 3} | {extra?: null | {}, bar?: int} | null} - #Foo: {foo?: *{bar: 3} | {bar?: int, extra?: null | {}} | null} - #Bar: {bar?: int, extra?: null | {}} - }) } -- large.cue -- full: { @@ -802,26 +550,15 @@ full: { } } out: (#Main & {namespace: "ns1"}).output - - @test(eq, { - #Resource: _ @test(ignore) - #Patches: _ @test(ignore) - #JSONPatch: _ @test(ignore) - #JSONOp: _ @test(ignore) - #Main: _ @test(ignore) - out: {ns1: [{op: "add", path: "/metadata", value: "foo"}]} - }) } -- ellipsis.cue -- nestedEllipsis: minimal: { - out: #Schema & { extra: "foo" } + out: #Schema & {extra: "foo"} #Schema: { #meta ... } #meta: {} - - @test(eq, {out: {extra: "foo"}, #Schema: {}, #meta: {}}) } nestedEllipsis: nestedWithPatterns: { out: #Schema & { @@ -835,39 +572,29 @@ nestedEllipsis: nestedWithPatterns: { #meta: name?: int objs?: _ } - - @test(eq, { - out: { - objs: {obj1: {extra: "foo", name?: int}} - #meta: {name?: int} - } - #Schema: {#meta: {name?: int}, objs?: {}} - }) } // evalv3 "field not allowed" regression with ellipses since v0.13.0; embedding // a schema with `...` alongside additional fields should not close the struct. // https://cuelang.org/issue/4015 issue4015: reduced: { - #X: { ... } + #X: {...} out: { // Embedded schema allows `a: _`. Adding `a` below should not change that. #X a: b: string - } @test(allows, string) @test(closed) + } out: { a: { c: "h" b: "x" } } - - @test(eq, {#X: {}, out: {a: {b: "x", c: "h"}}}) } issue4015: nested: { - #X: { foo: {...} } + #X: {foo: {...}} out: { #X - foo: {a: b: string} @test(allows, string) @test(closed) + foo: {a: b: string} } out: { foo: a: { @@ -875,14 +602,12 @@ issue4015: nested: { b: "x" } } - - @test(eq, {#X: {foo: {}}, out: {foo: {a: {b: "x", c: "h"}}}}) } issue4015: full: { #Schema: { cfg: { foo: { - enabled: bool | *false + enabled: bool | *false fooField: string } bar: barField: string @@ -905,70 +630,33 @@ issue4015: full: { foo: fooField: "h" bar: barField: "x" } - - // This one is rather confusing, but true. Note that this should no - // longer hold if this is converted to the explicitopen semantics, in - // which case #Schema applies "monotonically" limiting to its fields. - @test(allows, string) - @test(allows:todo=false, string, hint="for explicit open") - @test(closed) } - - @test(eq, { - #Schema: { - cfg: { - foo: {enabled: *false | bool, fooField: string} - bar: {barField: string} - } - capacity: *3 | int - } - #MoreCapacity: {capacity: 30} - out: { - cfg: {foo: {enabled: true, fooField: "h"}, bar: {barField: "x"}} - capacity: 30 - } - }) } -- issue3964.cue -- // evalv3 closedness regression since v0.13.1; a definition that embeds another // definition containing a disjunction should correctly allow matching fields. // https://cuelang.org/issue/3964 issue3964: reduced: { - #Output: { #Embedded } + #Output: {#Embedded} #Embedded: { name: string #Unused | #Used } #Unused: {} #Used: {} - - @test(eq, { - #Output: {name: string} - #Embedded: {name: string} - #Unused: {} - #Used: {} - }) } issue3964: full: { out: #Output & { name: "oauth2" used: "bar" } - #Output: { #Embedded } + #Output: {#Embedded} #Embedded: { name: string #Unused | #Used } #Unused: unused: string - #Used: used: string - - @test(eq, { - out: {name: "oauth2", used: "bar"} - #Output: {name: string, unused: string} | {name: string, used: string} - #Embedded: {name: string, unused: string} | {name: string, used: string} - #Unused: {unused: string} - #Used: {used: string} - }) + #Used: used: string } -- cycle.cue -- // evalv3 stack overflow due to latest closedness changes; mutually recursive @@ -979,16 +667,9 @@ issue4006: { #B fieldA: string } - #B: { #A } + #B: {#A} #C: #A & {} out: #C & #B - - @test(eq, { - #A: {fieldA: string} - #B: {fieldA: string} - #C: {fieldA: string} - out: {fieldA: string} - }) } -- out/compile -- --- chaineddef.cue diff --git a/internal/core/compile/testdata/sync/definitions/visibility.txtar b/internal/core/compile/testdata/sync/definitions/visibility.txtar index d40cb6f44..5227e6c5c 100644 --- a/internal/core/compile/testdata/sync/definitions/visibility.txtar +++ b/internal/core/compile/testdata/sync/definitions/visibility.txtar @@ -8,12 +8,7 @@ foo: #foo & { _#name: "bar" #name: "baz" -} @test(closed) @test(eq, { - _name: "foo" - _#name: "bar" - #name: "baz" - name: string -}) +} -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/disjunctions/019_ips.txtar b/internal/core/compile/testdata/sync/disjunctions/019_ips.txtar index 169e898b5..d7237d8e2 100644 --- a/internal/core/compile/testdata/sync/disjunctions/019_ips.txtar +++ b/internal/core/compile/testdata/sync/disjunctions/019_ips.txtar @@ -6,31 +6,13 @@ import "list" IP: list.Repeat([uint8], 4) Private: - *[ 192, 168, uint8, uint8] | - [ 10, uint8, uint8, uint8] | - [ 172, >=16 & <=32, uint8, uint8] + *[192, 168, uint8, uint8] | + [10, uint8, uint8, uint8] | + [172, >=16 & <=32, uint8, uint8] -Inst: Private & [ _, 10, ...] +Inst: Private & [_, 10, ...] -MyIP: Inst & [_, _, 10, 10] @test(eq, [10, 10, 10, 10]) -@test(eq, { - IP: [ - >=0 & <=255 & int, - >=0 & <=255 & int, - >=0 & <=255 & int, - >=0 & <=255 & int - ] - Private: *[192, 168, >=0 & <=255 & int, >=0 & <=255 & int] | - [10, >=0 & <=255 & int, >=0 & <=255 & int, >=0 & <=255 & int] | - [172, >=16 & <=32, >=0 & <=255 & int, >=0 & <=255 & int] - Inst: [ - 10, - 10, - >=0 & <=255 & int, - >=0 & <=255 & int - ] - MyIP: [10, 10, 10, 10] -}) +MyIP: Inst & [_, _, 10, 10] -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/disjunctions/confluence.txtar b/internal/core/compile/testdata/sync/disjunctions/confluence.txtar index 0efe67814..7699f6b83 100644 --- a/internal/core/compile/testdata/sync/disjunctions/confluence.txtar +++ b/internal/core/compile/testdata/sync/disjunctions/confluence.txtar @@ -3,14 +3,14 @@ import ( "net" "strings" ) + // evalv3 regression: disjunctions with conditionals depending on the // disjunction's own value were left unresolved. // https://cuelang.org/issue/3993 issue3993: reduced: { x: net.IPv4 | =~"fail" - x: { if net.IPv4(x) {=~"^10\\." } } + x: {if net.IPv4(x) {=~"^10\\."}} x: "10.10.10.10" - @test(eq, {x: "10.10.10.10"}) } issue3993: full: { @@ -22,7 +22,6 @@ issue3993: full: { addr: strings.HasPrefix("2a02:") } addr: "10.10.10.10" - @test(eq, {addr: "10.10.10.10"}) } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/disjunctions/crossembed.txtar b/internal/core/compile/testdata/sync/disjunctions/crossembed.txtar index ed805e24a..e8c246387 100644 --- a/internal/core/compile/testdata/sync/disjunctions/crossembed.txtar +++ b/internal/core/compile/testdata/sync/disjunctions/crossembed.txtar @@ -11,14 +11,6 @@ import "foo.test/main/imported" out: imported out: either: foo: "world" - -@test(eq, { - out: { - either: {foo: "world"} - #Foo: {foo: _} - #Bar: {bar: _} - } -}) -- imported/imported.cue -- package imported diff --git a/internal/core/compile/testdata/sync/disjunctions/defaults.txtar b/internal/core/compile/testdata/sync/disjunctions/defaults.txtar index 1d051d1e9..425eabf33 100644 --- a/internal/core/compile/testdata/sync/disjunctions/defaults.txtar +++ b/internal/core/compile/testdata/sync/disjunctions/defaults.txtar @@ -1,8 +1,8 @@ -- in.cue -- -passToSingleValue: p1: _ | *((_ | *"x") & "y") @test(eq, *"y" | _) -passToSingleValue: p2: _ | *((*"x" | _) & "y") @test(eq, *"y" | _) -passToSingleValue: p3: *((_ | *"x") & "y") | _ @test(eq, *"y" | _) -passToSingleValue: p4: *((*"x" | _) & "y") | _ @test(eq, *"y" | _) +passToSingleValue: p1: _ | *((_ | *"x") & "y") +passToSingleValue: p2: _ | *((*"x" | _) & "y") +passToSingleValue: p3: *((_ | *"x") & "y") | _ +passToSingleValue: p4: *((*"x" | _) & "y") | _ // eval: "incomplete value" regression with defaults involving multiple // definitions; default values that depend on other fields should resolve. @@ -18,17 +18,6 @@ issue3779: { fieldFoo: _ fieldBar: string | *fieldFoo } - @test(eq, { - out: { - fieldFoo: "foo" - fieldBar: *"foo" | string - } - #Foo: { - fieldFoo: *"foo-default" | string - fieldBar: *"foo-default" | string - } - #Bar: {fieldFoo: _, fieldBar: *_ | string} - }) } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/disjunctions/defembed.txtar b/internal/core/compile/testdata/sync/disjunctions/defembed.txtar index 589f7355e..3a3fd11da 100644 --- a/internal/core/compile/testdata/sync/disjunctions/defembed.txtar +++ b/internal/core/compile/testdata/sync/disjunctions/defembed.txtar @@ -7,55 +7,28 @@ x: { m1: (1 | (*2 | 3)) & (>=2 & <=3) m2: (1 | (*2 | 3)) & (2 | 3) m3: (*1 | *(*2 | 3)) & (2 | 3) - @test(eq, {m1: *2 | 3, m2: *2 | 3, m3: *2 | 3}) } y1: x & { {m4: x.m1 + x.m2 + x.m3} -} @test(eq, { - m4: 6 - m1: *2 | 3 - m2: *2 | 3 - m3: *2 | 3 -}) +} y2: { x {m4: y2.m1 + y2.m2 + y2.m3} - @test(eq, { - m4: 6 - m1: *2 | 3 - m2: *2 | 3 - m3: *2 | 3 - }) } Y=y3: { x {m4: Y.m1 + Y.m2 + Y.m3} } -@test(eq, { - m4: 6 - m1: *2 | 3 - m2: *2 | 3 - m3: *2 | 3 -}, at=y3) y4: x & { {m4: y4.m1 + y4.m2 + y4.m3} -} @test(eq, { - m4: 6 - m1: *2 | 3 - m2: *2 | 3 - m3: *2 | 3 -}) +} // Second disjunct in embedding is not possible because of previous declaration // of `b`, so it should be resolved to {a: 1}. z: { b: (*"a" | "b") | "c" {a: b} | {b: int} - @test(eq, { - b: *"a" | "b" | "c" - a: *"a" | "b" | "c" - }) } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/disjunctions/discriminator.txtar b/internal/core/compile/testdata/sync/disjunctions/discriminator.txtar index f4b78bc19..910a1ec11 100644 --- a/internal/core/compile/testdata/sync/disjunctions/discriminator.txtar +++ b/internal/core/compile/testdata/sync/disjunctions/discriminator.txtar @@ -9,36 +9,25 @@ noKind: { #Def: {<10, _hidden: "field"} | >200 | string // The data is an int, but the struct embeds a matching scalar kind too. - out: #Def & 123 @test(err, - suberr=(code=eval, contains="conflicting values", args=[123, string]), - suberr=(code=eval, contains="invalid value", args=[123, <10]), - suberr=(code=eval, contains="invalid value", args=[123, >200]), - pos=[]) + out: #Def & 123 } manyStructsEmpty: { #Def: {f1!: int} | {f2!: int} | string // The data is a struct, which matches multiple disjunct struct kinds. - out: #Def & {} @test(eq, {f1!: int} | {f2!: int}) + out: #Def & {} } manyScalars: { #Def: 1 | 2 | 3 // The data is an int, which matches all of the disjunct kinds. - out: #Def & 123 @test(err, - suberr=(code=eval, contains="conflicting values", args=[1, 123], pos=[-3:9, 0:8, 0:15]), - suberr=(code=eval, contains="conflicting values", args=[2, 123], pos=[-3:13, 0:8, 0:15]), - suberr=(code=eval, contains="conflicting values", args=[3, 123], pos=[-3:17, 0:8, 0:15])) + out: #Def & 123 } zeroScalars: { #Def: int | string | null // The data is a bool, which matches none of the disjunct scalar kinds. - out: #Def & true @test(err, - suberr=(code=eval, contains="conflicting values", args=[true, int]), - suberr=(code=eval, contains="conflicting values", args=[true, null]), - suberr=(code=eval, contains="conflicting values", args=[true, string]), - pos=[]) + out: #Def & true } } @@ -51,15 +40,7 @@ byKind: { #Def3: {f3: null | int} // The data is a struct, not a null. - out: #Def1 & {f1: f2: f3: "not an int"} @test(err, code=eval, - contains="6 errors in empty disjunction", - suberr=(code=eval, contains="conflicting values", args=[null], pos=[-5:15, 0:8, 0:21]), - suberr=(code=eval, contains="4 errors in empty disjunction"), - suberr=(code=eval, contains="conflicting values", args=[null], pos=[-5:22, -4:15, 0:8, 0:25]), - suberr=(code=eval, contains="2 errors in empty disjunction"), - suberr=(code=eval, contains="conflicting values", args=["not an int", int], pos=[-5:22, -4:22, -3:22, 0:8, 0:29]), - suberr=(code=eval, contains="conflicting values", args=["not an int", null], pos=[-5:22, -4:22, -3:15, 0:8, 0:29]), - pos=[]) + out: #Def1 & {f1: f2: f3: "not an int"} } nullableStructRequired: { @@ -68,15 +49,7 @@ byKind: { #Def3: {f3!: null | int} // The data is a struct, not a null. - out: #Def1 & {f1: f2: f3: "not an int"} @test(err, code=eval, - contains="6 errors in empty disjunction", - suberr=(code=eval, contains="conflicting values", args=[null], pos=[-5:16, 0:8, 0:21]), - suberr=(code=eval, contains="4 errors in empty disjunction"), - suberr=(code=eval, contains="conflicting values", args=[null], pos=[-5:23, -4:16, 0:8, 0:25]), - suberr=(code=eval, contains="2 errors in empty disjunction"), - suberr=(code=eval, contains="conflicting values", args=["not an int", int], pos=[-5:23, -4:23, -3:23, 0:8, 0:29]), - suberr=(code=eval, contains="conflicting values", args=["not an int", null], pos=[-5:23, -4:23, -3:16, 0:8, 0:29]), - pos=[]) + out: #Def1 & {f1: f2: f3: "not an int"} } nullableStructOptional: { @@ -85,15 +58,7 @@ byKind: { #Def3: {f3?: null | int} // The data is a struct, not a null. - out: #Def1 & {f1: f2: f3: "not an int"} @test(err, code=eval, - contains="6 errors in empty disjunction", - suberr=(code=eval, contains="conflicting values", args=[null], pos=[-5:16, 0:8, 0:21]), - suberr=(code=eval, contains="4 errors in empty disjunction"), - suberr=(code=eval, contains="conflicting values", args=[null], pos=[-5:23, -4:16, 0:8, 0:25]), - suberr=(code=eval, contains="2 errors in empty disjunction"), - suberr=(code=eval, contains="conflicting values", args=["not an int", int], pos=[-5:23, -4:23, -3:23, 0:8, 0:29]), - suberr=(code=eval, contains="conflicting values", args=["not an int", null], pos=[-5:23, -4:23, -3:16, 0:8, 0:29]), - pos=[]) + out: #Def1 & {f1: f2: f3: "not an int"} } nullableList: { @@ -102,27 +67,14 @@ byKind: { #Def3: [...null | int] // The data is a list, not a null. - out: #Def1 & [[["not an int"]]] @test(err, code=eval, - contains="6 errors in empty disjunction", - suberr=(code=eval, contains="conflicting values", args=[null], pos=[-5:14, 0:8, 0:17]), - suberr=(code=eval, contains="4 errors in empty disjunction"), - suberr=(code=eval, contains="conflicting values", args=[null], pos=[-5:21, -4:14, 0:8, 0:18]), - suberr=(code=eval, contains="2 errors in empty disjunction"), - suberr=(code=eval, contains="conflicting values", args=["not an int", int], pos=[-5:21, -4:21, -3:21, 0:8, 0:19]), - suberr=(code=eval, contains="conflicting values", args=["not an int", null], pos=[-5:21, -4:21, -3:14, 0:8, 0:19]), - pos=[]) + out: #Def1 & [[["not an int"]]] } scalarConstraints: { #Def: >10 | "" | null | false // The data is an integer, not any other scalar type. - out: #Def & 5 @test(err, - suberr=(code=eval, contains="conflicting values", args=[5, ""]), - suberr=(code=eval, contains="conflicting values", args=[5, false]), - suberr=(code=eval, contains="conflicting values", args=[5, null]), - suberr=(code=eval, contains="invalid value", args=[5, >10]), - pos=[]) + out: #Def & 5 } } -- out/compile -- diff --git a/internal/core/compile/testdata/sync/disjunctions/edge.txtar b/internal/core/compile/testdata/sync/disjunctions/edge.txtar index e3d974a04..3598a1104 100644 --- a/internal/core/compile/testdata/sync/disjunctions/edge.txtar +++ b/internal/core/compile/testdata/sync/disjunctions/edge.txtar @@ -19,62 +19,30 @@ cyclicalInsertInDisjunction: { // disjunctions would _not_ case the reference to cross disjunction // boundaries. c: {d: e, e: _} - c: {d: 1, e: 2} | {d : 2, e: 2} - @test(eq, {c: {d: 2, e: 2}}) + c: {d: 1, e: 2} | {d: 2, e: 2} } maybe1: { // In this case, the reference c.e crosses a disjunction boundary. // However, since the reference starts from within a disjunction, this // could be allowed, if we define it to be. c: d: c.e - c: {d: 1, e: 2} | {d : 2, e: 2} - @test(eq, {c: {d: 2, e: 2}}) + c: {d: 1, e: 2} | {d: 2, e: 2} } err1: { - // This should be an error: to resolve x in c.d, we need to first - // resolve x to a concrete value. As `x` is defined outside the - // disjunction, and the disjunction cannot be resolved without it, `x` - // cannot be evaluated to a concrete value, resulting in an error. - @test(permute, count=6) x: c.e c: d: x - c: {d: 1, e: 2} | {d : 2, e: 2} - @test(eq, {x: 2, c: {d: 2, e: 2}}) + c: {d: 1, e: 2} | {d: 2, e: 2} } err2: { - // This is a more obviously erroneous variant of err1. The div in x - // requires a concrete value for c.e. However, the disjunction can only - // be disambiguated as a result of computing x. This means c.e cannot - // be concrete at the time of evaluation. - // NOTE: not so obvious. It clearly works, and arguably it should. - @test(permute, count=6) x: div(c.e, 2) c: d: x - c: {d: 1, e: 2} | {d : 2, e: 3} - @test(eq, {x: 1, c: {d: 1, e: 2}}) + c: {d: 1, e: 2} | {d: 2, e: 3} } err3: { - // Here it is clear that d will not disambiguate the disjunction at c. - // So c.e. cannot be resolved. - @test(permute, count=6) - x: c.e @test(err, code=incomplete, contains="unresolved disjunction", pos=[0:6]) + x: c.e c: d: 1 | 2 | x - c: {d: 1, e: 2} | {d : 2, e: 3} - @test(eq, { - x: _|_ @test(err, code=incomplete, contains="unresolved disjunction", pos=[54:6]) - c: {d: 1, e: 2} | {d: 2, e: 3} - }) + c: {d: 1, e: 2} | {d: 2, e: 3} } - @test(eq, { - ok1: {c: {d: 2, e: 2}} - maybe1: {c: {d: 2, e: 2}} - err1: {x: 2, c: {d: 2, e: 2}} - err2: {x: 1, c: {d: 1, e: 2}} - err3: { - x: _|_ @test(err, code=incomplete, contains="unresolved disjunction {d:1,e:2} | {d:2,e:3} (type struct)", pos=[54:6]) - c: {d: 1, e: 2} | {d: 2, e: 3} - } - }) } preseveBottomSemantics: ok: { @@ -83,8 +51,7 @@ preseveBottomSemantics: ok: { // `a: _ | X`. As we do not simplify disjunctions, the result is `a: _ | X`. // However, we could consider simplifying in this case to `a: _` if we can // come up with a good general mechanism for subsumption. - #x: { #x | {} } - @test(eq, {#x: {}}) + #x: {#x | {}} } eliminateOpenVariant: ok: { @@ -92,14 +59,12 @@ eliminateOpenVariant: ok: { // except openness. TODO: should we disambiguate those? c: {a: 1} | #b #b: {a: 1} - @test(eq, {c: {a: 1} | {a: 1}, #b: {a: 1}}) } cyclicSelfElimination: ok: { // This should resolve to {y: 1} (works for new evaluator) y: 1 | {y: 1} y - @test(eq, {y: 1}) } // Value aliases must resolve to the specific disjunct arm's value, @@ -107,39 +72,36 @@ cyclicSelfElimination: ok: { issue4251_notC: { #NotC: x={ string - _must: true & x != "c" @test(err, code=incomplete, contains="non-concrete value string in operand to !=", pos=[0:17, -2:11, -1:3]) + _must: true & x != "c" } - @test(err, at=#NotC._must, =incomplete, contains="non-concrete value string in operand to !=", pos=[3:17, 1:11, 2:3]) a: #NotC a: "a" | "b" - a: "a" @test(eq, {"a", _must: true}) + a: "a" } issue4251_notB: { #NotB: x={ string - _must: true & x != "b" @test(err, code=incomplete, contains="non-concrete value string in operand to !=", pos=[0:17, -2:11, -1:3]) + _must: true & x != "b" } - @test(err, at=#NotB._must, code=incomplete, contains="non-concrete value string in operand to !=", pos=[3:17, 1:11, 2:3]) a: #NotB a: "a" | "b" - a: "a" @test(eq, {"a", _must: true}) + a: "a" } issue4251_notB_reversed: { #NotB: x={ string - _must: true & x != "b" @test(err, code=incomplete, contains="non-concrete value string in operand to !=", pos=[0:17, -2:11, -1:3]) + _must: true & x != "b" } - @test(err, at=#NotB._must, code=incomplete, contains="non-concrete value string in operand to !=", pos=[3:17, 1:11, 2:3]) a: #NotB a: "b" | "a" - a: "a" @test(eq, {"a", _must: true}) + a: "a" } -- panic.cue -- // This used to cause a panic with evalv3. panic1: { #TypeFoo: { - name: "foo" + name: "foo" // Make foo_field here optional and master panics too! foo_field: string } @@ -153,23 +115,10 @@ panic1: { objs: obj1: { type: #TypeFoo | #TypeBar type: *objs["missing"] | #TypeFoo | #TypeBar - } @test(eq, { - type: {name: "foo", foo_field: string} | {bar_field?: string, name: "bar"} - }) + } out: #TypeFoo | #TypeBar out: objs["obj1"].type - @test(eq, { - #TypeFoo: {name: "foo", foo_field: string} - #TypeBar: {bar_field?: string, name: "bar"} - #TypeBar2: {name: "bar"} - objs: { - obj1: { - type: {name: "foo", foo_field: string} | {bar_field?: string, name: "bar"} - } - } - out: {name: "foo", foo_field: string} | {bar_field?: string, name: "bar"} - }) } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/disjunctions/elimination.txtar b/internal/core/compile/testdata/sync/disjunctions/elimination.txtar index 51fe5cf20..dee834585 100644 --- a/internal/core/compile/testdata/sync/disjunctions/elimination.txtar +++ b/internal/core/compile/testdata/sync/disjunctions/elimination.txtar @@ -14,19 +14,13 @@ disambiguateClosed: { b: #Def & a a: #Def #Def: {{x: true} | {y: true}} - @test(eq, { - b: {x: true} | {y: true} - a: {x: true} | {y: true} - #Def: {x: true} | {y: true} - }) } // Checks should never be disabled for field matching. alwaysCheckMatchers1: { b: {[=~"^xxxx$"]: int} | null - b: {c: string} | null + b: {c: string} | null b: c: "yyyyy" - @test(eq, {b: {c: "yyyyy"}}) } alwaysCheckPatterns2: { @@ -40,137 +34,114 @@ alwaysCheckPatterns2: { c: string {[=~"^xxxx$"]: int} } - @test(eq, { - a: {c: "yyyyy"} - b: {c: "yyyyy"} - #X: string | {c: string} - }) } nestedNonMonotonic: resolved: n1: { - x: {a: struct.MinFields(2)} | null + x: {a: struct.MinFields(2)} | null x: {a: c: 1} | null x: {a: d: 1} | null - @test(eq, {x: {a: {c: 1, d: 1}} | null}) } nestedNonMonotonic: resolved: n2: { - x: {a: b: struct.MinFields(2)} | null + x: {a: b: struct.MinFields(2)} | null x: {a: b: c: 1} | null x: {a: b: d: 1} | null - @test(eq, {x: {a: {b: {c: 1, d: 1}}} | null}) } nestedNonMonotonic: eliminated: n1: p1: { - x: {a: struct.MaxFields(1)} | null + x: {a: struct.MaxFields(1)} | null x: {a: c: 1} | null x: {a: d: 1} | null - @test(eq, {x: null}) } nestedNonMonotonic: eliminated: n1: p2: { x: {a: c: 1} | null - x: {a: struct.MaxFields(1)} | null + x: {a: struct.MaxFields(1)} | null x: {a: d: 1} | null - @test(eq, {x: null}) } nestedNonMonotonic: eliminated: n1: p2: { x: {a: c: 1} | null x: {a: d: 1} | null - x: {a: struct.MaxFields(1)} | null + x: {a: struct.MaxFields(1)} | null // TODO: Should be p3, fix. } nestedNonMonotonic: eliminated: n2: p1: { - x: {a: b: struct.MaxFields(1)} | null + x: {a: b: struct.MaxFields(1)} | null x: {a: b: c: 1} | null x: {a: b: d: 1} | null - @test(eq, {x: null}) } nestedNonMonotonic: eliminated: n2: p2: { x: {a: b: c: 1} | null - x: {a: b: struct.MaxFields(1)} | null + x: {a: b: struct.MaxFields(1)} | null x: {a: b: d: 1} | null - @test(eq, {x: null}) } nestedNonMonotonic: eliminated: n2: p2: { x: {a: b: c: 1} | null x: {a: b: d: 1} | null - x: {a: b: struct.MaxFields(1)} | null + x: {a: b: struct.MaxFields(1)} | null // TODO: should be p3 } // TODO: should be incomplete. nestedNonMonotonic: incomplete: a: n1: p1: { - x: {a: struct.MinFields(2)} | null + x: {a: struct.MinFields(2)} | null x: {a: c: 1} | null - @test(eq, {x: null}) - @test(eq:todo, {x: {a: {c: 1} & struct.MinFields(2)} | null}) } // TODO: should be incomplete. nestedNonMonotonic: incomplete: a: n1: p2: { x: {a: c: 1} | null - x: {a: struct.MinFields(2)} | null - @test(eq, {x: null}) - @test(eq:todo, {x: {a: {c: 1} & struct.MinFields(2)} | null}) + x: {a: struct.MinFields(2)} | null } nestedNonMonotonic: incomplete: a: n2: p1: { - x: {a: b: struct.MinFields(2)} | null + x: {a: b: struct.MinFields(2)} | null x: {a: b: c: 1} | null - @test(eq, {x: {a: {b: {c: 1}}} | null}) } nestedNonMonotonic: incomplete: a: n2: p2: { x: {a: b: c: 1} | null - x: {a: b: struct.MinFields(2)} | null - @test(eq, {x: {a: {b: {c: 1}}} | null}) + x: {a: b: struct.MinFields(2)} | null } nestedNonMonotonic: incomplete: b: n1: p1: { - x: {a: struct.MinFields(3)} | null + x: {a: struct.MinFields(3)} | null x: {a: c: 1} | null x: {a: d: 1} | null - @test(eq, {x: null}) } nestedNonMonotonic: incomplete: b: n1: p2: { x: {a: c: 1} | null - x: {a: struct.MinFields(3)} | null + x: {a: struct.MinFields(3)} | null x: {a: d: 1} | null - @test(eq, {x: null}) } nestedNonMonotonic: incomplete: b: n1: p3: { x: {a: c: 1} | null x: {a: d: 1} | null - x: {a: struct.MinFields(3)} | null - @test(eq, {x: null}) + x: {a: struct.MinFields(3)} | null } nestedNonMonotonic: incomplete: b: n2: p1: { - x: {a: b: struct.MinFields(3)} | null + x: {a: b: struct.MinFields(3)} | null x: {a: b: c: 1} | null x: {a: b: d: 1} | null - @test(eq, {x: {a: {b: {c: 1, d: 1}}} | null}) } nestedNonMonotonic: incomplete: b: n2: p1: { x: {a: b: c: 1} | null - x: {a: b: struct.MinFields(3)} | null + x: {a: b: struct.MinFields(3)} | null x: {a: b: d: 1} | null - @test(eq) // TODO: rename to p2 } nestedNonMonotonic: incomplete: b: n2: p1: { x: {a: b: c: 1} | null x: {a: b: d: 1} | null - x: {a: b: struct.MinFields(3)} | null - @test(eq, {x: {a: {b: {c: 1, d: 1}}} | null}) // TODO: rename to p3 + x: {a: b: struct.MinFields(3)} | null } preserveClosedness: small: p1: { @@ -179,10 +150,6 @@ preserveClosedness: small: p1: { *{} | {a: string} *{} | {b: int} } - @test(eq, { - #A: *{a: string} | {a: string, b: int} - #B: *{} | {b: int} | {a: string} | {a: string, b: int} - }) } preserveClosedness: small: p2: { @@ -191,10 +158,6 @@ preserveClosedness: small: p2: { {a: string} | *{} *{} | {b: int} } - @test(eq, { - #A: *{a: string} | {a: string, b: int} - #B: *{} | {a: string, b: int} | {a: string} | {b: int} - }) } preserveClosedness: medium: p1: { @@ -203,10 +166,6 @@ preserveClosedness: medium: p1: { *{} | {a: string} | {b: string} *{} | {c: int} | {d: string} } - @test(eq, { - #A: *{a: string} | {a: string, c: int} | {a: string, d: string} - #B: *{} | {c: int} | {d: string} | {a: string} | {a: string, c: int} | {a: string, d: string} | {b: string} | {b: string, c: int} | {b: string, d: string} - }) } preserveClosedness: medium: p2: { @@ -215,10 +174,6 @@ preserveClosedness: medium: p2: { {a: string} | *{} | {b: string} *{} | {c: int} | {d: string} } - @test(eq, { - #A: *{a: string} | {a: string, c: int} | {a: string, d: string} - #B: *{} | {a: string, c: int} | {a: string, d: string} | {a: string} | {c: int} | {d: string} | {b: string} | {b: string, c: int} | {b: string, d: string} - }) } preserveClosedness: medium: p3: { @@ -227,10 +182,6 @@ preserveClosedness: medium: p3: { {a: string} | {b: string} | *{} *{} | {c: int} | {d: string} } - @test(eq, { - #A: *{a: string} | {a: string, c: int} | {a: string, d: string} - #B: *{} | {a: string, c: int} | {a: string, d: string} | {b: string} | {b: string, c: int} | {b: string, d: string} | {a: string} | {c: int} | {d: string} - }) } // If an error occurred in the last disjunction, it may sometimes be propagated @@ -242,70 +193,49 @@ noChildError: issue1608: { #type: fieldName: #subtype #subtype: string | {foo: string} | {bar: #subtype} - @test(eq, { - myValue: {fieldName: "some string"} - #type: {fieldName: string | {foo: string}} - #subtype: string | {foo: string} - }) } noChildError: t1: { - #D: {b: string} | {c: #D } + #D: {b: string} | {c: #D} o: #D & {b: "test"} - @test(eq, {#D: {b: string}, o: {b: "test"}}) } noChildError: t2: { o: #D & {b: "test"} - #D: {b: string} | {c: #D } - @test(eq, {o: {b: "test"}, #D: {b: string}}) + #D: {b: string} | {c: #D} } noChildError: t3: { - #D: {a: null} | {b: string} | {c: #D } + #D: {a: null} | {b: string} | {c: #D} o: #D & {b: "test"} - @test(eq, { - #D: {a: null} | {b: string} - o: {b: "test"} - }) } noChildError: t4: { o: #D & {b: "test"} - #D: {a: null} | {b: string} | {c: #D } - @test(eq, { - o: {b: "test"} - #D: {a: null} | {b: string} - }) + #D: {a: null} | {b: string} | {c: #D} } - issue1924: t1: { m: a: 2 x: *[m.b] | 2 - @test(eq, {m: {a: 2}, x: 2}) } issue1924: t2: { m: a: 2 x: *{v: m.b} | 3 - @test(eq, {m: {a: 2}, x: 3}) } issue1924: t3: { m: a: 2 x: *m.b | 1 - @test(eq, {m: {a: 2}, x: 1}) } // should eliminate erroneous comprehension and pass issue1838: t1: { p?: [] a: [for k in p {k}] | null - @test(eq, {p?: [], a: null}) } issue1838: t2: { p?: [] a: null | [for k in p {k}] - @test(eq, {p?: [], a: null}) } noHang: { @@ -316,7 +246,6 @@ noHang: { #X: x #X: #T - @test(eq, {#T: ["d"], x: ["d"], #X: ["d"]}) } issue1940: { @@ -329,14 +258,7 @@ issue1940: { #C: #B & { x: #A } - @test(eq, { - #T: ["d", []] - #A: {type: ["d", []]} - #B: {} - #C: {x: {type: ["d", []]}} - }) } - -- issue2209full.cue -- // Evaluator 0.5 regression where disjunctions combined with comprehensions // produced incorrect results or spurious errors. @@ -347,7 +269,7 @@ issue2209: simplified: t1: { #SpecFoo: foo: min: 1 #SpecBar: bar: min: 1 spec: bar: {} - spec: #SpecFoo | #SpecBar + spec: #SpecFoo | #SpecBar out: { {nullFoo: null} | {nullBar: null} {minFoo: int} | {minBar: int} @@ -356,30 +278,6 @@ issue2209: simplified: t1: { } X: spec } - @test(eq, { - #SpecFoo: {foo: {min: 1}} - #SpecBar: {bar: {min: 1}} - spec: {bar: {min: 1}} - out: { - minBar: 1 - X: {bar: {min: 1}} - nullFoo: null - minFoo: int - } | { - minBar: 1 - X: {bar: {min: 1}} - nullFoo: null - } | { - minBar: 1 - X: {bar: {min: 1}} - nullBar: null, - minFoo: int - } | { - minBar: 1 - X: {bar: {min: 1}} - nullBar: null - } - }) } issue2209: simplified: t2: { @@ -392,34 +290,6 @@ issue2209: simplified: t2: { } {f1: int} | {b2: int} {f2: int} | {b2: int} - @test(eq, { - #SpecFoo: {foo: {}} - #SpecBar: {bar: {x: 1}} - spec: {bar: {x: 1}} - BAZ: 1 - f1: int - f2: int - } | { - #SpecFoo: {foo: {}} - #SpecBar: {bar: {x: 1}} - spec: {bar: {x: 1}} - BAZ: 1 - f1: int - b2: int - } | { - #SpecFoo: {foo: {}} - #SpecBar: {bar: {x: 1}} - spec: {bar: {x: 1}} - BAZ: 1 - b2: int - f2: int - } | { - #SpecFoo: {foo: {}} - #SpecBar: {bar: {x: 1}} - spec: {bar: {x: 1}} - BAZ: 1 - b2: int - }) } // This test fails for 0.4 and 0.5. @@ -428,68 +298,15 @@ issue2209: simplified: t3: { {f1: int} | {b2: int} {f2: int} | {b2: int} BAZ: S.y - S: *#A | #B + S: *#A | #B #B: {x: 1, y: 1} S: x: 1 - @test(eq, { - #A: {v: 1} - BAZ: 1 - S: {x: 1, y: 1} - #B: {x: 1, y: 1} - f1: int - f2: int - } | { - #A: {v: 1} - BAZ: 1 - S: {x: 1, y: 1} - #B: {x: 1, y: 1} - f1: int - b2: int - } | { - #A: {v: 1} - BAZ: 1 - S: {x: 1, y: 1} - #B: {x: 1, y: 1} - b2: int - f2: int - } | { - #A: {v: 1} - BAZ: 1 - S: {x: 1, y: 1} - #B: {x: 1, y: 1} - b2: int - }) } issue2209: full: { Foo: #Abstract & {spec: foo: {}} - @test(shareID=FooSpec, at=Foo.spec) - @test(shareID=FooSpec, at=Foo.resource._X.spec) - @test(eq, at=Foo, { - spec: {foo: {min: *10 | int, max: *20 | int}} - resource: { - _X: spec: {foo: {min: *10 | int, max: *20 | int}} - spec: *{ - minFoo: *10 | int - maxFoo: *20 | int - minBar?: null - maxBar?: null - hoge?: null | bool - fuga?: null - } | { - minFoo: *10 | int - maxFoo: *20 | int - minBar?: null - maxBar?: null - hoge?: null - fuga?: null | bool - } - } - }) Bar: #Abstract & {spec: bar: {}} - @test(shareID=BarSpec, at=Bar.spec) - @test(shareID=BarSpec, at=Bar.resource._X.spec) #Abstract: X={ spec: _#Spec @@ -560,118 +377,7 @@ issue2209: full: { fuga?: null | bool } } - - @test(eq, at=Bar, { - spec: {bar: {min: *30 | int, max: *40 | int}} - resource: { - _X: spec: {bar: {min: *30 | int, max: *40 | int}} - spec: *{ - minFoo?: null - maxFoo?: null - minBar: *30 | int - maxBar: *40 | int - hoge?: null | bool - fuga?: null - } | { - minFoo?: null - maxFoo?: null - minBar: *30 | int - maxBar: *40 | int - hoge?: null - fuga?: null | bool - } - } - }) - // #Abstract: { - // spec: *{ - // foo: {min: *10 | int, max: *20 | int} - // } | { - // bar: {min: *30 | int, max: *40 | int} - // } - // resource: { - // _X: { - // spec: *{ - // foo: {min: *10 | int, max: *20 | int} - // } | { - // bar: {min: *30 | int, max: *40 | int} - // } - // } - // spec: *{ - // minFoo: *10 | int - // maxFoo: *20 | int - // minBar?: null - // maxBar?: null - // hoge?: null | bool - // fuga?: null - // } | { - // minFoo: *10 | int - // maxFoo: *20 | int - // minBar?: null - // maxBar?: null - // hoge?: null - // fuga?: null | bool - // } - // } - // } - // _#Spec: *{ - // foo: {min: *10 | int, max: *20 | int} - // } | { - // bar: {min: *30 | int, max: *40 | int} - // } - // _#SpecFoo: {foo: {min: *10 | int, max: *20 | int}} - // _#SpecBar: {bar: {min: *30 | int, max: *40 | int}} - // _Thing: { - // _X: _ - // spec: *{ - // minFoo: *10 | int - // maxFoo: *20 | int - // minBar?: null - // maxBar?: null - // hoge?: null | bool - // fuga?: null - // } | *{ - // minFoo?: null - // maxFoo?: null - // minBar: *30 | int - // maxBar: *40 | int - // hoge?: null | bool - // fuga?: null - // } | { - // minFoo: *10 | int - // maxFoo: *20 | int - // minBar?: null - // maxBar?: null - // hoge?: null - // fuga?: null | bool - // } | { - // minFoo?: null - // maxFoo?: null - // minBar: *30 | int - // maxBar: *40 | int - // hoge?: null - // fuga?: null | bool} - // } - // #Constrained: { - // spec: *{minFoo: *10 | int, maxFoo: *20 | int, minBar?: null, maxBar?: null, hoge?: null | bool, fuga?: null} | *{minFoo?: null, maxFoo?: null, minBar: *30 | int, maxBar: *40 | int, hoge?: null | bool, fuga?: null - // } | { - // minFoo: *10 | int, maxFoo: *20 | int, minBar?: null, maxBar?: null, hoge?: null, fuga?: null | bool - // } | { - // minFoo?: null, maxFoo?: null, minBar: *30 | int, maxBar: *40 | int, hoge?: null, fuga?: null | bool} - // } - // #Base: { - // spec: { - // minFoo?: null | int - // maxFoo?: null | int - // minBar?: null | int - // maxBar?: null | int - // hoge?: null | bool - // fuga?: null | bool - // } - // } - // }) } - - -- issue2246.cue -- // Evaluator regression where repeated use of an embedded disjunction resulted // in spurious "field not allowed" errors. @@ -679,19 +385,11 @@ issue2209: full: { issue2246: simplified: { #FormFoo: fooID: string #FormBar: barID: string - #Form: { #FormFoo | #FormBar } + #Form: {#FormFoo | #FormBar} data: {fooID: "123"} out1: #Form & data out2: #Form & out1 - @test(eq, { - #FormFoo: {fooID: string} - #FormBar: {barID: string} - #Form: {fooID: string} | {barID: string} - data: {fooID: "123"} - out1: {fooID: "123"} - out2: {fooID: "123"} - }) } issue2246: full: { data: forms: [{ @@ -720,31 +418,15 @@ issue2246: full: { } #summarizeReturn: { - in: #Input - out: [for k in in.forms { k.common }] + in: #Input + out: [for k in in.forms {k.common}] } #compute: { - in: #Input + in: #Input out: (#summarizeReturn & {"in": in}).out } - @test(eq, { - data: {forms: [{ - fooID: "00-0000001" - }]} - form1040: [3] - #K1: { - #_base: {common: 3} - #FormFoo: {fooID: string, common: 3} - #FormBar: {barID: string, common: 3} - #Form: {fooID: string, common: 3} | {barID: string, common: 3} - } - #Input: {forms: []} - #summarizeReturn: {in: {forms: []}, out: []} - #compute: {in: {forms: []}, out: []} - }) } - -- issue2263.cue -- // Disjunction regression in v0.5.0-beta.5 where multiple embedded disjunctions // in a definition were not evaluated correctly. @@ -761,14 +443,8 @@ issue2263: simplified: { avg: 60 } - #IDSource: id: string + #IDSource: id: string #TargetAverage: avg: number - @test(eq, { - metrics: {id: "foo", avg: 60} - #Metric: {id: string, avg: number} | {id: string} | {avg: number} | {} - #IDSource: {id: string} - #TargetAverage: {avg: number} - }) } issue2263: full: { metrics: [...#Metric] @@ -815,28 +491,6 @@ issue2263: full: { #TargetValue: { value: number } - @test(eq, { - metrics: [{ - avg: 60 - id: "foo" - }, { - id: "bar" - value: 80 - }, { - avg: 70 - uri: "baz" - }, { - uri: "qux" - value: 90 - }] - #Metric: {id: string, avg: number} | {id: string, value: number} | {uri: string, avg: number} | {uri: string, value: number} - #Source: {id: string} | {uri: string} - #Target: {avg: number} | {value: number} - #IDSource: {id: string} - #URISource: {uri: string} - #TargetAverage: {avg: number} - #TargetValue: {value: number} - }) } -- issue1417.cue -- // Regression where disjuncts sometimes behaved like conjuncts, causing @@ -846,10 +500,6 @@ issue1417: { #ID: !~"^a" | =~"^ab$" | =~"^aB$" #ID: =~"^a" | !~"[A-Z]" ids: [...#ID] & ["xyz", "ab", "aB"] - @test(eq, { - #ID: !~"^a" & =~"^a" | !~"^a" & !~"[A-Z]" | =~"^ab$" & =~"^a" | =~"^ab$" & !~"[A-Z]" | =~"^aB$" & =~"^a" | =~"^aB$" & !~"[A-Z]" - ids: ["xyz", "ab", "aB"] - }) } -- issue3149.cue -- // Evaluator regression where unifying disjunctions incorrectly failed to @@ -866,20 +516,6 @@ issue3149: { {name: "FooQuuxFoo"}, {name: "an exception"}, ] - @test(eq, { - #valid: { - name!: =~"^Foo" & =~"Foo$" | "an exception" - } - list: [{ - name: "FooBarFoo" - }, { - name: "FooBazFoo" - }, { - name: "FooQuuxFoo" - }, { - name: "an exception" - }] - }) } -- issue770.cue -- // Default value resolution issue where chained pattern constraints with default @@ -903,16 +539,6 @@ issue770: { h: boo: _ h: c: _ h: coo: _ - @test(eq, { - #A: {v: "a" | "b" | "c"} - h: { - a: {v: *"a" | "b" | "c"} - b: {v: *"a" | "b" | "c"} - boo: {v: *"a" | "b" | "c"} - c: {v: *"a" | "b" | "c"} - coo: {v: *"a" | "b" | "c"} - } - }) } -- issue3528.cue -- // evalv3 "incDependent: already closed" panic with repeated disjunctions @@ -928,57 +554,27 @@ issue3528: original: { container: [string]: string | #container #container: string | {volumes?: [...string]} } - @test(eq, { - workflows: [ - {container: {}, #container: string | {volumes?: []}}, - ] - test: { - container: {} - #container: string | {volumes?: []} - } - #Workflow: { - container: {} - #container: string | {volumes?: []} - } - }) } issue3528: reduced: { a?: #A - a: #A & {} + a: #A & {} #A: { A: [string]: 1 | #a #a: 2 | {v: 1} } - @test(eq, { - a: {A: {}, #a: 2 | {v: 1}} - #A: {A: {}, #a: 2 | {v: 1}} - }) -} -issue3528: counter: { - @test(eq, {}) } +issue3528: counter: {} issue3528: nested: t1: { {v: 1} | (2 | 3) {v: 1} | (2 | 3) {v: 1} | (2 | 3) {v: 1} | (2 | 3) - @test(eq, {v: 1} | { - 2 - @test(eq) - } | { - 3 - @test(eq) - }) } issue3528: nested: t2: { {v: 1} | 2 {v: 1} | (2 | 3) {v: 1} | 2 {v: 1} | 2 - @test(eq, {v: 1} | { - 2 - @test(eq) - }) } -- issue3784.cue -- // evalv3 regressions with "conflicting values" and "field not allowed" errors @@ -998,12 +594,6 @@ issue3784: reduced: { kind: "A" b: c: "x" } - @test(eq, { - #Schema: { - a: {kind: "A", b: {c?: string}} | {kind: "B"} - } - out: {a: {kind: "A", b: {c: "x"}}} - }) } issue3784: full: { #Schema: { @@ -1035,18 +625,6 @@ issue3784: full: { } } } - @test(eq, { - #Schema: { - pages?: {build_type!: "legacy", source!: {branch!: string, path?: string}, cname?: string} | {build_type!: "workflow", source?: {branch?: string, path?: string}, cname?: string} - } - out: { - pages: { - cname: "foo.com" - build_type: "legacy" - source: {branch: "main", path: "/"} - } - } - }) } issue3784: variant1: { #Schema: { @@ -1068,15 +646,6 @@ issue3784: variant1: { cname?: _ }) } - @test(eq, { - #Schema: { - pages: { - build_type!: "legacy" - source: {branch!: string, path?: string} - cname?: string - } - } - }) } issue3784: variant2: { #Schema: { @@ -1097,17 +666,6 @@ issue3784: variant2: { } cname?: string } - @test(eq, { - #Schema: {build_type!: "legacy", source!: {branch!: _}} | {build_type!: "workflow", cname?: _} - a: { - build_type!: "legacy" - source: { - branch!: string - path?: _|_ @test(err, code=eval, contains="issue3784.variant2.a.source.path: field not allowed", pos=[113:4]) - } - cname?: _|_ @test(err, code=eval, contains="issue3784.variant2.a.cname: field not allowed", pos=[115:3]) - } - }) } -- issue3958.cue -- // evalv3 regression where unifying an odd number of default disjunctions no @@ -1119,19 +677,10 @@ issue3958: t1: { test1: #schema & {int | *2} test2: #schema & {int | *4} - @test(eq, { - #schema: int | 3 | 1 - test1: int | 3 | 1 | 2 - test2: int | 3 | 1 | 4 - }) } issue3958: t2: { - a: (int | *4) & (int | *1) & (int | *3) & (int | *8) + a: (int | *4) & (int | *1) & (int | *3) & (int | *8) b: (int | *4) & (int | *1) & (int | *3) - @test(eq, { - a: int | 8 | 3 | 1 | 4 - b: int | 3 | 1 | 4 - }) } -- issue2685.cue -- // Nested definition with a default value incorrectly took the default value @@ -1139,7 +688,7 @@ issue3958: t2: { // https://cuelang.org/issue/2685 issue2685: { #Foo: { - bar: int + bar: int opt?: int } | *{ opt: int @@ -1151,10 +700,6 @@ issue2685: { { foo: #Foo } - @test(eq, { - #Foo: *{opt: int} | {bar: int, opt?: int} - foo: {bar: 0, opt?: int} - }) } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/disjunctions/embed.txtar b/internal/core/compile/testdata/sync/disjunctions/embed.txtar index 47ef1f420..700bdac3e 100644 --- a/internal/core/compile/testdata/sync/disjunctions/embed.txtar +++ b/internal/core/compile/testdata/sync/disjunctions/embed.txtar @@ -6,39 +6,33 @@ default: { y: *1 | {a: 2} y - @test(eq, {y: *1 | {a: 2}, a: 2}) } unambiguous: { y: 1 | {a: 2} y - @test(eq, {y: 1 | {a: 2}, a: 2}) } forDefault: { y: *1 | {a: 2} for x in [1] {y} - @test(eq, {y: *1 | {a: 2}, a: 2}) } // Carry over default to first disjunct. openDefault: { #y: *1 | {a: 2} #y - @test(eq, *{1, #y: *1 | {a: 2}} | {#y: *1 | {a: 2}, a: 2}) } openAmbiguous: { #y: 1 | {a: 2} #y - @test(eq, {1, #y: 1 | {a: 2}} | {#y: 1 | {a: 2}, a: 2}) } forceStruct: { #y: 1 | {a: 2} #y {} - @test(eq, {#y: 1 | {a: 2}, a: 2}) } defaultsMulti: { @@ -60,22 +54,11 @@ defaultsMulti: { a: #def & {a: "foo", e: "bar"} } - @test(eq, { - a: { - #def: *{} | {c: string} | {d: string} | {a: string} | {a: string, c: string} | {a: string, d: string} | {b: string} | {b: string, c: string} | {b: string, d: string} - a: *{a: "foo"} | {a: "foo", c: string} | {a: "foo", d: string} - } - b: { - #def: *{} | {d: string} | {e: string} | {c: string} | {c: string, d: string} | {c: string, e: string} | {d: string, e: string} | {a: string} | {a: string, d: string} | {a: string, e: string} | {a: string, c: string} | {a: string, c: string, d: string} | {a: string, c: string, e: string} | {a: string, d: string, e: string} | {b: string} | {b: string, d: string} | {b: string, e: string} | {b: string, c: string} | {b: string, c: string, d: string} | {b: string, c: string, e: string} | {b: string, d: string, e: string} - a: *{a: "foo", e: "bar"} | {a: "foo", e: "bar", c: string} | {a: "foo", e: "bar", d: string} - } - }) } nested: { a: 1 | 2 | *( (3 | 4 | *( 5 | 6 | *7)) & ( 3 | 4 | ( *7 | 8 ))) - @test(eq, {a: *7 | 2 | 3 | 4 | 1}) } -- issue3415.cue -- // evalv3: calculated embedded scalars with a default value disagree with v2 @@ -84,18 +67,14 @@ nested: { issue3415: full: { A: #A & { i: { - _a + _b - _a: 1 - _b: 10 + _a + _b + _a: 1 + _b: 10 } } #A: { i: *0 | number } - @test(eq, { - A: {i: {11, _a: 1, _b: 10}} - #A: {i: *0 | number} - }) } issue3415: reduced: { a: { @@ -103,7 +82,6 @@ issue3415: reduced: { #b: 10 } a: *0 | number - @test(eq, {a: {11, #b: 10}}) } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/disjunctions/errors.txtar b/internal/core/compile/testdata/sync/disjunctions/errors.txtar index 611c219d2..c72e32525 100644 --- a/internal/core/compile/testdata/sync/disjunctions/errors.txtar +++ b/internal/core/compile/testdata/sync/disjunctions/errors.txtar @@ -16,7 +16,6 @@ issue570: { result?: [... string] ... } - @test(err, code=eval, at=results.result, contains="conflicting values", args=["hello", [...string]], pos=[1:11, 2:19, 11:12]) } // Clarify when an error resulted from a failed disjunction; error messages @@ -29,16 +28,13 @@ issue516: { x: #Def x: match: metrics: "foo": {} - @test(err, code=eval, at=x, contains="2 errors in empty disjunction", pos=[]) } // issue #465 explicitDefaultError: { a: string | *_|_ - if a != "" { - } - @test(err, code=incomplete, contains="non-concrete value string in operand to !=", pos=[3:5, 1:5]) + if a != "" {} } // evaluator: export as YAML vs JSON emits different templated data when @@ -48,7 +44,6 @@ issue2916: { b: _ [_]: c: uint | *1 [string]: c: >=3 | *3 - @test(eq, {b: {c: *3 | >=3 & int}}) } // evaluator: inconsistent export output for different formats based on which // default is selected when multiple defaults are unified. @@ -56,7 +51,6 @@ issue2916: { issue3157: { foo: *42 | _ foo: *43 | bool - @test(eq, {foo: *43 | bool}) } -- issue3581.cue -- // evalv3: tools/flow unexpected error when a flow task result field is used as @@ -64,12 +58,8 @@ issue3157: { // https://cuelang.org/issue/3581 issue3581: reduced: { list: [...] | *[] - list: ["\(c)" ] @test(err, code=incomplete, contains="2 errors in empty disjunction", - suberr=(code=incomplete, contains="incompatible list lengths", args=[0, 1], pos=[-1:17]), - suberr=(code=incomplete, contains="invalid interpolation: non-concrete value", pos=[0:9]), - ) + list: ["\(c)"] c: _ - @test(eq, {list: _|_, c: _}) } -- issue3576.cue -- // evalv3: disjunct of definitions with identical optional fields results in @@ -84,11 +74,6 @@ issue3576: reduced: { } foo: #B | #A foo: a: "1" - @test(eq, { - #A: {a!: string} - #B: {} - foo: {a: "1"} - }) } issue3576: full: { #Run: { @@ -106,17 +91,11 @@ issue3576: full: { optionsValue: options } } - + #Option: {} - + foo: #Run | #Copy foo: run: "make" - @test(eq, { - #Run: {run!: string, options?: {} | [{}]} - #Copy: {copy!: string, options?: {} | [{}]} - #Option: {} - foo: {run: "make", options?: {} | [{}]} - }) } -- issue3599.cue -- // evalv3: "explicit error in source" regression when using bottom (_|_) in @@ -133,7 +112,7 @@ issue3599: full: { read?: _|_ } } - + #Minio: { container: #Action & { action: { @@ -147,41 +126,22 @@ issue3599: full: { doWrite: bool | *true container: action: defaultAction defaultAction: { - if doWrite { write: "somefile.txt" } - if !doWrite { read: "somefile.txt" } + if doWrite {write: "somefile.txt"} + if !doWrite {read: "somefile.txt"} } } - @test(skip, hint="somehow this test doesn't work. Fix it.") - @test(eq:todo, { - #Action: { - action: {read!: string, write?: _|_ @test(err, code=user, contains="explicit error (_|_ literal) in source", pos=[])} | {write!: string, read?: _|_ @test(err, code=user, contains="explicit error (_|_ literal) in source", pos=[])} - } - #Minio: { - container: { - action: { - write: "somefile.txt" - read?: _|_ @test(err, code=user, contains="explicit error (_|_ literal) in source (and 1 more errors)", pos=[23:13]) - } - } - doWrite: *true | bool - defaultAction: {write: "somefile.txt"} - } - }) } issue3599: reduced: p1: { - { a?: 1&2 } | { a: string, b?: 1&2 } - { } | { } - @test(eq, {a?: _|_ @test(err, code=eval, contains="conflicting values", args=[2, 1], pos=[49:25, 50:2, 50:9, 50:11])} | {a: string, b?: _|_ @test(err, code=eval, contains="conflicting values", args=[2, 1], pos=[49:25, 50:2, 50:35, 50:37])}) + {a?: 1 & 2} | {a: string, b?: 1 & 2} + {} | {} } issue3599: reduced: p2: { - { } | { } - { a?: 1&2 } | { a: string, b?: 1&2 } - @test(eq, {a?: _|_ @test(err, code=eval, contains="conflicting values", args=[2, 1], pos=[54:25, 56:2, 56:9, 56:11])} | {a: string, b?: _|_ @test(err, code=eval, contains="conflicting values", args=[2, 1], pos=[54:25, 56:2, 56:35, 56:37])}) + {} | {} + {a?: 1 & 2} | {a: string, b?: 1 & 2} } issue3599: let: { - { } | { a: B | 1, let B = 1&2 } - { } | { } - @test(eq, {} | {a: 1}) + {} | {a: B | 1, let B = 1 & 2, } + {} | {} } -- optionalerror.cue -- // evalv3 closedness regression with disjunctions and ellipses; a definition @@ -190,24 +150,9 @@ issue3599: let: { issue4022: reduced: { #NonNamespaced: metadata: namespace?: _|_ #NullOrNonNamespaced: int | #NonNamespaced - out: #NullOrNonNamespaced - out: #NonNamespaced + out: #NullOrNonNamespaced + out: #NonNamespaced out: metadata: {} - @test(eq, { - #NonNamespaced: { - metadata: { - namespace?: _|_ @test(err, code=user, contains="explicit error (_|_ literal) in source", pos=[5:40]) - } - } - #NullOrNonNamespaced: int | {metadata: { - namespace?: _|_ @test(err, code=user, contains="explicit error (_|_ literal) in source", pos=[5:40]) - }} - out: { - metadata: { - namespace?: _|_ @test(err, code=user, contains="explicit error (_|_ literal) in source", pos=[5:40]) - } - } - }) } issue4022: full: { #NonNamespaced: { @@ -227,25 +172,6 @@ issue4022: full: { metadata: name: "foo" apiVersion: "v1" } - @test(eq, { - #NonNamespaced: { - metadata: { - name!: string - namespace?: _|_ @test(err, code=user, contains="explicit error (_|_ literal) in source", pos=[30:16]) - } - } - #NullOrNonNamespaced: null | {metadata: { - name!: string - namespace?: _|_ @test(err, code=user, contains="explicit error (_|_ literal) in source", pos=[30:16]) - }} - out: { - metadata: { - name: "foo" - namespace?: _|_ @test(err, code=user, contains="explicit error (_|_ literal) in source", pos=[30:16]) - } - apiVersion: "v1" - } - }) } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/disjunctions/incomplete.txtar b/internal/core/compile/testdata/sync/disjunctions/incomplete.txtar index fbd76e5b8..939e2b82e 100644 --- a/internal/core/compile/testdata/sync/disjunctions/incomplete.txtar +++ b/internal/core/compile/testdata/sync/disjunctions/incomplete.txtar @@ -8,37 +8,26 @@ issue700: { a: y: "y" test1: *a.x | 1 test2: *a.y | 1 - @test(eq, {a: {y: "y"}, test1: 1, test2: *"y" | 1}) } lookup: { x: { name: "Hello" } - y: x.a @test(err, code=incomplete, contains="undefined field: a", pos=[0:14]) - ok1: *x.a | x @test(eq, {name: "Hello"}) - ok2: x | *x.a @test(eq, {name: "Hello"}) - ok3: x.a | *x @test(eq, {name: "Hello"}) - ok4: *x | x.a @test(eq, {name: "Hello"}) - ok5: x | x.a @test(eq) - ok5: x.a | x @test(eq, {name: "Hello"}) - allFail1: x.a | x.b @test(err, code=incomplete, contains="2 errors in empty disjunction", - suberr=(code=incomplete, contains="undefined field: a", pos=[0:14]), - suberr=(code=incomplete, contains="undefined field: b", pos=[0:20]), - ) - allFail2: x.a | x.b @test(err, code=incomplete, contains="2 errors in empty disjunction", - suberr=(code=incomplete, contains="undefined field: a", pos=[0:14]), - suberr=(code=incomplete, contains="undefined field: b", pos=[0:20]), - ) + y: x.a + ok1: *x.a | x + ok2: x | *x.a + ok3: x.a | *x + ok4: *x | x.a + ok5: x | x.a + ok5: x.a | x + allFail1: x.a | x.b + allFail2: x.a | x.b } func: { s: string - ok1: yaml.MarshalStream(s) | yaml.Marshal(s) @test(err, code=incomplete, - contains="2 errors in empty disjunction", - suberr=(code=incomplete, contains="non-concrete argument 0", pos=[0:7]), - suberr=(code=incomplete, contains="non-concrete argument 0", pos=[0:31]), - ) + ok1: yaml.MarshalStream(s) | yaml.Marshal(s) } // Default mark on interpolated string; a concrete override should suppress @@ -49,37 +38,21 @@ issue782: { inner: string interpolation: *"\(inner)" | string interpolation: "override" - @test(eq, { - inner: string - interpolation: "override" - }) } b: { inner: string interpolation: string | *"\(inner)" interpolation: "override" - @test(eq, { - inner: string - interpolation: "override" - }) } c: { inner: string interpolation: "\(inner)" | string interpolation: "override" - @test(eq, { - inner: string - interpolation: "override" - }) } d: { inner: string interpolation: string | "\(inner)" interpolation: "override" - @test(eq, { - inner: string - interpolation: "override" - }) } } -- issue3680.cue -- @@ -92,15 +65,13 @@ issue3680: t1: { b?: _|_ } {} | {} - @test(eq, {} | {a?: _|_, b?: _|_}) } issue3680: t2: { - x: {} | { + x: {} | { a?: _|_ b?: _|_ } - x: {} | {} - @test(eq, {x: {} | {a?: _|_, b?: _|_}}) + x: {} | {} } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/disjunctions/issue2209.txtar b/internal/core/compile/testdata/sync/disjunctions/issue2209.txtar index 99eb02808..d582dec2e 100644 --- a/internal/core/compile/testdata/sync/disjunctions/issue2209.txtar +++ b/internal/core/compile/testdata/sync/disjunctions/issue2209.txtar @@ -76,55 +76,6 @@ full: { fuga?: null | bool } } - @test(eq, { - Foo: { - spec: {foo: {min: *10 | int, max: *20 | int}} - resource: { - _X: { - spec: {foo: {min: *10 | int, max: *20 | int}} - } - spec: *{minFoo: *10 | int, maxFoo: *20 | int, minBar?: null, maxBar?: null, hoge?: null | bool, fuga?: null} | {minFoo: *10 | int, maxFoo: *20 | int, minBar?: null, maxBar?: null, hoge?: null, fuga?: null | bool} - } - } - Bar: { - spec: {bar: {min: *30 | int, max: *40 | int}} - resource: { - _X: { - spec: {bar: {min: *30 | int, max: *40 | int}} - } - spec: *{minFoo?: null, maxFoo?: null, minBar: *30 | int, maxBar: *40 | int, hoge?: null | bool, fuga?: null} | {minFoo?: null, maxFoo?: null, minBar: *30 | int, maxBar: *40 | int, hoge?: null, fuga?: null | bool} - } - } - #Abstract: { - spec: *{foo: {min: *10 | int, max: *20 | int}} | {bar: {min: *30 | int, max: *40 | int}} - resource: { - _X: { - spec: *{foo: {min: *10 | int, max: *20 | int}} | {bar: {min: *30 | int, max: *40 | int}} - } - spec: *{minFoo: *10 | int, maxFoo: *20 | int, minBar?: null, maxBar?: null, hoge?: null | bool, fuga?: null} | {minFoo: *10 | int, maxFoo: *20 | int, minBar?: null, maxBar?: null, hoge?: null, fuga?: null | bool} - } - } - _#Spec: *{foo: {min: *10 | int, max: *20 | int}} | {bar: {min: *30 | int, max: *40 | int}} - _#SpecFoo: {foo: {min: *10 | int, max: *20 | int}} - _#SpecBar: {bar: {min: *30 | int, max: *40 | int}} - _Thing: { - _X: _ - spec: *{minFoo: *10 | int, maxFoo: *20 | int, minBar?: null, maxBar?: null, hoge?: null | bool, fuga?: null} | *{minFoo?: null, maxFoo?: null, minBar: *30 | int, maxBar: *40 | int, hoge?: null | bool, fuga?: null} | {minFoo: *10 | int, maxFoo: *20 | int, minBar?: null, maxBar?: null, hoge?: null, fuga?: null | bool} | {minFoo?: null, maxFoo?: null, minBar: *30 | int, maxBar: *40 | int, hoge?: null, fuga?: null | bool} - } - #Constrained: { - spec: *{minFoo: *10 | int, maxFoo: *20 | int, minBar?: null, maxBar?: null, hoge?: null | bool, fuga?: null} | *{minFoo?: null, maxFoo?: null, minBar: *30 | int, maxBar: *40 | int, hoge?: null | bool, fuga?: null} | {minFoo: *10 | int, maxFoo: *20 | int, minBar?: null, maxBar?: null, hoge?: null, fuga?: null | bool} | {minFoo?: null, maxFoo?: null, minBar: *30 | int, maxBar: *40 | int, hoge?: null, fuga?: null | bool} - } - #Base: { - spec: { - minFoo?: null | int - maxFoo?: null | int - minBar?: null | int - maxBar?: null | int - hoge?: null | bool - fuga?: null | bool - } - } - }) } reduced: { @@ -153,23 +104,6 @@ reduced: { *{nullFoo: null} | {nullBar: null} } - @test(eq, { - Foo: { - spec: {foo: {min: *10 | int}} - out: *{_Xspec: {foo: {min: *10 | int}}, minFoo: *10 | int, nullFoo: null} | {_Xspec: {foo: {min: *10 | int}}, minFoo: *10 | int, nullBar: null} - } - Bar: { - spec: {bar: {min: *20 | int}} - out: *{_Xspec: {bar: {min: *20 | int}}, minBar: *20 | int, nullFoo: null} | {_Xspec: {bar: {min: *20 | int}}, minBar: *20 | int, nullBar: null} - } - #Obj: { - spec: *{foo: {min: *10 | int}} | {bar: {min: *20 | int}} - out: *{_Xspec: *{foo: {min: *10 | int}} | {bar: {min: *20 | int}}, minFoo: *10 | int, nullFoo: null} | {_Xspec: *{foo: {min: *10 | int}} | {bar: {min: *20 | int}}, minFoo: *10 | int, nullBar: null} - } - #SpecFoo: {foo: {min: *10 | int}} - #SpecBar: {bar: {min: *20 | int}} - #Out: *{minFoo: int, nullFoo: null} | *{minBar: int, nullFoo: null} | {minFoo: int, nullBar: null} | {minBar: int, nullBar: null} - }) } -- out/compile -- --- input.cue diff --git a/internal/core/compile/testdata/sync/disjunctions/issue3850.txtar b/internal/core/compile/testdata/sync/disjunctions/issue3850.txtar index 99880363f..9d0e10cb9 100644 --- a/internal/core/compile/testdata/sync/disjunctions/issue3850.txtar +++ b/internal/core/compile/testdata/sync/disjunctions/issue3850.txtar @@ -11,19 +11,8 @@ issue3850: full: { #WithFoo: { _global: global - foo: _global.glb1.glb2 + foo: _global.glb1.glb2 } - @test(eq, { - global: {glb1: {glb2: "123"}} - out: { - _global: {glb1: {glb2: "123"}} - foo: "123" - } - #WithFoo: { - _global: {glb1: {glb2: "123"}} - foo: "123" - } - }) } issue3850: incomplete: { global: glb1: glb2: "123" @@ -33,20 +22,9 @@ issue3850: incomplete: { #WithFoo: { _global: global - foo: _global.glb1.glb2 + foo: _global.glb1.glb2 ... } - @test(eq, { - global: {glb1: {glb2: "123"}} - out: { - _global: {glb1: {glb2: "123"}} - foo: "123" - } - #WithFoo: { - _global: {glb1: {glb2: "123"}} - foo: "123" - } - }) } issue3850: p2p: { out: *{} | _ @@ -54,10 +32,6 @@ issue3850: p2p: { out: { reg: #def #def: foo: _global - @test(eq, { - reg: {foo: "global value"} - #def: {foo: "global value"} - }) } _global: "global value" @@ -68,16 +42,11 @@ issue3875: full: { out: desc: { _hidden: _global.name - name: _hidden + name: _hidden } out: #Schema | "never" #Schema: desc: {...} - @test(eq, { - _global: {name: "foo"} - out: {desc: {_hidden: "foo", name: "foo"}} - #Schema: {desc: {}} - }) } issue3875: reduced: { global: a: "foo" @@ -89,11 +58,6 @@ issue3875: reduced: { out: S | null S: {} - @test(eq, { - global: {a: "foo"} - out: {desc: {a: "foo", b: "foo"}} - S: {} - }) } -- out/compile -- --- issue3850.cue diff --git a/internal/core/compile/testdata/sync/disjunctions/issue3857.txtar b/internal/core/compile/testdata/sync/disjunctions/issue3857.txtar index 80355d4b4..6d32970bb 100644 --- a/internal/core/compile/testdata/sync/disjunctions/issue3857.txtar +++ b/internal/core/compile/testdata/sync/disjunctions/issue3857.txtar @@ -4,20 +4,14 @@ # https://cuelang.org/issue/3857 -- in.cue -- reduced: t1: { - S: { if true { a: U } } + S: {if true {a: U}} x: S x: { - ["a"]: b: 1 | T - d: b: x.a + ["a"]: b: 1 | T + d: b: x.a } T: 1 U: b: 1 | 1 - @test(eq, { - S: {a: {b: 1}} - x: {d: {b: {b: 1}}, a: {b: 1}} - T: 1 - U: {b: 1} - }) } // issue3851: evalv3 incorrectly rejects a let field nested under multiple // disjunctions with "field not allowed", a regression not present in evalv2. @@ -25,67 +19,43 @@ reduced: t1: { issue3851: t1: { #Top: _ #Config: { - disj: _ | *"default" - shared: _ + disj: _ | *"default" + shared: _ } #Schema: { - [string]: #Config - if true { - one: shared: "foo" - } + [string]: #Config + if true { + one: shared: "foo" + } } out: #Schema out: { - ["one"]: disj: _ | #Top - two: shared: out.one.shared + ["one"]: disj: _ | #Top + two: shared: out.one.shared } - @test(eq, { - #Top: _ - #Config: {disj: *"default" | _, shared: _} - #Schema: { - one: {shared: "foo", disj: *"default" | _} - } - out: { - two: {shared: "foo", disj: *"default" | _} - one: {shared: "foo", disj: *"default" | _} - } - }) } issue3851: t2: { #Top: _ #Config: { - disj: _ | *{} - shared: _ + disj: _ | *{} + shared: _ } #Env: { - conf: [string]: #Config - if true { - conf: one: shared: "foo" - } + conf: [string]: #Config + if true { + conf: one: shared: "foo" + } } env1: #Env [string]: { - conf: ["one"]: disj: {} | #Top - conf: two: shared: conf.one.shared + conf: ["one"]: disj: {} | #Top + conf: two: shared: conf.one.shared } - @test(eq, { - #Top: _ - #Config: {disj: *{} | _, shared: _} - #Env: { - conf: {one: {shared: "foo", disj: *{} | _}} - } - env1: { - conf: { - two: {shared: "foo", disj: *{} | _} - one: {shared: "foo", disj: *{} | _} - } - } - }) } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/disjunctions/issue4339.txtar b/internal/core/compile/testdata/sync/disjunctions/issue4339.txtar index 2adf815eb..d7bb9209d 100644 --- a/internal/core/compile/testdata/sync/disjunctions/issue4339.txtar +++ b/internal/core/compile/testdata/sync/disjunctions/issue4339.txtar @@ -11,10 +11,7 @@ out: { enable: *true | false if enable {} -} @test(eq, - // TODO: we should be able to use @test(final) here, avoiding the defaults. - *{one: 1, enable: *true | false, extra: 1} | {one: 1, enable: *true | false}, -) +} -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/disjunctions/nested.txtar b/internal/core/compile/testdata/sync/disjunctions/nested.txtar index f4b86dcdf..bc0168774 100644 --- a/internal/core/compile/testdata/sync/disjunctions/nested.txtar +++ b/internal/core/compile/testdata/sync/disjunctions/nested.txtar @@ -1,5 +1,6 @@ -- issue3635.cue -- import "list" + // evalv3: `incDependent: already closed` panic with a builtin and a disjunction; // using list.Concat to satisfy a disjunction of map or list should not crash. // https://cuelang.org/issue/3635 @@ -11,10 +12,6 @@ issue3635: case1: { command: Run & { env: list.Concat([["foo"], ["bar"]]) } - @test(eq, { - Run: {env: *{} | []} - command: {env: ["foo", "bar"]} - }) } issue3635: case2: { @@ -33,49 +30,24 @@ issue3635: case2: { #env: [string]: bool | string } - @test(eq, { - out: [{ - name: "x" - container?: {} - #container: string | {env?: {}} - #env: [string]: bool | string - }] - #Schema: { - name?: string - container?: {} - #container: string | {env?: {}} - #env: [string]: bool | string - - } - }) } issue3635: reduced: { out: {X} & X X: { b: int | c - c: int | { e: d } + c: int | {e: d} } d: 1 - @test(eq, { - out: {b: int | {e: 1}, c: int | {e: 1}} - X: {b: int | {e: 1}, c: int | {e: 1}} - d: 1 - }) } issue3635: reduced_noshare: { out: {X} & X X: { b: int | c - c: int | { e: d & __no_sharing } + c: int | {e: d & __no_sharing} } d: 1 - @test(eq, { - out: {b: int | {e: 1}, c: int | {e: 1}} - X: {b: int | {e: 1}, c: int | {e: 1}} - d: 1 - }) } -- out/compile -- --- issue3635.cue diff --git a/internal/core/compile/testdata/sync/disjunctions/operands.txtar b/internal/core/compile/testdata/sync/disjunctions/operands.txtar index 328ef78fa..80cb03a08 100644 --- a/internal/core/compile/testdata/sync/disjunctions/operands.txtar +++ b/internal/core/compile/testdata/sync/disjunctions/operands.txtar @@ -1,15 +1,15 @@ # This file tests disjunctions used as operands. -- in.cue -- -list: *[1] | [2] @test(eq, *[1] | [2]) -condition: *true | false @test(eq, *true | false) -num: *1 | 2 @test(eq, *1 | 2) -object: *{a: 1} | {a: 2} @test(eq, *{a: 1} | {a: 2}) +list: *[1] | [2] +condition: *true | false +num: *1 | 2 +object: *{a: 1} | {a: 2} forLoop: [ for e in list { "count: \(e)" }, -] @test(eq, ["count: 1"]) +] conditional: { if condition { @@ -18,27 +18,22 @@ conditional: { if num < 5 { b: 3 } - @test(eq, {a: 3, b: 3}) } selector: { a: object.a - @test(eq, {a: 1}) } index: { a: list[0] - @test(eq, {a: 1}) } binOp: { a: num + 4 - @test(eq, {a: 5}) } unaryOp: { a: -num - @test(eq, {a: -1}) } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/disjunctions/propagate_err.txtar b/internal/core/compile/testdata/sync/disjunctions/propagate_err.txtar index 0d27c0c49..487143125 100644 --- a/internal/core/compile/testdata/sync/disjunctions/propagate_err.txtar +++ b/internal/core/compile/testdata/sync/disjunctions/propagate_err.txtar @@ -12,7 +12,6 @@ issue4056: full: { if strings.HasPrefix(a, "foo") { a: _ | error("error message 2") } - @test(eq, {a: "foo-bar"}) } issue4056: reduced: { a: "x" @@ -20,7 +19,6 @@ issue4056: reduced: { if len(a) > 0 { a: _ | error("b") } - @test(eq, {a: "x"}) } variant: { a: "x" @@ -28,14 +26,12 @@ variant: { if len(a) > 0 { a: _ } - @test(eq, {a: "x"}) } -- pending.cue -- // Be sure to emit errors for uncompleted pending arcs. err: { A: "forty two" if A < 100 {B: true} - @test(err, code=eval, contains="invalid operands", pos=[2:5, 1:5, 2:9]) } -- out/compile -- --- issue4056.cue diff --git a/internal/core/compile/testdata/sync/disjunctions/resolve.txtar b/internal/core/compile/testdata/sync/disjunctions/resolve.txtar index ef8186ceb..2b4cf395c 100644 --- a/internal/core/compile/testdata/sync/disjunctions/resolve.txtar +++ b/internal/core/compile/testdata/sync/disjunctions/resolve.txtar @@ -1,16 +1,14 @@ // Ensure that references are resolved on the boundaries of disjunctions. -- in.cue -- resolveAcrossDisjunct: t1: { - {} | { #B: 1} // d resolves to 1 in the second case. + {} | {#B: 1} // d resolves to 1 in the second case. {d: #B} | {} #B: int - @test(eq, {#B: int, d: int} | {#B: int} | {#B: 1, d: 1} | {#B: 1}) } resolveAcrossDisjunct: nested: { - {} | { a: b: #B: 1} // d resolves to 1 in the second case. + {} | {a: b: #B: 1} // d resolves to 1 in the second case. {d: a.b.#B} | {} a: b: #B: int - @test(eq, {a: {b: {#B: int}}, d: int} | {a: {b: {#B: int}}} | {a: {b: {#B: 1}}, d: 1} | {a: {b: {#B: 1}}}) } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/disjunctions/specdeviation.txtar b/internal/core/compile/testdata/sync/disjunctions/specdeviation.txtar index b62282631..573bc59d5 100644 --- a/internal/core/compile/testdata/sync/disjunctions/specdeviation.txtar +++ b/internal/core/compile/testdata/sync/disjunctions/specdeviation.txtar @@ -15,41 +15,31 @@ Proof: p: *_|_ | 2 | int // M2: remove mark p: 2 | int // value after removing default. -- in.cue -- -Q: *1 | int @test(eq, *1 | int) -q: *Q | int @test(eq, *1 | int) // 1 as expected +Q: *1 | int +q: *Q | int // 1 as expected P: *1 | int P: 2 -p: *P | int @test(eq, *2 | int) // now 2, but should be (2 | int), according to the spec: +p: *P | int // now 2, but should be (2 | int), according to the spec: // Here the inner default may not be used as it is masked by the outer default. -r: (*3 | (*1 | 2)) & (1 | 2) @test(eq, 1 | 2) +r: (*3 | (*1 | 2)) & (1 | 2) // Here the inner default is used, as there are no defaults marked in the // outer disjunction. -s: (3 | (*1 | 2)) & (1 | 2) @test(eq, *1 | 2) +s: (3 | (*1 | 2)) & (1 | 2) -s1: #Size & {min: 5} @test(eq, { - min: 5 - max: *5 | >5 - res: *0 | >=0 & int -}) +s1: #Size & {min: 5} #Size: { max: >min | *min res: uint | *0 min: >res | *(1 + res) - @test(eq, { - max: *1 | >0 | >1 - res: *0 | >=0 & int - min: *1 | >0 - }) } staged: { c: ("a" | "b") & (*(*"a" | string) | string) d: (*(*"a" | string) | string) & ("a" | "b") - @test(eq, {c: *"a" | *"b", d: *"a" | "b"}) } issue763a: { @@ -69,14 +59,6 @@ issue763a: { h: baa: _ h: boo: _ - @test(eq, { - #A: {v: "a" | "b" | "c"} - h: { - a: {v: *"a" | "b" | "c"} - baa: {v: *"a" | "b" | "c"} - boo: {v: *"a" | "b" | "c"} - } - }) } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/eval/bounds.txtar b/internal/core/compile/testdata/sync/eval/bounds.txtar index fcf97e3f9..412d25299 100644 --- a/internal/core/compile/testdata/sync/eval/bounds.txtar +++ b/internal/core/compile/testdata/sync/eval/bounds.txtar @@ -7,272 +7,266 @@ module: "x.test" language: version: "v0.14.0" -- in.cue -- -x0: 5 @test(eq, 5) -x1: b5 & 30 @test(eq, 30) +x0: 5 +x1: b5 & 30 -b0: 0 @test(eq, >0 & <5) -b1: b0 & int @test(eq, >0 & <5 & int) -b2: int & <5.5 @test(eq, <5.5 & int) -b3: <10 & <=5 @test(eq, <=5) -b4: >=20 & >20 @test(eq, >20) -b5: >=21 & >20 @test(eq, >=21) -b6: int & >5 & <=6 @test(eq, >5 & <=6 & int) +b0: 0 +b1: b0 & int +b2: int & <5.5 +b3: <10 & <=5 +b4: >=20 & >20 +b5: >=21 & >20 +b6: int & >5 & <=6 simplifyExpr: { // TODO: fill out later. - less1: <(<3) @test(err, code=incomplete, contains="non-concrete value <3", pos=[0:11]) - less2: <(<=3) @test(err, code=incomplete, contains="non-concrete value <=3", pos=[0:11]) - less3: <=(<3) @test(err, code=incomplete, contains="non-concrete value <3", pos=[0:12]) - less4: <=(<=3) @test(err, code=incomplete, contains="non-concrete value <=3", pos=[0:12]) - less5: <(!=3) @test(err, code=incomplete, contains="non-concrete value !=3", pos=[0:11]) - less6: <=(!=3) @test(err, code=incomplete, contains="non-concrete value !=3", pos=[0:12]) + less1: <(<3) + less2: <(<=3) + less3: <=(<3) + less4: <=(<=3) + less5: <(!=3) + less6: <=(!=3) - gtr1: >(>3) @test(err, code=incomplete, contains="non-concrete value >3", pos=[0:10]) - gtr2: >(>=3) @test(err, code=incomplete, contains="non-concrete value >=3", pos=[0:10]) - gtr3: >=(>3) @test(err, code=incomplete, contains="non-concrete value >3", pos=[0:11]) - gtr4: >=(>=3) @test(err, code=incomplete, contains="non-concrete value >=3", pos=[0:11]) - gtr5: >(!=3) @test(err, code=incomplete, contains="non-concrete value !=3", pos=[0:10]) - gtr6: >=(!=3) @test(err, code=incomplete, contains="non-concrete value !=3", pos=[0:11]) + gtr1: >(>3) + gtr2: >(>=3) + gtr3: >=(>3) + gtr4: >=(>=3) + gtr5: >(!=3) + gtr6: >=(!=3) - lg1: <(>3) @test(err, code=incomplete, contains="non-concrete value >3", pos=[0:9]) - lg2: <(>=3) @test(err, code=incomplete, contains="non-concrete value >=3", pos=[0:9]) - lg3: <=(>3) @test(err, code=incomplete, contains="non-concrete value >3", pos=[0:10]) - lg4: <=(>=3) @test(err, code=incomplete, contains="non-concrete value >=3", pos=[0:10]) + lg1: <(>3) + lg2: <(>=3) + lg3: <=(>3) + lg4: <=(>=3) - gl1: >(<3) @test(err, code=incomplete, contains="non-concrete value <3", pos=[0:9]) - gl2: >(<=3) @test(err, code=incomplete, contains="non-concrete value <=3", pos=[0:9]) - gl3: >=(<3) @test(err, code=incomplete, contains="non-concrete value <3", pos=[0:10]) - gl4: >=(<=3) @test(err, code=incomplete, contains="non-concrete value <=3", pos=[0:10]) + gl1: >(<3) + gl2: >(<=3) + gl3: >=(<3) + gl4: >=(<=3) - ne1: !=(!=3) @test(err, code=incomplete, contains="non-concrete value !=3", pos=[0:10]) - ne2: !=(<3) @test(err, code=incomplete, contains="non-concrete value <3", pos=[0:10]) - ne3: !=(<=3) @test(err, code=incomplete, contains="non-concrete value <=3", pos=[0:10]) - ne4: !=(>3) @test(err, code=incomplete, contains="non-concrete value >3", pos=[0:10]) - ne5: !=(>=3) @test(err, code=incomplete, contains="non-concrete value >=3", pos=[0:10]) + ne1: !=(!=3) + ne2: !=(<3) + ne3: !=(<=3) + ne4: !=(>3) + ne5: !=(>=3) s: string n: number i: int f: float b: bytes - basic1: <(i) @test(err, code=incomplete, contains="non-concrete value %s for bound %s", args=[i, <], pos=[0:12]) - basic2: >(n) @test(err, code=incomplete, contains="non-concrete value %s for bound %s", args=[n, >], pos=[0:12]) - basic3: >=(s) @test(err, code=incomplete, contains="non-concrete value %s for bound %s", args=[s, >=], pos=[0:13]) - basic4: <=(f) @test(err, code=incomplete, contains="non-concrete value %s for bound %s", args=[f, <=], pos=[0:13]) - basic5: <=(b) @test(err, code=incomplete, contains="non-concrete value %s for bound %s", args=[b, <=], pos=[0:13]) + basic1: <(i) + basic2: >(n) + basic3: >=(s) + basic4: <=(f) + basic5: <=(b) // Do NOT interpret this the same as `!= type`. - bne1: !=(s) @test(err, code=incomplete, contains="non-concrete value %s for bound %s", args=[s, !=], pos=[0:11]) - bne2: !=(n) @test(err, code=incomplete, contains="non-concrete value %s for bound %s", args=[n, !=], pos=[0:11]) - bne3: !=(n) @test(err, code=incomplete, contains="non-concrete value %s for bound %s", args=[n, !=], pos=[0:11]) - bne4: !=(i) @test(err, code=incomplete, contains="non-concrete value %s for bound %s", args=[i, !=], pos=[0:11]) - bne5: !=(b) @test(err, code=incomplete, contains="non-concrete value %s for bound %s", args=[b, !=], pos=[0:11]) + bne1: !=(s) + bne2: !=(n) + bne3: !=(n) + bne4: !=(i) + bne5: !=(b) - e1: <(=~"foo") @test(err, code=incomplete, contains="non-concrete value =~", pos=[0:8]) - e2: >(null) @test(err, code=eval, contains="cannot use null for bound", pos=[0:8]) + e1: <(=~"foo") + e2: >(null) } -- binarystring.cue -- simplifyBinary: strings: { - err1: { - p1: <"a" & >"b" @test(err, code=eval, contains="incompatible string bounds", pos=[0:16, 0:9]) - p2: >"b" & <"a" @test(err, code=eval, contains="incompatible string bounds", pos=[0:16, 0:9]) - } - err2: { - p1: >"b" & <="a" @test(err, code=eval, contains="incompatible string bounds", pos=[0:16, 0:9]) - p2: <="a" & >"b" @test(err, code=eval, contains="incompatible string bounds", pos=[0:17, 0:9]) - } - err3: { - p1: >="b" & <"b" @test(err, code=eval, contains="incompatible string bounds", pos=[0:17, 0:9]) - p2: <"b" & >="b" @test(err, code=eval, contains="incompatible string bounds", pos=[0:16, 0:9]) - p3: >"b" & <="b" @test(err, code=eval, contains="incompatible string bounds", pos=[0:16, 0:9]) - p4: <="b" & >"b" @test(err, code=eval, contains="incompatible string bounds", pos=[0:17, 0:9]) - } - ok1: { - p1: >"a" & <"b" @test(eq, >"a" & <"b") - p2: <"b" & >"a" @test(eq, >"a" & <"b") - } - ok2: { - p1: >"a" & <="b" @test(eq, >"a" & <="b") - p2: <="b" & >"a" @test(eq, >"a" & <="b") - p3: >="a" & <"b" @test(eq, >="a" & <"b") - p4: <"b" & >="a" @test(eq, >="a" & <"b") - } - ok3: { - p1: >="b" & <="c" @test(eq, >="b" & <="c") - p2: <="c" & >="b" @test(eq, >="b" & <="c") - } - ok4: { - p1: >="b" & <="b" @test(eq, >="b" & <="b") - } + err1: { + p1: <"a" & >"b" + p2: >"b" & <"a" + } + err2: { + p1: >"b" & <="a" + p2: <="a" & >"b" + } + err3: { + p1: >="b" & <"b" + p2: <"b" & >="b" + p3: >"b" & <="b" + p4: <="b" & >"b" + } + ok1: { + p1: >"a" & <"b" + p2: <"b" & >"a" + } + ok2: { + p1: >"a" & <="b" + p2: <="b" & >"a" + p3: >="a" & <"b" + p4: <"b" & >="a" + } + ok3: { + p1: >="b" & <="c" + p2: <="c" & >="b" + } + ok4: { + p1: >="b" & <="b" + } } simplifyBinary: byte: { - err1: { - p1: <'a' & >'b' @test(err, code=eval, contains="incompatible bytes bounds", pos=[0:16, 0:9]) - p2: >'b' & <'a' @test(err, code=eval, contains="incompatible bytes bounds", pos=[0:16, 0:9]) - } - err2: { - p1: >'b' & <='a' @test(err, code=eval, contains="incompatible bytes bounds", pos=[0:16, 0:9]) - p2: <='a' & >'b' @test(err, code=eval, contains="incompatible bytes bounds", pos=[0:17, 0:9]) - } - err3: { - p1: >='b' & <'b' @test(err, code=eval, contains="incompatible bytes bounds", pos=[0:17, 0:9]) - p2: <'b' & >='b' @test(err, code=eval, contains="incompatible bytes bounds", pos=[0:16, 0:9]) - p3: >'b' & <='b' @test(err, code=eval, contains="incompatible bytes bounds", pos=[0:16, 0:9]) - p4: <='b' & >'b' @test(err, code=eval, contains="incompatible bytes bounds", pos=[0:17, 0:9]) - } - ok1: { - p1: >'a' & <'b' @test(eq, >'a' & <'b') - p2: <'b' & >'a' @test(eq, >'a' & <'b') - } - ok2: { - p1: >'a' & <='b' @test(eq, >'a' & <='b') - p2: <='b' & >'a' @test(eq, >'a' & <='b') - p3: >='a' & <'b' @test(eq, >='a' & <'b') - p4: <'b' & >='a' @test(eq, >='a' & <'b') - } - ok3: { - p1: >='b' & <='c' @test(eq, >='b' & <='c') - p2: <='c' & >='b' @test(eq, >='b' & <='c') - } - ok4: { - p1: >='b' & <='b' @test(eq, >='b' & <='b') - } + err1: { + p1: <'a' & >'b' + p2: >'b' & <'a' + } + err2: { + p1: >'b' & <='a' + p2: <='a' & >'b' + } + err3: { + p1: >='b' & <'b' + p2: <'b' & >='b' + p3: >'b' & <='b' + p4: <='b' & >'b' + } + ok1: { + p1: >'a' & <'b' + p2: <'b' & >'a' + } + ok2: { + p1: >'a' & <='b' + p2: <='b' & >'a' + p3: >='a' & <'b' + p4: <'b' & >='a' + } + ok3: { + p1: >='b' & <='c' + p2: <='c' & >='b' + } + ok4: { + p1: >='b' & <='b' + } } -- binary.cue -- simplifyBinary: float: { - err1: { - p1: <1 & >2 @test(err, code=eval, contains="incompatible number bounds", pos=[0:14, 0:9]) - p2: >2 & <1 @test(err, code=eval, contains="incompatible number bounds", pos=[0:14, 0:9]) - } - err2: { - p1: >2 & <=1 @test(err, code=eval, contains="incompatible number bounds", pos=[0:14, 0:9]) - p2: <=1 & >2 @test(err, code=eval, contains="incompatible number bounds", pos=[0:15, 0:9]) - } - err3: { - p1: >=2 & <2 @test(err, code=eval, contains="incompatible number bounds", pos=[0:15, 0:9]) - p2: <2 & >=2 @test(err, code=eval, contains="incompatible number bounds", pos=[0:14, 0:9]) - p3: >2 & <=2 @test(err, code=eval, contains="incompatible number bounds", pos=[0:14, 0:9]) - p4: <=2 & >2 @test(err, code=eval, contains="incompatible number bounds", pos=[0:15, 0:9]) - } - ok1: { - p1: >1 & <2 @test(eq, >1 & <2) - p2: <2 & >1 @test(eq, >1 & <2) - } - ok2: { - p1: >=2 & <=2 @test(eq, >=2 & <=2) - p2: <=2 & >=2 @test(eq, >=2 & <=2) - } + err1: { + p1: <1 & >2 + p2: >2 & <1 + } + err2: { + p1: >2 & <=1 + p2: <=1 & >2 + } + err3: { + p1: >=2 & <2 + p2: <2 & >=2 + p3: >2 & <=2 + p4: <=2 & >2 + } + ok1: { + p1: >1 & <2 + p2: <2 & >1 + } + ok2: { + p1: >=2 & <=2 + p2: <=2 & >=2 + } } simplifyBinary: integer: { - [_]: [_]: int - err1: { - p1: <1 & >2 @test(err, code=eval, contains="incompatible integer bounds", pos=[0:14, 0:9]) - p2: >2 & <1 @test(err, code=eval, contains="incompatible integer bounds", pos=[0:14, 0:9]) - } - err2: { - p1: >2 & <=1 @test(err, code=eval, contains="incompatible integer bounds", pos=[0:14, 0:9]) - p2: <=1 & >2 @test(err, code=eval, contains="incompatible integer bounds", pos=[0:15, 0:9]) - } - err3: { - p1: >=2 & <2 @test(err, code=eval, contains="incompatible integer bounds", pos=[0:15, 0:9]) - p2: <2 & >=2 @test(err, code=eval, contains="incompatible integer bounds", pos=[0:14, 0:9]) - p3: >2 & <=2 @test(err, code=eval, contains="incompatible integer bounds", pos=[0:14, 0:9]) - p4: <=2 & >2 @test(err, code=eval, contains="incompatible integer bounds", pos=[0:15, 0:9]) - } - err4: { - p1: >1 & <2 @test(err, code=eval, contains="incompatible integer bounds", pos=[0:14, 0:9]) - p2: <2 & >1 @test(err, code=eval, contains="incompatible integer bounds", pos=[0:14, 0:9]) - } - ok1: { - p1: >=2 & <=3 @test(eq, >=2 & <=3 & int) - p2: <=3 & >=2 @test(eq, >=2 & <=3 & int) - } - ok2: { - p1: >=2 & <=2 @test(eq, >=2 & <=2 & int) - p2: <=2 & >=2 @test(eq, >=2 & <=2 & int) - } - ok3: { - p1: >=2 & <3 @test(eq, >=2 & <3 & int) - p2: >2 & <=3 @test(eq, >2 & <=3 & int) - p3: <3 & >=2 @test(eq, >=2 & <3 & int) - p4: <=3 & >2 @test(eq, >2 & <=3 & int) - } + [_]: [_]: int + err1: { + p1: <1 & >2 + p2: >2 & <1 + } + err2: { + p1: >2 & <=1 + p2: <=1 & >2 + } + err3: { + p1: >=2 & <2 + p2: <2 & >=2 + p3: >2 & <=2 + p4: <=2 & >2 + } + err4: { + p1: >1 & <2 + p2: <2 & >1 + } + ok1: { + p1: >=2 & <=3 + p2: <=3 & >=2 + } + ok2: { + p1: >=2 & <=2 + p2: <=2 & >=2 + } + ok3: { + p1: >=2 & <3 + p2: >2 & <=3 + p3: <3 & >=2 + p4: <=3 & >2 + } } -- equals.cue -- @experiment(structcmp) equalScalar: { - ok1: ==1 @test(eq, 1) + ok1: ==1 ok1: 1 ok2: [1, 2] - ok2: ==[1, 2] @test(eq, [1, 2]) + ok2: ==[1, 2] err1: ==1 - err1: 2 @test(err, code=eval, contains="out of bound ==1", pos=[-1:8, 0:8]) + err1: 2 err2: [1, 2] - err2: !=[1, 2] @test(err, code=eval, contains="out of bound !=", pos=[0:8, -1:8]) + err2: !=[1, 2] } equalStruct: { - ok1: =={} @test(eq, {}) + ok1: =={} ok1: {} ok2: {a: 1, b: 2} - ok2: =={a: 1, b: 2} @test(eq, {a: 1, b: 2}) + ok2: =={a: 1, b: 2} err1: =={} - err1: {a: 1, b: 2} @test(err, code=eval, contains="out of bound ==", pos=[-1:8, 0:8]) + err1: {a: 1, b: 2} err2: {a: 1, b: 2} - err2: !={a: 1, b: 2} @test(err, code=eval, contains="out of bound !=", pos=[0:8, -1:8]) + err2: !={a: 1, b: 2} } nonConcrete: { - ok0: =="foo" @test(eq, =="foo") + ok0: =="foo" _int: int - iErr1: ==_int @test(err, code=incomplete, contains="non-concrete value", pos=[0:11]) + iErr1: ==_int - iErr2: !=_int @test(err, code=incomplete, contains="non-concrete value", pos=[0:11]) + iErr2: !=_int iErr3: ==_int - iErr3: == 1 @test(err, code=incomplete, contains="non-concrete value", pos=[-1:11]) + iErr3: ==1 ok4: ==1 - ok4: _int @test(eq, ==1 & int) // v3: ==1 & int is not an error + ok4: _int // v3: ==1 & int is not an error eErr5: =="foo" - eErr5: _int @test(err, code=eval, contains="conflicting values", pos=[-13:8, -1:9, 0:9]) + eErr5: _int eErr6: ==_int - eErr6: "foo" @test(err, code=incomplete|eval, - hint="incompatible types, so this SHOULD be a permanent error", - contains="non-concrete value", pos=[-1:11]) @test(err:todo, code=eval) + eErr6: "foo" } -- issue4142.cue -- @experiment(structcmp) inDefinitions: ok1: { - #X: =={ name: "X" } - x: #X & { name: "X" } - @test(eq, {#X: {=={ name: "X" }}, x: {name: "X"}}) + #X: =={name: "X"} + x: #X & {name: "X"} } inDefinitions: ok2: { - x: #X & { name: "Y" } - #X: !={ name: "X" } - @test(eq, {x: {name: "Y"}, #X: {!={name: "X"}}}) + x: #X & {name: "Y"} + #X: !={name: "X"} } inDefinitions: err1: { - #X: =={ name: "X" } - x: #X & { name: "Y" } - @test(err, code=eval, at=x, contains="out of bound ==", pos=[1:6, 2:5]) + #X: =={name: "X"} + x: #X & {name: "Y"} } inDefinitions: err2: { - #X: !={ name: "X" } - x: #X & { name: "X" } - @test(err, code=eval, at=x, contains="out of bound !=", pos=[1:6, 2:5]) + #X: !={name: "X"} + x: #X & {name: "X"} } -- issue4251-panic.cue -- @experiment(structcmp) @@ -283,13 +277,13 @@ inDefinitions: err2: { // Regression: SimplifyBounds panicked on == bounds combined with other bound types. // https://cuelang.org/issue/4251 issue4251: ok: { - a: !="c" & =="a" & "a" @test(eq, "a") - b: =="b" & !="c" & "b" @test(eq, "b") - c: =="x" & >="a" & "x" @test(eq, "x") - d: <="z" & =="y" & "y" @test(eq, "y") + a: !="c" & =="a" & "a" + b: =="b" & !="c" & "b" + c: =="x" & >="a" & "x" + d: <="z" & =="y" & "y" } issue4251: fail: { - b: =="b" & !="b" & "b" @test(err, code=eval, contains="out of bound !=", pos=[0:13, 0:5, 0:21]) + b: =="b" & !="b" & "b" } -- out/compile -- --- binary.cue diff --git a/internal/core/compile/testdata/sync/eval/bulk.txtar b/internal/core/compile/testdata/sync/eval/bulk.txtar index 35e7b17ae..5d9f50e74 100644 --- a/internal/core/compile/testdata/sync/eval/bulk.txtar +++ b/internal/core/compile/testdata/sync/eval/bulk.txtar @@ -10,44 +10,32 @@ a: { b: 1 name: X } - - @test(eq, { - [=~"foo"]: { b: 1, name: string } - foo: {a: 1, b: 1, name: "foo"} - }) - @test(allows, foo) - @test(allows, foobar) - @test(allows, string) - // TODO(eval): struct isn't closed, so this should be true. - @test(allows:todo=false, bar) } d: a & { "foobar": { c: 2 } -} @test(eq, { - foobar: {c: 2, b: 1, name: "foobar"} - foo: {a: 1, b: 1, name: "foo"} -}) +} t1: { #a: { [>"e" & <"z"]: int } + // TODO(inline): support allow on fields. - b: #a & {f: 4} @test(eq, {f: 4}) @test(allows, f) @test(allows=false, a) @test(allows=false, string) - c: #a & {z: 4} @test(err, code=eval, at=z, contains="field not allowed", pos=[0:11]) + b: #a & {f: 4} + c: #a & {z: 4} } t2: { #a: { ["x" | "y"]: int } + // TODO(inline): support allow on fields. - b: #a & {x: 4} @test(eq, {x: 4}) @test(allows, x) @test(allows=false, z) @test(allows=false, string) - c: #a & {z: 4} @test(err, code=eval, at=z, contains="field not allowed", pos=[0:11]) + b: #a & {x: 4} + c: #a & {z: 4} } - -- issue2109.cue -- // Detect cycle: // The pattern constraint of FlagsURLS is applied to countries (because @@ -63,58 +51,33 @@ patternCycle: issue2109: p1: { countries: ["US", "GB", "AU"] FlagsURLs: {[or(countries)]: string} FlagsURLs - @test(eq, { - countries: ["US", "GB", "AU"] - FlagsURLs: {} - }) } patternCycle: issue2109: p2: { FlagsURLs: {[or(countries)]: string} FlagsURLs countries: ["US", "GB", "AU"] - @test(eq, { - FlagsURLs: {} - countries: ["US", "GB", "AU"] - }) } patternCycle: issue2109: p3: { FlagsURLs FlagsURLs: {[or(countries)]: string} countries: ["US", "GB", "AU"] - @test(eq, { - FlagsURLs: {} - countries: ["US", "GB", "AU"] - }) } patternCycle: t1: p1: { countries: "US" | "GB" | "AU" FlagsURLs: {[countries]: string} FlagsURLs - @test(eq, { - countries: "US" | "GB" | "AU" - FlagsURLs: {} - }) } patternCycle: t1: p2: { FlagsURLs countries: "US" | "GB" | "AU" FlagsURLs: {[countries]: string} - @test(eq, { - countries: "US" | "GB" | "AU" - FlagsURLs: {} - }) } patternCycle: t1: p3: { FlagsURLs FlagsURLs: {[countries]: string} countries: "US" | "GB" | "AU" - @test(eq, { - FlagsURLs: {} - countries: "US" | "GB" | "AU" - }) } - -- intpattern.cue -- // evalv3 regression: a pattern constraint definition with int key incorrectly // allowed a non-matching (non-int) field. @@ -122,20 +85,17 @@ patternCycle: t1: p3: { issue3670: { #X: [int]: string a: #X - a: "not_int": "c" @test(err, code=eval, contains="field not allowed", pos=[0:5]) + a: "not_int": "c" } dual: { _ + // As long as it is undecided whether this is a struct or list, this should // not be a conflict. Note that the spec does not allow int patterns, but // both v2 and v3 allow it, and we soon will, so it seems gratuitous to // break it now. [string]: _ - [int]: _ - - @test(eq, {_, [int]: _, [string]: _}) - - // TODO: test allows once we know what it means in this case. + [int]: _ } -- multi.cue -- // evalv3 regression: closedness values and default markers were incorrectly @@ -151,7 +111,7 @@ issue3638: full: { }] #Fields: { input: _ - output: [for x in input { x }] @test(err, code=incomplete, contains="cannot range over input (incomplete type _)", pos=[0:21]) + output: [for x in input {x}] ... } #Kubernetes: { @@ -175,40 +135,15 @@ issue3638: full: { used: #Kubernetes & { Routes: route: routes } - @test(eq, { - routes: default: {spec: [{ refs: ["default"] }]} - #Fields: { - input: _ - output: _|_ - } - #Kubernetes: { - Routes: route: {} - input: res1: route: {} - output: [{ route: {} }] - } - entrypoint: [{ route: default: spec: [{ refs: ["default"] }] }] - used: { - Routes: route: default: spec: [{ refs: ["default"] }] - input: res1: route: default: spec: [{ refs: ["default"] }] - output: [{ - route: default: spec: [{ refs: ["default"] }] - }] - } - }) } issue3638: reduced: { input: k1: [string]: a: 1 input: k1: foo: #x out: { - for x in input { x } - for x in input { x } + for x in input {x} + for x in input {x} } - #x: { a: int } | *{ b: 2 } - @test(eq, { - input: k1: foo: {a: 1} - out: foo: a: 1 - #x: *{b: 2} | {a: int} - }) + #x: {a: int} | *{b: 2} } // We expect that changing the pattern constraint into a field should give // not materially change the outcome. @@ -216,15 +151,10 @@ issue3638: compare: { input: k1: foo: a: 1 input: k1: foo: #x out: { - for x in input { x } - for x in input { x } + for x in input {x} + for x in input {x} } - #x: { a: int } | *{ b: 2 } - @test(eq, { - input: k1: foo: {a: 1} - out: foo: a: 1 - #x: *{b: 2} | {a: int} - }) + #x: {a: int} | *{b: 2} } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/eval/closed_disjunction.txtar b/internal/core/compile/testdata/sync/eval/closed_disjunction.txtar index 39efab7f3..8b166ad60 100644 --- a/internal/core/compile/testdata/sync/eval/closed_disjunction.txtar +++ b/internal/core/compile/testdata/sync/eval/closed_disjunction.txtar @@ -2,20 +2,17 @@ #A: { b?: int *{} | {c?: int} | {d?: int} | {e?: int} -} @test(eq, *{b?: int} | {b?: int, c?: int} | {b?: int, d?: int} | {b?: int, e?: int}) +} a: #A & { b: 3 c: 3 -} @test(eq, {b: 3, c: 3}) @test(closed) +} b: #A & { c: 3 d: 4 -} @test(err, code=eval, contains="2 errors in empty disjunction",, - suberr=(code=eval, contains="field not allowed", pos=[1:2]), - suberr=(code=eval, contains="field not allowed", pos=[2:2]) -) +} -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/eval/closedness.txtar b/internal/core/compile/testdata/sync/eval/closedness.txtar index 4f8cfae6f..f0f81a358 100644 --- a/internal/core/compile/testdata/sync/eval/closedness.txtar +++ b/internal/core/compile/testdata/sync/eval/closedness.txtar @@ -16,7 +16,7 @@ a: #A & { c: 2 e: 43 } -} @test(err, code=eval, contains="field not allowed", pos=[4:3]) +} // A constraint validation error fails to trigger when a field violating a // regex pattern constraint is duplicated via a for-loop comprehension. @@ -35,7 +35,7 @@ issue852: { for k, v in a { b: "\(k)": v } -} @test(err, code=eval, contains="field not allowed", pos=[7:5]) +} dynamic: { #D: { @@ -43,10 +43,6 @@ dynamic: { (key): int } d: #D & {foo: 3} - @test(eq, { - #D: {key: "foo", foo: int} - d: {foo: 3, key: "foo"} - }) } // Closedness appeared to be lost when using a comprehension: CUE incorrectly @@ -56,7 +52,7 @@ dynamic: { // even though {foo: "is foo"} does not unify with `#Bar & {...}`. issue4180: { out: { - if true { + if true { iter: #Schema & { FooOrBar: foo: "is foo" } @@ -69,14 +65,6 @@ issue4180: { FooOrBar: {...} FooOrBar: #Foo | #Bar } - @test(eq, { - out: {iter: {FooOrBar: {foo: "is foo"}}} - #Foo: {foo: string} - #Bar: {bar: string} - #Schema: { - FooOrBar: {foo: string} | {bar: string} - } - }) } -- embed.cue -- // evalv3: ordering of embedded structs affects template definition evaluation, @@ -108,25 +96,6 @@ issue3325: ok: { #Extended #Base } - @test(eq, { - #Items: {} - #Base: {name: "base", type: string, items: {}} - #Extended: { - type: "extended" - items: {"my-item": {name: "my-item"}} - name: "base" - } - broken: { - name: "base" - type: "extended" - items: {"my-item": {name: "my-item"}} - } - works: { - type: "extended" - items: {"my-item": {name: "my-item"}} - name: "base" - } - }) } patterns: shallow: { @@ -136,68 +105,68 @@ patterns: shallow: { #d: [<="y"]: int single: { - X: #a // "k" <= x - err: X @test(err, code=eval, path=j, contains="field not allowed", pos=[1:8]) + X: #a // "k" <= x + err: X err: j: 3 - ok: X @test(eq, {k: 3}) + ok: X ok: k: 3 } and: p1: { X: #a & #b // "k" <= x && x <= "m" - err: X @test(err, code=eval, path=j, contains="field not allowed", pos=[-16:6, 1:8]) + err: X err: j: 3 - ok: X @test(eq, {k: 3}) + ok: X ok: k: 3 } and: p2: { - X: #b & #a // "k" <= x && x <= "m" - err: X @test(err, code=eval, path=j, contains="field not allowed", pos=[-25:6, 1:8]) + X: #b & #a // "k" <= x && x <= "m" + err: X err: j: 3 - ok: X @test(eq, {k: 3}) + ok: X ok: k: 3 } andEmbed: p1: { - X: { #a & #b } // "k" <= x && x <= "m" + X: {#a & #b} // "k" <= x && x <= "m" - err: X @test(err, code=eval, path=j, contains="field not allowed", pos=[-35:6, 1:8]) + err: X err: j: 3 - ok: X @test(eq, {k: 3}) + ok: X ok: k: 3 } andEmbed: p2: { - X: { #b & #a } // "k" <= x && x <= "m" - err: X @test(err, code=eval, path=j, contains="field not allowed", pos=[-44:6, 1:8]) + X: {#b & #a} // "k" <= x && x <= "m" + err: X err: j: 3 - ok: X @test(eq, {k: 3}) + ok: X ok: k: 3 } orEmbed: p1: { - X: { #a, #b } // "k" <= x && x <= "m" + X: {#a, #b} // "k" <= x && x <= "m" - ok1: X @test(eq, {j: 3}) + ok1: X ok1: j: 3 - ok2: X @test(eq, {k: 3}) + ok2: X ok2: k: 3 } orEmbed: p2: { - X: { #b, #a } // "k" <= x && x <= "m" - ok1: X @test(eq, {j: 3}) + X: {#b, #a} // "k" <= x && x <= "m" + ok1: X ok1: j: 3 - ok2: X @test(eq, {k: 3}) + ok2: X ok2: k: 3 } @@ -207,10 +176,10 @@ patterns: shallow: { #a & #b #c & #d } - err1: X @test(eq, {j: 3}) + err1: X err1: j: 3 - ok1: X @test(eq, {k: 3}) + ok1: X ok1: k: 3 } @@ -220,10 +189,10 @@ patterns: shallow: { #c & #d #a & #b } - err1: X @test(eq, {j: 3}) + err1: X err1: j: 3 - ok1: X @test(eq, {k: 3}) + ok1: X ok1: k: 3 } @@ -234,13 +203,13 @@ patterns: shallow: { #c & #d ["p"]: int } - err1: X @test(eq, {j: 3}) + err1: X err1: j: 3 - ok1: X @test(eq, {k: 3}) + ok1: X ok1: k: 3 - ok2: X @test(eq, {p: 3}) + ok2: X ok2: p: 3 } @@ -249,57 +218,57 @@ patterns: shallow: { a: [>="k"]: int #a: a - p1: { // XXX // link to code - X: #a - err1: X @test(err, code=eval, path=j, contains="field not allowed", pos=[1:10]) + p1: {// XXX // link to code + X: #a + err1: X err1: j: 3 err2: X & __no_sharing - err2: j: 3 @test(err, code=eval, contains="field not allowed", pos=[0:10]) + err2: j: 3 ok: X - ok:k: 3 @test(eq, 3) + ok: k: 3 } p2: { #a: a & __no_sharing - X: #a + X: #a err1: X - err1: j: 3 @test(err, code=eval, contains="field not allowed", pos=[0:10]) + err1: j: 3 - err2: X & __no_sharing @test(err, code=eval, path=j, contains="field not allowed", pos=[1:10]) + err2: X & __no_sharing err2: j: 3 - ok: X @test(eq, {k: 3}) + ok: X ok: k: 3 } p3: { X: #a & __no_sharing - err1: X @test(err, code=eval, path=j, contains="field not allowed", pos=[1:10]) - err1: j: 3 + err1: X + err1: j: 3 - err2: X & __no_sharing @test(err, code=eval, path=j, contains="field not allowed", pos=[1:10]) - err2: j: 3 + err2: X & __no_sharing + err2: j: 3 - ok: X @test(eq, {k: 3}) - ok: k: 3 + ok: X + ok: k: 3 } p4: { #a: a & __no_sharing - X: #a - X: #a & __no_sharing + X: #a + X: #a & __no_sharing - err1: X @test(err, code=eval, path=j, contains="field not allowed", pos=[1:10]) + err1: X err1: j: 3 - err2: X & __no_sharing @test(err, code=eval, path=j, contains="field not allowed", pos=[1:10]) + err2: X & __no_sharing err2: j: 3 - ok: X @test(eq, {k: 3}) + ok: X ok: k: 3 } } @@ -312,68 +281,68 @@ patterns: nested: { #d: x: y: [<="y"]: int single: { - X: #a // "k" <= x - err: X @test(err, code=eval, path=x.y.j, contains="field not allowed", pos=[1:14]) + X: #a // "k" <= x + err: X err: x: y: j: 3 - ok: X @test(eq, {x: {y: {k: 3}}}) + ok: X ok: x: y: k: 3 } and: p1: { X: #a & #b // "k" <= x && x <= "m" - err: X @test(err, code=eval, path=x.y.j, contains="field not allowed", pos=[-16:12, 1:14]) + err: X err: x: y: j: 3 - ok: X @test(eq, {x: {y: {k: 3}}}) + ok: X ok: x: y: k: 3 } and: p2: { - X: #b & #a // "k" <= x && x <= "m" - err: X @test(err, code=eval, path=x.y.j, contains="field not allowed", pos=[-25:12, 1:14]) + X: #b & #a // "k" <= x && x <= "m" + err: X err: x: y: j: 3 - ok: X @test(eq, {x: {y: {k: 3}}}) + ok: X ok: x: y: k: 3 } andEmbed: p1: { - X: { #a & #b } // "k" <= x && x <= "m" + X: {#a & #b} // "k" <= x && x <= "m" - err: X @test(err, code=eval, path=x.y.j, contains="field not allowed", pos=[-35:12, 1:14]) + err: X err: x: y: j: 3 - ok: X @test(eq, {x: {y: {k: 3}}}) + ok: X ok: x: y: k: 3 } andEmbed: p2: { - X: { #b & #a } // "k" <= x && x <= "m" - err: X @test(err, code=eval, path=x.y.j, contains="field not allowed", pos=[-44:12, 1:14]) + X: {#b & #a} // "k" <= x && x <= "m" + err: X err: x: y: j: 3 - ok: X @test(eq, {x: {y: {k: 3}}}) + ok: X ok: x: y: k: 3 } orEmbed: p1: { - X: { #a, #b } // "k" <= x && x <= "m" + X: {#a, #b} // "k" <= x && x <= "m" - ok1: X @test(eq, {x: {y: {j: 3}}}) + ok1: X ok1: x: y: j: 3 - ok2: X @test(eq, {x: {y: {k: 3}}}) + ok2: X ok2: x: y: k: 3 } orEmbed: p2: { - X: { #b, #a } // "k" <= x && x <= "m" - ok1: X @test(eq, {x: {y: {j: 3}}}) + X: {#b, #a} // "k" <= x && x <= "m" + ok1: X ok1: x: y: j: 3 - ok2: X @test(eq, {x: {y: {k: 3}}}) + ok2: X ok2: x: y: k: 3 } @@ -383,10 +352,10 @@ patterns: nested: { #a & #b #c & #d } - err1: X @test(eq, {x: {y: {j: 3}}}) + err1: X err1: x: y: j: 3 - ok1: X @test(eq, {x: {y: {k: 3}}}) + ok1: X ok1: x: y: k: 3 } @@ -396,10 +365,10 @@ patterns: nested: { #c & #d #a & #b } - err1: X @test(eq, {x: {y: {j: 3}}}) + err1: X err1: x: y: j: 3 - ok1: X @test(eq, {x: {y: {k: 3}}}) + ok1: X ok1: x: y: k: 3 } @@ -410,13 +379,13 @@ patterns: nested: { #c & #d ["p"]: int } - err1: X @test(eq, {x: {y: {j: 3}}}) + err1: X err1: x: y: j: 3 - ok1: X @test(eq, {x: {y: {k: 3}}}) + ok1: X ok1: x: y: k: 3 - ok2: X @test(eq, {x: {y: {p: 3}}}) + ok2: X ok2: x: y: p: 3 } @@ -426,60 +395,60 @@ patterns: nested: { #a: a p1: { - X: #a - err1: X @test(err, code=eval, path=x.y.j, contains="field not allowed", pos=[1:16]) + X: #a + err1: X err1: x: y: j: 3 - err2: X & __no_sharing @test(err, code=eval, path=x.y.j, contains="field not allowed", pos=[1:16]) + err2: X & __no_sharing err2: x: y: j: 3 - ok: X @test(eq, {x: {y: {k: 3}}}) + ok: X ok: x: y: k: 3 } p2: { #a: a & __no_sharing - X: #a + X: #a - err1: X @test(err, code=eval, path=x.y.j, contains="field not allowed", pos=[1:16]) + err1: X err1: x: y: j: 3 - err2: X & __no_sharing @test(err, code=eval, path=x.y.j, contains="field not allowed", pos=[1:16]) + err2: X & __no_sharing err2: x: y: j: 3 - ok: X @test(eq, {x: {y: {k: 3}}}) + ok: X ok: x: y: k: 3 } p3: { X: #a & __no_sharing - err1: X @test(err, code=eval, path=x.y.j, contains="field not allowed", pos=[1:16]) + err1: X err1: x: y: j: 3 - err2: X & __no_sharing @test(err, code=eval, path=x.y.j, contains="field not allowed", pos=[1:16]) + err2: X & __no_sharing err2: x: y: j: 3 - ok: X @test(eq, {x: {y: {k: 3}}}) + ok: X ok: x: y: k: 3 } p4: { #a: a & __no_sharing - X: #a - X: #a & __no_sharing + X: #a + X: #a & __no_sharing - err1: X @test(err, code=eval, path=x.y.j, contains="field not allowed", pos=[1:16]) + err1: X err1: x: y: j: 3 - err2: X & __no_sharing @test(err, code=eval, path=x.y.j, contains="field not allowed", pos=[1:16]) + err2: X & __no_sharing err2: x: y: j: 3 - ok: X @test(eq, {x: {y: {k: 3}}}) + ok: X ok: x: y: k: 3 } } -} @test(err, code=eval, contains="field not allowed", pos=[168:16]) +} // Embedding a definition doesn't recursively close the embedder: closedness // is not propagated correctly when a definition is embedded in an open struct. @@ -488,40 +457,33 @@ issue2241: { #close: {} a: { - x: q: 2 - #close + x: q: 2 + #close } b: a b: x: r: 4 -} @test(err, code=eval, path=b.x.r, contains="field not allowed", pos=[9:8]) - +} -- ellipsis.cue -- // evalv3 regression: unification with {...} allowed extra fields where evalv2 // correctly rejected them as "field not allowed". // https://cuelang.org/issue/3778 issue3778: full: { #x: a?: string - #y: #x & { ... } + #y: #x & {...} z: #y & { a: "ok" b: "something" } - @test(err, code=eval, path=z.b, contains="field not allowed", pos=[5:3]) } issue3778: { keepOpen: { - #x: { a?: string, ... } - #y: #x & { ... } + #x: {a?: string, ...} + #y: #x & {...} z: #y & { a: "ok" b: "something" } - @test(eq, { - #x: {a?: string} - #y: {a?: string} - z: {a: "ok", b: "something"} - }) } } @@ -534,7 +496,6 @@ issue1867: one: { #T: {...} x: #T x: foo: "foo" - @test(err, code=eval, path=x.foo, contains="field not allowed", pos=[4:5]) } issue1867: two: { #S: {} @@ -542,7 +503,6 @@ issue1867: two: { #T: s: {...} x: #T.s x: foo: "foo" - @test(err, code=eval, path=x.foo, contains="field not allowed", pos=[5:5]) } // This third version used to not fail as expected on evalv2. issue1867: three: { @@ -550,7 +510,6 @@ issue1867: three: { #T: s: {...} x: #T.s x: foo: "foo" - @test(err, code=eval, contains="field not allowed", pos=[4:5]) } // evalv3 regression in detecting closedness: "field not allowed" errors were // incorrectly suppressed when validating nested structures with closedness constraints. @@ -563,7 +522,6 @@ issue3924: one: { #SchemaInner: allowed?: string out: #Schema & {foo: disallowed: "foo"} // should fail - @test(err, code=eval, path=out.foo.disallowed, contains="field not allowed", pos=[7:23]) } issue3924: two: { #Schema: { @@ -577,34 +535,29 @@ issue3924: two: { }) } out: #Schema & {foo: disallowed: "bar"} // should fail - @test(err, code=eval, path=out.foo.disallowed, contains="field not allowed", pos=[4:9, 11:23]) } issue3924: three: t1: { {foo: #job & {disallowed: "bar"}} - #job: { other?: string } + #job: {other?: string} #job: #def #def: allowed?: string - @test(err, code=eval, path=foo.disallowed, contains="field not allowed", pos=[1:16]) } issue3924: three: t2: { {foo: #job & {disallowed: "bar"}} - #job: { other?: string, ... } + #job: {other?: string, ...} #job: #def #def: allowed?: string - @test(err, code=eval, path=foo.disallowed, contains="field not allowed", pos=[1:16]) } issue3924: three: t3: { - #job: { ... } + #job: {...} #job: #def #def: {} foo: #job & {disallowed: "bar"} - @test(err, code=eval, path=foo.disallowed, contains="field not allowed", pos=[4:15]) } issue3924: four: { - A: { {foo: #B} } + A: {{foo: #B}} #B: allowed?: string out: A & {foo: disallowed: "foo"} // should fail - @test(err, code=eval, contains="field not allowed", pos=[3:17]) } -- reroot.cue -- import "list" @@ -617,43 +570,28 @@ issue3330: { #struct: { let empty = {} - field: null | { n: int } - field: empty & { n: 3 } + field: null | {n: int} + field: empty & {n: 3} } out: list.Concat([[#struct]]) - @test(eq, { - #struct: {field: {n: 3}} - out: [{ - field: n: 3 - }] - }) } matthew: ok1: { #struct: { - field: { n: 3 } & g + field: {n: 3} & g g: {} } out: #struct & {} - @test(eq, { - #struct: {field: {n: 3}, g: {}} - out: {field: {n: 3}, g: {}} - }) } matthew: ok2: { #struct: { - field: { n: 3 } & g + field: {n: 3} & g g: {} } out: #struct out2: out & {} - @test(eq, { - #struct: {field: {n: 3}, g: {}} - out: {field: {n: 3}, g: {}} - out2: {field: {n: 3}, g: {}} - }) } } // evalv3 "field not allowed" regression: a valid struct with a let binding and @@ -668,10 +606,6 @@ issue3331: { } } list.Concat([[#A]]) - @test(eq, { - #A: {c: {d: 1}} - [{c: {d: 1}}] - }) } variant1: ok: { #A: { @@ -681,21 +615,7 @@ issue3331: { } } [[#A]] - @test(eq, { - #A: {c: {d: 1}} - [[{c: {d: 1}}]] - }) } - @test(eq, { - original: {ok: { - #A: {c: {d: 1}} - [{c: {d: 1}}] - }} - variant1: {ok: { - #A: {c: {d: 1}} - [[{c: {d: 1}}]] - }} - }) } // indirect tests cases where a reference indirectly crosses a node that @@ -714,14 +634,6 @@ indirect: { b1: b.zx b1: d: 1 // This should fail as b.zx crosses a reference to definition. - @test(err:todo) - @test(eq, { - #A: {x: {a: {b: 1, c: 2}}, zx: {b: 1, c: 2}} - #x: {a: {b: 1}} - #y: {a: {c: 2}} - b: {x: {a: {b: 1, c: 2}}, zx: {b: 1, c: 2}} - b1: {d: 1, b: 1, c: 2} - }) } closed: err1: { X: { @@ -736,25 +648,20 @@ indirect: { c: #X } #X: {} - @test(err, at=Y.a.e, code=eval, contains="field not allowed", pos=[5:7]) } } // nested.a nested: ok1: { #A: { - b: {} + b: {} - #B: { - c: b & { - d: 1 + #B: { + c: b & { + d: 1 } } } x: #A - @test(eq, { - #A: {b: {}, #B: {c: {d: 1}}} - x: {b: {}, #B: {c: {d: 1}}} - }) } nested: embed: ok: { x: #A @@ -765,11 +672,6 @@ nested: embed: ok: { d: b & {e: int} b: {} } - @test(eq, { - x: {d: {e: int}, b: {}} - #A: {d: {e: int}, b: {}} - k: {d: {e: int}, b: {}} - }) } // nested.b tests insertion of a field (b) that has a conjunct rooted within // the tree it is referred in as well as a conjunct outside of it that refers @@ -780,14 +682,13 @@ nested: err1: { b: f: 1 v: #V #V: { - c: b & { // Fails as #B is not compatible. + c: b & {// Fails as #B is not compatible. d: 1 } } } - x: b: #B + x: b: #B #B: g: 1 - @test(err, at=x.#V.c.d, code=eval, contains="field not allowed", pos=[7:5]) } nested: err2: { @@ -802,7 +703,6 @@ nested: err2: { } x: #A x: b: g: 1 - @test(err, at=x.b.g, code=eval, contains="field not allowed", pos=[11:8]) } inline: { @@ -812,50 +712,33 @@ inline: { err1: (#x & {y: z: _}).y.z & { name: "a" age1: 5 // not allowed - } @test(err:todo, code=eval, contains="field not allowed") + } err2: (#x.y & {z: _}).z & { name: "a" age2: 5 // not allowed - } @test(err:todo, code=eval, contains="field not allowed") - @test(eq, { - #x: {y: {z?: {name: string}}} - err1: {name: "a", age1: 5} - err2: {name: "a", age2: 5} - }) + } } // minInDef defines examples where a definition is mixed into an open struct, // where then this struct refers to a field that is closed by the definition. mixInDef: { refInside: { - #x: b: c: {d: {}, e: f: {} } + #x: b: c: {d: {}, e: f: {}} a: #x a: b: c: d: {} a: b: c: e: c.d - @test(eq, { - #x: {b: {c: {d: {}, e: {f: {}}}}} - a: {b: {c: {d: {}, e: {f: {}}}}} - }) } refEdge: { - #x: c: {d: {}, e: f: {} } + #x: c: {d: {}, e: f: {}} a: #x a: c: d: {} a: c: e: c.d - @test(eq, { - #x: {c: {d: {}, e: {f: {}}}} - a: {c: {d: {}, e: {f: {}}}} - }) } refOutside: { - #x: c: {d: {}, e: f: {} } + #x: c: {d: {}, e: f: {}} a: #x a: c: d: {} a: c: e: a.c.d // crosses definition - @test(eq, { - #x: {c: {d: {}, e: {f: {}}}} - a: {c: {d: {}, e: {f: {}}}} - }) } } @@ -874,16 +757,6 @@ issue3601: original: { final: version: "v1" } } - @test(eq, { - out: {foo: {final: {version: "v1"}}} - #Transform: { - output: {foo: {final: {version: "v1"}}} - } - #Patch: { - target: {} - output: {foo: {final: {version: "v1"}}} - } - }) } issue3601: originalNoShare: { // Like the original, but with explicit no sharing. @@ -898,16 +771,6 @@ issue3601: originalNoShare: { final: version: "v1" } } - @test(eq, { - out: {foo: {final: {version: "v1"}}} - #Transform: { - output: {foo: {final: {version: "v1"}}} - } - #Patch: { - target: {} - output: {foo: {final: {version: "v1"}}} - } - }) } issue3601: reduced: { #X: { @@ -917,15 +780,15 @@ issue3601: reduced: { } original: { - Y: (#X & __no_sharing).a + Y: (#X & __no_sharing).a out: Y & __no_sharing } moreInlining: { out: (#X & {}).a & {} } noInline: { - Y: #X & __no_sharing - Z: Y & __no_sharing + Y: #X & __no_sharing + Z: Y & __no_sharing out: Z.a & __no_sharing } moreNesting: { @@ -937,23 +800,7 @@ issue3601: reduced: { Y: (#X.a & __no_sharing).b Z: Y & __no_sharing } - @test(eq, { - #X: {a: {b: {c: "v1"}}, empty: {}} - original: {Y: {b: {c: "v1"}}, out: {b: {c: "v1"}}} - moreInlining: {out: {b: {c: "v1"}}} - noInline: { - Y: {a: {b: {c: "v1"}}, empty: {}} - Z: {a: {b: {c: "v1"}}, empty: {}} - out: {b: {c: "v1"}} - } - moreNesting: { - #X: {a: {b: {c: {d: "v1"}}}, empty: {}} - Y: {c: {d: "v1"}} - Z: {c: {d: "v1"}} - } - }) } - -- validation.cue -- import "list" @@ -963,14 +810,9 @@ import "list" issue3332: { #def: field: list.MinItems(1) use: #def & { - field: ["value"] + field: ["value"] } - @test(eq, { - #def: {field: list.MinItems(1)} - use: {field: ["value"]} - }) } - -- out/compile -- --- ellipsis.cue { diff --git a/internal/core/compile/testdata/sync/eval/comprehensions.txtar b/internal/core/compile/testdata/sync/eval/comprehensions.txtar index 2b522efc2..6b0799db7 100644 --- a/internal/core/compile/testdata/sync/eval/comprehensions.txtar +++ b/internal/core/compile/testdata/sync/eval/comprehensions.txtar @@ -5,7 +5,7 @@ -- in.cue -- import "strings" -a: {x: 10, y: 100, z: 50} @test(eq, {x: 10, y: 100, z: 50}) +a: {x: 10, y: 100, z: 50} b: { for k, v in a if v <= 50 { "\(k)": v @@ -18,98 +18,89 @@ b: { if k > 0 { l: 40 } - @test(eq, {x: 10, k: 20, l: 40, z: 50}) } c: { for k, v in a let y = v + 10 if y > 50 { "\(k)": y } - @test(eq, {y: 110, z: 60}) } A: { X: run: "dfoo" - @test(eq, {X: {run: "dfoo", files: "dfoo"}}) } if true { A: X: { run: string - files: "\(strings.Join([ run], "\n"))" + files: "\(strings.Join([run], "\n"))" } } matchOrder: { - a1: { - out: [string]: Val: 1 - out: in.a + a1: { + out: [string]: Val: 1 + out: in.a - in: a: { - if true { - b: {} - } - } - @test(eq, {out: {b: {Val: 1}}, in: {a: {b: {}}}}) - } - a2: { - out: [string]: Val: 1 + in: a: { + if true { + b: {} + } + } + } + a2: { + out: [string]: Val: 1 - in: a: { - if true { - b: {} - } - } + in: a: { + if true { + b: {} + } + } - out: in.a - @test(eq, {out: {b: {Val: 1}}, in: {a: {b: {}}}}) - } - a3: { + out: in.a + } + a3: { - in: a: { - if true { - b: {} - } - } + in: a: { + if true { + b: {} + } + } - out: [string]: Val: 1 - out: in.a - @test(eq, {in: {a: {b: {}}}, out: {b: {Val: 1}}}) - } - a4: { - out: in.a - out: [string]: Val: 1 + out: [string]: Val: 1 + out: in.a + } + a4: { + out: in.a + out: [string]: Val: 1 - in: a: { - if true { - b: {} - } - } - @test(eq, {out: {b: {Val: 1}}, in: {a: {b: {}}}}) - } - a5: { - out: in.a + in: a: { + if true { + b: {} + } + } + } + a5: { + out: in.a - in: a: { - if true { - b: {} - } - } + in: a: { + if true { + b: {} + } + } - out: [string]: Val: 1 - @test(eq, {out: {b: {Val: 1}}, in: {a: {b: {}}}}) - } - a6: { - in: a: { - if true { - b: {} - } - } + out: [string]: Val: 1 + } + a6: { + in: a: { + if true { + b: {} + } + } - out: in.a - out: [string]: Val: 1 - @test(eq, {in: {a: {b: {}}}, out: {b: {Val: 1}}}) - } + out: in.a + out: [string]: Val: 1 + } } -- issue3691.cue -- // evalv3 panic: incDependent "already closed" when processing conditional @@ -125,7 +116,6 @@ issue3691: original: { b: c: 1 } } - @test(err, code=eval, at=a.b.c, contains="conflicting values", args=[string, 1], pos=[1:15, 2:15, 3:5, 4:3, 5:10]) } // Structural cycles follow a different code path. issue3691: structuralCycle: { @@ -136,7 +126,6 @@ issue3691: structuralCycle: { b: c: a } } - @test(err, code=eval, at=a.b.c, contains="conflicting values", pos=[1:15, 2:5, 2:15, 3:5, 4:3, 5:10]) } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/eval/conflicts.txtar b/internal/core/compile/testdata/sync/eval/conflicts.txtar index dbc863137..e5a5fb2f3 100644 --- a/internal/core/compile/testdata/sync/eval/conflicts.txtar +++ b/internal/core/compile/testdata/sync/eval/conflicts.txtar @@ -3,18 +3,10 @@ i: int s: string t0: { - @test(err, code=eval, at=v, - contains="conflicting values", - args=[int, string], - pos=[-3:4, -2:4, 5:5, 5:9]) v: i & s } t1: { - @test(err, code=eval, at=x.a.b, - contains="conflicting values", - args=[3, 4], - pos=[6:9, 10:9, 13:5, 13:11]) #d1: { a: b: 3 } @@ -24,11 +16,6 @@ t1: { } x: #d1 & #d2 - @test(eq, { - #d1: a: b: 3 - #d2: a: b: 4 - x: a: b: _|_ - }) } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/eval/conjuncts.txtar b/internal/core/compile/testdata/sync/eval/conjuncts.txtar index 92e2bd1ad..8ad6c96b1 100644 --- a/internal/core/compile/testdata/sync/eval/conjuncts.txtar +++ b/internal/core/compile/testdata/sync/eval/conjuncts.txtar @@ -3,14 +3,13 @@ // regression fixes for undefined field errors (issue 2351) and cycle errors // (issue 2355) in the v3 evaluator. -- in.cue -- - conjunct: t1: ({ #early: *"X" | string #early } & { #early: *"X" | string string -}) @test(eq, *{"X", #early: *"X" | string} | {string, #early: *"X" | string}) +}) conjunct: t2: { #early: *"X" | string @@ -19,18 +18,16 @@ conjunct: t2: { conjunct: t2: { #early: *"X" | string string -} @test(eq, *{"X", #early: *"X" | string} | {string, #early: *"X" | string}) +} -conjunct: t3: (conjunct.t1 & conjunct.t2) @test(eq, *{"X", #early: *"X" | string} | {string, #early: *"X" | string}) +conjunct: t3: (conjunct.t1 & conjunct.t2) handleComprehensions: { if false { subs: #sub2 & 2 } #sub2: 2 - @test(eq, {#sub2: 2}) } - -- issue2351.cue -- // Regression between v0.4.3 and v0.5.0: "undefined field" error when embedding // a for comprehension, caused by incorrect error reporting for let/hidden fields. @@ -41,7 +38,6 @@ issue2351: let: { param: _param & [{}] gen: [for p in param {p}] }).gen - @test(err, code=eval, contains="conflicting values", pos=[0:17, 1:15, 2:2, 3:10, 3:19]) } issue2351: hidden: { @@ -50,13 +46,7 @@ issue2351: hidden: { in2: _in1 out: [for x in in2 {x}] }.out - @test(skip, hint="TODO(inline): allow ignoring hidden values.") - @test(eq:todo, { - @test(final) - ["foo"] - }) } - -- issue2355.cue -- // Regression v0.4.3→v0.5.0: cycle error when using let fields within nested // struct embeddings, breaking previously working code. @@ -64,12 +54,12 @@ issue2351: hidden: { issue2355: { #GetF1: { in: _ - out: in.f1 @test(err, code=incomplete, contains="%s undefined as %s is incomplete (type %s)", args=[in.f1, in, _], pos=[0:8]) + out: in.f1 } #PutOut1: { in: _ - out: out1: "\(in)" @test(err, code=incomplete, contains="invalid interpolation", pos=[0:14]) + out: out1: "\(in)" } export: { @@ -80,21 +70,7 @@ issue2355: { }).out }).out } - @test(eq, { - #GetF1: { - in: _ - out: _|_ - } - #PutOut1: { - in: _ - out: { - out1: _|_ - } - } - export: {out1: "foo"} - }) } - -- out/compile -- --- in.cue { diff --git a/internal/core/compile/testdata/sync/eval/counters.txtar b/internal/core/compile/testdata/sync/eval/counters.txtar index 87a076954..5cbbbbceb 100644 --- a/internal/core/compile/testdata/sync/eval/counters.txtar +++ b/internal/core/compile/testdata/sync/eval/counters.txtar @@ -24,35 +24,14 @@ issue3750: original: { } } - #Bar: { kind: "bar" meta: strs: [...string] } - @test(eq, { - out: { - sub: { - sub: { - sub: { - sub: {kind: "bar", meta: {strs: []}} - meta: {strs: []} - } |{kind: "bar", meta: {strs: []}} - meta: {strs: []} - } | {kind: "bar", meta: {strs: []}} - meta: {strs: []} - } - meta: {strs: []} - } - #Foo: { - sub: {kind: "bar", meta: {strs: []}} - meta: {strs: []} - } - #Bar: {kind: "bar", meta: {strs: []}} - }) } issue3750: reduced: { - out: Foo & { sub: Foo } + out: Foo & {sub: Foo} Foo: { sub: Foo | {a: b: _} @@ -61,16 +40,6 @@ issue3750: reduced: { for _, w in list.FlattenN([b], 1) {} } } - @test(eq, { - out: { - sub: { - sub: {sub: {sub: {a: {b: _}}, a: {b: _}} | {a: {b: _}}, a: {b: _}} | {a: {b: _}} - a: {b: _} - } - a: {b: _} - } - Foo: {sub: {a: {b: _}}, a: {b: _}} - }) } -- issue3780.cue -- import "strings" @@ -91,7 +60,6 @@ issue3780: panic1: { kind: "object" ... } - @test(err, code=incomplete, hint="required field missing: param") } issue3780: panic2: { parent: { @@ -108,9 +76,6 @@ issue3780: panic2: { ... } } - @test(eq, { - parent: {objs: {}, param?: bool, #Objects: {}} - }) } -- issue3770.cue -- // evalv3 regression: fields generated by a for loop in a let binding were @@ -124,9 +89,8 @@ issue3770: task: { } x: b: 1 } - m: null | { } + m: null | {} out: m.x.a - @test(eq, {m: {x: {b: 1, a: 1}}, out: 1}) } -- issue3824.cue -- // evalv3 panic: "unexpected uninitialized node" when combining if comprehensions @@ -134,36 +98,23 @@ issue3770: task: { // https://cuelang.org/issue/3824 issue3824: panic: { thing: { - spec: name: string - outputField: string + spec: name: string + outputField: string } val: string things: [_]: thing things: [_]: { - spec: *{ - name: "self-signed" - } | {...} + spec: *{ + name: "self-signed" + } | {...} } if true { - things: "name": {} - val: things["name"].outputField + things: "name": {} + val: things["name"].outputField } - @test(eq, { - thing: { - spec: {name: string} - outputField: string - } - val: string - things: { - name: { - spec: *{name: "self-signed"} | {name: string} - outputField: string - } - } - }) } -- out/compile -- --- issue3750.cue diff --git a/internal/core/compile/testdata/sync/eval/cycles_ref.txtar b/internal/core/compile/testdata/sync/eval/cycles_ref.txtar index 38ed4184c..d17707263 100644 --- a/internal/core/compile/testdata/sync/eval/cycles_ref.txtar +++ b/internal/core/compile/testdata/sync/eval/cycles_ref.txtar @@ -1,11 +1,11 @@ -- in.cue -- -a: b + 100 @test(eq, 200) -b: a - 100 @test(eq, 100) +a: b + 100 +b: a - 100 a: 200 -c: d & {b: 2} @test(eq, {a: 1, b: 2}) -d: e @test(eq, {a: 1, b: 2}) -e: {a: 1} @test(eq, {a: 1, b: 2}) +c: d & {b: 2} +d: e +e: {a: 1} e: c -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/eval/deref.txtar b/internal/core/compile/testdata/sync/eval/deref.txtar index 58415a40c..e397c67eb 100644 --- a/internal/core/compile/testdata/sync/eval/deref.txtar +++ b/internal/core/compile/testdata/sync/eval/deref.txtar @@ -21,13 +21,8 @@ issue4011: full: { } site: [_]: hugo: production: {} - @test(eq, {site: cls: { - fs: Create: config: Contents: {} - hugo: production: {} - }}) } issue4011: reduced: { - @test(eq, {result: foo: true, envs: foo: {}}) result: { for envName in ["foo"] let env = envs[envName] diff --git a/internal/core/compile/testdata/sync/eval/discontinuous.txtar b/internal/core/compile/testdata/sync/eval/discontinuous.txtar index 94fd97b92..e6dc52659 100644 --- a/internal/core/compile/testdata/sync/eval/discontinuous.txtar +++ b/internal/core/compile/testdata/sync/eval/discontinuous.txtar @@ -5,19 +5,17 @@ a: [for c in foo.bar.baz { c }] -a: [{name: "http"}] @test(eq, [{name: "http", port: 8080}]) +a: [{name: "http"}] foo: { x.D bar: baz: [{port: 8080}] - @test(eq, {bar: {baz: [{port: 8080}]}}) } x: { D: bar: DSpec DSpec: {} - @test(eq, {D: bar: {}, DSpec: {}}) } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/eval/disjselfcycle.txtar b/internal/core/compile/testdata/sync/eval/disjselfcycle.txtar index b412fcc70..3fb44a011 100644 --- a/internal/core/compile/testdata/sync/eval/disjselfcycle.txtar +++ b/internal/core/compile/testdata/sync/eval/disjselfcycle.txtar @@ -11,9 +11,6 @@ issue4119: reduced: { f: i.f } ] - @test(eq, {x: *[{ - f: 123 - }] | []}) } // This test is added to test the memory management bug isn't triggered // one level deeper. This test is expected to fail, as it now triggers @@ -27,7 +24,6 @@ issue4119: reducedNested: { f: i.f } ]} - @test(err, code=eval, path=x.y.0.f, contains="undefined field: %s", args=[f], pos=[5:9]) } issue4119: full: { _img: img={ @@ -63,17 +59,6 @@ issue4119: full: { art: images: ko: { val: "test" } - @test(eq, { - _img: { - val: string - accounts: {groups: [{ gid: 65532 }]} - } - art: images: ko: { - val: "test" - accounts: {groups: *[{ gid: 65532 }] | []} - } - #Image: {val: string, accounts?: groups?: []} - }) } -- out/compile -- --- comprehensions.cue diff --git a/internal/core/compile/testdata/sync/eval/disjunctioncross.txtar b/internal/core/compile/testdata/sync/eval/disjunctioncross.txtar index 4474eef10..59d96a046 100644 --- a/internal/core/compile/testdata/sync/eval/disjunctioncross.txtar +++ b/internal/core/compile/testdata/sync/eval/disjunctioncross.txtar @@ -13,7 +13,7 @@ _appDefaults: two: two: optional: *"optional set" | string // Use a discriminator field to disambiguation additional per-disjunct // information. valueDiscriminator: crossing: { - out: #Application & { oneOrTwo: kind: "two" } + out: #Application & {oneOrTwo: kind: "two"} #Application: { oneOrTwo: #OneOrTwo // oneOrTwo.kind resolves will resolve to "two" regardless of whether @@ -21,23 +21,10 @@ valueDiscriminator: crossing: { // processed. oneOrTwo: *_appDefaults[oneOrTwo.kind] | _ } - @test(eq, { - out: { - oneOrTwo: - *{kind: "two", two: {optional: *"optional set" | string}} | - {kind: "two", two: {optional?: string}} - } - #Application: { - oneOrTwo: - *{kind: "two", two: {optional: *"optional set" | string}} | - {kind: "one", one: {oneField: "value"}} | - {kind: "two", two: {optional?: string}} - } - }) } valueDiscriminator: local: { - out: #Application & { oneOrTwo: kind: "two" } + out: #Application & {oneOrTwo: kind: "two"} #Application: { oneOrTwo: #OneOrTwo // oneOrTwo.kind always resolves to the value of the disjunct. @@ -45,25 +32,16 @@ valueDiscriminator: local: { // oneOrTwo~X: *_appDefaults[X.kind] | _ // oneOrTwo: *_appDefaults[self.kind] | _ // try { oneOrTwo: _appDefaults.(self.kind)? } - oneOrTwo: X={ *_appDefaults[X.kind] | _ } + oneOrTwo: X={*_appDefaults[X.kind] | _} } - @test(eq, { - out: oneOrTwo: - *{kind: "two", two: {optional: *"optional set" | string}} | - {kind: "two", two: {optional?: string}} - #Application: oneOrTwo: - *{kind: "two", two: {optional: *"optional set" | string}} | - {kind: "one", one: {oneField: "value"}} | - {kind: "two", two: {optional?: string}} - }) } // Use a value that is available AFTER a disjunction is resolved to augment // values. We may not want to support this in perpetuity, as this relies on // closedness to discrimnate the disjuncts. But for now, as there is no // alternative to discriminating based on fields, we will support it. -fieldDiscriminator: crossing:{ - out: #Application & { oneOrTwo: two: {} } +fieldDiscriminator: crossing: { + out: #Application & {oneOrTwo: two: {}} #Application: { oneOrTwo: #OneOrTwo // The value of oneOrTwo.kind depends on whether oneOrTwo resolves @@ -72,37 +50,15 @@ fieldDiscriminator: crossing:{ // selected. oneOrTwo: *_appDefaults[oneOrTwo.kind] | _ } - @test(eq, { - out: oneOrTwo: - *{two: {optional: *"optional set" | string}, kind: "two"} | - {two: {optional?: string}, kind: "two"} - #Application: oneOrTwo: - *{kind: "two", two: {optional: *"optional set" | string}} | - {kind: "one", one: {oneField: "value"}} | - {kind: "two", two: {optional?: string}} - }) } -fieldDiscriminator: local:{ - out: #Application & { oneOrTwo: two: {} } +fieldDiscriminator: local: { + out: #Application & {oneOrTwo: two: {}} #Application: { oneOrTwo: #OneOrTwo // oneOrTwo.kind always resolves to the value of the disjunct. - oneOrTwo: X={ *_appDefaults[X.kind] | _ } + oneOrTwo: X={*_appDefaults[X.kind] | _} } - @test(eq, { - out: { - oneOrTwo: - *{two: {optional: *"optional set" | string}, kind: "two"} | - {two: {optional?: string}, kind: "two"} - } - #Application: { - oneOrTwo: - *{kind: "two", two: {optional: *"optional set" | string}} | - {kind: "one", one: {oneField: "value"}} | - {kind: "two", two: {optional?: string}} - } - }) } // Do not hide error messages. Here, the inner failure of both disjuncts means @@ -126,18 +82,10 @@ issue3967: error: nested: { } } } - if X.oneOrTwo.kind == "never" { - } - } - if X.oneOrTwo.kind == "never" { + if X.oneOrTwo.kind == "never" {} } + if X.oneOrTwo.kind == "never" {} } - @test(eq, { - out: {oneOrTwo: {two: {}}} - #Application: { - oneOrTwo: {kind: "one", one: {oneField: "value"}} - } - }) } issue3967: { error: local: { @@ -145,7 +93,7 @@ issue3967: { oneOrTwo: two: {} } #Application: { - oneOrTwo: X= { #OneOrTwo & { + oneOrTwo: X= {#OneOrTwo & { if X.kind == "two" { two: { if X.two.optional == _|_ { @@ -153,27 +101,10 @@ issue3967: { } } } - if X.kind == "never" { - } + if X.kind == "never" {} }} } } - @test(eq, { - error: { - nested: { - out: {oneOrTwo: {two: {}}} - #Application: { - oneOrTwo: {kind: "one", one: {oneField: "value"}} - } - } - local: { - out: {oneOrTwo: {two: {}}} - #Application: { - oneOrTwo: {kind: "one", one: {oneField: "value"}} - } - } - } - }) } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/eval/disjunctions.txtar b/internal/core/compile/testdata/sync/eval/disjunctions.txtar index 51495a004..e9df48ddb 100644 --- a/internal/core/compile/testdata/sync/eval/disjunctions.txtar +++ b/internal/core/compile/testdata/sync/eval/disjunctions.txtar @@ -1,6 +1,6 @@ -- in.cue -- -a: *1 | int @test(eq, *1 | int) -aa: *1 | *2 | int @test(eq, *1 | *2 | int) +a: *1 | int +aa: *1 | *2 | int b: { name: "int" @@ -8,56 +8,47 @@ b: { } | { name: "str" val: string -} @test(eq, {name: "int", val: int} | {name: "str", val: string}) +} -d: b & {val: 3} @test(eq, {val: 3, name: "int"}) -c: b & {name: "int", val: 3} @test(eq, {name: "int", val: 3}) -e: b & {val: "foo"} @test(eq, {val: "foo", name: "str"}) -f: b & {name: "str", val: 3} @test(err, - suberr=(code=eval, contains="conflicting values", pos=[-10:8, 0:4, 0:15]), - suberr=(code=eval, contains="conflicting values", pos=[-6:8, 0:4, 0:27])) +d: b & {val: 3} +c: b & {name: "int", val: 3} +e: b & {val: "foo"} +f: b & {name: "str", val: 3} // Disjunct elimination based on type. e1: { a: null | {bar: 2} b: (a & {}).bar - @test(eq, {a: null | {bar: 2}, b: 2}) } d1: { - a: (null | {c: 1}) & {} + a: (null | {c: 1}) & {} b: {} & (null | {c: 1}) - @test(eq, {a: {c: 1}, b: {c: 1}}) } d2: { - a: ([...] | {c: 1}) & {} + a: ([...] | {c: 1}) & {} b: {} & ([...] | {c: 1}) - @test(eq, {a: {c: 1}, b: {c: 1}}) } d3: { - a: (string | {c: 1}) & {} + a: (string | {c: 1}) & {} b: {} & (string | {c: 1}) - @test(eq, {a: {c: 1}, b: {c: 1}}) } d4: { - a: (string | {c: 1}) & {} + a: (string | {c: 1}) & {} b: {} & (string | {c: 1}) - @test(eq, {a: {c: 1}, b: {c: 1}}) } d5: { - a: (number | {c: 1}) & {} + a: (number | {c: 1}) & {} b: {} & (number | {c: 1}) - @test(eq, {a: {c: 1}, b: {c: 1}}) } d6: { - a: (int | {c: 1}) & {} + a: (int | {c: 1}) & {} b: {} & (int | {c: 1}) - @test(eq, {a: {c: 1}, b: {c: 1}}) } t10: p1: { @@ -68,11 +59,6 @@ t10: p1: { test: name: "Test" test: #A - @test(eq, { - schema: {name: "Test"} - #A: string | {name: string} - test: {name: "Test"} - }) } t10: p2: { @@ -82,11 +68,6 @@ t10: p2: { test: name: "Test" test: #A - @test(eq, { - schema: {name: "Test"} - #A: string | {name: string} - test: {name: "Test"} - }) } t10: p3: { @@ -97,43 +78,27 @@ t10: p3: { schema: string | {name: string} schema: test - @test(eq, { - #A: string | {name: string} - test: {name: "Test"} - schema: {name: "Test"} - }) } t11: p1: { a: #A a: b - b: #A & ["b"] + b: #A & ["b"] #A: ["a" | "b"] | {} - @test(eq, { - a: ["b"] - b: ["b"] - #A: ["a" | "b"] | {} - }) } t11: p2: { - b: #A & ["b"] + b: #A & ["b"] #A: ["a" | "b"] | {} a: b a: #A - @test(eq, { - b: ["b"] - #A: ["a" | "b"] | {} - a: ["b"] - }) } cross: { a: *"word" | string a: string | *"word" - @test(eq, {a: *"word" | string}) } d100: { @@ -141,10 +106,6 @@ d100: { // This would be a spec change. Disallow for now. i: null | {bar: 2} j: i.bar - @test(eq, { - i: null | {bar: 2} - j: _|_ @test(err, code=incomplete, contains="d100.j: unresolved disjunction null | {bar:2} (type (null|struct))", pos=[142:5]) - }) } // Regression test for empty disjunction with combined definitions and @@ -174,27 +135,15 @@ issue641: { x: "foobar" } } - @test(eq, { - #A: {type: "a", x: ""} - #B: {type: "b", x: string} - #C: { - b: {type: "a", x: ""} | {type: "b", x: string} - } - e: {foobar: {b: {x: "foobar", type: "b"}}} - }) } -- issue3406.cue -- // evalv3 panic with inconsistent state when unifying a struct with itself // embedded via a disjunction field. // https://cuelang.org/issue/3406 issue3406: { - out: d & { d } + out: d & {d} d: kind: "foo" | "bar" - d: { kind: "foo" } | { kind: "bar" } - @test(eq, { - out: {kind: "foo"} | {kind: "bar"} - d: {kind: "foo"} | {kind: "bar"} - }) + d: {kind: "foo"} | {kind: "bar"} } -- issue3411.cue -- // evalv3 nil pointer dereference when unifying optional fields with defaults. @@ -202,32 +151,17 @@ issue3406: { issue3411: { x: y?: [...string] x: {y: ["foo"]} | *{y: ["bar"]} - @test(eq, {x: *{y: ["bar"]} | {y: ["foo"]}}) } -- issue3490.cue -- // evalv3 "incDependent: already closed" panic regression involving disjunctions. // https://cuelang.org/issue/3490 issue3490: nested: p1: { - ("a"|"b") | "b" - "a"|"b" - @test(eq, { - "a" - @test(eq) - } | { - "b" - @test(eq) - }) + ("a" | "b") | "b" + "a" | "b" } issue3490: nested: p2: { - "a"|"b" - ("a"|"b") | "b" - @test(eq, { - "a" - @test(eq) - } | { - "b" - @test(eq) - }) + "a" | "b" + ("a" | "b") | "b" } issue3490: full: { data: [...#Schema] @@ -237,18 +171,6 @@ issue3490: full: { #D1: "d1" #D2: "d2" } - @test(eq, { - data: [{ - runs?: "foo" | ["d1"] | ["d1", "d2"] - #D1: "d1" - #D2: "d2" - }] - #Schema: { - runs?: "foo" | ["d1"] | ["d1", "d2"] - #D1: "d1" - #D2: "d2" - } - }) } -- issue3434.cue -- // evalv3 panic "unexpected overlay in next" with disjunctions inside definitions. @@ -257,7 +179,6 @@ issue3434: t1: { ({} | {}) {["x"]: 1} {["y"]: 2} - @test(eq, {["x"]: 1, ["y"]: 2}) } issue3434: full: { out: #Schema & { @@ -271,18 +192,6 @@ issue3434: full: { {[=~"^bar"]: [...#matrixConfig] | string} } } - @test(eq, { - out: { - steps: [{ run: "example" }] - #matrixConfig: string | [] - matrix?: {} - } - #Schema: { - steps: [] - #matrixConfig: string | [] - matrix?: {} - } - }) } -- issue3597.cue -- // evalv3 index out of range panic in overlayContext.allocCC with let inside @@ -302,11 +211,6 @@ issue3597: t1: { foo: bar bar: {} - @test(eq, { - #Schema: {_ok: bool} | {_ok: true} | {_ok: true, x: true} - foo: {_ok: bool} | {_ok: true} | {_ok: true, x: true} - bar: {_ok: bool} | {_ok: true} | {_ok: true, x: true} - }) } issue3597: t2: { ok: true @@ -315,11 +219,6 @@ issue3597: t2: { _ | {x: Ok} } foo: X & {X} - @test(eq, { - ok: true - X: _ | _ | {x: true} - foo: _ | _ | {x: true} - }) } -- dependencies.cue -- // evalv3 incorrectly allowed a field inside a struct disjunction that should @@ -331,11 +230,6 @@ issue3606: { } & #S #S: string | {} - - @test(err, code=eval, - suberr=(code=eval, path=data, contains="conflicting values %s and %s (mismatched types %s and %s)", - args=[{notAllowed:true}, string, struct, string], pos=[1:8, 3:6, 5:6]), - suberr=(code=eval, path=data.notAllowed, contains="field not allowed", pos=[2:3])) } // evalv3 gives a different result vs evalv2 when openinline is enabled; list @@ -352,21 +246,9 @@ issue3672: { // The unification inline appears to be critical #def: (#fn & {}).#out - + v: #def v: x: [{y: true}] // Should be one element - @test(eq, { - #A: string | {y: true} - #B: string | {y: true} | {a: "append"} | {b: "prepend"} - #fn: { - #C: string | {y: true} | {a: "append"} | {b: "prepend"} - #out: {x: []} - } - #def: {x: []} - v: {x: [{ - y: true - }]} - }) } // Regression giving "non-concrete value _ (type _)" error when interpolating // a string default from a disjunction via a definition alias. @@ -376,35 +258,27 @@ issue3681: { out: one: #strDefaultDef out: two: "\(strDefault)" - strDefault: *"fallback" | string + strDefault: *"fallback" | string #strDefaultDef: strDefault - @test(eq, { - out: { - one: *"fallback" | string - two: "fallback" - } - strDefault: *"fallback" | string - #strDefaultDef: *"fallback" | string - }) } // evalv3 "undefined field" regression when a comprehension condition references // a field whose default is provided by a disjunction. // https://cuelang.org/issue/3699 issue3699: { reduced: p1: { - y: { if x.z { 1 } } + y: {if x.z {1}} x: *{z: true} | {} } reduced: p2: { - y: { if x.z { 1 } } + y: {if x.z {1}} x: *{z: true} | {} } reduced: full: { _res: { _fooTrue: {} | *{foo: true} _msgSwitch: [ - if _fooTrue.foo { msg: "foo" }, - { msg: "bar" }, + if _fooTrue.foo {msg: "foo"}, + {msg: "bar"}, ][0] out: _msgSwitch.msg } @@ -413,28 +287,14 @@ issue3699: { } out: res.out } - @test(eq, { - reduced: { - p1: {y: 1, x: *{z: true} | {}} - p2: {y: 1, x: *{z: true} | {}} - full: { - _res: { - _fooTrue: *{foo: true} | {} - _msgSwitch: {msg: "foo"} - out: "foo" - } - out: "foo" - } - } - }) } -- indexelim.cue -- import "math/bits" indexElimination: { - inStruct: x: { a: *x[0] | 0 }.a @test(eq, 0) - inList1: x: [x[0]][0] @test(eq, _) - inList2: x: [*x[0] | 0][0] @test(eq, 0) + inStruct: x: {a: *x[0] | 0}.a + inList1: x: [x[0]][0] + inList2: x: [*x[0] | 0][0] // evalv3 strange behavior with chaining of list comprehensions, // incorrect results when indexing the output of a for loop. // https://cuelang.org/issue/3124 @@ -443,11 +303,6 @@ indexElimination: { x: [true, false, true, true] y: [for _, v in x {[if v {1}, 0][0]}] z: [for i, v in y {bits.Set(*z[i-1] | 0, len(y)-i-1, v)}][3] - @test(eq, { - x: [true, false, true, true] - y: [1, 0, 1, 1] - z: 1 - }) } } -- issue3899.cue -- @@ -455,38 +310,20 @@ indexElimination: { // a string interpolation references an optional field inside a disjunction. // https://cuelang.org/issue/3899 issue3899: reduced: { - @test(permute, count=2) - b: c + "" | string + b: c+"" | string c?: string - @test(eq, {b: string, c?: string}) } issue3899: full: { out: #Schema & { name: "foo" - } - #Schema: { - _versions: foo: "123" - spec: limits: true - name!: string - spec: image: string | *"\(name)" - deployImage: _versions[spec.image] @test(err, code=incomplete, - contains="invalid non-ground value %s (must be concrete %s)", - args=[string, string], pos=[-1:18]) - } - @test(eq, { - out: { - name: "foo" - _versions: {foo: "123"} - spec: {limits: true, image: *"foo" | string} - deployImage: "123" - } - #Schema: { - _versions: {foo: "123"} - spec: {limits: true, image: string} - name!: string - deployImage: _|_ - } - }) + } + #Schema: { + _versions: foo: "123" + spec: limits: true + name!: string + spec: image: string | *"\(name)" + deployImage: _versions[spec.image] + } } -- issue3891.cue -- // evalv3 "incomplete value" regression with repeated disjunctions where a @@ -496,10 +333,8 @@ issue3891: reduced: { {x: _} | null {x: _} | null x: *a.y | _ - a: b @test(shareID=r3891ab) - @test(shareID=r3891ab, at=b) + a: b b: y: 1 - @test(eq, {x: *1 | _, a: {y: 1}, b: {y: 1}}) } issue3891: full: { out: #Foo | "never" @@ -508,23 +343,14 @@ issue3891: full: { _input: (_transform & {in: sub1: sub2: "bar"}).out } _transform: { - in: _ + in: _ out: in } #Foo: foo?: _ _fooTemplate: { _input: _ - foo: *_input.sub1.sub2 | _ + foo: *_input.sub1.sub2 | _ } - @test(eq, { - out: { - _input: {sub1: {sub2: "bar"}} - foo: *"bar" | _ - } - _transform: {in: _, out: _} - #Foo: {foo?: _} - _fooTemplate: {_input: _, foo: _} - }) } -- out/compile -- --- dependencies.cue diff --git a/internal/core/compile/testdata/sync/eval/dynamic_field.txtar b/internal/core/compile/testdata/sync/eval/dynamic_field.txtar index 04d4ebedd..cb96468d5 100644 --- a/internal/core/compile/testdata/sync/eval/dynamic_field.txtar +++ b/internal/core/compile/testdata/sync/eval/dynamic_field.txtar @@ -5,41 +5,32 @@ -- in.cue -- a: "foo" "\(a)": b: c: d: e -e: 2 @test(eq, 2) +e: 2 b: "bar" X="\(b)": { a: 1 } -c: X @test(eq, {a: 1}) +c: X withError: { // Panic when running cue eval with a struct used in a string interpolation. // https://cuelang.org/issue/799 issue799: {key: int32} & {"\(1 & 2)": 123} - // TODO(inline): access _wrapped_ error somehow: underlying error is - // "conflicting values 2 and 1". - @test(err, code=eval, contains="invalid interpolation", pos=[3:28, 3:31, 3:35]) } parenExprRefParent: { a: (x): {} x: "foo" - @test(eq, {a: {foo: {}}, x: "foo"}) } parenExprRefEqual: { (x): {} x: "foo" - @test(eq, {x: "foo", foo: {}}) } chainedResolution: x: { - @test(permute, count=6) (x.baz): "bar" (x.foo): "baz" - baz: "foo" - @test(eq, { - baz: "foo", foo: "bar", bar: "baz" - }) + baz: "foo" } // A dynamic field key that references an incomplete value (string interpolation @@ -52,30 +43,12 @@ noCycleError: { } foo: bar: entries: (foo.baz.#ID): true foo: baz: {} - @test(err, at=foo.bar.entries, code=incomplete, - suberr=(code=incomplete, contains="dynamic field must be concrete", pos=[4:22]), - suberr=(code=incomplete, contains="non-concrete value string", pos=[2:8, 2:11]), - ) - @test(err, at=foo.bar.#ID, code=incomplete, contains="non-concrete value string", pos=[2:8, 2:11]) - @test(err, at=foo.baz.#ID, code=incomplete, contains="non-concrete value string", pos=[2:8, 2:11]) - - @test(eq, { - foo: { - bar: { - entries: _|_ - #ID: _|_ - } - baz: { #ID: _|_ } - } - }) } - -- constraints.cue -- constraints: { t1: "foo" t2: "bar" (t1)?: (t2)!: 3 - @test(eq, {t1: "foo", t2: "bar", foo?: {bar!: 3}}) } -- issue3828.cue -- // evalv3 regression: a let inside a comprehension with a dynamic field key @@ -84,12 +57,11 @@ constraints: { issue3828: reduced: { a: b: {} a: [_]: { - if true let x=str { + if true let x = str { (x): true } } str: "foobot1" - @test(eq, {a: {b: {foobot1: true}}, str: "foobot1"}) } issue3828: full: { orgs: org1: { @@ -102,13 +74,6 @@ issue3828: full: { collaborators: (repo_name): (orgBotUser): true } } - @test(eq, { - orgs: org1: { - repos: {repo1: {}} - collaborators: {repo1: {bot1: true}} - } - botUser: "bot1" - }) } -- out/compile -- --- constraints.cue diff --git a/internal/core/compile/testdata/sync/eval/embed.txtar b/internal/core/compile/testdata/sync/eval/embed.txtar index 5998d132e..63701a662 100644 --- a/internal/core/compile/testdata/sync/eval/embed.txtar +++ b/internal/core/compile/testdata/sync/eval/embed.txtar @@ -16,7 +16,6 @@ Common: { x: #A x: { c: int - @test(eq, {c: int, a: int, b: int}) } #B: { @@ -29,17 +28,15 @@ x: { y: #B y: { c: int - @test(eq, {c: int, a: int}) } -- noclose.cue -- double: { a: b?: c: d: "c" a: {{ b: {{ - c: e: "member" + c: e: "member" }} }} - @test(eq, {a: {b: {c: {d: "c", e: "member"}}}}) } doubleAsComprehension: { a: b?: c: d: "c" @@ -52,7 +49,6 @@ doubleAsComprehension: { } } } - @test(eq, {a: {b: {c: {d: "c", e: "member"}}}}) } fieldNotAllowed: { // This was not correctly enforced in evalv2. @@ -69,7 +65,6 @@ fieldNotAllowed: { #Y objs: name: "Two" } - @test(err, at=addTwo.objs.extra, code=eval, contains="field not allowed", pos=[3:5]) } t2: { #AddObjsExtra: { @@ -92,56 +87,30 @@ fieldNotAllowed: { name: "One" } } - @test(err, at=#AddTwo.objs.two.labels.app, code=incomplete, contains="undefined field: one", pos=[13:23]) - - @test(err, at=#AddTwo.objs.two.extra, code=eval, contains="field not allowed", pos=[3:5]) - @test(err, at=#AddTwo.objs.two.extra.unused, code=eval, contains="field not allowed", pos=[3:12]) - @test(err, at=out.objs.one.extra.unused, code=eval, contains="field not allowed", pos=[3:12]) - @test(err, at=out.objs.one.extra, code=eval, contains="field not allowed", pos=[3:5]) - @test(err, at=out.objs.one.name, code=eval, contains="field not allowed", pos=[18:5]) - @test(err, at=out.objs.two.extra.unused, code=eval, contains="field not allowed", pos=[3:12]) - - // This error is perculated up. - @test(err, code=eval, - hint="the error chosen here is somewhat arbitrary, okay to ignore as long as the others are good", - suberr=(code=eval, path=out.objs.one.name, contains="field not allowed", pos=[18:5]), - suberr=(code=eval, path=out.objs.one.extra, contains="field not allowed", pos=[3:5])) } t3: { x: #X #X: y: { z: { a: [string]: string - b: E: "1" + b: E: "1" } ... } - - @test(shareID=YY, at=#Y) - @test(shareID=YY, at=x1.y) - x1: y: #Y + x1: y: #Y #Y: port?: string x: y: { z: b: E: string port: z.b.E z: a: c?: string - } @test(eq, { - z: {b: E: "1", a: c?: string} - port: "1" - }) + } if true { w: x & { y: x1.y } } - @test(err, at=w.y.z.b.E, code=eval, contains="field not allowed", pos=[5:8, 16:10]) - @test(err, at=w.y.z.a, code=eval, contains="field not allowed", pos=[4:5, 18:7]) - @test(err, at=w.y.z.b, code=eval, contains="field not allowed", pos=[5:5, 16:7]) - @test(err, code=eval, - suberr=(code=eval, path=w.y.z.b, contains="field not allowed", pos=[5:5, 16:7]), - suberr=(code=eval, path=w.y.z.a, contains="field not allowed", pos=[4:5, 18:7])) } } closednessInversion: { @@ -153,15 +122,6 @@ closednessInversion: { base.x a: b: c: "d" } - @test(eq, { - base: {x: {y: *"default" | string}} - #X: {x: {}} - #Y: {y: *"default" | string} - out: { - a: {b: {c: "d"}} - y: *"default" | string - } - }) } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/eval/errunifiy.txtar b/internal/core/compile/testdata/sync/eval/errunifiy.txtar index 2a654b407..c134fb760 100644 --- a/internal/core/compile/testdata/sync/eval/errunifiy.txtar +++ b/internal/core/compile/testdata/sync/eval/errunifiy.txtar @@ -1,9 +1,9 @@ Incomplete errors should not unify with values. -- in.cue -- -a: or([]) @test(err, code=incomplete, contains="empty list", pos=[0:4]) +a: or([]) a: "t" -b: _|_ @test(err, code=user, contains="explicit error", pos=[0:4]) +b: _|_ b: "t" -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/eval/expressions.txtar b/internal/core/compile/testdata/sync/eval/expressions.txtar index 57ee0661a..bf4c276c2 100644 --- a/internal/core/compile/testdata/sync/eval/expressions.txtar +++ b/internal/core/compile/testdata/sync/eval/expressions.txtar @@ -2,22 +2,22 @@ module: "test.com" language: version: "v0.15.0" -- in.cue -- -a: 1 @test(eq, 1) -b: 1 + 2 @test(eq, 3) -c: 3 - 1 @test(eq, 2) -d: rem(5, 3) @test(eq, 2) +a: 1 +b: 1 + 2 +c: 3 - 1 +d: rem(5, 3) // StructCmp examples - now that the experiment is accepted structComparison: { - equalStructs: {a: 1, b: 2} == {a: 1, b: 2} @test(eq, true) - differentStructs: {a: 1} == {a: 2} @test(eq, false) - emptyStructs: {} == {} @test(eq, true) + equalStructs: {a: 1, b: 2} == {a: 1, b: 2} + differentStructs: {a: 1} == {a: 2} + emptyStructs: {} == {} } mixedComparison: { - structVsNumber: {a: 1} == 1 @test(eq, false) - listVsStruct: [1, 2] == {a: 1} @test(eq, false) - stringVsNumber: "hello" == 42 @test(eq, false) + structVsNumber: {a: 1} == 1 + listVsStruct: [1, 2] == {a: 1} + stringVsNumber: "hello" == 42 } -- out/compile -- --- in.cue diff --git a/internal/core/compile/testdata/sync/eval/fields.txtar b/internal/core/compile/testdata/sync/eval/fields.txtar index f38bdc5ed..a1b0b19a2 100644 --- a/internal/core/compile/testdata/sync/eval/fields.txtar +++ b/internal/core/compile/testdata/sync/eval/fields.txtar @@ -2,11 +2,10 @@ bulkToSelf: { a: { foo: [string]: int - foo: bar: "3" @test(err, any, code=eval, contains="conflicting values") + foo: bar: "3" } } intField: { - @test(err, code=eval, contains="integer fields not supported", pos=[2:3]) (2): string } -- out/compile -- diff --git a/internal/core/compile/testdata/sync/eval/incomplete.txtar b/internal/core/compile/testdata/sync/eval/incomplete.txtar index b7dcdc435..a005e1c58 100644 --- a/internal/core/compile/testdata/sync/eval/incomplete.txtar +++ b/internal/core/compile/testdata/sync/eval/incomplete.txtar @@ -6,25 +6,22 @@ -- in.cue -- s: string -e1: s + s @test(err, code=incomplete, - suberr=(code=incomplete, contains="non-concrete value %v in operand to %s", args=[string, +], pos=[0:6, -2:4]), - suberr=(code=incomplete, contains="non-concrete value %v in operand to %s", args=[string, +], pos=[0:6, -2:4]), -) -e2: >"bar" & s @test(eq, >"bar") // okay: "bar" is concrete, result is a valid bound -e3: >s & "foo" @test(err, code=incomplete, contains="non-concrete value s for bound >", pos=[0:7]) -e3b: >s @test(err, code=incomplete, contains="non-concrete value s for bound >", pos=[0:7]) +e1: s + s +e2: >"bar" & s // okay: "bar" is concrete, result is a valid bound +e3: >s & "foo" +e3b: >s -e4: >e1 & s @test(err, code=incomplete, pos=[-8:6, -10:4]) -e5: e1 & s +e5: =5 @test(err, code=incomplete, pos=[-1:5, 0:5, 0:11]) + a: c - b + b: c - a + c: a+b & >=5 } -a: int @test(eq, int) -okay: (>10 & 10 &