//! RED PHASE: Failing tests that define exact behavior expected for error conversion use anyhow::Error; use rtx_eval::error::RTXEvalError; #[cfg(test)] mod error_conversion_tests { use super::*; /// TEST: RTXEvalError should convert from anyhow::Error seamlessly /// This test defines the expected behavior for anyhow integration #[test] fn test_rtx_error_from_anyhow_error() { let anyhow_error = anyhow::anyhow!("Test validation error"); // This should compile and work - currently fails let rtx_error: RTXEvalError = anyhow_error.into(); // Should be wrapped as ValidationError match rtx_error { RTXEvalError::ValidationError { message } => { assert!(message.contains("Test validation error")); } _ => panic!("Expected ValidationError variant"), } } /// TEST: RTXEvalResult should work with ? operator from anyhow functions #[test] fn test_anyhow_question_mark_operator() { fn returns_anyhow_error() -> anyhow::Result<()> { Err(anyhow::anyhow!("Anyhow error")) } fn uses_rtx_result() -> rtx_eval::RTXEvalResult<()> { returns_anyhow_error()?; // This should work after implementing From Ok(()) } let result = uses_rtx_result(); assert!(result.is_err()); match result.unwrap_err() { RTXEvalError::ValidationError { .. } => {} // Expected _ => panic!("Wrong error type"), } } /// TEST: Chain of error conversions should preserve context #[test] fn test_error_chain_preservation() { let io_error = std::io::Error::new(std::io::ErrorKind::NotFound, "File not found"); let anyhow_error = anyhow::Error::from(io_error).context("Failed to read benchmark data"); let rtx_error: RTXEvalError = anyhow_error.into(); // Should preserve error context let error_string = format!("{}", rtx_error); assert!(error_string.contains("Failed to read benchmark data")); } }