mirror of
https://github.com/salsa-rs/salsa.git
synced 2025-01-22 21:05:11 +00:00
Add a test for tracked function with multiple salsa struct args
This commit is contained in:
parent
2cae1ef5bb
commit
d34ed1495e
1 changed files with 25 additions and 0 deletions
25
tests/tracked_fn_multiple_args.rs
Normal file
25
tests/tracked_fn_multiple_args.rs
Normal file
|
@ -0,0 +1,25 @@
|
|||
//! Test that a `tracked` fn on multiple salsa struct args
|
||||
//! compiles and executes successfully.
|
||||
|
||||
#[salsa::input]
|
||||
struct MyInput {
|
||||
field: u32,
|
||||
}
|
||||
|
||||
#[salsa::interned]
|
||||
struct MyInterned<'db> {
|
||||
field: u32,
|
||||
}
|
||||
|
||||
#[salsa::tracked]
|
||||
fn tracked_fn<'db>(db: &'db dyn salsa::Database, input: MyInput, interned: MyInterned<'db>) -> u32 {
|
||||
input.field(db) + interned.field(db)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn execute() {
|
||||
let db = salsa::DatabaseImpl::new();
|
||||
let input = MyInput::new(&db, 22);
|
||||
let interned = MyInterned::new(&db, 33);
|
||||
assert_eq!(tracked_fn(&db, input, interned), 55);
|
||||
}
|
Loading…
Reference in a new issue