2022-09-14 13:45:59 +00:00
|
|
|
#![allow(warnings)]
|
|
|
|
|
|
|
|
use expect_test::expect;
|
|
|
|
use salsa::DebugWithDb;
|
|
|
|
|
|
|
|
#[salsa::jar(db = Db)]
|
|
|
|
struct Jar(MyInput);
|
|
|
|
|
|
|
|
trait Db: salsa::DbWithJar<Jar> {}
|
|
|
|
|
2022-11-04 23:37:18 +00:00
|
|
|
#[derive(Clone, Debug)]
|
|
|
|
struct Field {}
|
|
|
|
|
2022-09-14 13:45:59 +00:00
|
|
|
#[salsa::input(jar = Jar)]
|
|
|
|
struct MyInput {
|
|
|
|
#[id]
|
|
|
|
id_one: u32,
|
|
|
|
#[id]
|
|
|
|
id_two: u16,
|
2022-11-04 23:37:18 +00:00
|
|
|
|
|
|
|
field: Field,
|
2022-09-14 13:45:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[salsa::db(Jar)]
|
|
|
|
#[derive(Default)]
|
|
|
|
struct Database {
|
|
|
|
storage: salsa::Storage<Self>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl salsa::Database for Database {}
|
|
|
|
|
|
|
|
impl Db for Database {}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_debug() {
|
|
|
|
let mut db = Database::default();
|
|
|
|
|
2022-11-04 23:37:18 +00:00
|
|
|
let input = MyInput::new(&mut db, 50, 10, Field {});
|
2022-09-14 13:45:59 +00:00
|
|
|
|
|
|
|
let actual = format!("{:?}", input.debug(&db));
|
2024-04-03 09:59:11 +00:00
|
|
|
let expected = expect!["MyInput { [salsa id]: 0, id_one: 50, id_two: 10, field: Field }"];
|
2022-09-14 13:45:59 +00:00
|
|
|
expected.assert_eq(&actual);
|
|
|
|
}
|
2022-11-04 23:37:18 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_set() {
|
|
|
|
let mut db = Database::default();
|
|
|
|
let input = MyInput::new(&mut db, 50, 10, Field {});
|
|
|
|
input.set_field(&mut db).to(Field {});
|
|
|
|
}
|