#![allow(missing_docs)]
use rexpect::session::spawn_command;
use std::process::Command;
fn spawn_ruchy_repl() -> rexpect::session::PtySession {
let cmd = Command::new("ruchy");
spawn_command(cmd, Some(10000)).expect("Failed to spawn ruchy REPL")
}
#[test]
fn test_matrix_native_01_addition() {
let mut repl = spawn_ruchy_repl();
repl.exp_string("ruchy>")
.expect("Failed to find REPL prompt");
repl.send_line("10 + 20").expect("Failed to send command");
repl.exp_string("30").expect("Result should be 30");
}
#[test]
fn test_matrix_native_02_subtraction() {
let mut repl = spawn_ruchy_repl();
repl.exp_string("ruchy>")
.expect("Failed to find REPL prompt");
repl.send_line("100 - 42").expect("Failed to send command");
repl.exp_string("58").expect("Result should be 58");
}
#[test]
fn test_matrix_native_03_multiplication() {
let mut repl = spawn_ruchy_repl();
repl.exp_string("ruchy>")
.expect("Failed to find REPL prompt");
repl.send_line("6 * 7").expect("Failed to send command");
repl.exp_string("42").expect("Result should be 42");
}
#[test]
fn test_matrix_native_04_division() {
let mut repl = spawn_ruchy_repl();
repl.exp_string("ruchy>")
.expect("Failed to find REPL prompt");
repl.send_line("100 / 4").expect("Failed to send command");
repl.exp_string("25").expect("Result should be 25");
}
#[test]
fn test_matrix_native_05_operator_precedence() {
let mut repl = spawn_ruchy_repl();
repl.exp_string("ruchy>")
.expect("Failed to find REPL prompt");
repl.send_line("2 + 3 * 4").expect("Failed to send command");
repl.exp_string("14")
.expect("Result should be 14 (precedence check)");
}
#[test]
fn test_matrix_native_06_parentheses() {
let mut repl = spawn_ruchy_repl();
repl.exp_string("ruchy>")
.expect("Failed to find REPL prompt");
repl.send_line("(2 + 3) * 4")
.expect("Failed to send command");
repl.exp_string("20").expect("Result should be 20");
}
#[test]
fn test_matrix_native_07_variables() {
let mut repl = spawn_ruchy_repl();
repl.exp_string("ruchy>")
.expect("Failed to find REPL prompt");
repl.send_line("let x = 10")
.expect("Failed to send command");
repl.exp_string("ruchy>")
.expect("Failed to find REPL prompt");
repl.send_line("x * 2").expect("Failed to send command");
repl.exp_string("20").expect("Result should be 20");
}
#[test]
fn test_matrix_native_08_multi_step_computation() {
let mut repl = spawn_ruchy_repl();
repl.exp_string("ruchy>")
.expect("Failed to find REPL prompt");
repl.send_line("let a = 5").expect("Failed to send command");
repl.exp_string("ruchy>")
.expect("Failed to find REPL prompt");
repl.send_line("let b = 10")
.expect("Failed to send command");
repl.exp_string("ruchy>")
.expect("Failed to find REPL prompt");
repl.send_line("let c = 15")
.expect("Failed to send command");
repl.exp_string("ruchy>")
.expect("Failed to find REPL prompt");
repl.send_line("a + b + c").expect("Failed to send command");
repl.exp_string("30").expect("Result should be 30");
}