# Regression test for two vet issues relating trailing input,
# https://cuelang.org/issue/2179 and https://cuelang.org/issue/2439. (CUE)

# First, sanity check that other commands spot the trailing invalid syntax.
! exec hof eval   data-trailing-garbage.json
stderr 'invalid JSON'

skip

! exec hof def    data-trailing-garbage.json
stderr 'invalid JSON'
! exec hof export data-trailing-garbage.json
stderr 'invalid JSON'

# ! exec hof eval   data-trailing-garbage.jsonl
# stderr 'invalid JSON'

# Then, check that vet does too.
! exec hof vet schema.cue data-trailing-garbage.json
stderr 'invalid JSON'
# ! exec hof vet schema.cue data-trailing-garbage.jsonl
# stderr 'invalid JSON'

# Check that even the last value is validated as well.
! exec hof vet schema.cue data-trailing-mismatch.json
stderr 'foo: conflicting values "789" and int'
# ! exec hof vet schema.cue data-trailing-mismatch.jsonl
# stderr 'foo: conflicting values "789" and int'

-- schema.cue --
foo: int
-- data-trailing-garbage.json --
{
	"foo": 123
}
hi there
-- data-trailing-mismatch.json --
{
	"foo": 123
}
{
	"foo": 456
}
{
	"foo": "789"
}
-- data-trailing-garbage.jsonl --
{
	"foo": 123
}
{
	"foo": 456
}
hi there
-- data-trailing-mismatch.jsonl --
{
	"foo": 123
}
{
	"foo": 456
}
{
	"foo": "789"
}
