Skip to content

Ignore comments within String constants #81

Open
@nedtwigg

Description

@nedtwigg

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.
     """)
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions