mirror of
https://github.com/salsa-rs/salsa.git
synced 2025-01-22 21:05:11 +00:00
fix typos: deponds -> depends
This commit is contained in:
parent
6645774d55
commit
31a4c68fc7
2 changed files with 29 additions and 29 deletions
|
@ -11,8 +11,8 @@ use expect_test::expect;
|
|||
struct Jar(
|
||||
MyInput,
|
||||
MyTracked,
|
||||
final_result_deponds_on_x,
|
||||
final_result_deponds_on_y,
|
||||
final_result_depends_on_x,
|
||||
final_result_depends_on_y,
|
||||
intermediate_result,
|
||||
);
|
||||
|
||||
|
@ -24,14 +24,14 @@ struct MyInput {
|
|||
}
|
||||
|
||||
#[salsa::tracked(jar = Jar)]
|
||||
fn final_result_deponds_on_x(db: &dyn Db, input: MyInput) -> u32 {
|
||||
db.push_log(format!("final_result_deponds_on_x({:?})", input));
|
||||
fn final_result_depends_on_x(db: &dyn Db, input: MyInput) -> u32 {
|
||||
db.push_log(format!("final_result_depends_on_x({:?})", input));
|
||||
intermediate_result(db, input).x(db) * 2
|
||||
}
|
||||
|
||||
#[salsa::tracked(jar = Jar)]
|
||||
fn final_result_deponds_on_y(db: &dyn Db, input: MyInput) -> u32 {
|
||||
db.push_log(format!("final_result_deponds_on_y({:?})", input));
|
||||
fn final_result_depends_on_y(db: &dyn Db, input: MyInput) -> u32 {
|
||||
db.push_log(format!("final_result_depends_on_y({:?})", input));
|
||||
intermediate_result(db, input).y(db) * 2
|
||||
}
|
||||
|
||||
|
@ -71,39 +71,39 @@ impl HasLogger for Database {
|
|||
fn execute() {
|
||||
// x = (input.field + 1) / 2
|
||||
// y = input.field / 2
|
||||
// final_result_deponds_on_x = x * 2 = (input.field + 1) / 2 * 2
|
||||
// final_result_deponds_on_y = y * 2 = input.field / 2 * 2
|
||||
// final_result_depends_on_x = x * 2 = (input.field + 1) / 2 * 2
|
||||
// final_result_depends_on_y = y * 2 = input.field / 2 * 2
|
||||
let mut db = Database::default();
|
||||
|
||||
// intermediate results:
|
||||
// x = (22 + 1) / 2 = 11
|
||||
// y = 22 / 2 = 11
|
||||
let input = MyInput::new(&mut db, 22);
|
||||
assert_eq!(final_result_deponds_on_x(&db, input), 22);
|
||||
assert_eq!(final_result_depends_on_x(&db, input), 22);
|
||||
db.assert_logs(expect![[r#"
|
||||
[
|
||||
"final_result_deponds_on_x(MyInput(Id { value: 1 }))",
|
||||
"final_result_depends_on_x(MyInput(Id { value: 1 }))",
|
||||
]"#]]);
|
||||
|
||||
assert_eq!(final_result_deponds_on_y(&db, input), 22);
|
||||
assert_eq!(final_result_depends_on_y(&db, input), 22);
|
||||
db.assert_logs(expect![[r#"
|
||||
[
|
||||
"final_result_deponds_on_y(MyInput(Id { value: 1 }))",
|
||||
"final_result_depends_on_y(MyInput(Id { value: 1 }))",
|
||||
]"#]]);
|
||||
|
||||
input.set_field(&mut db, 23);
|
||||
// x = (23 + 1) / 2 = 12
|
||||
// Intermediate result x changes, so final result depends on x
|
||||
// needs to be recomputed;
|
||||
assert_eq!(final_result_deponds_on_x(&db, input), 24);
|
||||
assert_eq!(final_result_depends_on_x(&db, input), 24);
|
||||
db.assert_logs(expect![[r#"
|
||||
[
|
||||
"final_result_deponds_on_x(MyInput(Id { value: 1 }))",
|
||||
"final_result_depends_on_x(MyInput(Id { value: 1 }))",
|
||||
]"#]]);
|
||||
|
||||
// y = 23 / 2 = 11
|
||||
// Intermediate result y is the same, so final result depends on y
|
||||
// does not need to be recomputed;
|
||||
assert_eq!(final_result_deponds_on_y(&db, input), 22);
|
||||
assert_eq!(final_result_depends_on_y(&db, input), 22);
|
||||
db.assert_logs(expect!["[]"]);
|
||||
}
|
|
@ -8,7 +8,7 @@ use salsa_2022_tests::{HasLogger, Logger};
|
|||
use expect_test::expect;
|
||||
|
||||
#[salsa::jar(db = Db)]
|
||||
struct Jar(MyInput, result_deponds_on_x, result_deponds_on_y);
|
||||
struct Jar(MyInput, result_depends_on_x, result_depends_on_y);
|
||||
|
||||
trait Db: salsa::DbWithJar<Jar> + HasLogger {}
|
||||
|
||||
|
@ -19,14 +19,14 @@ struct MyInput {
|
|||
}
|
||||
|
||||
#[salsa::tracked(jar = Jar)]
|
||||
fn result_deponds_on_x(db: &dyn Db, input: MyInput) -> u32 {
|
||||
db.push_log(format!("result_deponds_on_x({:?})", input));
|
||||
fn result_depends_on_x(db: &dyn Db, input: MyInput) -> u32 {
|
||||
db.push_log(format!("result_depends_on_x({:?})", input));
|
||||
input.x(db) + 1
|
||||
}
|
||||
|
||||
#[salsa::tracked(jar = Jar)]
|
||||
fn result_deponds_on_y(db: &dyn Db, input: MyInput) -> u32 {
|
||||
db.push_log(format!("result_deponds_on_y({:?})", input));
|
||||
fn result_depends_on_y(db: &dyn Db, input: MyInput) -> u32 {
|
||||
db.push_log(format!("result_depends_on_y({:?})", input));
|
||||
input.y(db) - 1
|
||||
}
|
||||
|
||||
|
@ -53,33 +53,33 @@ impl HasLogger for Database {
|
|||
|
||||
#[test]
|
||||
fn execute() {
|
||||
// result_deponds_on_x = x + 1
|
||||
// result_deponds_on_y = y - 1
|
||||
// result_depends_on_x = x + 1
|
||||
// result_depends_on_y = y - 1
|
||||
let mut db = Database::default();
|
||||
|
||||
let input = MyInput::new(&mut db, 22, 33);
|
||||
assert_eq!(result_deponds_on_x(&db, input), 23);
|
||||
assert_eq!(result_depends_on_x(&db, input), 23);
|
||||
db.assert_logs(expect![[r#"
|
||||
[
|
||||
"result_deponds_on_x(MyInput(Id { value: 1 }))",
|
||||
"result_depends_on_x(MyInput(Id { value: 1 }))",
|
||||
]"#]]);
|
||||
|
||||
assert_eq!(result_deponds_on_y(&db, input), 32);
|
||||
assert_eq!(result_depends_on_y(&db, input), 32);
|
||||
db.assert_logs(expect![[r#"
|
||||
[
|
||||
"result_deponds_on_y(MyInput(Id { value: 1 }))",
|
||||
"result_depends_on_y(MyInput(Id { value: 1 }))",
|
||||
]"#]]);
|
||||
|
||||
input.set_x(&mut db, 23);
|
||||
// input x changes, so result depends on x needs to be recomputed;
|
||||
assert_eq!(result_deponds_on_x(&db, input), 24);
|
||||
assert_eq!(result_depends_on_x(&db, input), 24);
|
||||
db.assert_logs(expect![[r#"
|
||||
[
|
||||
"result_deponds_on_x(MyInput(Id { value: 1 }))",
|
||||
"result_depends_on_x(MyInput(Id { value: 1 }))",
|
||||
]"#]]);
|
||||
|
||||
// input y is the same, so result depends on y
|
||||
// does not need to be recomputed;
|
||||
assert_eq!(result_deponds_on_y(&db, input), 32);
|
||||
assert_eq!(result_depends_on_y(&db, input), 32);
|
||||
db.assert_logs(expect!["[]"]);
|
||||
}
|
Loading…
Reference in a new issue