2022-08-05 04:41:00 +00:00
|
|
|
//! Test that a `tracked` fn on a `salsa::input`
|
|
|
|
//! compiles and executes successfully.
|
|
|
|
|
2024-07-16 10:04:01 +00:00
|
|
|
#[salsa::input]
|
2022-08-05 04:41:00 +00:00
|
|
|
struct MyInput {
|
|
|
|
field: u32,
|
|
|
|
}
|
|
|
|
|
2024-07-16 10:04:01 +00:00
|
|
|
#[salsa::tracked]
|
2024-05-24 01:16:30 +00:00
|
|
|
struct MyTracked<'db> {
|
2022-08-05 04:41:00 +00:00
|
|
|
field: u32,
|
|
|
|
}
|
|
|
|
|
2024-07-16 10:04:01 +00:00
|
|
|
#[salsa::tracked]
|
2024-07-19 13:13:48 +00:00
|
|
|
fn tracked_fn(db: &dyn salsa::Database, input: MyInput) -> MyTracked<'_> {
|
2022-08-05 04:41:00 +00:00
|
|
|
MyTracked::new(db, input.field(db) * 2)
|
|
|
|
}
|
|
|
|
|
2022-08-06 06:26:22 +00:00
|
|
|
#[test]
|
|
|
|
fn execute() {
|
2024-07-27 12:29:41 +00:00
|
|
|
let db = salsa::DatabaseImpl::new();
|
2022-09-03 21:48:24 +00:00
|
|
|
let input = MyInput::new(&db, 22);
|
2022-08-05 04:41:00 +00:00
|
|
|
assert_eq!(tracked_fn(&db, input).field(&db), 44);
|
|
|
|
}
|