From 52ae4107eb1fc449dfc528fad2654b2e8f3a4ed2 Mon Sep 17 00:00:00 2001 From: Roger Peppe Date: Fri, 9 Aug 2024 15:05:07 +0100 Subject: [PATCH] encoding/jsonschema: add test for numeric enum with type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The current logic causes an error when combining the `type` specifier with a numeric enum. This change adds a test that demonstrates that issue, to be fixed in a subsequent CL. For #3173. Signed-off-by: Roger Peppe Change-Id: Ie401aea5a165e7c6353ef12473adcc6a45ddce35 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1199213 Unity-Result: CUE porcuepine TryBot-Result: CUEcueckoo Reviewed-by: Daniel Martí --- encoding/jsonschema/testdata/num.txtar | 1 - encoding/jsonschema/testdata/numericenum.txtar | 13 +++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 encoding/jsonschema/testdata/numericenum.txtar diff --git a/encoding/jsonschema/testdata/num.txtar b/encoding/jsonschema/testdata/num.txtar index 2dad4a44042..ed5dbd03943 100644 --- a/encoding/jsonschema/testdata/num.txtar +++ b/encoding/jsonschema/testdata/num.txtar @@ -37,7 +37,6 @@ }, "additionalProperties": false } - -- out/decode/cue -- import ( "strings" diff --git a/encoding/jsonschema/testdata/numericenum.txtar b/encoding/jsonschema/testdata/numericenum.txtar new file mode 100644 index 00000000000..043826338eb --- /dev/null +++ b/encoding/jsonschema/testdata/numericenum.txtar @@ -0,0 +1,13 @@ +# Test that we can use a "number" type constraint with a numeric enum. +# See issue #3173. + +# TODO fix this so it works. + +-- type.json -- +{ + "type": "number", + "enum": [ 1, 2, 3] +} +-- out/decode/err -- +constraint not allowed because type number is excluded: + type.json:2:5