File tree Expand file tree Collapse file tree 1 file changed +14
-10
lines changed
Expand file tree Collapse file tree 1 file changed +14
-10
lines changed Original file line number Diff line number Diff line change @@ -434,9 +434,6 @@ chrono_from_js_impls! {
434434
435435#[ cfg( test) ]
436436mod test {
437- #[ cfg( target_arch = "wasm32" ) ]
438- use super :: Error ;
439-
440437 #[ test]
441438 fn js_to_system_time ( ) {
442439 use crate :: { Context , Runtime } ;
@@ -462,15 +459,22 @@ mod test {
462459 }
463460
464461 // wasm32-wasip1 and wasm32-wasip2 do not support SystemTime before the Unix Epoch
462+ // before rust 1.94.0.
465463 #[ cfg( target_arch = "wasm32" ) ]
466464 {
467- let res: Error = ctx
468- . eval :: < SystemTime , & str > ( "new Date(-123456789)" )
469- . unwrap_err ( ) ;
470- assert_eq ! (
471- "Error converting from js 'Date' into type 'SystemTime': Timestamp too small" ,
472- res. to_string( )
473- ) ;
465+ let res = ctx. eval :: < SystemTime , & str > ( "new Date(-123456789)" ) ;
466+ match res {
467+ Ok ( date) => {
468+ assert_eq ! (
469+ Duration :: from_millis( 123456789 ) ,
470+ SystemTime :: UNIX_EPOCH . duration_since( date) . unwrap( )
471+ ) ;
472+ }
473+ Err ( e) => assert_eq ! (
474+ "Error converting from js 'Date' into type 'SystemTime': Timestamp too small" ,
475+ e. to_string( )
476+ ) ,
477+ } ;
474478 }
475479 } ) ;
476480 }
You can’t perform that action at this time.
0 commit comments