File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed
tests/expected/loop-contract Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change 1+ trim_ascii_start.loop_invariant_base.1\
2+ - Status: SUCCESS\
3+ - Description: "Check invariant before entry for loop trim_ascii_start.0"
4+
5+ trim_ascii_start.loop_invariant_step.1\
6+ - Status: SUCCESS\
7+ - Description: "Check invariant after step for loop trim_ascii_start.0"
8+
9+ VERIFICATION:- SUCCESSFUL
Original file line number Diff line number Diff line change 1+ // Copyright Kani Contributors
2+ // SPDX-License-Identifier: Apache-2.0 OR MIT
3+
4+ // kani-flags: -Z loop-contracts
5+
6+ //! Check if while-let invariant is correctly applied.
7+
8+ #![ feature( proc_macro_hygiene) ]
9+ #![ feature( stmt_expr_attributes) ]
10+
11+ #[ kani:: proof]
12+ fn trim_ascii_start ( ) {
13+ let mut a: [ u8 ; 10 ] = kani:: any ( ) ;
14+ let s = a. as_slice ( ) ;
15+ let mut bytes = s;
16+ #[ kani:: loop_invariant(
17+ bytes. len( ) <= s. len( ) &&
18+ ( bytes. len( ) == 0 || ( & s[ s. len( ) -bytes. len( ) ..] ) . as_ptr( ) == bytes. as_ptr( ) )
19+ ) ]
20+ while let [ first, rest @ ..] = bytes {
21+ if first. is_ascii_whitespace ( ) {
22+ bytes = rest;
23+ } else {
24+ break ;
25+ }
26+ }
27+ }
You can’t perform that action at this time.
0 commit comments