File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
src/builtins/compiled/duration Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff 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+ }
You can’t perform that action at this time.
0 commit comments