Skip to content

Commit 2d72374

Browse files
committed
add one test from 262 balanced_subseconds.js
1 parent 7dd200e commit 2d72374

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/builtins/compiled/duration/tests.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,3 +734,27 @@ fn test_duration_total() {
734734
3.7944444444444443
735735
);
736736
}
737+
738+
// balance-subseconds.js
739+
#[test]
740+
fn balance_subseconds() {
741+
// Test positive
742+
let pos = Duration::from_partial_duration(PartialDuration {
743+
milliseconds: Some(FiniteF64::from(999)),
744+
microseconds: Some(FiniteF64::from(999999)),
745+
nanoseconds: Some(FiniteF64::from(999999999)),
746+
..Default::default()
747+
})
748+
.unwrap();
749+
assert_eq!(pos.total(TemporalUnit::Second, None).unwrap(), 2.998998999);
750+
751+
// Test negative
752+
let neg = Duration::from_partial_duration(PartialDuration {
753+
milliseconds: Some(FiniteF64::from(-999)),
754+
microseconds: Some(FiniteF64::from(-999999)),
755+
nanoseconds: Some(FiniteF64::from(-999999999)),
756+
..Default::default()
757+
})
758+
.unwrap();
759+
assert_eq!(neg.total(TemporalUnit::Second, None).unwrap(), -2.998998999);
760+
}

0 commit comments

Comments
 (0)