-
Notifications
You must be signed in to change notification settings - Fork 182
Add Arbitrary implementation for std::ascii::EscapeDefault #4782
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
Open
acearyanarun
wants to merge
5
commits into
model-checking:main
Choose a base branch
from
acearyanarun:arbitrary-ascii-escape-default
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e5bd1d8
Add Arbitrary implementation for ascii EscapeDefault
acearyanarun fca69f5
Update Arbitrary implementation tests for std::ascii::EscapeDefault
acearyanarun 24cc0bf
Merge branch 'main' into arbitrary-ascii-escape-default
feliperodri 6abbcc6
Resolve main conflicts and format EscapeDefault Arbitrary changes
acearyanarun a60b9c9
Move EscapeDefault Arbitrary test to expected suite and document unro…
acearyanarun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| Checking harness check_arbitrary_escape_default... | ||
|
|
||
| Status: SATISFIED\ | ||
| Description: "0 bytes remaining" | ||
|
|
||
| Status: SATISFIED\ | ||
| Description: "1 byte remaining" | ||
|
|
||
| Status: SATISFIED\ | ||
| Description: "2 bytes remaining" | ||
|
|
||
| Status: SATISFIED\ | ||
| Description: "3 bytes remaining" | ||
|
|
||
| Status: SATISFIED\ | ||
| Description: "4 bytes remaining" | ||
|
|
||
| Status: SATISFIED\ | ||
| Description: "front consumed" | ||
|
|
||
| Status: SATISFIED\ | ||
| Description: "back consumed" | ||
|
|
||
| Status: SATISFIED\ | ||
| Description: "front and back consumed" | ||
|
|
||
| 8 of 8 cover properties satisfied | ||
| 1 successfully verified harnesses, 0 failures |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| // Copyright Kani Contributors | ||
| // SPDX-License-Identifier: Apache-2.0 OR MIT | ||
| // | ||
| //! Ensure that kani::any can generate valid std::ascii::EscapeDefault states, | ||
| //! including states consumed from the front, from the back, and from both ends. | ||
|
|
||
| use std::ascii::EscapeDefault; | ||
|
|
||
| #[kani::proof] | ||
| fn check_arbitrary_escape_default() { | ||
| let mut escape: EscapeDefault = kani::any(); | ||
|
|
||
| let remaining = [escape.next(), escape.next(), escape.next(), escape.next()]; | ||
|
|
||
| // EscapeDefault yields at most four bytes. | ||
| assert!(escape.next().is_none()); | ||
|
|
||
| let count = remaining.iter().filter(|byte| byte.is_some()).count(); | ||
|
|
||
| // Every remaining length from fully consumed to fully unconsumed is reachable. | ||
| kani::cover!(count == 0, "0 bytes remaining"); | ||
| kani::cover!(count == 1, "1 byte remaining"); | ||
| kani::cover!(count == 2, "2 bytes remaining"); | ||
| kani::cover!(count == 3, "3 bytes remaining"); | ||
| kani::cover!(count == 4, "4 bytes remaining"); | ||
|
|
||
| // Observable front-consumed state: b"\\x00" -> b"x00". | ||
| kani::cover!(remaining == [Some(b'x'), Some(b'0'), Some(b'0'), None], "front consumed"); | ||
|
|
||
| // Observable back-consumed state: b"\\x00" -> b"\\x". | ||
| kani::cover!(remaining == [Some(b'\\'), Some(b'x'), None, None], "back consumed"); | ||
|
|
||
| // Observable mixed front/back state: b"\\x00" -> b"x0". | ||
| kani::cover!(remaining == [Some(b'x'), Some(b'0'), None, None], "front and back consumed"); | ||
| } |
10 changes: 10 additions & 0 deletions
10
tests/script-based-pre/autoharness_ascii_escape_default/Cargo.toml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| # Copyright Kani Contributors | ||
| # SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
|
||
| [package] | ||
| name = "autoharness_ascii_escape_default" | ||
| version = "0.1.0" | ||
| edition = "2024" | ||
|
|
||
| [lints.rust] | ||
| unexpected_cfgs = { level = "warn", check-cfg = ['cfg(kani)'] } |
6 changes: 6 additions & 0 deletions
6
tests/script-based-pre/autoharness_ascii_escape_default/config.yml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| # Copyright Kani Contributors | ||
| # SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
|
||
| script: escape_default.sh | ||
| expected: escape_default.expected | ||
| exit_code: 0 |
1 change: 1 addition & 0 deletions
1
tests/script-based-pre/autoharness_ascii_escape_default/escape_default.expected
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| | autoharness_ascii_escape_default | consume_escape_default | #[kani::proof] | Success | |
9 changes: 9 additions & 0 deletions
9
tests/script-based-pre/autoharness_ascii_escape_default/escape_default.sh
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| #!/usr/bin/env bash | ||
| # Copyright Kani Contributors | ||
| # SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| cargo kani autoharness -Z autoharness --output-format=regular 2>&1 \ | ||
| | grep -E '^\| autoharness_ascii_escape_default \| consume_escape_default .*Success' \ | ||
| | tr -s ' ' |
8 changes: 8 additions & 0 deletions
8
tests/script-based-pre/autoharness_ascii_escape_default/src/lib.rs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| // Copyright Kani Contributors | ||
| // SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
|
||
| #![allow(dead_code)] | ||
|
|
||
| pub fn consume_escape_default(value: std::ascii::EscapeDefault) -> usize { | ||
| value.count() | ||
| } |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.