From 5fde3600ac2ba89f19dc3b581b8c6336df609af9 Mon Sep 17 00:00:00 2001 From: Roger Peppe Date: Tue, 13 Aug 2024 11:55:43 +0100 Subject: [PATCH] encoding/jsonschema: fix type exclusion test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Change-Id: Id01c93b9085bff7726e8042a8d039e0ee5fd7ceb Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1199398 TryBot-Result: CUEcueckoo Unity-Result: CUE porcuepine Reviewed-by: Daniel Martí --- .../{emptyanyof.txtar => emptyobjinanyof.txtar} | 0 encoding/jsonschema/testdata/impossibleallof.txtar | 10 ++++++++++ encoding/jsonschema/testdata/typedis.txtar | 14 ++------------ 3 files changed, 12 insertions(+), 12 deletions(-) rename encoding/jsonschema/testdata/{emptyanyof.txtar => emptyobjinanyof.txtar} (100%) create mode 100644 encoding/jsonschema/testdata/impossibleallof.txtar diff --git a/encoding/jsonschema/testdata/emptyanyof.txtar b/encoding/jsonschema/testdata/emptyobjinanyof.txtar similarity index 100% rename from encoding/jsonschema/testdata/emptyanyof.txtar rename to encoding/jsonschema/testdata/emptyobjinanyof.txtar diff --git a/encoding/jsonschema/testdata/impossibleallof.txtar b/encoding/jsonschema/testdata/impossibleallof.txtar new file mode 100644 index 00000000000..544c88da441 --- /dev/null +++ b/encoding/jsonschema/testdata/impossibleallof.txtar @@ -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 diff --git a/encoding/jsonschema/testdata/typedis.txtar b/encoding/jsonschema/testdata/typedis.txtar index 5095e39442e..94fa42cccd5 100644 --- a/encoding/jsonschema/testdata/typedis.txtar +++ b/encoding/jsonschema/testdata/typedis.txtar @@ -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 ...