@@ -404,17 +404,11 @@ fn test_duration_compare() {
404404 )
405405 }
406406}
407- /*
408- TODO: Uncomment
409407
410- The below test should fail, but currently doesn't. This has to do with weird
411- floating point math in IsValidDuration Step 6-8 that defers to C++ std::remquo
412-
413- Needs further clarification.
408+ const MAX_SAFE_INT : i64 = 9_007_199_254_740_991 ;
414409
415410#[ test]
416411fn duration_round_out_of_range_norm_conversion ( ) {
417- const MAX_SAFE_INT: i64 = 9_007_199_254_740_991;
418412 let duration = Duration :: new ( 0 , 0 , 0 , 0 , 0 , 0 , MAX_SAFE_INT , 0 , 0 , 999_999_999 ) . unwrap ( ) ;
419413 let err = duration. round_with_provider ( RoundingOptions {
420414 largest_unit : Some ( Unit :: Nanosecond ) ,
@@ -423,4 +417,17 @@ fn duration_round_out_of_range_norm_conversion() {
423417 } , None , & NeverProvider :: default ( ) ) ;
424418 assert ! ( err. is_err( ) )
425419}
426- */
420+
421+ #[ test]
422+ #[ cfg_attr( not( feature = "float64_representable_durations" ) , should_panic) ]
423+ fn duration_float64_representable ( ) {
424+ // built-ins/Temporal/Duration/prototype/add/float64-representable-integer
425+ let duration = Duration :: new ( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , MAX_SAFE_INT as i128 , 0 ) . unwrap ( ) ;
426+ let duration2 = Duration :: new ( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , MAX_SAFE_INT as i128 - 1 , 0 ) . unwrap ( ) ;
427+ let added = duration. add ( & duration2) . unwrap ( ) ;
428+ assert_eq ! ( added. microseconds, 18014398509481980 ) ;
429+ assert_eq ! ( added. as_temporal_string( Default :: default ( ) ) . unwrap( ) , "PT18014398509.48198S" ) ;
430+ let one_ms = Duration :: new ( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 ) . unwrap ( ) ;
431+ let added_plus_one = added. add ( & one_ms) . unwrap ( ) ;
432+ assert_eq ! ( added, added_plus_one, "Should not internally use a more accurate representation when adding" ) ;
433+ }
0 commit comments