From a983b19a4dde512d1821d675ed80d89e01179e55 Mon Sep 17 00:00:00 2001 From: Marcel van Lohuizen Date: Thu, 2 May 2024 16:34:28 +0200 Subject: [PATCH] pkg: update tests to use matrix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To reduce the otherwise large number of diffs, we filter the "(and X more errors)" strings from error messages. Issue #3060 Issue #2884 Signed-off-by: Marcel van Lohuizen Change-Id: I47c140f04dcbd78a2cd22fc7ca074f4e323dc843 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1194196 Unity-Result: CUE porcuepine TryBot-Result: CUEcueckoo Reviewed-by: Daniel Martí --- pkg/encoding/json/testdata/gen.txtar | 263 ++++++++++++++++++++++++++ pkg/internal/builtintest/testing.go | 17 +- pkg/list/testdata/gen.txtar | 170 ++++++++++++++++- pkg/list/testdata/list.txtar | 139 +++++++++++++- pkg/path/testdata/join.txtar | 266 +++++++++++++++++++++++++++ pkg/struct/testdata/gen.txtar | 46 +++++ pkg/struct/testdata/struct.txtar | 50 +++++ pkg/uuid/testdata/uuid.txtar | 55 ++++++ 8 files changed, 997 insertions(+), 9 deletions(-) diff --git a/pkg/encoding/json/testdata/gen.txtar b/pkg/encoding/json/testdata/gen.txtar index 9fb438e440a..30241974734 100644 --- a/pkg/encoding/json/testdata/gen.txtar +++ b/pkg/encoding/json/testdata/gen.txtar @@ -86,6 +86,269 @@ unmarshalStream: { nums1: '1 2' nums2: "1 2" } +-- out/json-v3 -- +Errors: +validate.t2.result: error in call to encoding/json.Validate: invalid value 10 (out of bound <3): + ./in.cue:6:10 + ./in.cue:9:27 + json.Validate:1:6 +unmarshal.trailingInvalid.#result: error in call to encoding/json.Unmarshal: json: invalid JSON: + ./in.cue:39:11 +unmarshal.trailingValid.#result: error in call to encoding/json.Unmarshal: json: invalid JSON: + ./in.cue:39:11 + +Result: +import "encoding/json" + +validate: { + t1: { + str: *"{\"a\":10}" | string + schema: { + b: string + } + result: true + } + t2: { + str: *"{\"a\":10}" | string + schema: { + a: <3 + } + result: _|_ // validate.t2.result: error in call to encoding/json.Validate: validate.t2.schema.a: invalid value 10 (out of bound <3) + } + + // Issue #2395 + enforceRequired: { + str: "{}" + schema: { + x!: int + } + result: json.Validate(str, schema) + } +} +valid: { + t1: { + "1" + #result: json.Valid(string) + } +} +compact: { + t1: { + "[1, 2]" + #result: "[1,2]" + } +} +indent: { + t1: { + "{\"a\": 1, \"b\": 2}" + #initial: *"" | string + #indent: *" " | string + #result: """ + { + "a": 1, + "b": 2 + } + """ + } +} +unmarshal: { + t1: { + "1" + #result: 1 + } + trailingValid: { + #result: _|_ // unmarshal.trailingValid.#result: error in call to encoding/json.Unmarshal: json: invalid JSON + } + trailingInvalid: { + #result: _|_ // unmarshal.trailingInvalid.#result: error in call to encoding/json.Unmarshal: json: invalid JSON + } +} +marshalStream: { + t1: { + #result: json.MarshalStream(X) + [{ + a: 1 + }, { + b: 2 + }] + } + t2: { + #result: json.MarshalStream(X) + [{ + a: 1 + }, { + b: *2 | int + }] + } + t3: { + #result: json.MarshalStream(X) + [{ + a: "\\ \" & < >" + }, { + b: "" + }] + } +} +marshal: { + t1: { + #x: int + a: #x + } & { + _ + #result: json.Marshal(X) + } + t2: { + a: #"\ " & < >"# + } & { + _ + #result: json.Marshal(X) + } +} +htmlEscape: { + t1: marshal.t2.#result & { + string + #result: json.HTMLEscape(X) + } + t2: marshalStream.t3.#result & { + string + #result: json.HTMLEscape(X) + } +} +unmarshalStream: { + t1: { + "{\"a\": 1}{\"b\": 2}" + #result: [{ + a: 1 + }, { + b: 2 + }] + } + t2: { + '{"a": 1}{"b": 2}' + #result: [{ + a: 1 + }, { + b: 2 + }] + } + empty1: { + '' + #result: [] + } + empty2: { + "" + #result: [] + } + nums1: { + '1 2' + #result: [1, 2] + } + nums2: { + "1 2" + #result: [1, 2] + } +} +-- diff/-out/json-v3<==>+out/json -- +diff old new +--- old ++++ new +@@ -75,23 +75,15 @@ + } + marshalStream: { + t1: { +- #result: """ +- {"a":1} +- {"b":2} +- +- """ +- [{ +- a: 1 +- }, { +- b: 2 +- }] +- } +- t2: { +- #result: """ +- {"a":1} +- {"b":2} +- +- """ ++ #result: json.MarshalStream(X) ++ [{ ++ a: 1 ++ }, { ++ b: 2 ++ }] ++ } ++ t2: { ++ #result: json.MarshalStream(X) + [{ + a: 1 + }, { +@@ -99,11 +91,7 @@ + }] + } + t3: { +- #result: """ +- {"a":"\\\\ \\" & < >"} +- {"b":""} +- +- """ ++ #result: json.MarshalStream(X) + [{ + a: "\\ \" & < >" + }, { +@@ -113,31 +101,27 @@ + } + marshal: { + t1: { +- #x: int +- #result: json.Marshal(X) +- a: int +- } +- t2: { +- a: "\\ \" & < >" +- #result: "{\"a\":\"\\\\ \\\" & < >\"}" ++ #x: int ++ a: #x ++ } & { ++ _ ++ #result: json.Marshal(X) ++ } ++ t2: { ++ a: #"\ " & < >"# ++ } & { ++ _ ++ #result: json.Marshal(X) + } + } + htmlEscape: { +- t1: { +- "{\"a\":\"\\\\ \\\" & < >\"}" +- #result: "{\"a\":\"\\\\ \\\" \\u0026 \\u003c \\u003e\"}" +- } +- t2: { +- """ +- {"a":"\\\\ \\" & < >"} +- {"b":""} +- +- """ +- #result: """ +- {"a":"\\\\ \\" \\u0026 \\u003c \\u003e"} +- {"b":""} +- +- """ ++ t1: marshal.t2.#result & { ++ string ++ #result: json.HTMLEscape(X) ++ } ++ t2: marshalStream.t3.#result & { ++ string ++ #result: json.HTMLEscape(X) + } + } + unmarshalStream: { +-- diff/todo/p0 -- +Builtins left as unevaluated in output. -- out/json -- Errors: validate.t2.result: error in call to encoding/json.Validate: invalid value 10 (out of bound <3): diff --git a/pkg/internal/builtintest/testing.go b/pkg/internal/builtintest/testing.go index 3d4da7aa499..37a740991c6 100644 --- a/pkg/internal/builtintest/testing.go +++ b/pkg/internal/builtintest/testing.go @@ -16,25 +16,30 @@ package builtintest import ( "fmt" + "regexp" "testing" "cuelang.org/go/cue/format" "cuelang.org/go/internal/core/eval" "cuelang.org/go/internal/core/export" - "cuelang.org/go/internal/core/runtime" "cuelang.org/go/internal/core/validate" + "cuelang.org/go/internal/cuetdtest" "cuelang.org/go/internal/cuetxtar" ) func Run(name string, t *testing.T) { test := cuetxtar.TxTarTest{ - Root: "./testdata", - Name: name, + Root: "./testdata", + Name: name, + Matrix: cuetdtest.SmallMatrix, } - r := runtime.New() + // Find common patterns that we want to ignore for testing purposes. + // TODO(evalv3): remove once new implementation is stable. + re := regexp.MustCompile(` \(and \d* more errors\)`) test.Run(t, func(t *cuetxtar.Test) { + r := t.Runtime() a := t.Instance() v, errs := r.Build(nil, a) @@ -68,6 +73,8 @@ func Run(name string, t *testing.T) { t.Fatal(err) } - fmt.Fprint(t, string(b)) + s := re.ReplaceAllString(string(b), "") + + fmt.Fprint(t, s) }) } diff --git a/pkg/list/testdata/gen.txtar b/pkg/list/testdata/gen.txtar index 1a18f067912..8dcfb659f29 100644 --- a/pkg/list/testdata/gen.txtar +++ b/pkg/list/testdata/gen.txtar @@ -62,6 +62,172 @@ t52: list.MaxItems([1, 2, 3, 4], 5) t53: list.MaxItems([1, 2, 3, 4], 2) t54: list.Sort([{a: 1}, {b: 2}], list.Ascending) t55: list.Avg([4, 8, 12]) +-- out/list-v3 -- +Errors: +t2: error in call to list.Avg: empty list: + ./in.cue:4:6 +t3: cannot use "foo" (type string) as list in argument 1 to list.Avg: + ./in.cue:5:15 +t7: error in call to list.Drop: negative index: + ./in.cue:9:6 +t13: error in call to list.FlattenN: cannot use value "foo" (type string) as list: + ./in.cue:15:6 + ./in.cue:15:20 +t14: cannot use "foo" (type string) as int in argument 2 to list.FlattenN: + ./in.cue:16:24 +t16: error in call to list.Max: empty list: + ./in.cue:18:6 +t17: cannot use "foo" (type string) as list in argument 1 to list.Max: + ./in.cue:19:15 +t19: error in call to list.Min: empty list: + ./in.cue:21:6 +t20: cannot use "foo" (type string) as list in argument 1 to list.Min: + ./in.cue:22:15 +t23: cannot use "foo" (type string) as list in argument 1 to list.Product: + ./in.cue:25:19 +t24: error in call to list.Range: step must be non zero: + ./in.cue:26:6 +t25: error in call to list.Range: end must be greater than start when step is positive: + ./in.cue:27:6 +t26: error in call to list.Range: end must be less than start when step is negative: + ./in.cue:28:6 +t33: error in call to list.Slice: negative index: + ./in.cue:35:6 +t34: error in call to list.Slice: invalid index: 3 > 1: + ./in.cue:36:6 +t35: error in call to list.Slice: slice bounds out of range: + ./in.cue:37:6 +t36: error in call to list.Slice: slice bounds out of range: + ./in.cue:38:6 +t40: error in call to list.Sort: conflicting values *adt.BasicType and *adt.StructLit (mismatched types number and struct): + ./in.cue:46:6 + ./in.cue:46:25 + list:10:9 +t42: invalid list element 0 in argument 0 to call: cannot use value 1 (int) as string: + ./in.cue:48:6 + ./in.cue:48:24 +t45: cannot use "foo" (type string) as list in argument 1 to list.Sum: + ./in.cue:51:15 +t49: error in call to list.Take: negative index: + ./in.cue:55:6 +t54: error in call to list.Sort: conflicting values *adt.BasicType and *adt.StructLit (mismatched types number and struct): + ./in.cue:60:6 + ./in.cue:60:25 + list:10:9 + +Result: +t1: 2.5 +t2: _|_ // t2: error in call to list.Avg: empty list +t3: _|_ // t3: cannot use "foo" (type string) as list in argument 1 to list.Avg +t4: [1, 2, 3, 4] +t5: [3, 4] +t6: [] +t7: _|_ // t7: error in call to list.Drop: negative index +t8: [1, 2, 3, 4] +t9: [1, [[2, 3], []], [4]] +t10: [1, [2, 3], [], 4] +t11: [1, 2, 3, 4] +t12: [] +t13: _|_ // t13: error in call to list.FlattenN: cannot use value "foo" (type string) as list +t14: _|_ // t14: cannot use "foo" (type string) as int in argument 2 to list.FlattenN +t15: 4 +t16: _|_ // t16: error in call to list.Max: empty list +t17: _|_ // t17: cannot use "foo" (type string) as list in argument 1 to list.Max +t18: 1 +t19: _|_ // t19: error in call to list.Min: empty list +t20: _|_ // t20: cannot use "foo" (type string) as list in argument 1 to list.Min +t21: 24 +t22: 1 +t23: _|_ // t23: cannot use "foo" (type string) as list in argument 1 to list.Product +t24: _|_ // t24: error in call to list.Range: step must be non zero +t25: _|_ // t25: error in call to list.Range: end must be greater than start when step is positive +t26: _|_ // t26: error in call to list.Range: end must be less than start when step is negative +t27: [0, 1, 2, 3, 4] +t28: [0] +t29: [0, 2, 4] +t30: [5, 4, 3, 2, 1] +t31: [0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5] +t32: [2, 3] +t33: _|_ // t33: error in call to list.Slice: negative index +t34: _|_ // t34: error in call to list.Slice: invalid index: 3 > 1 +t35: _|_ // t35: error in call to list.Slice: slice bounds out of range +t36: _|_ // t36: error in call to list.Slice: slice bounds out of range +t37: [] +t38: [1, 2, 3, 4] +t39: [{ + a: 1 + v: 2 +}, { + a: 1 + v: 3 +}, { + a: 2 + v: 1 +}] +t40: _|_ // t40: error in call to list.Sort: Ascending.x: conflicting values *adt.BasicType and *adt.StructLit (mismatched types number and struct) +t41: ["a", "b"] +t42: _|_ // t42: invalid list element 0 in argument 0 to call: cannot use value 1 (int) as string +t43: 10 +t44: 0 +t45: _|_ // t45: cannot use "foo" (type string) as list in argument 1 to list.Sum +t46: [] +t47: [1, 2] +t48: [1, 2, 3, 4] +t49: _|_ // t49: error in call to list.Take: negative index +t50: true +t51: false +t52: true +t53: false +t54: _|_ // t54: error in call to list.Sort: Ascending.x: conflicting values *adt.BasicType and *adt.StructLit (mismatched types number and struct) +t55: 8 +-- diff/-out/list-v3<==>+out/list -- +diff old new +--- old ++++ new +@@ -34,9 +34,10 @@ + ./in.cue:37:6 + t36: error in call to list.Slice: slice bounds out of range: + ./in.cue:38:6 +-t40: error in call to list.Sort: 2 errors in empty disjunction:: ++t40: error in call to list.Sort: conflicting values *adt.BasicType and *adt.StructLit (mismatched types number and struct): + ./in.cue:46:6 +- list:13:9 ++ ./in.cue:46:25 ++ list:10:9 + t42: invalid list element 0 in argument 0 to call: cannot use value 1 (int) as string: + ./in.cue:48:6 + ./in.cue:48:24 +@@ -44,9 +45,10 @@ + ./in.cue:51:15 + t49: error in call to list.Take: negative index: + ./in.cue:55:6 +-t54: error in call to list.Sort: 2 errors in empty disjunction:: ++t54: error in call to list.Sort: conflicting values *adt.BasicType and *adt.StructLit (mismatched types number and struct): + ./in.cue:60:6 +- list:13:9 ++ ./in.cue:60:25 ++ list:10:9 + + Result: + t1: 2.5 +@@ -97,7 +99,7 @@ + a: 2 + v: 1 + }] +-t40: _|_ // t40: error in call to list.Sort: Ascending.x: 2 errors in empty disjunction: ++t40: _|_ // t40: error in call to list.Sort: Ascending.x: conflicting values *adt.BasicType and *adt.StructLit (mismatched types number and struct) + t41: ["a", "b"] + t42: _|_ // t42: invalid list element 0 in argument 0 to call: cannot use value 1 (int) as string + t43: 10 +@@ -111,5 +113,5 @@ + t51: false + t52: true + t53: false +-t54: _|_ // t54: error in call to list.Sort: Ascending.x: 2 errors in empty disjunction: ++t54: _|_ // t54: error in call to list.Sort: Ascending.x: conflicting values *adt.BasicType and *adt.StructLit (mismatched types number and struct) + t55: 8 +-- diff/todo/p2 -- +Missing empty disjunction error. -- out/list -- Errors: t2: error in call to list.Avg: empty list: @@ -162,7 +328,7 @@ t39: [{ a: 2 v: 1 }] -t40: _|_ // t40: error in call to list.Sort: Ascending.x: 2 errors in empty disjunction: (and 5 more errors) +t40: _|_ // t40: error in call to list.Sort: Ascending.x: 2 errors in empty disjunction: t41: ["a", "b"] t42: _|_ // t42: invalid list element 0 in argument 0 to call: cannot use value 1 (int) as string t43: 10 @@ -176,5 +342,5 @@ t50: true t51: false t52: true t53: false -t54: _|_ // t54: error in call to list.Sort: Ascending.x: 2 errors in empty disjunction: (and 5 more errors) +t54: _|_ // t54: error in call to list.Sort: Ascending.x: 2 errors in empty disjunction: t55: 8 diff --git a/pkg/list/testdata/list.txtar b/pkg/list/testdata/list.txtar index fc23f6af2bc..1c66055e45f 100644 --- a/pkg/list/testdata/list.txtar +++ b/pkg/list/testdata/list.txtar @@ -59,6 +59,141 @@ maxItems: { fail1: [0, 1] } +-- out/list-v3 -- +Errors: +repeat.t8.v: error in call to list.Repeat: negative count: + ./in.cue:4:30 +concat.t8.v: error in call to list.Concat: cannot use value 1 (type int) as list: + ./in.cue:19:22 + ./in.cue:31:10 +concat.t7.v: cannot use 1 (type int) as list in argument 1 to list.Concat: + ./in.cue:30:9 +minItems.fail1: invalid value [] (does not satisfy list.MinItems(1)): len(list) < MinItems(1) (0 < 1): + ./in.cue:45:12 + ./in.cue:45:26 +maxItems.fail1: invalid value [0,1] (does not satisfy list.MaxItems(1)): len(list) > MaxItems(1) (2 > 1): + ./in.cue:53:12 + ./in.cue:53:26 + +Result: +import "list" + +repeat: { + t1: { + x: [] + n: 0 + v: [] + } + t2: { + x: [1] + n: 0 + v: [] + } + t3: { + x: [1] + n: 1 + v: [1] + } + t4: { + x: [1, 2] + n: 1 + v: [1, 2] + } + t5: { + x: [] + n: 3 + v: [] + } + t6: { + x: [1, 2] + n: 3 + v: [1, 2, 1, 2, 1, 2] + } + t7: { + x: [1, 2, 3, 4] + n: 3 + v: [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] + } + t8: { + x: [1] + n: -1 + v: _|_ // repeat.t8.v: error in call to list.Repeat: negative count + } +} +concat: { + t1: { + x: [] + v: [] + } + t2: { + x: [[]] + v: [] + } + t3: { + x: [[1]] + v: [1] + } + t4: { + x: [[1, 2]] + v: [1, 2] + } + t5: { + x: [[1], [2]] + v: [1, 2] + } + t6: { + x: [[1, 2], [3, 4]] + v: [1, 2, 3, 4] + } + t7: { + x: 1 + v: _|_ // concat.t7.v: cannot use 1 (type int) as list in argument 1 to list.Concat + } + t8: { + x: [1, [2]] + v: _|_ // concat.t8.v: error in call to list.Concat: cannot use value 1 (type int) as list + } +} +unique: { + issue797: { + mylst: [{ + foo: "bar" + }, { + foo: "baz" + }] + } +} +// Issue #2099 +minItems: { + incomplete1: [...] & list.MinItems(1) + fail1: _|_ // minItems.fail1: invalid value [] (does not satisfy list.MinItems(1)): len(list) < MinItems(1) (0 < 1) + ok1: [0, ...] + ok2: [0] +} +maxItems: { + ok1: [...] + ok2: [0, ...] + ok3: [0, ...] + fail1: _|_ // maxItems.fail1: invalid value [0,1] (does not satisfy list.MaxItems(1)): len(list) > MaxItems(1) (2 > 1) +} +-- diff/-out/list-v3<==>+out/list -- +diff old new +--- old ++++ new +@@ -9,11 +9,9 @@ + minItems.fail1: invalid value [] (does not satisfy list.MinItems(1)): len(list) < MinItems(1) (0 < 1): + ./in.cue:45:12 + ./in.cue:45:26 +- ./in.cue:47:9 + maxItems.fail1: invalid value [0,1] (does not satisfy list.MaxItems(1)): len(list) > MaxItems(1) (2 > 1): + ./in.cue:53:12 + ./in.cue:53:26 +- ./in.cue:58:9 + + Result: + import "list" +-- diff/todo/p2 -- +Missing error positions. -- out/list -- Errors: repeat.t8.v: error in call to list.Repeat: negative count: @@ -168,7 +303,7 @@ unique: { // Issue #2099 minItems: { incomplete1: [...] & list.MinItems(1) - fail1: _|_ // minItems.fail1: invalid value [] (does not satisfy list.MinItems(1)): len(list) < MinItems(1) (0 < 1) (and 1 more errors) + fail1: _|_ // minItems.fail1: invalid value [] (does not satisfy list.MinItems(1)): len(list) < MinItems(1) (0 < 1) ok1: [0, ...] ok2: [0] } @@ -176,5 +311,5 @@ maxItems: { ok1: [...] ok2: [0, ...] ok3: [0, ...] - fail1: _|_ // maxItems.fail1: invalid value [0,1] (does not satisfy list.MaxItems(1)): len(list) > MaxItems(1) (2 > 1) (and 1 more errors) + fail1: _|_ // maxItems.fail1: invalid value [0,1] (does not satisfy list.MaxItems(1)): len(list) > MaxItems(1) (2 > 1) } diff --git a/pkg/path/testdata/join.txtar b/pkg/path/testdata/join.txtar index b7e07098603..01cd44288e1 100644 --- a/pkg/path/testdata/join.txtar +++ b/pkg/path/testdata/join.txtar @@ -57,6 +57,272 @@ Join: [_]: [ {arg: [#"C:a"#, #"b"#]}, {arg: [#"\\host\share"#, #"foo"#]}, ] +-- out/path-v3 -- +joinSingle: "a/b" +Join: { + unix: [{ + arg: ["a", "b"] + out: "a/b" + }, { + arg: ["a/b", "c/d"] + out: "a/b/c/d" + }, { + arg: ["/"] + out: "/" + }, { + arg: ["a"] + out: "a" + }, { + arg: ["a", "b"] + out: "a/b" + }, { + arg: ["a", ""] + out: "a" + }, { + arg: ["", "b"] + out: "b" + }, { + arg: ["/", "a"] + out: "/a" + }, { + arg: ["/", "a/b"] + out: "/a/b" + }, { + arg: ["/", ""] + out: "/" + }, { + arg: ["//", "a"] + out: "/a" + }, { + arg: ["directory", "file"] + out: "directory/file" + }, { + arg: ["C:\\Windows\\", "System32"] + out: "C:\\Windows\\/System32" + }, { + arg: ["C:\\Windows\\", ""] + out: "C:\\Windows\\" + }, { + arg: ["C:\\", "Windows"] + out: "C:\\/Windows" + }, { + arg: ["C:", "a\\b"] + out: "C:/a\\b" + }, { + arg: ["C:", "a", "b"] + out: "C:/a/b" + }, { + arg: ["C:", "", "", "b"] + out: "C:/b" + }, { + arg: ["C:", ""] + out: "C:" + }, { + arg: ["C:", "", ""] + out: "C:" + }, { + arg: ["C:.", "a"] + out: "C:./a" + }, { + arg: ["C:a", "b"] + out: "C:a/b" + }, { + arg: ["\\\\host\\share", "foo"] + out: "\\\\host\\share/foo" + }] + windows: [{ + arg: ["a", "b"] + out: "a\\b" + }, { + arg: ["a/b", "c/d"] + out: "a\\b\\c\\d" + }, { + arg: ["/"] + out: "\\" + }, { + arg: ["a"] + out: "a" + }, { + arg: ["a", "b"] + out: "a\\b" + }, { + arg: ["a", ""] + out: "a" + }, { + arg: ["", "b"] + out: "b" + }, { + arg: ["/", "a"] + out: "\\a" + }, { + arg: ["/", "a/b"] + out: "\\a\\b" + }, { + arg: ["/", ""] + out: "\\" + }, { + arg: ["//", "a"] + out: "\\a" + }, { + arg: ["directory", "file"] + out: "directory\\file" + }, { + arg: ["C:\\Windows\\", "System32"] + out: "C:\\Windows\\System32" + }, { + arg: ["C:\\Windows\\", ""] + out: "C:\\Windows" + }, { + arg: ["C:\\", "Windows"] + out: "C:\\Windows" + }, { + arg: ["C:", "a\\b"] + out: "C:a\\b" + }, { + arg: ["C:", "a", "b"] + out: "C:a\\b" + }, { + arg: ["C:", "", "", "b"] + out: "C:b" + }, { + arg: ["C:", ""] + out: "C:." + }, { + arg: ["C:", "", ""] + out: "C:." + }, { + arg: ["C:.", "a"] + out: "C:a" + }, { + arg: ["C:a", "b"] + out: "C:a\\b" + }, { + arg: ["\\\\host\\share", "foo"] + out: "\\\\host\\share\\foo" + }] +} +-- diff/-out/path-v3<==>+out/path -- +diff old new +--- old ++++ new +@@ -37,37 +37,37 @@ + arg: ["directory", "file"] + out: "directory/file" + }, { +- arg: [#"C:\Windows\"#, #"System32"#] ++ arg: ["C:\\Windows\\", "System32"] + out: "C:\\Windows\\/System32" + }, { +- arg: [#"C:\Windows\"#, #""#] ++ arg: ["C:\\Windows\\", ""] + out: "C:\\Windows\\" + }, { +- arg: [#"C:\"#, #"Windows"#] ++ arg: ["C:\\", "Windows"] + out: "C:\\/Windows" + }, { +- arg: [#"C:"#, #"a\b"#] ++ arg: ["C:", "a\\b"] + out: "C:/a\\b" + }, { +- arg: [#"C:"#, #"a"#, #"b"#] ++ arg: ["C:", "a", "b"] + out: "C:/a/b" + }, { +- arg: [#"C:"#, #""#, #""#, #"b"#] ++ arg: ["C:", "", "", "b"] + out: "C:/b" + }, { +- arg: [#"C:"#, #""#] +- out: "C:" +- }, { +- arg: [#"C:"#, #""#, #""#] +- out: "C:" +- }, { +- arg: [#"C:."#, #"a"#] ++ arg: ["C:", ""] ++ out: "C:" ++ }, { ++ arg: ["C:", "", ""] ++ out: "C:" ++ }, { ++ arg: ["C:.", "a"] + out: "C:./a" + }, { +- arg: [#"C:a"#, #"b"#] ++ arg: ["C:a", "b"] + out: "C:a/b" + }, { +- arg: [#"\\host\share"#, #"foo"#] ++ arg: ["\\\\host\\share", "foo"] + out: "\\\\host\\share/foo" + }] + windows: [{ +@@ -107,37 +107,37 @@ + arg: ["directory", "file"] + out: "directory\\file" + }, { +- arg: [#"C:\Windows\"#, #"System32"#] ++ arg: ["C:\\Windows\\", "System32"] + out: "C:\\Windows\\System32" + }, { +- arg: [#"C:\Windows\"#, #""#] +- out: "C:\\Windows" +- }, { +- arg: [#"C:\"#, #"Windows"#] +- out: "C:\\Windows" +- }, { +- arg: [#"C:"#, #"a\b"#] +- out: "C:a\\b" +- }, { +- arg: [#"C:"#, #"a"#, #"b"#] +- out: "C:a\\b" +- }, { +- arg: [#"C:"#, #""#, #""#, #"b"#] ++ arg: ["C:\\Windows\\", ""] ++ out: "C:\\Windows" ++ }, { ++ arg: ["C:\\", "Windows"] ++ out: "C:\\Windows" ++ }, { ++ arg: ["C:", "a\\b"] ++ out: "C:a\\b" ++ }, { ++ arg: ["C:", "a", "b"] ++ out: "C:a\\b" ++ }, { ++ arg: ["C:", "", "", "b"] + out: "C:b" + }, { +- arg: [#"C:"#, #""#] +- out: "C:." +- }, { +- arg: [#"C:"#, #""#, #""#] +- out: "C:." +- }, { +- arg: [#"C:."#, #"a"#] ++ arg: ["C:", ""] ++ out: "C:." ++ }, { ++ arg: ["C:", "", ""] ++ out: "C:." ++ }, { ++ arg: ["C:.", "a"] + out: "C:a" + }, { +- arg: [#"C:a"#, #"b"#] +- out: "C:a\\b" +- }, { +- arg: [#"\\host\share"#, #"foo"#] ++ arg: ["C:a", "b"] ++ out: "C:a\\b" ++ }, { ++ arg: ["\\\\host\\share", "foo"] + out: "\\\\host\\share\\foo" + }] + } +-- diff/todo/p2 -- +Differing string representation of semantically identical strings. -- out/path -- joinSingle: "a/b" Join: { diff --git a/pkg/struct/testdata/gen.txtar b/pkg/struct/testdata/gen.txtar index b70101b3a98..9a2441db63b 100644 --- a/pkg/struct/testdata/gen.txtar +++ b/pkg/struct/testdata/gen.txtar @@ -8,6 +8,52 @@ t2: struct.MinFields(0) & {a: 1} t3: struct.MinFields(2) & {a: 1} t4: struct.MaxFields(0) & {a: 1} t5: struct.MaxFields(2) & {a: 1} +-- out/structs-v3 -- +Errors: +t1: conflicting values "" and struct.MinFields(0) (mismatched types string and struct): + ./in.cue:3:5 + ./in.cue:3:27 +t4: invalid value {a:1} (does not satisfy struct.MaxFields(0)): len(fields) > MaxFields(0) (1 > 0): + ./in.cue:6:5 + ./in.cue:6:22 + +Result: +import "struct" + +t1: _|_ // t1: conflicting values "" and struct.MinFields(0) (mismatched types string and struct) +t2: { + a: 1 +} +t3: struct.MinFields(2) & { + a: 1 +} +t4: _|_ // t4: invalid value {a:1} (does not satisfy struct.MaxFields(0)): len(fields) > MaxFields(0) (1 > 0) +t5: { + a: 1 +} +-- diff/-out/structs-v3<==>+out/structs -- +diff old new +--- old ++++ new +@@ -1,5 +1,5 @@ + Errors: +-t1: conflicting values struct.MinFields(0) and "" (mismatched types struct and string): ++t1: conflicting values "" and struct.MinFields(0) (mismatched types string and struct): + ./in.cue:3:5 + ./in.cue:3:27 + t4: invalid value {a:1} (does not satisfy struct.MaxFields(0)): len(fields) > MaxFields(0) (1 > 0): +@@ -9,7 +9,7 @@ + Result: + import "struct" + +-t1: _|_ // t1: conflicting values struct.MinFields(0) and "" (mismatched types struct and string) ++t1: _|_ // t1: conflicting values "" and struct.MinFields(0) (mismatched types string and struct) + t2: { + a: 1 + } +-- diff/explanation -- +Benign differences in error message due to different order of +evaluation. -- out/structs -- Errors: t1: conflicting values struct.MinFields(0) and "" (mismatched types struct and string): diff --git a/pkg/struct/testdata/struct.txtar b/pkg/struct/testdata/struct.txtar index dbb1c49a939..9d2bed669fd 100644 --- a/pkg/struct/testdata/struct.txtar +++ b/pkg/struct/testdata/struct.txtar @@ -20,6 +20,56 @@ maxFields: { fail1: {a: 1, b: 2} } +-- out/structs-v3 -- +Errors: +minFields.fail1: invalid value {} (does not satisfy struct.MinFields(1)): len(fields) < MinFields(1) (0 < 1): + ./in.cue:4:12 + ./in.cue:4:29 +maxFields.fail1: invalid value {a:1,b:2} (does not satisfy struct.MaxFields(1)): len(fields) > MaxFields(1) (2 > 1): + ./in.cue:13:12 + ./in.cue:13:29 + +Result: +import "struct" + +minFields: { + incomplete1: {} & struct.MinFields(1) + fail1: _|_ // minFields.fail1: invalid value {} (does not satisfy struct.MinFields(1)): len(fields) < MinFields(1) (0 < 1) + ok1: { + a: 1 + } + ok2: { + a: 1 + } +} +maxFields: { + ok1: {} + ok2: { + a: 1 + } + ok3: { + a: 1 + } + fail1: _|_ // maxFields.fail1: invalid value {a:1,b:2} (does not satisfy struct.MaxFields(1)): len(fields) > MaxFields(1) (2 > 1) +} +-- diff/-out/structs-v3<==>+out/structs -- +diff old new +--- old ++++ new +@@ -2,11 +2,9 @@ + minFields.fail1: invalid value {} (does not satisfy struct.MinFields(1)): len(fields) < MinFields(1) (0 < 1): + ./in.cue:4:12 + ./in.cue:4:29 +- ./in.cue:7:9 + maxFields.fail1: invalid value {a:1,b:2} (does not satisfy struct.MaxFields(1)): len(fields) > MaxFields(1) (2 > 1): + ./in.cue:13:12 + ./in.cue:13:29 +- ./in.cue:19:9 + + Result: + import "struct" +-- diff/todo/p2 -- +Missing error positions. -- out/structs -- Errors: minFields.fail1: invalid value {} (does not satisfy struct.MinFields(1)): len(fields) < MinFields(1) (0 < 1): diff --git a/pkg/uuid/testdata/uuid.txtar b/pkg/uuid/testdata/uuid.txtar index be42ca17b90..32dc0eb8dd8 100644 --- a/pkg/uuid/testdata/uuid.txtar +++ b/pkg/uuid/testdata/uuid.txtar @@ -26,6 +26,61 @@ variant: a: uuid.Variant(sha1.a) version: a: uuid.Version(sha1.a) urn: a: uuid.URN(sha1.a) toInt: a: uuid.ToInt(sha1.a) +-- out/uuid-v3 -- +Errors: +invalid.a: invalid value "052EF62D-7223-58B6-A551-C1DEEE46D401" (does not satisfy uuid.Valid): invalid UUID "052EF62D-7223-58B6-A551-C1DEEE46D401": + ./in.cue:14:5 +invalid.b: invalid value "052ef62d_7223_58b6_a551_c1deee46d401" (does not satisfy uuid.Valid): invalid UUID "052ef62d_7223_58b6_a551_c1deee46d401": + ./in.cue:17:5 + +Result: +sha1: { + a: "052ef62d-7223-58b6-a551-c1deee46d401" +} +md5: { + a: "d891d69e-ae5c-39e0-9ead-164abd207f1f" +} +valid: { + a: "052ef62d-7223-58b6-a551-c1deee46d401" +} +invalid: { + a: _|_ // invalid.a: invalid value "052EF62D-7223-58B6-A551-C1DEEE46D401" (does not satisfy uuid.Valid): invalid.a: invalid UUID "052EF62D-7223-58B6-A551-C1DEEE46D401" + b: _|_ // invalid.b: invalid value "052ef62d_7223_58b6_a551_c1deee46d401" (does not satisfy uuid.Valid): invalid.b: invalid UUID "052ef62d_7223_58b6_a551_c1deee46d401" +} +parse: { + a: "052ef62d-7223-58b6-a551-c1deee46d401" +} +fromInt: { + a: "052ef62d-7223-58b6-a551-c1deee46d401" +} +variant: { + a: 1 +} +version: { + a: 5 +} +urn: { + a: "urn:uuid:052ef62d-7223-58b6-a551-c1deee46d401" +} +toInt: { + a: 93651793875903522077150095950593860979557386807737776869062002310283964632724204171313 +} +-- diff/-out/uuid-v3<==>+out/uuid -- +diff old new +--- old ++++ new +@@ -1,9 +1,7 @@ + Errors: + invalid.a: invalid value "052EF62D-7223-58B6-A551-C1DEEE46D401" (does not satisfy uuid.Valid): invalid UUID "052EF62D-7223-58B6-A551-C1DEEE46D401": +- ./in.cue:13:5 + ./in.cue:14:5 + invalid.b: invalid value "052ef62d_7223_58b6_a551_c1deee46d401" (does not satisfy uuid.Valid): invalid UUID "052ef62d_7223_58b6_a551_c1deee46d401": +- ./in.cue:16:5 + ./in.cue:17:5 + + Result: +-- diff/todo/p2 -- +Missing error positions. -- out/uuid -- Errors: invalid.a: invalid value "052EF62D-7223-58B6-A551-C1DEEE46D401" (does not satisfy uuid.Valid): invalid UUID "052EF62D-7223-58B6-A551-C1DEEE46D401":