mirror of
https://github.com/salsa-rs/salsa.git
synced 2025-01-23 05:07:27 +00:00
cd5622c6de
Use `Query.set(db, key, value)` to set. Not sure about this.
33 lines
703 B
Rust
33 lines
703 B
Rust
#![cfg(test)]
|
|
|
|
use crate::implementation::DatabaseImpl;
|
|
use crate::queries::Database;
|
|
|
|
#[test]
|
|
fn memoized_twice() {
|
|
let query = DatabaseImpl::default();
|
|
let v1 = query.memoized(());
|
|
let v2 = query.memoized(());
|
|
assert_eq!(v1, v2);
|
|
}
|
|
|
|
#[test]
|
|
fn volatile_twice() {
|
|
let query = DatabaseImpl::default();
|
|
let v1 = query.volatile(());
|
|
let v2 = query.volatile(());
|
|
assert_eq!(v1 + 1, v2);
|
|
}
|
|
|
|
#[test]
|
|
fn intermingled() {
|
|
let query = DatabaseImpl::default();
|
|
let v1 = query.volatile(());
|
|
let v2 = query.memoized(());
|
|
let v3 = query.volatile(());
|
|
let v4 = query.memoized(());
|
|
|
|
assert_eq!(v1 + 1, v2);
|
|
assert_eq!(v2 + 1, v3);
|
|
assert_eq!(v2, v4);
|
|
}
|