From 35bfeaf4af4bcccf355f1e0e1a38547a2982a251 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 14 Jan 2020 12:16:48 +0100 Subject: Add a test --- crates/ra_ide/src/syntax_highlighting.rs | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'crates/ra_ide/src') 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 #[cfg(test)] mod tests { - use crate::mock_analysis::single_file; + use std::fs; + use test_utils::{assert_eq_text, project_dir, read_text}; + use crate::mock_analysis::{single_file, MockAnalysis}; + #[test] fn te3st_highlighting() { let (analysis, file_id) = single_file( @@ -359,7 +362,7 @@ impl E { let dst_file = project_dir().join("crates/ra_ide/src/snapshots/highlighting.html"); let actual_html = &analysis.highlight_as_html(file_id, false).unwrap(); let expected_html = &read_text(&dst_file); - std::fs::write(dst_file, &actual_html).unwrap(); + fs::write(dst_file, &actual_html).unwrap(); assert_eq_text!(expected_html, actual_html); } @@ -385,7 +388,21 @@ fn bar() { let dst_file = project_dir().join("crates/ra_ide/src/snapshots/rainbow_highlighting.html"); let actual_html = &analysis.highlight_as_html(file_id, true).unwrap(); let expected_html = &read_text(&dst_file); - std::fs::write(dst_file, &actual_html).unwrap(); + fs::write(dst_file, &actual_html).unwrap(); assert_eq_text!(expected_html, actual_html); } + + #[test] + fn accidentally_quadratic() { + let file = project_dir().join("crates/ra_syntax/test_data/accidentally_quadratic"); + let src = fs::read_to_string(file).unwrap(); + + let mut mock = MockAnalysis::new(); + let file_id = mock.add_file("/main.rs", &src); + let host = mock.analysis_host(); + + // let t = std::time::Instant::now(); + let _ = host.analysis().highlight(file_id).unwrap(); + // eprintln!("elapsed: {:?}", t.elapsed()); + } } -- cgit v1.2.3