mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 04:08:19 +00:00
Implemented Default, PartialOrd, and Ord for RocDec
This commit is contained in:
parent
2936a37a1c
commit
b7ec1f143b
2 changed files with 42 additions and 1 deletions
|
@ -307,6 +307,35 @@ mod test_roc_std {
|
|||
assert_eq!(format!("{example}"), "3.141592653589793238");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn roc_dec_sort() {
|
||||
let neg_one_point_five = RocDec::from_str("-1.5").unwrap();
|
||||
|
||||
let mut sorted_by_ord = [
|
||||
neg_one_point_five,
|
||||
RocDec::from(35),
|
||||
RocDec::from(-10057),
|
||||
RocDec::from(0),
|
||||
];
|
||||
|
||||
sorted_by_ord.sort();
|
||||
|
||||
let manually_sorted = [
|
||||
RocDec::from(-10057),
|
||||
neg_one_point_five,
|
||||
RocDec::from(0),
|
||||
RocDec::from(35),
|
||||
];
|
||||
|
||||
assert_eq!(sorted_by_ord, manually_sorted);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn roc_dec_default() {
|
||||
// check if derived Default still returns zero if the implementation ever changes
|
||||
assert_eq!(RocDec::from(0), RocDec::default());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn safe_send_no_copy() {
|
||||
let x = RocStr::from("This is a long string but still unique. Yay!!!");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue