2022-08-28 12:43:14 +00:00
|
|
|
//! Test that a constant `tracked` fn (has no inputs)
|
|
|
|
//! compiles and executes successfully.
|
|
|
|
#![allow(warnings)]
|
|
|
|
|
2024-08-20 19:34:38 +00:00
|
|
|
use crate::common::LogDatabase;
|
|
|
|
|
|
|
|
mod common;
|
|
|
|
|
2022-09-03 15:55:31 +00:00
|
|
|
#[salsa::tracked]
|
2024-07-17 10:41:56 +00:00
|
|
|
fn tracked_fn(db: &dyn salsa::Database) -> u32 {
|
2022-08-28 12:43:14 +00:00
|
|
|
44
|
|
|
|
}
|
|
|
|
|
2024-08-20 19:34:38 +00:00
|
|
|
#[salsa::tracked]
|
|
|
|
fn tracked_custom_db(db: &dyn LogDatabase) -> u32 {
|
|
|
|
44
|
|
|
|
}
|
|
|
|
|
2022-08-28 12:43:14 +00:00
|
|
|
#[test]
|
|
|
|
fn execute() {
|
2024-07-27 12:29:41 +00:00
|
|
|
let mut db = salsa::DatabaseImpl::new();
|
2022-08-28 12:43:14 +00:00
|
|
|
assert_eq!(tracked_fn(&db), 44);
|
|
|
|
}
|
2024-08-20 19:34:38 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn execute_custom() {
|
|
|
|
let mut db = common::LoggerDatabase::new();
|
|
|
|
assert_eq!(tracked_custom_db(&db), 44);
|
|
|
|
}
|