about summary refs log tree commit diff
path: root/tvix/cli/tests/repl.rs
blob: 8d49e7771db3cb2eaefe2d22257dd02c327b68a1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
use std::ffi::OsString;

use clap::Parser;
use expect_test::expect;
use tvix_cli::init_io_handle;

macro_rules! test_repl {
    ($name:ident() {$($send:expr => $expect:expr;)*}) => {
        #[test]
        fn $name() {
            let tokio_runtime = tokio::runtime::Runtime::new().unwrap();
            let args = tvix_cli::Args::parse_from(Vec::<OsString>::new());
            let mut repl = tvix_cli::Repl::new(init_io_handle(&tokio_runtime, &args), &args);
            $({
                let result = repl.send($send.into());
                $expect.assert_eq(result.output())
                ;
            })*
        }
    }
}

test_repl!(simple_expr_eval() {
    "1" => expect![[r#"
        => 1 :: int
    "#]];
});