#![allow(deprecated)]
#![allow(clippy::unwrap_used)] #![allow(clippy::expect_used)]
#![allow(non_snake_case)]
use assert_cmd::Command;
use predicates::prelude::*;
fn bashrs_repl() -> Command {
let mut cmd = assert_cmd::cargo_bin_cmd!("bashrs");
cmd.arg("repl");
cmd
}
#[test]
fn test_REPL_003_005_normal_mode_command() {
bashrs_repl()
.write_stdin("echo hello\nquit\n")
.assert()
.success()
.stdout(predicate::str::contains("normal"))
.stdout(predicate::str::contains("Command not implemented").not());
}
#[test]
fn test_REPL_003_005_purify_mode_auto_purify() {
bashrs_repl()
.write_stdin(":mode purify\nmkdir /tmp/test\nquit\n")
.assert()
.success()
.stdout(predicate::str::contains("purify"))
.stdout(predicate::str::contains("Purified")); }
#[test]
fn test_REPL_003_005_purify_mode_shows_purified() {
bashrs_repl()
.write_stdin(":mode purify\nrm /tmp/test\nquit\n")
.assert()
.success()
.stdout(predicate::str::contains("Purified")); }
#[test]
fn test_REPL_003_005_lint_mode_auto_lint() {
bashrs_repl()
.write_stdin(":mode lint\ncat file.txt | grep pattern\nquit\n")
.assert()
.success()
.stdout(predicate::str::contains("lint"))
.stdout(predicate::str::contains("SC").or(predicate::str::contains("Found")));
}
#[test]
fn test_REPL_003_005_lint_mode_clean_code() {
bashrs_repl()
.write_stdin(":mode lint\necho \"hello\"\nquit\n")
.assert()
.success()
.stdout(predicate::str::contains("lint"));
}
#[test]
fn test_REPL_003_005_mode_switching_changes_behavior() {
bashrs_repl()
.write_stdin(":mode\n:mode purify\n:mode normal\nquit\n")
.assert()
.success()
.stdout(predicate::str::contains("normal"))
.stdout(predicate::str::contains("purify"));
}
#[test]
fn test_REPL_003_005_mode_persists() {
bashrs_repl()
.write_stdin(":mode purify\nmkdir test1\nmkdir test2\nquit\n")
.assert()
.success()
.stdout(predicate::str::contains("✓ Purified:").count(2)); }
#[test]
fn test_REPL_003_005_invalid_bash_handled() {
bashrs_repl()
.write_stdin(":mode purify\nif then fi\nquit\n")
.assert()
.success()
.stdout(predicate::str::contains("error").or(predicate::str::contains("Parse")));
}
#[test]
fn test_REPL_003_005_invalid_mode_error() {
bashrs_repl()
.write_stdin(":mode invalidmode\nquit\n")
.assert()
.success()
.stdout(predicate::str::contains("Error").or(predicate::str::contains("Unknown mode")));
}
#[test]
fn test_REPL_003_005_parse_command_in_any_mode() {
bashrs_repl()
.write_stdin(":mode purify\n:parse echo hello\nquit\n")
.assert()
.success()
.stdout(predicate::str::contains("Parse successful"));
}
#[test]
fn test_REPL_003_005_lint_command_in_any_mode() {
bashrs_repl()
.write_stdin(":mode normal\n:lint echo hello\nquit\n")
.assert()
.success();
}
#[test]
fn test_REPL_003_005_purify_command_in_any_mode() {
bashrs_repl()
.write_stdin(":mode lint\n:purify mkdir test\nquit\n")
.assert()
.success()
.stdout(predicate::str::contains("Purification"));
}