Ensure last array items (array[$]
) compare correctly (#1534)
This commit is contained in:
parent
44c3f32f69
commit
3048748573
1 changed files with 10 additions and 1 deletions
|
@ -46,7 +46,7 @@ impl Value {
|
||||||
(None, Some(_)) => Some(Ordering::Less),
|
(None, Some(_)) => Some(Ordering::Less),
|
||||||
(_, _) => Some(Ordering::Equal),
|
(_, _) => Some(Ordering::Equal),
|
||||||
},
|
},
|
||||||
Part::Last => match (a.first(), b.first()) {
|
Part::Last => match (a.last(), b.last()) {
|
||||||
(Some(a), Some(b)) => a.compare(b, path.next(), collate, numeric),
|
(Some(a), Some(b)) => a.compare(b, path.next(), collate, numeric),
|
||||||
(Some(_), None) => Some(Ordering::Greater),
|
(Some(_), None) => Some(Ordering::Greater),
|
||||||
(None, Some(_)) => Some(Ordering::Less),
|
(None, Some(_)) => Some(Ordering::Less),
|
||||||
|
@ -192,4 +192,13 @@ mod tests {
|
||||||
let res = one.compare(&two, &idi, false, false);
|
let res = one.compare(&two, &idi, false, false);
|
||||||
assert_eq!(res, Some(Ordering::Greater));
|
assert_eq!(res, Some(Ordering::Greater));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn compare_last() {
|
||||||
|
let idi = Idiom::parse("test[$]");
|
||||||
|
let one = Value::parse("{ test: [1,5] }");
|
||||||
|
let two = Value::parse("{ test: [2,4] }");
|
||||||
|
let res = one.compare(&two, &idi, false, false);
|
||||||
|
assert_eq!(res, Some(Ordering::Greater))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue