use super::*;
#[cfg_attr(coverage_nightly, coverage(off))]
#[cfg(test)]
mod graph_symbol_tests {
use super::*;
use std::fs;
use tempfile::TempDir;
fn create_test_project() -> TempDir {
let temp_dir = TempDir::new().expect("Failed to create temp dir");
let main_rs = temp_dir.path().join("main.rs");
fs::write(
&main_rs,
r#"
fn main() {
println!("Hello, world!");
}
fn complex_function(x: i32, y: i32) -> i32 {
if x > 0 {
if y > 0 { x + y } else { x - y }
} else {
-x
}
}
"#,
)
.expect("Failed to write main.rs");
temp_dir
}
#[tokio::test]
async fn test_handle_analyze_graph_metrics_basic() {
let temp_dir = create_test_project();
let result = handle_analyze_graph_metrics(
temp_dir.path().to_path_buf(),
vec![GraphMetricType::Centrality],
vec![],
0.85,
100,
1e-6,
false,
GraphMetricsOutputFormat::Summary,
None,
None,
None,
false,
10,
0.0,
)
.await;
let _ = result;
}
#[tokio::test]
async fn test_handle_analyze_graph_metrics_all_metrics() {
let temp_dir = create_test_project();
let result = handle_analyze_graph_metrics(
temp_dir.path().to_path_buf(),
vec![GraphMetricType::All],
vec![],
0.85,
100,
1e-6,
false,
GraphMetricsOutputFormat::Json,
None,
None,
None,
false,
10,
0.0,
)
.await;
let _ = result;
}
#[tokio::test]
async fn test_handle_analyze_graph_metrics_with_pagerank_seeds() {
let temp_dir = create_test_project();
let result = handle_analyze_graph_metrics(
temp_dir.path().to_path_buf(),
vec![GraphMetricType::PageRank],
vec!["main".to_string()],
0.85,
100,
1e-6,
false,
GraphMetricsOutputFormat::Summary,
None,
None,
None,
false,
10,
0.0,
)
.await;
let _ = result;
}
#[tokio::test]
async fn test_handle_analyze_graph_metrics_custom_damping() {
let temp_dir = create_test_project();
let result = handle_analyze_graph_metrics(
temp_dir.path().to_path_buf(),
vec![GraphMetricType::PageRank],
vec![],
0.90, 200, 1e-8, false,
GraphMetricsOutputFormat::Summary,
None,
None,
None,
false,
10,
0.0,
)
.await;
let _ = result;
}
#[tokio::test]
async fn test_handle_analyze_symbol_table_basic() {
let temp_dir = create_test_project();
let result = handle_analyze_symbol_table(
temp_dir.path().to_path_buf(),
SymbolTableOutputFormat::Summary,
None,
None,
vec![],
vec![],
false,
false,
None,
false,
)
.await;
let _ = result;
}
#[tokio::test]
async fn test_handle_analyze_symbol_table_json_format() {
let temp_dir = create_test_project();
let result = handle_analyze_symbol_table(
temp_dir.path().to_path_buf(),
SymbolTableOutputFormat::Json,
None,
None,
vec![],
vec![],
false,
false,
None,
false,
)
.await;
let _ = result;
}
#[tokio::test]
async fn test_handle_analyze_symbol_table_with_filter() {
let temp_dir = create_test_project();
let result = handle_analyze_symbol_table(
temp_dir.path().to_path_buf(),
SymbolTableOutputFormat::Summary,
Some(SymbolTypeFilter::Functions),
None,
vec![],
vec![],
false,
false,
None,
false,
)
.await;
let _ = result;
}
#[tokio::test]
async fn test_handle_analyze_symbol_table_with_query() {
let temp_dir = create_test_project();
let result = handle_analyze_symbol_table(
temp_dir.path().to_path_buf(),
SymbolTableOutputFormat::Summary,
None,
Some("main".to_string()),
vec![],
vec![],
false,
false,
None,
false,
)
.await;
let _ = result;
}
#[tokio::test]
async fn test_handle_analyze_symbol_table_show_unreferenced() {
let temp_dir = create_test_project();
let result = handle_analyze_symbol_table(
temp_dir.path().to_path_buf(),
SymbolTableOutputFormat::Detailed,
None,
None,
vec![],
vec![],
true, false,
None,
false,
)
.await;
let _ = result;
}
#[tokio::test]
async fn test_handle_analyze_symbol_table_show_references() {
let temp_dir = create_test_project();
let result = handle_analyze_symbol_table(
temp_dir.path().to_path_buf(),
SymbolTableOutputFormat::Detailed,
None,
None,
vec![],
vec![],
false,
true, None,
false,
)
.await;
let _ = result;
}
#[tokio::test]
async fn test_handle_analyze_symbol_table_all_filters() {
let temp_dir = create_test_project();
let filters = [
SymbolTypeFilter::Functions,
SymbolTypeFilter::Classes,
SymbolTypeFilter::Types,
SymbolTypeFilter::Variables,
SymbolTypeFilter::Modules,
SymbolTypeFilter::All,
];
for filter in filters {
let result = handle_analyze_symbol_table(
temp_dir.path().to_path_buf(),
SymbolTableOutputFormat::Summary,
Some(filter),
None,
vec![],
vec![],
false,
false,
None,
false,
)
.await;
let _ = result;
}
}
}
#[cfg_attr(coverage_nightly, coverage(off))]
#[cfg(test)]
mod property_tests {
use proptest::prelude::*;
proptest! {
#[test]
fn basic_property_stability(_input in ".*") {
prop_assert!(true);
}
#[test]
fn module_consistency_check(_x in 0u32..1000) {
prop_assert!(_x < 1001);
}
#[test]
fn test_period_days_reasonable(days in 1u32..365) {
prop_assert!(days > 0);
prop_assert!(days < 366);
}
#[test]
fn test_top_files_positive(top in 1usize..1000) {
prop_assert!(top > 0);
}
#[test]
fn test_confidence_threshold_valid(threshold in 0.0f32..1.0) {
prop_assert!(threshold >= 0.0);
prop_assert!(threshold <= 1.0);
}
#[test]
fn test_damping_factor_valid(damping in 0.0f32..1.0) {
prop_assert!(damping >= 0.0);
prop_assert!(damping <= 1.0);
}
#[test]
fn test_max_iterations_positive(iterations in 1usize..10000) {
prop_assert!(iterations > 0);
}
#[test]
fn test_min_lines_reasonable(lines in 1usize..100000) {
prop_assert!(lines > 0);
prop_assert!(lines < 100001);
}
#[test]
fn test_convergence_threshold_small(threshold in 1e-10f64..1e-3) {
prop_assert!(threshold > 0.0);
prop_assert!(threshold < 0.01);
}
#[test]
fn test_tdg_threshold_positive(threshold in 0.0f64..10.0) {
prop_assert!(threshold >= 0.0);
}
}
}