use assert_cmd::Command;
use predicates::prelude::*;
use std::io::Write;
#[test]
fn check_on_a_broken_program_reports_a_diagnostic_and_exits_nonzero() {
let mut src = tempfile::Builder::new().suffix(".qala").tempfile().unwrap();
write!(src, "fn main() is io {{\n let x: i64 = \"nope\"\n}}").unwrap();
Command::cargo_bin("qala")
.unwrap()
.arg("check")
.arg(src.path())
.assert()
.failure() .stderr(predicate::str::contains("error:")); }
#[test]
fn check_on_a_good_program_succeeds_without_running_it() {
let mut src = tempfile::Builder::new().suffix(".qala").tempfile().unwrap();
write!(src, "fn main() is io {{\n println(\"hi\")\n}}").unwrap();
Command::cargo_bin("qala")
.unwrap()
.arg("check")
.arg(src.path())
.assert()
.success()
.stdout(predicate::str::is_empty());
}