use dever_runtime::task::{self, RunError}; let value = String::from("move to the worker"); let address = value.as_ptr() as usize; let result = task::run(true, 1, async |scope| Ok::<_, ()>(@text@(scope, value).await)).unwrap().unwrap(); assert_eq!(result.as_ptr() as usize, address); assert_eq!(task::run(true, 1, async |scope| Ok::<_, ()>(@borrowed@(scope, "hello".into()).await)).unwrap().unwrap(), 5); assert_eq!(task::run(true, 1, async |scope| Ok::<_, ()>(@multiple@(scope, 20).await)).unwrap().unwrap(), 41); assert_eq!(task::run(true, 1, async |scope| Ok::<_, ()>(@handled@(scope).await)).unwrap().unwrap(), 41); assert_eq!(task::run(true, 1, async |scope| Ok::<_, ()>(@together@(scope).await)).unwrap().unwrap(), 62); assert_eq!(task::run(true, 1, async |scope| Ok::<_, ()>(@captured@(scope, 42).await)).unwrap().unwrap(), 42); assert_eq!(task::run(true, 1, async |scope| Ok::<_, ()>(@captured@(scope, 0).await)).unwrap().unwrap(), -1); assert_eq!(task::run(true, 1, async |scope| Ok::<_, ()>(@capturedNever@(scope).await)).unwrap().unwrap(), -1); assert!(matches!(task::run(true, 1, async |scope| @neverReturns@(scope).await).unwrap(), Err(RunError::Business { .. }))); assert!(matches!(task::run(true, 1, async |scope| @argumentFailure@(scope, 0).await).unwrap(), Err(RunError::Business { .. }))); assert_eq!(task::run(true, 1, async |scope| @nested@(scope, 42).await).unwrap().unwrap(), 42); match task::run(true, 1, async |scope| Ok::<_, ()>(@multiple@(scope, i64::MAX).await)).unwrap() { Err(RunError::Fault { primary, additional }) => { assert_eq!(primary.downcast_ref::<&'static FaultInfo>().unwrap().source, @source_path@); assert!(additional.is_empty()); } _ => panic!("expected original arithmetic fault"), }