Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore comments within String constants #81

Open
nedtwigg opened this issue Jan 5, 2024 · 0 comments
Open

Ignore comments within String constants #81

nedtwigg opened this issue Jan 5, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@nedtwigg
Copy link
Member

nedtwigg commented Jan 5, 2024

This code is too simple.

// TODO: there is a bug here due to string constants, and non-C file comments
val newComment =
if (str.contains("//selfieonce") || str.contains("// selfieonce")) {
WritableComment.ONCE

fun removeSelfieOnceComments() {
// TODO: there is a bug here due to string constants, and non-C file comments
contentSlice =
Slice(contentSlice.toString().replace("//selfieonce", "").replace("// selfieonce", ""))
}

For example:

class Test {
  @Test public void example() {
    expectSelfie("underTest").toBe("""
This is a string constant
// selfieonce
The comment above is not really a comment.
We effectively have a "forbidden value" that can't be inside inline snapshots.
     """)
  }
}
@nedtwigg nedtwigg changed the title Handle comments within String constants Ignore comments within String constants Jan 5, 2024
@nedtwigg nedtwigg added the bug Something isn't working label Jan 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant