Skip to content

Write a sourcepos test for each NodeValue variant#498

Merged
kivikakk merged 3 commits intokivikakk:mainfrom
SamWilsn:sourcepos-tests
Feb 25, 2025
Merged

Write a sourcepos test for each NodeValue variant#498
kivikakk merged 3 commits intokivikakk:mainfrom
SamWilsn:sourcepos-tests

Conversation

@SamWilsn
Copy link
Copy Markdown
Contributor

@SamWilsn SamWilsn commented Dec 4, 2024

Not sure if these are already covered elsewhere. I wrote one for my own knowledge, and kept going... A few are disabled because I believe the returned sourcepos are incorrect.

Apologies for stacking this on top of #497. Looking at just 38f2403 might be best.

@digitalmoksha
Copy link
Copy Markdown
Collaborator

Some of these are covered at the bottom of the specific test file, such as https://github.com/kivikakk/comrak/blob/main/src/tests/wikilinks.rs#L218-L276, though not everything is covered. So more coverage of this is super helpful.

Yeah, there is still more work to do on getting inline sourcepos working consistently.

@SamWilsn
Copy link
Copy Markdown
Contributor Author

SamWilsn commented Dec 6, 2024

How do you feel about the whole strum plus match approach to ensuring all variants are tested?

Comment thread src/tests/sourcepos.rs
Comment on lines +398 to +418
List // end is 3:0
| Item // end is 3:0
| TaskItem // end is 4:0
| DescriptionItem // end is 4:0
| DescriptionTerm // end is 3:0
| DescriptionDetails // end is 4:0
| HtmlInline // end is 1:31 but should be 3:14
| LineBreak // start is 1:15 but should be 1:13
| Code // is 1:8-1:12 but should be 1:7-1:13
| ThematicBreak // end is 4:0
| Link // inconsistent between link types
| Math // is 3:2-3:6 but should be 3:1-3:7
Copy link
Copy Markdown
Contributor Author

@SamWilsn SamWilsn Dec 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If y'all can confirm that all of these are bugs, I'll try my hand at fixing them.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think those are all incorrect sourcesos 😢

@kivikakk
Copy link
Copy Markdown
Owner

👋 A lot has changed, so I've brought this PR up-to-date! I really like the approach, and I'd be happy to merge it now, rather than wait for all sourcepos to be fixed first (which will probably necessitate another big rebase).

Some of the changes in this branch have already landed in slightly different form, so a few commits got omitted; please feel free to restore to your version (or whatever you like), my force push here is mostly a suggestion in case you're a fan!

@SamWilsn
Copy link
Copy Markdown
Contributor Author

Thank you! I haven't had time to work on this in... four months apparently 😅

Go ahead with whatever commits you think are best.

@kivikakk kivikakk marked this pull request as ready for review February 25, 2025 05:23
@kivikakk kivikakk enabled auto-merge February 25, 2025 05:23
@kivikakk kivikakk merged commit 58c8cc4 into kivikakk:main Feb 25, 2025
@kivikakk
Copy link
Copy Markdown
Owner

Thanks so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants