unisonweb / unison

A friendly programming language from the future
https://unison-lang.org
Other
5.81k stars 271 forks source link

Create some unit tests for Doc syntax #5376

Closed sellout closed 1 month ago

sellout commented 1 month ago

Overview

The goal of this is faster testing cycles and more precise test cases than using transcripts. However, there is a bunch of background work to make it work. Most notably it

Implementation notes

This takes more advantage of fixed-point operators to allow changing the structure more easily (dropping annotations for test cases).

The Doc restructuring also encodes more of the restrictions in types (which had previously been in comments). We don’t want to keep those restrictions, but they reflect what the parser is currently able to parse.

This PR also changes the lexer unit tests a bit to catch some failures that could previously be missed. E.g., since it dropped the first and last token of the actual result (to match the provided expected result), an Err lexeme could be dropped, making a failure look like a success when compared against an empty expected result, or at least obscuring the reason for a failure.

Interesting/controversial decisions

I don’t know … recursion schemes? Although they’re already used in a few places, like the ABTs.

Test coverage

This adds a bunch of new unit tests, but none of them are particularly interesting, just a few to justify the existence of the new test suite.

Loose ends

Moar tests in the suite, that focus on edge cases. But with upcoming changes like #5255, it seems premature to try to explore the boundaries of the current syntax.