1
0
mirror of https://github.com/bspeice/qadapt synced 2025-07-02 06:16:30 -04:00

Add an async demonstration

This commit is contained in:
2018-12-08 18:05:46 -05:00
parent 26ebd50fc0
commit 9e5b2b0f7a
4 changed files with 60 additions and 24 deletions

View File

@ -39,4 +39,4 @@ fn list_push() {
} else {
panic!("Intentional")
}
}
}

33
tests/async.rs Normal file
View File

@ -0,0 +1,33 @@
use futures::future::ok;
use futures::prelude::*;
use qadapt::assert_no_alloc;
use qadapt::no_alloc;
use qadapt::QADAPT;
#[global_allocator]
static Q: QADAPT = QADAPT;
#[no_alloc]
fn async_box() -> impl Future<Item = Box<u8>, Error = ()> {
ok(12).and_then(|e| Ok(Box::new(e)))
}
#[test]
fn raw_call() {
async_box();
}
#[test]
fn guarded_call() {
assert_no_alloc!(async_box());
}
#[test]
#[should_panic]
fn guarded_poll() {
if cfg!(debug_assertions) {
assert_no_alloc!(async_box().poll().unwrap());
} else {
panic!("Intentional")
}
}