diff options
| author | Rose Hogenson <rosehogenson@posteo.net> | 2025-10-26 08:31:12 -0700 |
|---|---|---|
| committer | Rose Hogenson <rosehogenson@posteo.net> | 2025-10-26 08:31:12 -0700 |
| commit | 121b6d8e6f7a07cd119def27aaddc9e1e83dae1d (patch) | |
| tree | ca0e2261532e3c6985724ae8bc9164615f4b8a3c /asspb_test.go | |
| parent | Make sure to remove \r\n as well as \n for Windows (diff) | |
| download | ccl-121b6d8e6f7a07cd119def27aaddc9e1e83dae1d.tar.zst | |
Refine numeric literal syntax
Leading zeros are no longer permitted in decimal literals, which is
technically a backwards-incompatible change, but I consider it to be
something like a bug fix. Anyway, the project is unlikely to have any
users that would be impacted.
Diffstat (limited to 'asspb_test.go')
| -rw-r--r-- | asspb_test.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/asspb_test.go b/asspb_test.go index 7600dee..2425571 100644 --- a/asspb_test.go +++ b/asspb_test.go @@ -43,18 +43,38 @@ field_repeated [5, 6] can just span multiple lines"`, want: map[string]any{"field": "strings\ncan just span multiple lines"}, }, { + desc: "Zero", + msg: `field: 0`, + want: map[string]any{"field": 0.}, + }, { desc: "Hex", msg: `field: 0xff`, want: map[string]any{"field": 255.}, }, { + desc: "CapitalHex", + msg: `field: 0XfF`, + want: map[string]any{"field": 255.}, + }, { + desc: "HexLeadingZero", + msg: `field: 0x0f`, + want: map[string]any{"field": 15.}, + }, { desc: "Float", msg: `field: 1.5e10`, want: map[string]any{"field": 1.5e10}, }, { + desc: "FloatCapitalE", + msg: `field: 1.5E10`, + want: map[string]any{"field": 1.5e10}, + }, { desc: "NegativeFloat", msg: `field: -1.5e-10`, want: map[string]any{"field": -1.5e-10}, }, { + desc: "PositiveFloat", + msg: `field: +1.5e+10`, + want: map[string]any{"field": 1.5e10}, + }, { desc: "Int", msg: `field: 10`, want: map[string]any{"field": 10.}, @@ -63,6 +83,10 @@ can just span multiple lines"`, msg: `field: -10`, want: map[string]any{"field": -10.}, }, { + desc: "PositiveInt", + msg: `field: +10`, + want: map[string]any{"field": 10.}, + }, { desc: "String", msg: `field: 'asdf'`, want: map[string]any{"field": "asdf"}, @@ -238,6 +262,9 @@ func TestUnmarshal_Invalid(t *testing.T) { }, { desc: "ListBadMsgVal", msg: `field [{asdf}]`, + }, { + desc: "IntLeadingZero", + msg: `field: 0644`, }} { t.Run(tc.desc, func(t *testing.T) { t.Parallel() |
