-
Notifications
You must be signed in to change notification settings - Fork 204
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
feat: Add test(should_fail)
attribute for tests that are meant to fail
#2418
Conversation
Co-authored-by: Blaine Bublitz <[email protected]>
Co-authored-by: Blaine Bublitz <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking great! I had a few code style recommendations that will clean up a bit
Co-authored-by: Blaine Bublitz <[email protected]>
ahh thought it would be better to use just one filter_map? i don't have a preference though do u want to go with 2? |
I think he's trying to remove the internal mapper, so you can combine the two techniques (a flat_map followed by a filter_map` pub fn get_all_test_functions<'a>(
&'a self,
interner: &'a NodeInterner,
) -> impl Iterator<Item = TestFunction> + 'a {
self.modules
.iter()
.flat_map(|(_, module)| module.value_definitions())
.filter_map(|id| {
if let Some(func_id) = id.as_function() {
match interner.function_meta(&func_id).attributes {
Some(Attribute::Test(scope)) => Some(TestFunction::new(func_id, scope)),
_ => None,
}
} else {
None
}
})
} technically this is one less closure than what kev suggested, but I'm guessing the compiler would optimize them away 🤔 |
Co-authored-by: Blaine Bublitz <[email protected]>
Just going to run this on a few examples |
This is something we should do in a separate issue, when a test should fail, but it passes. There is no red line to tell us what passed that should not have passed. This is in comparison to the opposite. To illustrate, run #[test]
fn foo(){
assert(1 == 2);
} #[test(should_fail)]
fn foo(){
assert(1 == 1);
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LGTM -- @phated did you have any other concerns?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Nice work @Ethan-000 - I think we can follow on with more descriptive error messages (such as what kev mentioned or noting that a test failed because it succeeded but was expected to fail)
Thanks for the review 🙂 |
* master: fix: Implement new mem2reg pass (#2420) feat(nargo): Support optional directory in git dependencies (#2436) fix(acir_gen): Pass accurate contents to slice inputs for bb func calls (#2435) fix(ssa): codegen missing check for unary minus (#2413) fix(lsp): Remove duplicated creation of lenses (#2433) feat: Add `test(should_fail)` attribute for tests that are meant to fail (#2418) chore: improve error message for InternalError (#2429) chore: Add stdlib to every crate as it is added to graph (#2392)
Should this be documented (i.e. meant to be used by Noir devs)? |
ahh yes should probably be documented with #2541 |
Thanks! Created noir-lang/docs#372 for documenting this issue (while #2541 can be documented with noir-lang/docs#367). |
Description
Problem*
Resolves #1994
Summary*
Documentation
This PR requires documentation updates when merged.
Additional Context
PR Checklist*
cargo fmt
on default settings.