use std::process::{Command, Stdio};
#[test]
fn formats_stdin() {
let mut child = Command::new(env!("CARGO_BIN_EXE_lingua"))
.args(["fmt", "--stdin"])
.stdin(Stdio::piped())
.stdout(Stdio::piped())
.spawn()
.unwrap();
std::io::Write::write_all(child.stdin.as_mut().unwrap(), b"fn test( ) {\ntrue\n}").unwrap();
let output = child.wait_with_output().unwrap();
assert!(output.status.success());
assert_eq!(
String::from_utf8(output.stdout).unwrap(),
"fn test() {\n true\n}"
);
}
#[test]
fn parses_files() {
let output = Command::new(env!("CARGO_BIN_EXE_lingua"))
.args(["parse", "test/examples/function.lingua"])
.output()
.unwrap();
assert!(output.status.success());
assert!(
String::from_utf8(output.stdout)
.unwrap()
.contains("brainrot")
);
}