11use super :: { Duration , Instant , SystemTime , UNIX_EPOCH } ;
2- use core :: sync :: atomic :: AtomicU64 ;
2+ # [ cfg ( not ( target_arch = "wasm32" ) ) ]
33use test:: { black_box, Bencher } ;
44
55macro_rules! assert_almost_eq {
@@ -25,6 +25,7 @@ fn instant_monotonic() {
2525}
2626
2727#[ test]
28+ #[ cfg( not( target_arch = "wasm32" ) ) ]
2829fn instant_monotonic_concurrent ( ) -> crate :: thread:: Result < ( ) > {
2930 let threads: Vec < _ > = ( 0 ..8 )
3031 . map ( |_| {
@@ -195,10 +196,18 @@ fn since_epoch() {
195196#[ test]
196197fn monotonizer_wrapping_backslide ( ) {
197198 use super :: monotonic:: inner:: { monotonize_impl, ZERO } ;
199+ use core:: sync:: atomic:: AtomicU64 ;
198200
199201 let reference = AtomicU64 :: new ( 0 ) ;
200202
201- let time = ZERO . checked_add_duration ( & Duration :: from_secs ( 0xffff_ffff ) ) . unwrap ( ) ;
203+ let time = match ZERO . checked_add_duration ( & Duration :: from_secs ( 0xffff_ffff ) ) {
204+ Some ( time) => time,
205+ None => {
206+ // platform cannot represent u32::MAX seconds so it won't have to deal with this kind
207+ // of overflow either
208+ return ;
209+ }
210+ } ;
202211
203212 let monotonized = monotonize_impl ( & reference, time) ;
204213 let expected = ZERO . checked_add_duration ( & Duration :: from_secs ( 1 << 32 ) ) . unwrap ( ) ;
@@ -211,6 +220,7 @@ fn monotonizer_wrapping_backslide() {
211220macro_rules! bench_instant_threaded {
212221 ( $bench_name: ident, $thread_count: expr) => {
213222 #[ bench]
223+ #[ cfg( not( target_arch = "wasm32" ) ) ]
214224 fn $bench_name( b: & mut Bencher ) -> crate :: thread:: Result <( ) > {
215225 use crate :: sync:: atomic:: { AtomicBool , Ordering } ;
216226 use crate :: sync:: Arc ;
0 commit comments