use super::*;
use std::fs;
use std::path::{Path, PathBuf};
use tempfile::TempDir;
use super::replay_handler::determine_output_path;
use super::transpile_handler::read_source_file;
use super::wasm_handler::{determine_wasm_output_path, parse_ruchy_source};
#[test]
fn test_handle_eval_command_basic() {
let result = handle_eval_command("2 + 2", false, "text", false);
assert!(result.is_ok());
}
#[test]
fn test_handle_eval_command_verbose() {
let result = handle_eval_command("42", true, "text", false);
assert!(result.is_ok());
}
#[test]
fn test_handle_eval_command_json_format() {
let result = handle_eval_command("1 + 1", false, "json", false);
assert!(result.is_ok());
}
#[test]
fn test_handle_eval_command_invalid_expr() {
let result = handle_eval_command("invalid++syntax", false, "text", false);
assert!(result.is_err());
}
#[test]
fn test_parse_ruchy_source_from_string() {
let temp_dir = TempDir::new().expect("Failed to create temporary test directory");
let file_path = temp_dir.path().join("test.ruchy");
fs::write(&file_path, "2 + 2")
.unwrap_or_else(|_| panic!("Failed to write test file: {}", file_path.display()));
let ast = parse_ruchy_source(&file_path).expect("parse_ruchy_source should succeed");
assert!(matches!(
ast.kind,
ruchy::frontend::ast::ExprKind::Binary { .. }
));
}
#[test]
fn test_parse_ruchy_source_from_file() {
let temp_dir = TempDir::new().expect("Failed to create temporary test directory");
let file_path = temp_dir.path().join("test.ruchy");
fs::write(&file_path, "let x = 42")
.unwrap_or_else(|_| panic!("Failed to write test file: {}", file_path.display()));
let ast = parse_ruchy_source(&file_path).expect("parse_ruchy_source should succeed");
assert!(matches!(
ast.kind,
ruchy::frontend::ast::ExprKind::Let { .. }
));
}
#[test]
fn test_read_source_from_file() {
let temp_dir = TempDir::new().expect("Failed to create temporary test directory");
let file_path = temp_dir.path().join("test.ruchy");
let content = "fun hello() { 42 }";
fs::write(&file_path, content)
.unwrap_or_else(|_| panic!("Failed to write test file: {}", file_path.display()));
let result = read_source_file(&file_path, false).expect("read_source_file should succeed");
assert_eq!(result, content);
}
#[test]
fn test_read_source_from_stdin() {
}
#[test]
fn test_determine_output_path_explicit() {
let output = determine_output_path(Some(Path::new("output.rs")));
assert_eq!(output, PathBuf::from("output.rs"));
}
#[test]
fn test_determine_output_path_default() {
let output = determine_output_path(None);
assert_eq!(output, Path::new("tests/generated_from_replays.rs"));
}
#[test]
fn test_determine_output_path_no_extension() {
let output = determine_output_path(None);
assert_eq!(output, Path::new("tests/generated_from_replays.rs"));
}
#[test]
fn test_write_transpiled_output_to_file() {
let temp_dir = TempDir::new().expect("Failed to create temporary test directory");
let output_path = temp_dir.path().join("output.rs");
fs::write(&output_path, "let x = 42;")
.unwrap_or_else(|_| panic!("Failed to write test file: {}", output_path.display()));
let content = fs::read_to_string(&output_path)
.unwrap_or_else(|_| panic!("Failed to read output file: {}", output_path.display()));
assert_eq!(content, "let x = 42;");
}
#[test]
fn test_determine_wasm_output_path_explicit() {
let output =
determine_wasm_output_path(Path::new("input.ruchy"), Some(Path::new("output.wasm")));
assert_eq!(output, PathBuf::from("output.wasm"));
}
#[test]
fn test_determine_wasm_output_path_default() {
let output = determine_wasm_output_path(Path::new("input.ruchy"), None);
assert_eq!(output, PathBuf::from("input.wasm"));
}
#[test]
fn test_handle_run_command_basic() {
}
#[test]
fn test_handle_test_command_basic() {
let temp_dir = TempDir::new().expect("Failed to create temporary test directory");
let file_path = temp_dir.path().join("test.ruchy");
fs::write(&file_path, "test basic { assert(1 == 1) }")
.unwrap_or_else(|_| panic!("Failed to write test file: {}", file_path.display()));
}
#[test]
fn test_print_transpilation_status() {
println!("test.ruchy: transpilation completed"); }