mirror of https://github.com/stjepang/smol
Merge pull request #120 from Byron/some-tests-for-tasks
Tests to prevent against recent regression of Task::blocking(…).detach()
This commit is contained in:
commit
1487fa52bc
|
@ -0,0 +1,23 @@
|
|||
#[test]
|
||||
fn spawn() {
|
||||
assert_eq!(42, smol::run(smol::Task::spawn(async { 42 })));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn spawn_detach() {
|
||||
let (s, r) = piper::chan(1);
|
||||
smol::Task::spawn(async move { s.send(()).await }).detach();
|
||||
assert_eq!(Some(()), smol::run(r.recv()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn blocking() {
|
||||
assert_eq!(42, smol::run(smol::Task::blocking(async { 42 })));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn blocking_detach() {
|
||||
let (s, r) = piper::chan(1);
|
||||
smol::Task::blocking(async move { s.send(()).await }).detach();
|
||||
assert_eq!(Some(()), smol::run(r.recv()));
|
||||
}
|
Loading…
Reference in New Issue