feat(testing): add matches: and any arms to execution error assertion macros#2893
Closed
AlgofootPrint wants to merge 1 commit into
Closed
feat(testing): add matches: and any arms to execution error assertion macros#2893AlgofootPrint wants to merge 1 commit into
matches: and any arms to execution error assertion macros#2893AlgofootPrint wants to merge 1 commit into
Conversation
Extends assert_execution_error! and assert_transaction_executor_error! with two new arms: - matches: $pat $(if $guard)? -- pattern-matches the inner ExecutionError directly, with an optional guard expression. Allows testing non- FailedAssertion variants (e.g. DivideByZero, CycleLimitExceeded) and FailedAssertion with a specific err_code guard, without writing a manual match statement. - any -- accepts any Err result; useful when the test only cares that execution failed, not which error was produced. Closes 0xMiden#2807
Collaborator
|
closing as not meeting our https://github.com/0xMiden/protocol?tab=contributing-ov-file#contribution-quality:
please refrain from opening further PRs unless assigned. We take the liberty to ban contributors not following our contribution guide as this results in overhead for the team. Thanks for your understanding. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #2807
Extends
assert_execution_error!andassert_transaction_executor_error!incrates/miden-testing/src/utils.rswith two new arms (keeping the:inmatches:per @Keinberger's preference for consistency with #2805):matches: $pat $(if $guard)?- pattern-matches the innerExecutionErrordirectly, with an optional guard expression. Covers non-
FailedAssertionvariantsand
FailedAssertionwith a specificerr_codeguard:any- accepts anyErr, panics onOk:For
assert_transaction_executor_error!the same two arms are added; the outerTransactionExecutorError::TransactionProgramExecutionFailed(...)wrapper ishandled internally so `` matches
ExecutionErrordirectly.Tests
Three new unit tests in
utils.rs:assert_execution_error_any-anyarm with aFailedAssertionassert_execution_error_matches_divide_by_zero-matches:without guard onDivideByZeroassert_execution_error_matches_with_err_code_guard-matches:withifguard onerr_codeA compile-time-only check verifies the
anyarm type-checks forassert_transaction_executor_error!.Not included
The Rust SDK
assert_with_code/assertz_with_code/assert_eq_with_codehelpers - those cross into compiler/SDK territory and need coordination with the
compiler team as noted by @Keinberger.