Skip to content

Commit

Permalink
encoding/jsonschema: add test for numeric enum with type
Browse files Browse the repository at this point in the history
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 <rogpeppe@gmail.com>
Change-Id: Ie401aea5a165e7c6353ef12473adcc6a45ddce35
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1199213
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
  • Loading branch information
rogpeppe committed Aug 13, 2024
1 parent f00a023 commit 52ae410
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
1 change: 0 additions & 1 deletion encoding/jsonschema/testdata/num.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
},
"additionalProperties": false
}

-- out/decode/cue --
import (
"strings"
Expand Down
13 changes: 13 additions & 0 deletions encoding/jsonschema/testdata/numericenum.txtar
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 52ae410

Please sign in to comment.