alexfertel / bulloak

Generate tests based on the Branching Tree Technique.
https://bulloak.dev
Apache License 2.0
260 stars 14 forks source link

Bulloak fails when word ‘when’ is used deep in the ‘It’ leaf #54

Closed matmilbury closed 8 months ago

matmilbury commented 8 months ago
Foo
└── It reverts when X.

Running bulloak scaffold Foo.tree results in an error: bulloak error: invalid identifier: ..

I understand it’s because bulloak sees the word ‘when’ in the leaf name and thinks it’s a condition instead of an action.

While I understand I could write:

Foo
└── When X
    └── It reverts.

I don’t like that because then the action statement becomes a comment which is not checked with bulloak check if removed.

Besides, there are legitimate usecases for the word ‘when’ used to describe the action.

Expected behavior: The word ‘when’ has a special meaning only at the beginning of a leaf name.

matmilbury commented 8 months ago

Temporary workaround:

Foo
└── It reverts when X

(no dot at the end of the action statement).

alexfertel commented 8 months ago

I understand it’s because bulloak sees the word ‘when’ in the leaf name and thinks it’s a condition instead of an action.

Ah, not exactly. It's because top-level actions are scaffolded as tests, and thus must be valid identifiers.

Does that make sense to you?

matmilbury commented 8 months ago

Hmmm… sort of.

But then why

Foo
└── It reverts when X.

fails while

Foo
└── It reverts X.

works?

alexfertel commented 8 months ago

Ooh, that's because of a parsing error. Great catch! it enters identifier mode in the tokenizer after the when token. I'll make some time to fix it.

alexfertel commented 8 months ago

Okay, finally had time to fix this! You can check it [here].(https://github.com/alexfertel/bulloak/commit/488fb6351b49da2c71ce09cd1a06b572988d03c9)

Will publish a new version in a few.