about summary refs log tree commit diff
path: root/tvix/eval/builtin-macros
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/eval/builtin-macros')
-rw-r--r--tvix/eval/builtin-macros/src/lib.rs4
-rw-r--r--tvix/eval/builtin-macros/tests/tests.rs28
2 files changed, 19 insertions, 13 deletions
diff --git a/tvix/eval/builtin-macros/src/lib.rs b/tvix/eval/builtin-macros/src/lib.rs
index ff1c52e03fd8..5a54d499124d 100644
--- a/tvix/eval/builtin-macros/src/lib.rs
+++ b/tvix/eval/builtin-macros/src/lib.rs
@@ -209,8 +209,8 @@ pub fn builtins(_args: TokenStream, item: TokenStream) -> TokenStream {
     }
 
     items.push(parse_quote! {
-        pub fn builtins() -> Vec<crate::Builtin> {
-            vec![#(#builtins),*]
+        pub fn builtins() -> Vec<(&'static str, Value)> {
+            vec![#(#builtins),*].into_iter().map(|b| (b.name(), Value::Builtin(b))).collect()
         }
     });
 
diff --git a/tvix/eval/builtin-macros/tests/tests.rs b/tvix/eval/builtin-macros/tests/tests.rs
index 5705d9202f6e..fb062d34b99a 100644
--- a/tvix/eval/builtin-macros/tests/tests.rs
+++ b/tvix/eval/builtin-macros/tests/tests.rs
@@ -1,11 +1,9 @@
-pub use tvix_eval::internal;
-pub use tvix_eval::Value;
+pub use tvix_eval::{Builtin, BuiltinArgument, Value, VM};
 use tvix_eval_builtin_macros::builtins;
 
 #[builtins]
 mod builtins {
-    use tvix_eval::internal::VM;
-    use tvix_eval::{ErrorKind, Value};
+    use tvix_eval::{ErrorKind, Value, VM};
 
     /// Test docstring.
     ///
@@ -26,13 +24,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(
-            r#" 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"),
+    }
 }