Dever v0.0.2
This commit is contained in:
commit
e6e175ebcf
816 files changed
+120349
No files matched your search
@@ -0,0 +1,42 @@
|
||||
use dever_runtime::{task, stream::AsyncStream, Bytes};
|
||||
task::execute(true, async {
|
||||
let result = @ordered@(&[0, 1, 2, 3], 3).await.unwrap();
|
||||
assert_eq!(result.f0, [0, 2, 4, 6]);
|
||||
assert_eq!(result.f1, [4, 6]);
|
||||
assert!(@ordered@(&[], 1).await.unwrap().f0.is_empty());
|
||||
assert_eq!(@ordered@(&[0, 1, 2, 3], 1).await.unwrap().f0, [0, 2, 4, 6]);
|
||||
assert_eq!(@actions@(&[0, 1, -1, 2]).await.unwrap(), 3);
|
||||
@zero@(&[0, 1, 2]).await.unwrap();
|
||||
let values = vec!["甲".to_owned(), "乙丙".to_owned()];
|
||||
assert_eq!(@textLengths@(&values, "suffix").await, [7, 8]);
|
||||
assert_eq!(@textCopies@(values, "尾").await, ["甲尾", "乙丙尾"]);
|
||||
assert_eq!(@rangeValues@(4).await, [1, 2, 3, 4]);
|
||||
assert_eq!(@byteValues@(&Bytes::from_static(&[0, 255])).await, [1, 256]);
|
||||
let stream = AsyncStream::values(vec![0, 1, 2, 3]);
|
||||
assert_eq!(@streamValues@(&stream).await.unwrap(), [0, 2, 4, 6]);
|
||||
assert!(stream.next().await.unwrap().is_none());
|
||||
assert_eq!(@walked@(0).await.unwrap(), [0, 2, 4, 6]);
|
||||
assert_eq!(@asyncWalked@(0).await.unwrap(), [0, 2, 4, 6]);
|
||||
let failed = @failFast@(&[0, 1, 2]).await;
|
||||
assert!(matches!(failed, Err(Failure::@Trouble@(@Trouble@::Broken))));
|
||||
let stream = AsyncStream::values(vec![0, 1, 2]);
|
||||
assert!(@failedStream@(&stream).await.is_err());
|
||||
assert!(stream.next().await.unwrap().is_none());
|
||||
assert_eq!(@capturedInput@(vec!["a".into(), "b".into()]).await, ["a2", "b2"]);
|
||||
assert_eq!(@decimals@(&[Decimal::from_int(3), Decimal::from_int(6)]).await, [Decimal::from_int(1), Decimal::from_int(2)]);
|
||||
let stream = AsyncStream::values(vec![0, 2]);
|
||||
{
|
||||
use std::{future::{Future, poll_fn}, task::Poll};
|
||||
let mut pending = Box::pin(@failedStream@(&stream));
|
||||
poll_fn(|cx| { assert!(pending.as_mut().poll(cx).is_pending()); Poll::Ready(()) }).await;
|
||||
}
|
||||
assert!(stream.next().await.unwrap().is_none());
|
||||
assert_eq!(@textWalk@(@Cursor@ { f0: "state".into(), f1: 3 }).await, ["state", "state", "state"]);
|
||||
assert_eq!(@asyncTextWalk@(@Cursor@ { f0: "state".into(), f1: 3 }).await.unwrap(), ["state", "state", "state"]);
|
||||
}).unwrap();
|
||||
assert_eq!(task::run(true, 2, async |scope| Ok::<_, ()>(@spawned@(scope, &[0, 1, 2]).await)).unwrap().unwrap(), [1, 2, 3]);
|
||||
assert_eq!(task::run(true, 2, async |scope| @children@(scope, &[0, 1, 2, 3]).await).unwrap().unwrap(), [0, 2, 4, 6]);
|
||||
let fault = task::run(true, 2, async |_scope| Ok::<_, ()>(@faulted@(&[1], i64::MAX).await)).unwrap().unwrap_err();
|
||||
let task::RunError::Fault { primary, additional } = fault else { panic!("original fault required") };
|
||||
assert!(additional.is_empty());
|
||||
assert_eq!(primary.downcast_ref::<&'static FaultInfo>().unwrap().source, @source_path@);
|
||||
Reference in new issue
Block a user