Add tests for edn/read-string#910
Conversation
|
Thanks, Brandon! @dgr What are your thoughts on the approach here? |
dgr
left a comment
There was a problem hiding this comment.
Overall, this is great. I would be careful about conditionalizing for other dialects. In some cases, some of these things seem like bugs and it's appropriate for the test to fail. Then leave it for the dialect authors to make the decision of what they want to do. If you conditionalize everything, it gives the dialect authors a false sense that everything is fine because the test passes and they don't review it.
I love this! Overall, this is quite well done and comprehensive. |
There was a problem hiding this comment.
Pull request overview
Adds a comprehensive, cross-dialect test suite for clojure.edn/read-string to close #908 and to codify expected EDN-reader behavior (including dialect divergences and a few non-EDN extensions).
Changes:
- Introduces a new
.cljctest namespace coveringedn/read-stringacross strings, numbers, collections, tags, comments/discard, and options. - Adds dialect-conditional assertions for known behavioral differences (JVM/CLR/CLJS/Babashka/Basilisp/Phel).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
I believe this was what I originally intended to do, similar to the cases immediately above it. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
I agree, the tests are comprehensive. I also appreciate Brandon's work in getting these written. I want to convey caution before we continue, though. Are we testing the right thing? This repo is a test suite for core functions, to ensure they exist and behave correctly. I would imagine that the As an example of how we don't do this, in other cases.
Overall, we don't test the underlying compiler+runtime. This is a unit testing repo for core functions. If we continue down this path, this repo will grow to contain:
Keep in mind that we have a policy against LLM-generated code. Outside of generating this test code, we cannot reasonably expand the scope of this repo to contain all of these tests. I think this would be biting off far more than we can chew. Brandon asked if |
|
@jeaye I'd be happy to scale these tests back a bit. I was originally hesitant to create a 900 LOC PR, but went for it since each test seemed like it carried its weight. I think we could certainly remove the non-edn extension tests... since those are not part of the EDN spec. That should cut the size of the tests significantly by maybe 100 lines.
Many of the other tests I think we could go without altogether or collapse to just a handful of cases. A few candidates I see just skimming through:
|
Yeah, this is 30x larger than the median test file in the repo (~30 lines). That is generally an indicator that EITHER an LLM was used and there's serious over-testing OR we're being way too specific about something. For
Then we can test each of the options to ensure their behavior works, but each of those only needs to test the happy path and any edge cases we can figure. |
|
I think it's quite reasonable to test That said, perhaps this is a progressive thing, where we shoot for a minimum simple test and if somebody wants to go further, more power to them. Perhaps we don't require such great tests as @brandoncorrea delivered, but we gratefully accept them if somebody wants to write them. Finally, I think this also goes to the point I made to you privately on Slack, @jeaye. In these non-core libraries, if they are based mostly on Clojure code that will be reused in multiple implementations and the behavior is what it is as long as |
|
Following up publicly, after speaking privately with folks. We're going to move forward to merge Brandon's hard work, which intentionally grows the scope of the clojure-test-suite to now handle testing parsers for data formats. We're going to trim down some of the over-testing prior to merging. |
This PR closes #908.
These tests attempt to cover all behaviors according to edn-format.
Many of these tests were inspired by ClojureScript's reader tests.
Additional tests were added to flesh out all behaviors of the EDN spec, as well as some edge cases, negative scenarios, dialect-specific divergences, and some EDN extensions that some dialects implement and others do not (reader-conditionalized where applicable).
Babashka, JVM, CLR, and CLJS have all been tested and pass locally. Phel and Basilisp have been left to fail where apparent gaps exist.