diff options
Diffstat (limited to 'tvix/eval/builtin-macros/tests/tests.rs')
-rw-r--r-- | tvix/eval/builtin-macros/tests/tests.rs | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/tvix/eval/builtin-macros/tests/tests.rs b/tvix/eval/builtin-macros/tests/tests.rs index b270594b0f..288b6670e1 100644 --- a/tvix/eval/builtin-macros/tests/tests.rs +++ b/tvix/eval/builtin-macros/tests/tests.rs @@ -1,21 +1,22 @@ -pub use tvix_eval::internal; -pub use tvix_eval::Value; +pub use tvix_eval::{Builtin, Value}; use tvix_eval_builtin_macros::builtins; #[builtins] mod builtins { - use tvix_eval::internal::VM; + use tvix_eval::generators::{Gen, GenCo}; use tvix_eval::{ErrorKind, Value}; - /// Test docstring + /// Test docstring. + /// + /// It has multiple lines! #[builtin("identity")] - pub fn builtin_identity(_vm: &mut VM, x: Value) -> Result<Value, ErrorKind> { + pub async fn builtin_identity(co: GenCo, x: Value) -> Result<Value, ErrorKind> { Ok(x) } #[builtin("tryEval")] - pub fn builtin_try_eval(_: &mut VM, #[lazy] _x: Value) -> Result<Value, ErrorKind> { - todo!() + pub async fn builtin_try_eval(_co: GenCo, #[lazy] _x: Value) -> Result<Value, ErrorKind> { + unimplemented!("builtin is never called") } } @@ -24,6 +25,21 @@ 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")); + let (_, identity) = builtins + .iter() + .find(|(name, _)| *name == "identity") + .unwrap(); + + match identity { + Value::Builtin(identity) => assert_eq!( + identity.documentation(), + Some( + r#" Test docstring. + + It has multiple lines!"# + ) + ), + + _ => panic!("builtin was not a builtin"), + } } |