Dever v0.0.2

This commit is contained in:
Codex committed 2026-11-27 06:03:56 +00:00
commit e6e175ebcf
816 files changed
+120349

No files matched your search

+29
View File
@@ -0,0 +1,29 @@
use dever_runtime::{task::{self, RunError}, value::secret::Secret};
let password = Secret::from_input(b"test-only-password".to_vec());
let hash = task::run(true, 1, async |scope| @hash@(scope, password.clone()).await).unwrap().unwrap();
assert!(hash.starts_with("$argon2id$v=19$m=19456,t=2,p=1$"));
assert!(task::run(true, 1, async |scope| @verify@(scope, password.clone(), hash.clone()).await).unwrap().unwrap());
assert!(task::run(true, 1, async |scope| @spawned@(scope, password.clone(), hash.clone()).await).unwrap().unwrap());
assert_eq!(task::run(true, 1, async |scope| @multiple@(scope, password.clone(), hash.clone()).await).unwrap().unwrap(), hash.len() as i64);
assert!(task::run(true, 1, async |scope| @handled@(scope, password.clone(), hash.clone()).await).unwrap().unwrap());
assert!(task::run(true, 1, async |scope| @together@(scope, password.clone(), hash.clone()).await).unwrap().unwrap());
task::run(true, 1, async |scope| @grouped@(scope, password.clone(), hash.clone()).await).unwrap().unwrap();
assert!(!task::run(true, 1, async |scope| Ok::<_, ()>(@captured@(scope, password.clone(), "invalid".into()).await)).unwrap().unwrap());
assert!(matches!(task::run(true, 1, async |scope| @argumentFailure@(scope, password.clone(), String::new()).await).unwrap(), Err(RunError::Business { .. })));
for spawned in [false, true] {
match task::run(true, 1, async |scope| {
if spawned { @spawnedOverflow@(scope, password.clone(), hash.clone(), i64::MAX).await }
else { @overflow@(scope, password.clone(), hash.clone(), 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"),
}
}
let path = std::path::Path::new(@source_path@).with_extension("json");
std::fs::write(&path, format!(r#"{{"module":{{"main":{{"main":{{"password":"test-only-password","saved_hash":"{hash}"}}}}}}}}"#)).unwrap();
let settings = load_settings(&path).unwrap();
assert!(task::run(true, 1, async |scope| @configured@(scope, &settings).await).unwrap().unwrap());
assert_eq!(std::sync::Arc::strong_count(&settings), 1);