about summary refs log blame commit diff
path: root/tvix/eval/builtin-macros/tests/tests.rs
blob: b270594b0f33a48d9c529a52e33f05fd95cec1d7 (plain) (tree)
1
2
3
4
5
6
7
8
9

                            

                                       

              

                                      
 
                      














                                                                                        


                                                                             
 
pub use tvix_eval::internal;
pub use tvix_eval::Value;
use tvix_eval_builtin_macros::builtins;

#[builtins]
mod builtins {
    use tvix_eval::internal::VM;
    use tvix_eval::{ErrorKind, Value};

    /// Test docstring
    #[builtin("identity")]
    pub fn builtin_identity(_vm: &mut VM, x: Value) -> Result<Value, ErrorKind> {
        Ok(x)
    }

    #[builtin("tryEval")]
    pub fn builtin_try_eval(_: &mut VM, #[lazy] _x: Value) -> Result<Value, ErrorKind> {
        todo!()
    }
}

#[test]
fn builtins() {
    let builtins = builtins::builtins();
    assert_eq!(builtins.len(), 2);

    let identity = builtins.iter().find(|b| b.name() == "identity").unwrap();
    assert_eq!(identity.documentation(), Some(" Test docstring"));
}