Skip to content

Commit

Permalink
encoding/jsonschema: fix type exclusion test
Browse files Browse the repository at this point in the history
This test was added by https://cue-review.googlesource.com/c/cue/+/5648
but included a case that was later made an error in
https://cue-review.googlesource.com/c/cue/+/6302 (the self-contradictory
`allOf` case), thus meaning the rest of the test was not
actually checked.

We move that case into its own test, ensuring that the other
cases pass.

We also rename the `emptyanyof` because it is not actually
testing an empty anyOf, but rather an empty object _inside_
an anyOf.

Signed-off-by: Roger Peppe <[email protected]>
Change-Id: Id01c93b9085bff7726e8042a8d039e0ee5fd7ceb
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1199398
TryBot-Result: CUEcueckoo <[email protected]>
Unity-Result: CUE porcuepine <[email protected]>
Reviewed-by: Daniel Martí <[email protected]>
  • Loading branch information
rogpeppe committed Aug 13, 2024
1 parent 89c7b4b commit 5fde360
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
10 changes: 10 additions & 0 deletions encoding/jsonschema/testdata/impossibleallof.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
-- type.json --
{
"allOf": [
{ "type": "object" },
{ "type": "string" }
]
}
-- out/decode/err --
constraint not allowed because type string is excluded:
type.json:4:11
14 changes: 2 additions & 12 deletions encoding/jsonschema/testdata/typedis.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,13 @@
"minimum": 3
}
]
},
"empty": {
"allOf": [
{ "type": "object" },
{ "type": "string" }
]
}
}
}
-- out/decode/err --
constraint not allowed because type string is excluded:
type.json:39:15
-- out/decode/cue --
// Main schema
intOrString1?: int | string
intOrString2?: int | string
intOrString3?: string | int
disjunction?: string | int | int & >=3
empty?: _|_
intOrString3?: (int | string) & (number | string)
disjunction?: (int | string) & (number | string) | int & >=3
...

0 comments on commit 5fde360

Please sign in to comment.