aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-01-14 11:16:48 +0000
committerAleksey Kladov <[email protected]>2020-01-15 15:52:28 +0000
commit35bfeaf4af4bcccf355f1e0e1a38547a2982a251 (patch)
tree7e972f3d3f4873e6ce401140c41587b72a616e00 /crates/ra_ide
parentc640c2ea114f21bc6e4913dac38cdc451c41ceae (diff)
Add a test
Diffstat (limited to 'crates/ra_ide')
-rw-r--r--crates/ra_ide/src/syntax_highlighting.rs23
1 files changed, 20 insertions, 3 deletions
diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs
index fd422d07c..0cacc58d4 100644
--- a/crates/ra_ide/src/syntax_highlighting.rs
+++ b/crates/ra_ide/src/syntax_highlighting.rs
@@ -310,9 +310,12 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
310 310
311#[cfg(test)] 311#[cfg(test)]
312mod tests { 312mod tests {
313 use crate::mock_analysis::single_file; 313 use std::fs;
314
314 use test_utils::{assert_eq_text, project_dir, read_text}; 315 use test_utils::{assert_eq_text, project_dir, read_text};
315 316
317 use crate::mock_analysis::{single_file, MockAnalysis};
318
316 #[test] 319 #[test]
317 fn te3st_highlighting() { 320 fn te3st_highlighting() {
318 let (analysis, file_id) = single_file( 321 let (analysis, file_id) = single_file(
@@ -359,7 +362,7 @@ impl<X> E<X> {
359 let dst_file = project_dir().join("crates/ra_ide/src/snapshots/highlighting.html"); 362 let dst_file = project_dir().join("crates/ra_ide/src/snapshots/highlighting.html");
360 let actual_html = &analysis.highlight_as_html(file_id, false).unwrap(); 363 let actual_html = &analysis.highlight_as_html(file_id, false).unwrap();
361 let expected_html = &read_text(&dst_file); 364 let expected_html = &read_text(&dst_file);
362 std::fs::write(dst_file, &actual_html).unwrap(); 365 fs::write(dst_file, &actual_html).unwrap();
363 assert_eq_text!(expected_html, actual_html); 366 assert_eq_text!(expected_html, actual_html);
364 } 367 }
365 368
@@ -385,7 +388,21 @@ fn bar() {
385 let dst_file = project_dir().join("crates/ra_ide/src/snapshots/rainbow_highlighting.html"); 388 let dst_file = project_dir().join("crates/ra_ide/src/snapshots/rainbow_highlighting.html");
386 let actual_html = &analysis.highlight_as_html(file_id, true).unwrap(); 389 let actual_html = &analysis.highlight_as_html(file_id, true).unwrap();
387 let expected_html = &read_text(&dst_file); 390 let expected_html = &read_text(&dst_file);
388 std::fs::write(dst_file, &actual_html).unwrap(); 391 fs::write(dst_file, &actual_html).unwrap();
389 assert_eq_text!(expected_html, actual_html); 392 assert_eq_text!(expected_html, actual_html);
390 } 393 }
394
395 #[test]
396 fn accidentally_quadratic() {
397 let file = project_dir().join("crates/ra_syntax/test_data/accidentally_quadratic");
398 let src = fs::read_to_string(file).unwrap();
399
400 let mut mock = MockAnalysis::new();
401 let file_id = mock.add_file("/main.rs", &src);
402 let host = mock.analysis_host();
403
404 // let t = std::time::Instant::now();
405 let _ = host.analysis().highlight(file_id).unwrap();
406 // eprintln!("elapsed: {:?}", t.elapsed());
407 }
391} 408}