Repository navigation
Conversation
Implement a new unittest block in `source/djson/tests.d` to verify that `JSONSyntaxException` is thrown when a comma is missing between entries in JSON arrays and objects. - Covers lazy parsing (via `parseAll()`) - Covers eager parsing (via `parseJSONComplete()`) - Validates the error messages "Expected ',' between array entries" and "Expected ',' between object entries". Co-authored-by: trikko <647157+trikko@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
There was a problem hiding this comment.
Code Review
This pull request introduces new unit tests to verify that the parser correctly identifies and reports missing commas in JSON arrays and objects, covering both lazy and eager parsing modes. Feedback suggests expanding these tests to include complex nested structures to more thoroughly validate the lazy parser's value-skipping logic.
| unittest { | ||
| // 27. Error conditions: missing commas | ||
|
|
||
| // Missing comma in array (lazy) | ||
| auto lazyArr = parseJSON("[1 2]"); | ||
| auto e1 = collectException!JSONSyntaxException(lazyArr.parseAll()); | ||
| assert(e1 !is null); | ||
| assert(e1.msg == "Expected ',' between array entries"); | ||
|
|
||
| // Missing comma in array (eager) | ||
| auto e2 = collectException!JSONSyntaxException(parseJSONComplete("[1 2]")); | ||
| assert(e2 !is null); | ||
| assert(e2.msg == "Expected ',' between array entries"); | ||
|
|
||
| // Missing comma in object (lazy) | ||
| auto lazyObj = parseJSON(`{"a": 1 "b": 2}`); | ||
| auto e3 = collectException!JSONSyntaxException(lazyObj.parseAll()); | ||
| assert(e3 !is null); | ||
| assert(e3.msg == "Expected ',' between object entries"); | ||
|
|
||
| // Missing comma in object (eager) | ||
| auto e4 = collectException!JSONSyntaxException(parseJSONComplete(`{"a": 1 "b": 2}`)); | ||
| assert(e4 !is null); | ||
| assert(e4.msg == "Expected ',' between object entries"); | ||
| } |
There was a problem hiding this comment.
The current tests only cover missing commas between primitive values (integers). It would be beneficial to include test cases where the first element is a complex type, such as an object or an array (e.g., [{"a":1} 2]). This would specifically verify that the lazy parser's skipValue logic correctly advances the input pointer to the expected comma position even after traversing nested structures.
This PR addresses the missing test coverage for the error condition where a comma is omitted between array entries. It also extends this coverage to objects for better consistency.
🎯 What
unittestblock tosource/djson/tests.d.[1 2]and{"a": 1 "b": 2}malformed JSON scenarios.📊 Coverage
The following scenarios are now covered:
✨ Result
Improved reliability of the parser by ensuring that these simple syntax errors are correctly caught and reported with the intended exception and message.
PR created automatically by Jules for task 10578925783853504611 started by @trikko