Skip to content

Commit

Permalink
internal/core/adt: add tests for validator dedupping
Browse files Browse the repository at this point in the history
Issue #3418

Signed-off-by: Marcel van Lohuizen <[email protected]>
Change-Id: Id499a84ed80f18eb5ec8efdc0b2cda1a54c07188
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1200736
Unity-Result: CUE porcuepine <[email protected]>
Reviewed-by: Roger Peppe <[email protected]>
TryBot-Result: CUEcueckoo <[email protected]>
  • Loading branch information
mpvl committed Sep 5, 2024
1 parent 2fb6f45 commit 2662ebe
Showing 1 changed file with 205 additions and 11 deletions.
216 changes: 205 additions & 11 deletions cue/testdata/builtins/validators.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -114,18 +114,41 @@ issue2098: incomplete1: {
_a[0]
}

-- issue3418.cue --
issue3418: t1: "foo" & matchN(1, [1&2]) & matchN(1, [_])
issue3418: t2: "foo" & matchN(1, [_]) & matchN(1, [1&2])
issue3418: t3: {
x: "foo"
x: matchN(1, [_])
x: matchN(1, [1&2])
}
issue3418: t4: {
x: "foo"
x: matchN(1, [1&2])
x: matchN(1, [_])
}

-- out/eval/stats --
Leaks: 0
Freed: 50
Reused: 45
Allocs: 5
Retain: 0
Leaks: 4
Freed: 73
Reused: 67
Allocs: 10
Retain: 8

Unifications: 50
Conjuncts: 91
Disjuncts: 52
Unifications: 77
Conjuncts: 146
Disjuncts: 83
-- out/evalalpha --
Errors:
issue3418.0: conflicting values 2 and 1:
./issue3418.cue:1:35
./issue3418.cue:1:37
issue3418.t3.0: conflicting values 2 and 1:
./issue3418.cue:6:16
./issue3418.cue:6:18
issue3418.t4.0: conflicting values 2 and 1:
./issue3418.cue:10:16
./issue3418.cue:10:18
callOfCallToValidator.e: cannot call previously called validator b:
./in.cue:94:5

Expand Down Expand Up @@ -224,28 +247,82 @@ Result:
}
}
}
issue3418: (_|_){
// [eval]
t1: (_|_){
// [eval] issue3418.0: conflicting values 2 and 1:
// ./issue3418.cue:1:35
// ./issue3418.cue:1:37
}
t2: (_|_){
// [eval] issue3418.0: conflicting values 2 and 1:
// ./issue3418.cue:2:52
// ./issue3418.cue:2:54
}
t3: (_|_){
// [eval]
x: (_|_){
// [eval] issue3418.t3.0: conflicting values 2 and 1:
// ./issue3418.cue:6:16
// ./issue3418.cue:6:18
}
}
t4: (_|_){
// [eval]
x: (_|_){
// [eval] issue3418.t4.0: conflicting values 2 and 1:
// ./issue3418.cue:10:16
// ./issue3418.cue:10:18
}
}
}
}
-- diff/-out/evalalpha<==>+out/eval --
diff old new
--- old
+++ new
@@ -20,7 +20,6 @@
@@ -1,15 +1,15 @@
Errors:
+issue3418.0: conflicting values 2 and 1:
+ ./issue3418.cue:1:35
+ ./issue3418.cue:1:37
+issue3418.t3.0: conflicting values 2 and 1:
+ ./issue3418.cue:6:16
+ ./issue3418.cue:6:18
+issue3418.t4.0: conflicting values 2 and 1:
+ ./issue3418.cue:10:16
+ ./issue3418.cue:10:18
callOfCallToValidator.e: cannot call previously called validator b:
./in.cue:94:5
-issue3418.t2: invalid value "foo" (does not satisfy matchN(1, _|_(issue3418.0: conflicting values 2 and 1))): 0 matched, expected 1:
- ./issue3418.cue:2:41
- ./issue3418.cue:2:16
- ./issue3418.cue:2:48
-issue3418.t3.x: invalid value "foo" (does not satisfy matchN(1, _|_(issue3418.t3.0: conflicting values 2 and 1))): 0 matched, expected 1:
- ./issue3418.cue:6:5
- ./issue3418.cue:4:5
- ./issue3418.cue:5:5
- ./issue3418.cue:6:12

Result:
(_|_){
@@ -29,7 +29,6 @@
kv: (_|_){
// [incomplete] incompleteError2.MyType.kv: invalid value {} (does not satisfy struct.MinFields(1)): len(fields) < MinFields(1) (0 < 1):
// ./in.cue:22:7
- // ./in.cue:21:7
// ./in.cue:22:24
}
}
@@ -44,7 +43,6 @@
@@ -53,7 +52,6 @@
kv: (_|_){
// [incomplete] violation.#MyType.kv: invalid value {} (does not satisfy struct.MinFields(1)): len(fields) < MinFields(1) (0 < 1):
// ./in.cue:49:7
- // ./in.cue:48:7
// ./in.cue:49:24
}
}
@@ -91,15 +89,10 @@
@@ -100,15 +98,10 @@
0: (int){ 1 }
}
}
Expand All @@ -262,12 +339,67 @@ diff old new
// ./in.cue:112:20
}
}
@@ -115,25 +108,31 @@
}
issue3418: (_|_){
// [eval]
- t1: (string){ "foo" }
+ t1: (_|_){
+ // [eval] issue3418.0: conflicting values 2 and 1:
+ // ./issue3418.cue:1:35
+ // ./issue3418.cue:1:37
+ }
t2: (_|_){
- // [eval] issue3418.t2: invalid value "foo" (does not satisfy matchN(1, _|_(issue3418.0: conflicting values 2 and 1))): 0 matched, expected 1:
- // ./issue3418.cue:2:41
- // ./issue3418.cue:2:16
- // ./issue3418.cue:2:48
+ // [eval] issue3418.0: conflicting values 2 and 1:
+ // ./issue3418.cue:2:52
+ // ./issue3418.cue:2:54
}
t3: (_|_){
// [eval]
x: (_|_){
- // [eval] issue3418.t3.x: invalid value "foo" (does not satisfy matchN(1, _|_(issue3418.t3.0: conflicting values 2 and 1))): 0 matched, expected 1:
- // ./issue3418.cue:6:5
- // ./issue3418.cue:4:5
- // ./issue3418.cue:5:5
- // ./issue3418.cue:6:12
- }
- }
- t4: (struct){
- x: (string){ "foo" }
+ // [eval] issue3418.t3.0: conflicting values 2 and 1:
+ // ./issue3418.cue:6:16
+ // ./issue3418.cue:6:18
+ }
+ }
+ t4: (_|_){
+ // [eval]
+ x: (_|_){
+ // [eval] issue3418.t4.0: conflicting values 2 and 1:
+ // ./issue3418.cue:10:16
+ // ./issue3418.cue:10:18
+ }
}
}
}
-- diff/todo/p2 --
Missing error at incomplete1: index 0 is erased.
-- out/eval --
Errors:
callOfCallToValidator.e: cannot call previously called validator b:
./in.cue:94:5
issue3418.t2: invalid value "foo" (does not satisfy matchN(1, _|_(issue3418.0: conflicting values 2 and 1))): 0 matched, expected 1:
./issue3418.cue:2:41
./issue3418.cue:2:16
./issue3418.cue:2:48
issue3418.t3.x: invalid value "foo" (does not satisfy matchN(1, _|_(issue3418.t3.0: conflicting values 2 and 1))): 0 matched, expected 1:
./issue3418.cue:6:5
./issue3418.cue:4:5
./issue3418.cue:5:5
./issue3418.cue:6:12

Result:
(_|_){
Expand Down Expand Up @@ -371,6 +503,29 @@ Result:
}
}
}
issue3418: (_|_){
// [eval]
t1: (string){ "foo" }
t2: (_|_){
// [eval] issue3418.t2: invalid value "foo" (does not satisfy matchN(1, _|_(issue3418.0: conflicting values 2 and 1))): 0 matched, expected 1:
// ./issue3418.cue:2:41
// ./issue3418.cue:2:16
// ./issue3418.cue:2:48
}
t3: (_|_){
// [eval]
x: (_|_){
// [eval] issue3418.t3.x: invalid value "foo" (does not satisfy matchN(1, _|_(issue3418.t3.0: conflicting values 2 and 1))): 0 matched, expected 1:
// ./issue3418.cue:6:5
// ./issue3418.cue:4:5
// ./issue3418.cue:5:5
// ./issue3418.cue:6:12
}
}
t4: (struct){
x: (string){ "foo" }
}
}
}
-- out/compile --
--- in.cue
Expand Down Expand Up @@ -478,3 +633,42 @@ Result:
}
}
}
--- issue3418.cue
{
issue3418: {
t1: (("foo" & matchN(1, [
(1 & 2),
])) & matchN(1, [
_,
]))
}
issue3418: {
t2: (("foo" & matchN(1, [
_,
])) & matchN(1, [
(1 & 2),
]))
}
issue3418: {
t3: {
x: "foo"
x: matchN(1, [
_,
])
x: matchN(1, [
(1 & 2),
])
}
}
issue3418: {
t4: {
x: "foo"
x: matchN(1, [
(1 & 2),
])
x: matchN(1, [
_,
])
}
}
}

0 comments on commit 2662ebe

Please sign in to comment.