encoding/jsonschema: improve mergeAllOf behavior
The `mergeAllOf` function wasn't working quite as expected.
This change applies a few fixes:
- Flattening is now more efficient and hopefully obvious,
using the conjuncts iterator
- A single-element allOf is flattened into its single element
- `item.apply` methods are expected to call the argument function
rather than just invoke `apply` recursively.
We add a unit test to make it easier to test the behavior
directly.
Signed-off-by: Roger Peppe <rogpeppe@gmail.com>
Change-Id: I542b7d9874203843b758c9ccc5f45d8bae47d174
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1224260
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>