mirror of
https://github.com/salsa-rs/salsa.git
synced 2025-02-02 09:46:06 +00:00
Add test for durability
This commit is contained in:
parent
e1f162742d
commit
8d956a8229
1 changed files with 37 additions and 0 deletions
|
@ -4,6 +4,7 @@ use std::panic::{RefUnwindSafe, UnwindSafe};
|
||||||
|
|
||||||
use expect_test::expect;
|
use expect_test::expect;
|
||||||
use salsa::storage::HasJarsDyn;
|
use salsa::storage::HasJarsDyn;
|
||||||
|
use salsa::Durability;
|
||||||
|
|
||||||
// Axes:
|
// Axes:
|
||||||
//
|
//
|
||||||
|
@ -40,6 +41,7 @@ use salsa::storage::HasJarsDyn;
|
||||||
// | Intra | Fallback | Both | Tracked | direct | cycle_revalidate |
|
// | Intra | Fallback | Both | Tracked | direct | cycle_revalidate |
|
||||||
// | Intra | Fallback | New | Tracked | direct | cycle_appears |
|
// | Intra | Fallback | New | Tracked | direct | cycle_appears |
|
||||||
// | Intra | Fallback | Old | Tracked | direct | cycle_disappears |
|
// | Intra | Fallback | Old | Tracked | direct | cycle_disappears |
|
||||||
|
// | Intra | Fallback | Old | Tracked | direct | cycle_disappears_durability |
|
||||||
// | Intra | Mixed | N/A | Tracked | direct | cycle_mixed_1 |
|
// | Intra | Mixed | N/A | Tracked | direct | cycle_mixed_1 |
|
||||||
// | Intra | Mixed | N/A | Tracked | direct | cycle_mixed_2 |
|
// | Intra | Mixed | N/A | Tracked | direct | cycle_mixed_2 |
|
||||||
// | Cross | Panic | N/A | Tracked | both | parallel/parallel_cycle_none_recover.rs |
|
// | Cross | Panic | N/A | Tracked | both | parallel/parallel_cycle_none_recover.rs |
|
||||||
|
@ -295,6 +297,41 @@ fn cycle_disappears() {
|
||||||
assert!(cycle_a(&db, abc).is_ok());
|
assert!(cycle_a(&db, abc).is_ok());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A variant on `cycle_disappears` in which the values of
|
||||||
|
/// `a` and `b` are set with durability values.
|
||||||
|
/// If we are not careful, this could cause us to overlook
|
||||||
|
/// the fact that the cycle will no longer occur.
|
||||||
|
#[test]
|
||||||
|
fn cycle_disappears_durability() {
|
||||||
|
let mut db = Database::default();
|
||||||
|
let abc = ABC::new(
|
||||||
|
&mut db,
|
||||||
|
CycleQuery::None,
|
||||||
|
CycleQuery::None,
|
||||||
|
CycleQuery::None,
|
||||||
|
);
|
||||||
|
abc.set_a(&mut db)
|
||||||
|
.with_durability(Durability::LOW)
|
||||||
|
.to(CycleQuery::B);
|
||||||
|
abc.set_b(&mut db)
|
||||||
|
.with_durability(Durability::HIGH)
|
||||||
|
.to(CycleQuery::A);
|
||||||
|
|
||||||
|
assert!(cycle_a(&db, abc).is_err());
|
||||||
|
|
||||||
|
// At this point, `a` read `LOW` input, and `b` read `HIGH` input. However,
|
||||||
|
// because `b` participates in the same cycle as `a`, its final durability
|
||||||
|
// should be `LOW`.
|
||||||
|
//
|
||||||
|
// Check that setting a `LOW` input causes us to re-execute `b` query, and
|
||||||
|
// observe that the cycle goes away.
|
||||||
|
abc.set_a(&mut db)
|
||||||
|
.with_durability(Durability::LOW)
|
||||||
|
.to(CycleQuery::None);
|
||||||
|
|
||||||
|
assert!(cycle_b(&mut db, abc).is_ok());
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn cycle_mixed_1() {
|
fn cycle_mixed_1() {
|
||||||
let mut db = Database::default();
|
let mut db = Database::default();
|
||||||
|
|
Loading…
Reference in a new issue