aboutsummaryrefslogtreecommitdiff
path: root/crates/salsa/tests
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-09-12 20:30:48 +0100
committerAleksey Kladov <[email protected]>2018-09-15 22:00:05 +0100
commit60fdfec32759d5e006eae9fe09a87b1a28b19983 (patch)
tree1d92756db29c8bf4fcca33fdb2bb1b9041c53398 /crates/salsa/tests
parentcecc7ad5b20e693cb8d962187bd83b9ac234de97 (diff)
eager invalidation
Diffstat (limited to 'crates/salsa/tests')
-rw-r--r--crates/salsa/tests/integration.rs32
1 files changed, 24 insertions, 8 deletions
diff --git a/crates/salsa/tests/integration.rs b/crates/salsa/tests/integration.rs
index 2872d3913..3cec330e6 100644
--- a/crates/salsa/tests/integration.rs
+++ b/crates/salsa/tests/integration.rs
@@ -1,5 +1,6 @@
1extern crate salsa; 1extern crate salsa;
2use std::{ 2use std::{
3 iter::once,
3 sync::Arc, 4 sync::Arc,
4 collections::hash_map::{HashMap, DefaultHasher}, 5 collections::hash_map::{HashMap, DefaultHasher},
5 any::Any, 6 any::Any,
@@ -113,30 +114,45 @@ fn test_number_of_lines() {
113 assert_eq!(trace.len(), 0); 114 assert_eq!(trace.len(), 0);
114 115
115 state.insert(1, "hello\nworld".to_string()); 116 state.insert(1, "hello\nworld".to_string());
116 let db = db.with_ground_data(state.clone()); 117 let mut inv = salsa::Invalidations::new();
118 inv.invalidate(GET_TEXT, once(i_print(&1u32)));
119 inv.invalidate(GET_FILES, once(i_print(&())));
120 let db = db.with_ground_data(state.clone(), inv);
117 let (newlines, trace) = get::<(), usize>(&db, TOTAL_NEWLINES, ()); 121 let (newlines, trace) = get::<(), usize>(&db, TOTAL_NEWLINES, ());
118 assert_eq!(*newlines, 2); 122 assert_eq!(*newlines, 2);
119 assert_eq!(trace.len(), 4); 123 assert_eq!(trace.len(), 4);
120 124
121 state.insert(2, "spam\neggs".to_string()); 125 state.insert(2, "spam\neggs".to_string());
122 let db = db.with_ground_data(state.clone()); 126 let mut inv = salsa::Invalidations::new();
127 inv.invalidate(GET_TEXT, once(i_print(&2u32)));
128 inv.invalidate(GET_FILES, once(i_print(&())));
129 let db = db.with_ground_data(state.clone(), inv);
123 let (newlines, trace) = get::<(), usize>(&db, TOTAL_NEWLINES, ()); 130 let (newlines, trace) = get::<(), usize>(&db, TOTAL_NEWLINES, ());
124 assert_eq!(*newlines, 4); 131 assert_eq!(*newlines, 4);
125 assert_eq!(trace.len(), 5); 132 assert_eq!(trace.len(), 4);
126 133
134 let mut invs = vec![];
127 for i in 0..10 { 135 for i in 0..10 {
128 state.insert(i + 10, "spam".to_string()); 136 let id = i + 10;
137 invs.push(i_print(&id));
138 state.insert(id, "spam".to_string());
129 } 139 }
130 let db = db.with_ground_data(state.clone()); 140 let mut inv = salsa::Invalidations::new();
141 inv.invalidate(GET_TEXT, invs.into_iter());
142 inv.invalidate(GET_FILES, once(i_print(&())));
143 let db = db.with_ground_data(state.clone(), inv);
131 let (newlines, trace) = get::<(), usize>(&db, TOTAL_NEWLINES, ()); 144 let (newlines, trace) = get::<(), usize>(&db, TOTAL_NEWLINES, ());
132 assert_eq!(*newlines, 14); 145 assert_eq!(*newlines, 14);
133 assert_eq!(trace.len(), 24); 146 assert_eq!(trace.len(), 22);
134 147
135 state.insert(15, String::new()); 148 state.insert(15, String::new());
136 let db = db.with_ground_data(state.clone()); 149 let mut inv = salsa::Invalidations::new();
150 inv.invalidate(GET_TEXT, once(i_print(&15u32)));
151 inv.invalidate(GET_FILES, once(i_print(&())));
152 let db = db.with_ground_data(state.clone(), inv);
137 let (newlines, trace) = get::<(), usize>(&db, TOTAL_NEWLINES, ()); 153 let (newlines, trace) = get::<(), usize>(&db, TOTAL_NEWLINES, ());
138 assert_eq!(*newlines, 13); 154 assert_eq!(*newlines, 13);
139 assert_eq!(trace.len(), 15); 155 assert_eq!(trace.len(), 4);
140} 156}
141 157
142fn o_print<T: Hash>(x: &T) -> salsa::OutputFingerprint { 158fn o_print<T: Hash>(x: &T) -> salsa::OutputFingerprint {