Skip to content

Commit

Permalink
cue: add an attribute test with a non-Go integer literal
Browse files Browse the repository at this point in the history
10Mi is a valid CUE integer literal per the spec section
https://cuelang.org/docs/reference/spec/#numeric-literals
but it is not a valid Go integer literal.

The following commit resolves a TODO to use cue/literal for parsing
numbers from attributes, changing the behavior of this test.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: I8ea07d0fa5bb2eb1c8ce293c16387395c954dfaf
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1204903
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
Reviewed-by: Paul Jolly <paul@myitcv.io>
  • Loading branch information
mvdan committed Nov 29, 2024
1 parent 3c11890 commit 3487155
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cue/attribute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ func TestAttributeInt(t *testing.T) {
a: {
a: 0 @foo(1,3,c=1)
b: 1 @bar(a,-4,c,d=1) @foo(a,,d=1)
c: 2 @nongo(10Mi)
}
`
testCases := []struct {
Expand Down Expand Up @@ -325,6 +326,11 @@ func TestAttributeInt(t *testing.T) {
attr: "foo",
pos: 2,
err: errors.New(`strconv.ParseInt: parsing "c=1": invalid syntax`),
}, {
path: "c",
attr: "nongo",
pos: 0,
err: errors.New(`strconv.ParseInt: parsing "10Mi": invalid syntax`),
}}
for _, tc := range testCases {
cuetdtest.FullMatrix.Run(t, fmt.Sprintf("%s.%s:%d", tc.path, tc.attr, tc.pos), func(t *testing.T, m *cuetdtest.M) {
Expand Down

0 comments on commit 3487155

Please sign in to comment.