jsonnet icon indicating copy to clipboard operation
jsonnet copied to clipboard

More extensive test suite for std.format

Open sbarzowski opened this issue 4 years ago • 2 comments

It's by far the most complex stdlib function.

We had two bugs already and we are considering a native implementation in go-jsonnet. We already have quite a lot of tests, but we can still do better.

We can even auto-generate a lot of tests and generate the correct results with Python (we're supposed to be mostly compatible).

Here's what we have currently: https://github.com/google/jsonnet/blob/v0.17.0/test_suite/format.jsonnet

sbarzowski avatar Jan 12 '21 18:01 sbarzowski

We can also consider writing some property tests. E.g. checking that for all x, std.abs(std.parseJson(std.format('%.3f, [x])) - x) < 0.001.

sbarzowski avatar Jan 12 '21 18:01 sbarzowski

We also hit a format bug in sjsonnet: https://github.com/databricks/sjsonnet/issues/144. The current implementation in jsonnet also doesn't match Python's formatting (which is linked as the only reference for the formatter behavior in the spec) in this case.

szeiger avatar Feb 23 '22 15:02 szeiger