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

Add fixme tests for function contracts #3371

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

celinval
Copy link
Contributor

@celinval celinval commented Jul 22, 2024

I'm adding a few fix-me tests that I bumped into while working on #3363. Most of them will be fixed by #3363, except the one related to #3370.

The original PR is already quite large, so I decided to just push all of these as fixme tests for now. This is now ready for review!

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.

@celinval celinval changed the title Test contract support to parameter patterns Add fixme tests for function contracts Jul 26, 2024
@celinval celinval marked this pull request as ready for review July 26, 2024 22:06
@celinval celinval requested a review from a team as a code owner July 26, 2024 22:06
@feliperodri feliperodri added this to the Function Contracts milestone Jul 31, 2024
@tautschnig tautschnig added the Z-Contracts Issue related to code contracts label Aug 1, 2024
tests/kani/FunctionContracts/fixme_receiver_contracts.rs Outdated Show resolved Hide resolved
fn check_set_val() {
let mut obj = CharASCII::any();
let original = obj.0;
let new_val = kani::any_where(|new| *new != original);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No.. I used to have an assertion after that relied on it.

tests/kani/FunctionContracts/fixme_old_requires_order.rs Outdated Show resolved Hide resolved
Co-authored-by: Zyad Hassan <88045115+zhassan-aws@users.noreply.github.com>

impl kani::Arbitrary for CharASCII {
fn any() -> CharASCII {
let val = kani::any_where(|inner: &u8| *inner <= 128);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This now needs to be updated to a strict less than (*inner < 128).

/// receivers.
impl CharASCII {
#[kani::modifies(&self.0)]
#[kani::requires(new_val <= 128)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here (and other occurrences below).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Z-Contracts Issue related to code contracts
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants