add some tests about setting with same value

This commit is contained in:
Niko Matsakis 2018-10-11 04:59:07 -04:00
parent 5e381f314b
commit a0c983403d
2 changed files with 26 additions and 0 deletions

View file

@ -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();

View file

@ -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(&[]);
}