-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
40 changed files
with
268 additions
and
263 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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
File renamed without changes.
This file contains 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 @@ | ||
// Copyright Kani Contributors | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
// Test that a coroutine can be passed as a parameter. | ||
// (adapted from https://github.com/model-checking/kani/issues/1075) | ||
|
||
#![feature(coroutines, coroutine_trait)] | ||
|
||
use std::ops::{Coroutine, CoroutineState}; | ||
use std::pin::Pin; | ||
|
||
fn foo<G: Coroutine<Yield = u8, Return = u8> + Unpin>(mut g: G) | ||
where | ||
<G as std::ops::Coroutine>::Return: std::cmp::PartialEq, | ||
{ | ||
let res = Pin::new(&mut g).resume(()); | ||
assert_eq!(res, CoroutineState::Yielded(1)); | ||
let res2 = Pin::new(&mut g).resume(()); | ||
assert_eq!(res2, CoroutineState::Complete(2)); | ||
} | ||
|
||
#[kani::proof] | ||
fn main() { | ||
foo(|| { | ||
yield 1; | ||
return 2; | ||
}); | ||
} |
This file contains 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 @@ | ||
SUCCESS\ | ||
Description: "assertion failed: res == CoroutineState::Yielded(val)" | ||
|
||
SUCCESS\ | ||
Description: "assertion failed: res == CoroutineState::Complete(!val)" | ||
|
||
UNREACHABLE\ | ||
Description: "coroutine resumed after completion" | ||
|
||
VERIFICATION:- SUCCESSFUL |
This file contains 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,23 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
#![feature(coroutines, coroutine_trait)] | ||
|
||
use std::ops::{Coroutine, CoroutineState}; | ||
use std::pin::Pin; | ||
|
||
#[kani::proof] | ||
#[kani::unwind(2)] | ||
fn main() { | ||
let val: bool = kani::any(); | ||
let mut coroutine = move || { | ||
let x = val; | ||
yield x; | ||
return !x; | ||
}; | ||
|
||
let res = Pin::new(&mut coroutine).resume(()); | ||
assert_eq!(res, CoroutineState::Yielded(val)); | ||
let res = Pin::new(&mut coroutine).resume(()); | ||
assert_eq!(res, CoroutineState::Complete(!val)); | ||
} |
This file contains 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
16 changes: 8 additions & 8 deletions
16
tests/expected/generators/pin/main.rs → tests/expected/coroutines/pin/main.rs
This file contains 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 |
---|---|---|
@@ -1,27 +1,27 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
// Test contains a call to a generator via a Pin | ||
// Test contains a call to a coroutine via a Pin | ||
// from https://github.com/model-checking/kani/issues/416 | ||
|
||
#![feature(generators, generator_trait)] | ||
#![feature(coroutines, coroutine_trait)] | ||
|
||
use std::ops::{Generator, GeneratorState}; | ||
use std::ops::{Coroutine, CoroutineState}; | ||
use std::pin::Pin; | ||
|
||
#[kani::proof] | ||
fn main() { | ||
let mut generator = || { | ||
let mut coroutine = || { | ||
yield 1; | ||
return true; | ||
}; | ||
|
||
match Pin::new(&mut generator).resume(()) { | ||
GeneratorState::Yielded(1) => {} | ||
match Pin::new(&mut coroutine).resume(()) { | ||
CoroutineState::Yielded(1) => {} | ||
_ => panic!("unexpected return from resume"), | ||
} | ||
match Pin::new(&mut generator).resume(()) { | ||
GeneratorState::Complete(true) => {} | ||
match Pin::new(&mut coroutine).resume(()) { | ||
CoroutineState::Complete(true) => {} | ||
_ => panic!("unexpected yield from resume"), | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.