mirror of
https://github.com/salsa-rs/salsa.git
synced 2025-01-12 16:35:21 +00:00
add some tests about setting with same value
This commit is contained in:
parent
5e381f314b
commit
a0c983403d
2 changed files with 26 additions and 0 deletions
|
@ -43,6 +43,15 @@ fn invalidate_constant_1() {
|
|||
db.query(ConstantsInput).set_constant('a', 66);
|
||||
}
|
||||
|
||||
/// Test that use can still `set` an input that is constant, so long
|
||||
/// as you don't change the value.
|
||||
#[test]
|
||||
fn set_after_constant_same_value() {
|
||||
let db = &TestContextImpl::default();
|
||||
db.query(ConstantsInput).set_constant('a', 44);
|
||||
db.query(ConstantsInput).set('a', 44);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn not_constant() {
|
||||
let db = &TestContextImpl::default();
|
||||
|
|
|
@ -60,3 +60,20 @@ fn revalidate() {
|
|||
assert_eq!(v, 66);
|
||||
db.assert_log(&[]);
|
||||
}
|
||||
|
||||
/// Test that invoking `set` on an input with the same value does not
|
||||
/// trigger a new revision.
|
||||
#[test]
|
||||
fn set_after_no_change() {
|
||||
let db = &TestContextImpl::default();
|
||||
|
||||
db.query(Input1).set((), 44);
|
||||
let v = db.max(());
|
||||
assert_eq!(v, 44);
|
||||
db.assert_log(&["Max invoked"]);
|
||||
|
||||
db.query(Input1).set((), 44);
|
||||
let v = db.max(());
|
||||
assert_eq!(v, 44);
|
||||
db.assert_log(&[]);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue