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

assert for no errors #21926

Closed
2 tasks
Eliyaan opened this issue Jul 24, 2024 · 1 comment
Closed
2 tasks

assert for no errors #21926

Eliyaan opened this issue Jul 24, 2024 · 1 comment
Labels
Feature Request This issue is made to request a feature.

Comments

@Eliyaan
Copy link
Contributor

Eliyaan commented Jul 24, 2024

Describe the feature

To be able to assert whether or not the function returns an error.

fn foo() !MyStruct 

assert foo // fails if Result type is returned

Use Case

To be able to check for no errors in tests files. The Result type is very useful for handling errors and I think that being able to test them with v test goes hand in hand with it's purpose to handle errors properly. (I dont have a specific syntax in mind)

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

Version used

V 0.4.6

Environment details (OS name and version, etc.)

V 0.4.6

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

@Eliyaan Eliyaan added the Feature Request This issue is made to request a feature. label Jul 24, 2024
@Eliyaan Eliyaan changed the title assert for no erros assert for no errors Jul 24, 2024
@Eliyaan
Copy link
Contributor Author

Eliyaan commented Jul 24, 2024

For tests is works well like that :

fn test_abc() {
    foo()!
}

Where there is an error, it propagates the error and the test fails

@Eliyaan Eliyaan closed this as completed Jul 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request This issue is made to request a feature.
Projects
None yet
Development

No branches or pull requests

1 participant