about summary refs log tree commit diff
path: root/tvix/eval/builtin-macros/tests/tests.rs
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2023-01-13T11·18+0300
committertazjin <tazjin@tvl.su>2023-01-20T15·39+0000
commitf12f938166e5b0c773f3553fb7e7422a58e83c6d (patch)
treea120aa4f8fcd744e58048d627ab02b08d1a2f4d0 /tvix/eval/builtin-macros/tests/tests.rs
parent972c867b365631f771f6933cd9a6384316d5aea5 (diff)
refactor(tvix/eval): directly return builtin tuples from macro r/5707
All invocations of the builtin macro had to previously filter through
the `builtin_tuple` function, but it's more sensible to directly
return these from the macro.

Change-Id: I45600ba84d56c9528d3e92570461c319eea595ce
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7825
Tested-by: BuildkiteCI
Reviewed-by: flokli <flokli@flokli.de>
Diffstat (limited to 'tvix/eval/builtin-macros/tests/tests.rs')
-rw-r--r--tvix/eval/builtin-macros/tests/tests.rs28
1 files changed, 17 insertions, 11 deletions
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"),
+    }
 }