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

Illegal syntax for decorators compiles and runs without warning, but has no effect #264

Closed
zhihaoy opened this issue Aug 8, 2019 · 2 comments

Comments

@zhihaoy
Copy link
Contributor

zhihaoy commented Aug 8, 2019

Description

TEST_CASE("my case", test_suite("costly")) { ... }

The * operator should be used instead, but the above code compiles and runs, which causes confusion (for example, -tse=costly does nothing to the end-users).

@onqtam
Copy link
Member

onqtam commented Aug 11, 2019

Which compiler are you using? The DOCTEST_TEST_CASE macro has a single argument and when I use GCC on my local linux box it properly errors about the extra argument from your example. I see from previous issues that you've been using MSVC - perhaps there is some warning?

And actually I could transition from the * operator to the comma , operator (with keeping backwards compatibility) - I just tried it and it worked! A problem are the TEST_CASE_TEMPLATE macros however, because the decorator part which would need to become a VARARG macro parameter isn't the last one but the first one... So in order to keep things consistent between TEST_CASE and TEST_CASE_TEMPLATE perhaps only operator* will be allowed...

@zhihaoy
Copy link
Contributor Author

zhihaoy commented Aug 12, 2019

MSVC. Ahh, this time I do see a warning:

warning C4002:  too many arguments for function-
like macro invocation 'DOCTEST_TEST_CASE'

I wasn't expecting a warning. Sorry about that.

There is a way to dispatch on fixed numbers of arguments in macros, which can make TEST_CAST("name", test_suite("suite") * skip()) work.

@zhihaoy zhihaoy closed this as completed Aug 12, 2019
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

No branches or pull requests

2 participants