1
1
use assert_cmd::Command;
2

            
3
1
#[test]
4
#[cfg_attr(miri, ignore)]
5
1
fn eval() {
6
1
    let mut cmd = Command::cargo_bin("bud").unwrap();
7
1
    let result = cmd.arg("1 + 2").assert().success();
8
1
    let result = std::str::from_utf8(&result.get_output().stdout).unwrap();
9
1
    assert_eq!(result, "3\n");
10
1
}
11

            
12
1
#[test]
13
#[cfg_attr(miri, ignore)]
14
1
fn pipe() {
15
1
    let mut cmd = Command::cargo_bin("bud").unwrap();
16
1
    let result = cmd.write_stdin("1 + 2").assert().success();
17
1
    let result = std::str::from_utf8(&result.get_output().stdout).unwrap();
18
1
    assert_eq!(result, "3\n");
19
1
}
20

            
21
1
#[test]
22
#[cfg_attr(miri, ignore)]
23
1
fn eval_and_pipe() {
24
1
    let mut cmd = Command::cargo_bin("bud").unwrap();
25
1
    let result = cmd.arg("1 + 2").write_stdin("3 + 4").assert().success();
26
1
    let result = std::str::from_utf8(&result.get_output().stdout).unwrap();
27
1
    assert_eq!(result, "3\n7\n");
28
1
}
29

            
30
1
#[test]
31
#[cfg_attr(miri, ignore)]
32
1
fn run_file() {
33
1
    std::fs::write(
34
1
        "run_file.bud",
35
1
        br#"
36
1
        function test(a, b)
37
1
            a + b
38
1
        end
39
1
    "#,
40
1
    )
41
1
    .unwrap();
42
1
    let mut cmd = Command::cargo_bin("bud").unwrap();
43
1
    let result = cmd
44
1
        .arg("-f")
45
1
        .arg("run_file.bud")
46
1
        .arg("test(1, 2)")
47
1
        .assert()
48
1
        .success();
49
1
    let result = std::str::from_utf8(&result.get_output().stdout).unwrap();
50
1
    assert_eq!(result, "3\n");
51
1
    std::fs::remove_file("run_file.bud").unwrap();
52
1
}