Skip to content

Commit 2662ebe

Browse files
committed
internal/core/adt: add tests for validator dedupping
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]>
1 parent 2fb6f45 commit 2662ebe

File tree

1 file changed

+205
-11
lines changed

1 file changed

+205
-11
lines changed

cue/testdata/builtins/validators.txtar

+205-11
Original file line numberDiff line numberDiff line change
@@ -114,18 +114,41 @@ issue2098: incomplete1: {
114114
_a[0]
115115
}
116116

117+
-- issue3418.cue --
118+
issue3418: t1: "foo" & matchN(1, [1&2]) & matchN(1, [_])
119+
issue3418: t2: "foo" & matchN(1, [_]) & matchN(1, [1&2])
120+
issue3418: t3: {
121+
x: "foo"
122+
x: matchN(1, [_])
123+
x: matchN(1, [1&2])
124+
}
125+
issue3418: t4: {
126+
x: "foo"
127+
x: matchN(1, [1&2])
128+
x: matchN(1, [_])
129+
}
130+
117131
-- out/eval/stats --
118-
Leaks: 0
119-
Freed: 50
120-
Reused: 45
121-
Allocs: 5
122-
Retain: 0
132+
Leaks: 4
133+
Freed: 73
134+
Reused: 67
135+
Allocs: 10
136+
Retain: 8
123137

124-
Unifications: 50
125-
Conjuncts: 91
126-
Disjuncts: 52
138+
Unifications: 77
139+
Conjuncts: 146
140+
Disjuncts: 83
127141
-- out/evalalpha --
128142
Errors:
143+
issue3418.0: conflicting values 2 and 1:
144+
./issue3418.cue:1:35
145+
./issue3418.cue:1:37
146+
issue3418.t3.0: conflicting values 2 and 1:
147+
./issue3418.cue:6:16
148+
./issue3418.cue:6:18
149+
issue3418.t4.0: conflicting values 2 and 1:
150+
./issue3418.cue:10:16
151+
./issue3418.cue:10:18
129152
callOfCallToValidator.e: cannot call previously called validator b:
130153
./in.cue:94:5
131154

@@ -224,28 +247,82 @@ Result:
224247
}
225248
}
226249
}
250+
issue3418: (_|_){
251+
// [eval]
252+
t1: (_|_){
253+
// [eval] issue3418.0: conflicting values 2 and 1:
254+
// ./issue3418.cue:1:35
255+
// ./issue3418.cue:1:37
256+
}
257+
t2: (_|_){
258+
// [eval] issue3418.0: conflicting values 2 and 1:
259+
// ./issue3418.cue:2:52
260+
// ./issue3418.cue:2:54
261+
}
262+
t3: (_|_){
263+
// [eval]
264+
x: (_|_){
265+
// [eval] issue3418.t3.0: conflicting values 2 and 1:
266+
// ./issue3418.cue:6:16
267+
// ./issue3418.cue:6:18
268+
}
269+
}
270+
t4: (_|_){
271+
// [eval]
272+
x: (_|_){
273+
// [eval] issue3418.t4.0: conflicting values 2 and 1:
274+
// ./issue3418.cue:10:16
275+
// ./issue3418.cue:10:18
276+
}
277+
}
278+
}
227279
}
228280
-- diff/-out/evalalpha<==>+out/eval --
229281
diff old new
230282
--- old
231283
+++ new
232-
@@ -20,7 +20,6 @@
284+
@@ -1,15 +1,15 @@
285+
Errors:
286+
+issue3418.0: conflicting values 2 and 1:
287+
+ ./issue3418.cue:1:35
288+
+ ./issue3418.cue:1:37
289+
+issue3418.t3.0: conflicting values 2 and 1:
290+
+ ./issue3418.cue:6:16
291+
+ ./issue3418.cue:6:18
292+
+issue3418.t4.0: conflicting values 2 and 1:
293+
+ ./issue3418.cue:10:16
294+
+ ./issue3418.cue:10:18
295+
callOfCallToValidator.e: cannot call previously called validator b:
296+
./in.cue:94:5
297+
-issue3418.t2: invalid value "foo" (does not satisfy matchN(1, _|_(issue3418.0: conflicting values 2 and 1))): 0 matched, expected 1:
298+
- ./issue3418.cue:2:41
299+
- ./issue3418.cue:2:16
300+
- ./issue3418.cue:2:48
301+
-issue3418.t3.x: invalid value "foo" (does not satisfy matchN(1, _|_(issue3418.t3.0: conflicting values 2 and 1))): 0 matched, expected 1:
302+
- ./issue3418.cue:6:5
303+
- ./issue3418.cue:4:5
304+
- ./issue3418.cue:5:5
305+
- ./issue3418.cue:6:12
306+
307+
Result:
308+
(_|_){
309+
@@ -29,7 +29,6 @@
233310
kv: (_|_){
234311
// [incomplete] incompleteError2.MyType.kv: invalid value {} (does not satisfy struct.MinFields(1)): len(fields) < MinFields(1) (0 < 1):
235312
// ./in.cue:22:7
236313
- // ./in.cue:21:7
237314
// ./in.cue:22:24
238315
}
239316
}
240-
@@ -44,7 +43,6 @@
317+
@@ -53,7 +52,6 @@
241318
kv: (_|_){
242319
// [incomplete] violation.#MyType.kv: invalid value {} (does not satisfy struct.MinFields(1)): len(fields) < MinFields(1) (0 < 1):
243320
// ./in.cue:49:7
244321
- // ./in.cue:48:7
245322
// ./in.cue:49:24
246323
}
247324
}
248-
@@ -91,15 +89,10 @@
325+
@@ -100,15 +98,10 @@
249326
0: (int){ 1 }
250327
}
251328
}
@@ -262,12 +339,67 @@ diff old new
262339
// ./in.cue:112:20
263340
}
264341
}
342+
@@ -115,25 +108,31 @@
343+
}
344+
issue3418: (_|_){
345+
// [eval]
346+
- t1: (string){ "foo" }
347+
+ t1: (_|_){
348+
+ // [eval] issue3418.0: conflicting values 2 and 1:
349+
+ // ./issue3418.cue:1:35
350+
+ // ./issue3418.cue:1:37
351+
+ }
352+
t2: (_|_){
353+
- // [eval] issue3418.t2: invalid value "foo" (does not satisfy matchN(1, _|_(issue3418.0: conflicting values 2 and 1))): 0 matched, expected 1:
354+
- // ./issue3418.cue:2:41
355+
- // ./issue3418.cue:2:16
356+
- // ./issue3418.cue:2:48
357+
+ // [eval] issue3418.0: conflicting values 2 and 1:
358+
+ // ./issue3418.cue:2:52
359+
+ // ./issue3418.cue:2:54
360+
}
361+
t3: (_|_){
362+
// [eval]
363+
x: (_|_){
364+
- // [eval] issue3418.t3.x: invalid value "foo" (does not satisfy matchN(1, _|_(issue3418.t3.0: conflicting values 2 and 1))): 0 matched, expected 1:
365+
- // ./issue3418.cue:6:5
366+
- // ./issue3418.cue:4:5
367+
- // ./issue3418.cue:5:5
368+
- // ./issue3418.cue:6:12
369+
- }
370+
- }
371+
- t4: (struct){
372+
- x: (string){ "foo" }
373+
+ // [eval] issue3418.t3.0: conflicting values 2 and 1:
374+
+ // ./issue3418.cue:6:16
375+
+ // ./issue3418.cue:6:18
376+
+ }
377+
+ }
378+
+ t4: (_|_){
379+
+ // [eval]
380+
+ x: (_|_){
381+
+ // [eval] issue3418.t4.0: conflicting values 2 and 1:
382+
+ // ./issue3418.cue:10:16
383+
+ // ./issue3418.cue:10:18
384+
+ }
385+
}
386+
}
387+
}
265388
-- diff/todo/p2 --
266389
Missing error at incomplete1: index 0 is erased.
267390
-- out/eval --
268391
Errors:
269392
callOfCallToValidator.e: cannot call previously called validator b:
270393
./in.cue:94:5
394+
issue3418.t2: invalid value "foo" (does not satisfy matchN(1, _|_(issue3418.0: conflicting values 2 and 1))): 0 matched, expected 1:
395+
./issue3418.cue:2:41
396+
./issue3418.cue:2:16
397+
./issue3418.cue:2:48
398+
issue3418.t3.x: invalid value "foo" (does not satisfy matchN(1, _|_(issue3418.t3.0: conflicting values 2 and 1))): 0 matched, expected 1:
399+
./issue3418.cue:6:5
400+
./issue3418.cue:4:5
401+
./issue3418.cue:5:5
402+
./issue3418.cue:6:12
271403

272404
Result:
273405
(_|_){
@@ -371,6 +503,29 @@ Result:
371503
}
372504
}
373505
}
506+
issue3418: (_|_){
507+
// [eval]
508+
t1: (string){ "foo" }
509+
t2: (_|_){
510+
// [eval] issue3418.t2: invalid value "foo" (does not satisfy matchN(1, _|_(issue3418.0: conflicting values 2 and 1))): 0 matched, expected 1:
511+
// ./issue3418.cue:2:41
512+
// ./issue3418.cue:2:16
513+
// ./issue3418.cue:2:48
514+
}
515+
t3: (_|_){
516+
// [eval]
517+
x: (_|_){
518+
// [eval] issue3418.t3.x: invalid value "foo" (does not satisfy matchN(1, _|_(issue3418.t3.0: conflicting values 2 and 1))): 0 matched, expected 1:
519+
// ./issue3418.cue:6:5
520+
// ./issue3418.cue:4:5
521+
// ./issue3418.cue:5:5
522+
// ./issue3418.cue:6:12
523+
}
524+
}
525+
t4: (struct){
526+
x: (string){ "foo" }
527+
}
528+
}
374529
}
375530
-- out/compile --
376531
--- in.cue
@@ -478,3 +633,42 @@ Result:
478633
}
479634
}
480635
}
636+
--- issue3418.cue
637+
{
638+
issue3418: {
639+
t1: (("foo" & matchN(1, [
640+
(1 & 2),
641+
])) & matchN(1, [
642+
_,
643+
]))
644+
}
645+
issue3418: {
646+
t2: (("foo" & matchN(1, [
647+
_,
648+
])) & matchN(1, [
649+
(1 & 2),
650+
]))
651+
}
652+
issue3418: {
653+
t3: {
654+
x: "foo"
655+
x: matchN(1, [
656+
_,
657+
])
658+
x: matchN(1, [
659+
(1 & 2),
660+
])
661+
}
662+
}
663+
issue3418: {
664+
t4: {
665+
x: "foo"
666+
x: matchN(1, [
667+
(1 & 2),
668+
])
669+
x: matchN(1, [
670+
_,
671+
])
672+
}
673+
}
674+
}

0 commit comments

Comments
 (0)