Skip to content

Commit a4483d9

Browse files
authored
Merge pull request #583 from DelSkayn/ef-fix-nightly
Fix test for wasm32
2 parents c99675e + 9564d8c commit a4483d9

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

core/src/value/convert/from.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -434,9 +434,6 @@ chrono_from_js_impls! {
434434

435435
#[cfg(test)]
436436
mod 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
}

0 commit comments

Comments
 (0)