135 lines
4.7 KiB
Rust
135 lines
4.7 KiB
Rust
use std::process::Command;
|
|
use std::fs;
|
|
|
|
fn main() {
|
|
println!("Complex Tensor Implementation Validation");
|
|
println!("=========================================");
|
|
|
|
// Test compilation first
|
|
println!("\n1. Testing compilation...");
|
|
|
|
let output = Command::new("rustc")
|
|
.arg("--crate-type")
|
|
.arg("lib")
|
|
.arg("--edition")
|
|
.arg("2021")
|
|
.arg("-L")
|
|
.arg("crates/rtx-tensor/target/debug/deps")
|
|
.arg("crates/rtx-tensor/src/lib.rs")
|
|
.arg("-o")
|
|
.arg("/tmp/test_complex_tensor.rlib")
|
|
.output();
|
|
|
|
match output {
|
|
Ok(result) => {
|
|
if result.status.success() {
|
|
println!("✅ Compilation successful!");
|
|
} else {
|
|
println!("❌ Compilation failed:");
|
|
println!("stderr: {}", String::from_utf8_lossy(&result.stderr));
|
|
println!("stdout: {}", String::from_utf8_lossy(&result.stdout));
|
|
return;
|
|
}
|
|
}
|
|
Err(e) => {
|
|
println!("❌ Failed to run rustc: {}", e);
|
|
return;
|
|
}
|
|
}
|
|
|
|
// Test that key files exist
|
|
println!("\n2. Checking file structure...");
|
|
|
|
let required_files = [
|
|
"crates/rtx-tensor/src/complex/mod.rs",
|
|
"crates/rtx-tensor/src/complex/tensor.rs",
|
|
"crates/rtx-tensor/src/complex/complex_tensor_tests.rs",
|
|
];
|
|
|
|
for file in &required_files {
|
|
if fs::metadata(file).is_ok() {
|
|
println!("✅ {} exists", file);
|
|
} else {
|
|
println!("❌ {} missing", file);
|
|
}
|
|
}
|
|
|
|
// Count lines of code
|
|
println!("\n3. Implementation statistics...");
|
|
|
|
let tensor_file = "crates/rtx-tensor/src/complex/tensor.rs";
|
|
if let Ok(content) = fs::read_to_string(tensor_file) {
|
|
let line_count = content.lines().count();
|
|
println!("✅ ComplexTensor implementation: {} lines", line_count);
|
|
|
|
if line_count > 850 {
|
|
println!("⚠️ Warning: File exceeds 850 lines ({} lines)", line_count);
|
|
} else {
|
|
println!("✅ File size within limit (under 850 lines)");
|
|
}
|
|
}
|
|
|
|
let test_file = "crates/rtx-tensor/src/complex/complex_tensor_tests.rs";
|
|
if let Ok(content) = fs::read_to_string(test_file) {
|
|
let line_count = content.lines().count();
|
|
let test_count = content.matches("#[test]").count();
|
|
println!("✅ Test file: {} lines, {} tests", line_count, test_count);
|
|
}
|
|
|
|
// Check feature completeness by counting implementations
|
|
println!("\n4. Feature completeness check...");
|
|
|
|
if let Ok(content) = fs::read_to_string(tensor_file) {
|
|
let features = [
|
|
("zeros", content.contains("fn zeros")),
|
|
("ones", content.contains("fn ones")),
|
|
("from_real_imag", content.contains("fn from_real_imag")),
|
|
("from_polar", content.contains("fn from_polar")),
|
|
("add", content.contains("fn add")),
|
|
("sub", content.contains("fn sub")),
|
|
("mul", content.contains("fn mul")),
|
|
("div", content.contains("fn div")),
|
|
("conjugate", content.contains("fn conjugate")),
|
|
("magnitude", content.contains("fn magnitude")),
|
|
("phase", content.contains("fn phase")),
|
|
("exp", content.contains("fn exp")),
|
|
("fft", content.contains("fn fft")),
|
|
("ifft", content.contains("fn ifft")),
|
|
];
|
|
|
|
for (feature, implemented) in &features {
|
|
if *implemented {
|
|
println!("✅ {} implemented", feature);
|
|
} else {
|
|
println!("❌ {} missing", feature);
|
|
}
|
|
}
|
|
}
|
|
|
|
println!("\n5. TDD Methodology Validation...");
|
|
|
|
if let Ok(content) = fs::read_to_string(test_file) {
|
|
let has_creation_tests = content.contains("test_complex_tensor_zeros");
|
|
let has_arithmetic_tests = content.contains("test_complex_tensor_add");
|
|
let has_fft_tests = content.contains("test_complex_tensor_fft");
|
|
|
|
if has_creation_tests && has_arithmetic_tests && has_fft_tests {
|
|
println!("✅ TDD approach: Tests written first ✅");
|
|
} else {
|
|
println!("❌ TDD validation incomplete");
|
|
}
|
|
}
|
|
|
|
println!("\n6. Integration Check...");
|
|
|
|
if let Ok(content) = fs::read_to_string("crates/rtx-tensor/src/lib.rs") {
|
|
if content.contains("pub use complex::") {
|
|
println!("✅ Complex module exported in lib.rs");
|
|
} else {
|
|
println!("❌ Complex module not exported");
|
|
}
|
|
}
|
|
|
|
println!("\nValidation Complete!");
|
|
println!("====================");
|
|
} |