update test: don't need mut reference when create inputs

This commit is contained in:
XFFXFF 2022-09-25 01:23:36 +00:00
parent cc6ab647fa
commit a8e16a72d2
3 changed files with 9 additions and 9 deletions

View file

@ -91,7 +91,7 @@ fn basic() {
let mut db = Database::default(); let mut db = Database::default();
// Creates 3 tracked structs // Creates 3 tracked structs
let input = MyInput::new(&mut db, 3); let input = MyInput::new(&db, 3);
assert_eq!(final_result(&db, input), 2 * 2 + 2); assert_eq!(final_result(&db, input), 2 * 2 + 2);
db.assert_logs(expect![[r#" db.assert_logs(expect![[r#"
[ [

View file

@ -35,7 +35,7 @@ impl Db for Database {}
fn execute() { fn execute() {
let mut db = Database::default(); let mut db = Database::default();
let input = MyInput::new(&mut db, 22); let input = MyInput::new(&db, 22);
let tracked = tracked_fn(&db, input); let tracked = tracked_fn(&db, input);
// modify the input and change the revision // modify the input and change the revision

View file

@ -39,8 +39,8 @@ impl HasLogger for Database {
#[test] #[test]
fn basic() { fn basic() {
let mut db = Database::default(); let db = Database::default();
let input1 = MyInput::new(&mut db, 3, 4); let input1 = MyInput::new(&db, 3, 4);
let input2 = MyInput::get(&db); let input2 = MyInput::get(&db);
assert_eq!(input1, input2); assert_eq!(input1, input2);
@ -52,20 +52,20 @@ fn basic() {
#[test] #[test]
#[should_panic] #[should_panic]
fn twice() { fn twice() {
let mut db = Database::default(); let db = Database::default();
let input1 = MyInput::new(&mut db, 3, 4); let input1 = MyInput::new(&db, 3, 4);
let input2 = MyInput::get(&db); let input2 = MyInput::get(&db);
assert_eq!(input1, input2); assert_eq!(input1, input2);
// should panic here // should panic here
_ = MyInput::new(&mut db, 3, 5); _ = MyInput::new(&db, 3, 5);
} }
#[test] #[test]
fn debug() { fn debug() {
let mut db = Database::default(); let db = Database::default();
let input = MyInput::new(&mut db, 3, 4); let input = MyInput::new(&db, 3, 4);
let actual = format!("{:?}", input.debug(&db)); let actual = format!("{:?}", input.debug(&db));
let expected = expect![[r#"MyInput { [salsa id]: 0, id_field: 4 }"#]]; let expected = expect![[r#"MyInput { [salsa id]: 0, id_field: 4 }"#]];
expected.assert_eq(&actual); expected.assert_eq(&actual);