Skip to content

Commit 353f7ca

Browse files
committed
fix(test): update mixed-type ordering test to match Ord contract fix
The test was asserting Ordering::Equal for mixed-type comparisons, which was the exact bug the previous commit fixed. Updated to assert consistent antisymmetric ordering and non-equality instead. https://claude.ai/code/session_01MYGPgMX6xJmjz7g27bsMcD
1 parent 16a2c17 commit 353f7ca

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

helix-db/src/protocol/value.rs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2748,12 +2748,21 @@ mod tests {
27482748

27492749
#[test]
27502750
fn test_value_ordering_mixed_types() {
2751-
// Non-comparable types should return Equal
2752-
assert_eq!(
2753-
Value::String("test".to_string()).cmp(&Value::I32(42)),
2754-
Ordering::Equal
2755-
);
2756-
assert_eq!(Value::Boolean(true).cmp(&Value::F64(3.14)), Ordering::Equal);
2751+
// Non-comparable types should return a consistent ordering based on variant
2752+
// discriminant, not Equal (which would violate the Ord contract since
2753+
// PartialEq returns false for these pairs).
2754+
let s = Value::String("test".to_string());
2755+
let i = Value::I32(42);
2756+
let b = Value::Boolean(true);
2757+
let f = Value::F64(3.14);
2758+
2759+
// Ordering must be consistent (antisymmetric)
2760+
assert_eq!(s.cmp(&i), i.cmp(&s).reverse());
2761+
assert_eq!(b.cmp(&f), f.cmp(&b).reverse());
2762+
2763+
// Ordering must not be Equal for different variant types
2764+
assert_ne!(s.cmp(&i), Ordering::Equal);
2765+
assert_ne!(b.cmp(&f), Ordering::Equal);
27572766
}
27582767

27592768
#[test]

0 commit comments

Comments
 (0)