about summary refs log tree commit diff
path: root/tvix/eval/src/value/attrs/tests.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/eval/src/value/attrs/tests.rs')
-rw-r--r--tvix/eval/src/value/attrs/tests.rs35
1 files changed, 21 insertions, 14 deletions
diff --git a/tvix/eval/src/value/attrs/tests.rs b/tvix/eval/src/value/attrs/tests.rs
index 637114c89bc7..65d3c8d7ca0e 100644
--- a/tvix/eval/src/value/attrs/tests.rs
+++ b/tvix/eval/src/value/attrs/tests.rs
@@ -80,8 +80,9 @@ fn test_kv_attrs() {
     .expect("constructing K/V pair attrs should succeed");
 
     match kv_attrs {
-        NixAttrs(AttrsRep::KV { name, value }) if name == meaning_val || value == forty_two_val => {
-        }
+        NixAttrs(AttrsRep::KV { name, value })
+            if name.to_str().unwrap() == meaning_val.to_str().unwrap()
+                || value.to_str().unwrap() == forty_two_val.to_str().unwrap() => {}
 
         _ => panic!(
             "K/V attribute set should use optimised representation, but got {:?}",
@@ -93,7 +94,7 @@ fn test_kv_attrs() {
 #[test]
 fn test_empty_attrs_iter() {
     let attrs = NixAttrs::construct(0, vec![]).unwrap();
-    assert_eq!(attrs.iter().next(), None);
+    assert!(attrs.iter().next().is_none());
 }
 
 #[test]
@@ -114,13 +115,18 @@ fn test_kv_attrs_iter() {
     )
     .expect("constructing K/V pair attrs should succeed");
 
-    assert_eq!(
-        kv_attrs.iter().collect::<Vec<_>>(),
-        vec![
-            (NixString::NAME_REF, &meaning_val),
-            (NixString::VALUE_REF, &forty_two_val)
-        ]
-    );
+    let mut iter = kv_attrs
+        .iter()
+        .collect::<Vec<_>>()
+        .into_iter()
+        .map(|(k, v)| (k, v));
+    let (k, v) = iter.next().unwrap();
+    assert!(k == NixString::NAME_REF);
+    assert!(v.to_str().unwrap() == meaning_val.to_str().unwrap());
+    let (k, v) = iter.next().unwrap();
+    assert!(k == NixString::VALUE_REF);
+    assert!(v.as_int().unwrap() == forty_two_val.as_int().unwrap());
+    assert!(iter.next().is_none());
 }
 
 #[test]
@@ -131,8 +137,9 @@ fn test_map_attrs_iter() {
     )
     .expect("simple attr construction should succeed");
 
-    assert_eq!(
-        attrs.iter().collect::<Vec<_>>(),
-        vec![(&NixString::from("key"), &Value::String("value".into()))],
-    );
+    let mut iter = attrs.iter().collect::<Vec<_>>().into_iter();
+    let (k, v) = iter.next().unwrap();
+    assert!(k == &NixString::from("key"));
+    assert!(v.to_str().unwrap().as_str() == "value");
+    assert!(iter.next().is_none());
 }