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

Mark fail() function virtual #29

Open
0xbok opened this issue Mar 10, 2022 · 4 comments
Open

Mark fail() function virtual #29

0xbok opened this issue Mar 10, 2022 · 4 comments

Comments

@0xbok
Copy link

0xbok commented Mar 10, 2022

When writing tests and experimenting, sometimes it is beneficial to let fail() quit as soon as the first test fails. This helps debugging and avoid a lot of logs on screen.

Something like this

function fail() internal {
     revert();
}

Marking this function virtual allows us to update this function as necessary.

@PaulRBerg
Copy link

As discussed in #30, one of the goals of DSTest is to let users run multiple assertions in one test.

If the fail function reverted, or was made virtual, the assumptions made by multiple dependees (such as Foundry) would break.

@0xPhaze
Copy link
Contributor

0xPhaze commented Feb 22, 2023

I'm in favor of this change. A dev might have a reason/need to explicitly override this function. Being able to change the fail() behavior to an assert(false) statement will make compatibility with other frameworks, such as Echidna and the SMTChecker much easier.

@PaulRBerg
Copy link

@0xPhaze if you'd like to get immediate support for a virtual fail() function today, check out PRBTest. It's completely compatible with Forge Std, e.g. see how I use it in PRBMath.

@0xPhaze
Copy link
Contributor

0xPhaze commented Feb 22, 2023

Great, good to know. I'll use it for now. I'd still like to see this added to ds-test in the future.

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 a pull request may close this issue.

3 participants