Skip to content

Commit 46feda5

Browse files
committed
cmd/cue: add a regression test for issue 2704
Trying to export or vet the cue and json files together, where the first contained a schema with a disjunction and a regular expression, results in an incorrect error with the old evaluator. Thankfully, the new evaluator already handles this correctly. Add a regression test to ensure that this edge case remains fixed. Note that I was unable to reproduce this bug with cmd/cue with the old evaluator using a single CUE file, so it was hard to add this reproducer as a unit test case elsewhere. Closes #2704. Signed-off-by: Daniel Martí <[email protected]> Change-Id: I13e4180dba7486909a50fa0fe1300ac05b183ca0 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1194741 Reviewed-by: Paul Jolly <[email protected]> Unity-Result: CUE porcuepine <[email protected]> TryBot-Result: CUEcueckoo <[email protected]>
1 parent c3dc2f2 commit 46feda5

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# https://cuelang.org/issues/2704
2+
3+
! exec cue export schema.cue data.json
4+
cmp stderr evalv2-stderr.golden
5+
! exec cue vet schema.cue data.json
6+
cmp stderr evalv2-stderr.golden
7+
8+
# This issue is already fixed in the new evaluator.
9+
env CUE_EXPERIMENT=evalv3
10+
11+
exec cue export schema.cue data.json
12+
cmp stdout evalv3-stdout.golden
13+
exec cue vet schema.cue data.json
14+
! stdout .
15+
16+
-- evalv2-stderr.golden --
17+
1: invalid value "value" (out of bound =~"^[0-9]+$"):
18+
./schema.cue:1:14
19+
./data.json:1:7
20+
-- evalv3-stdout.golden --
21+
[
22+
"5",
23+
"value"
24+
]
25+
-- schema.cue --
26+
#schema: [...=~"^[0-9]+$" | string]
27+
#schema
28+
-- data.json --
29+
["5", "value"]

0 commit comments

Comments
 (0)