Implicit braces in ocamltest trees #2693
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The new tree syntax for ocamltest greatly improves the common case where several test cases are sequentially composed, each depending on the last. We can now write such tests as
without increasing the indentation level. This makes sense because these tests are not “nested” in any meaningful sense, any more than consecutive statements in imperative code are nested. Practically speaking, the great advantage is that we can now add
test1a
betweentest1
andtest2
without increasing indentation (or other markers of nested-ness).Unfortunately, this only works if
test1a
belongs in the sequence with the other tests. But it might be completely independent: for example, it might check an error case that is only meaningful aftertest1
but has no bearing on the other tests. In that case, we have three unpalatable options:test1a
fails.test1a
and risk emotional damage the next time you try to rebase.test1a
but don't indent, then try to invent a convention that will help you keep the formatting straight.The annoying thing here is that
test4
is still not meaningfully “more nested” thantest1
. It just happens that there's an extra branch jutting out of the sequence somewhere betweentest1
andtest4
, and the syntax makes that everyone's problem.My proposed syntax is this:
This is exactly as if we'd put braces around everything from
test2
totest27
, but it once again expresses that this is simply a sequence of tests in a chain. It's just that now there are some tests that branch off from the sequence.