File tree Expand file tree Collapse file tree
tests/rust/wasm32-wasip3/src/bin Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -23,17 +23,26 @@ struct Component;
2323export ! ( Component ) ;
2424impl exports:: wasi:: cli:: run:: Guest for Component {
2525 async fn run ( ) -> Result < ( ) , ( ) > {
26- sleep_10ms ( ) . await ;
26+ sleep_10ms_wait_for ( ) . await ;
27+ sleep_10ms_wait_until ( ) . await ;
2728 sleep_0ms ( ) ;
2829 sleep_backwards_in_time ( ) ;
2930 Ok ( ( ) )
3031 }
3132}
3233
33- async fn sleep_10ms ( ) {
34+ async fn sleep_10ms_wait_for ( ) {
3435 let dur = 10_000_000 ;
35- monotonic_clock:: wait_until ( monotonic_clock :: now ( ) + dur) . await ;
36+ let deadline = monotonic_clock:: now ( ) + dur;
3637 monotonic_clock:: wait_for ( dur) . await ;
38+ assert ! ( monotonic_clock:: now( ) >= deadline, "wait_for never resolves before the deadline" ) ;
39+ }
40+
41+ async fn sleep_10ms_wait_until ( ) {
42+ let dur = 10_000_000 ;
43+ let deadline = monotonic_clock:: now ( ) + dur;
44+ monotonic_clock:: wait_until ( deadline) . await ;
45+ assert ! ( monotonic_clock:: now( ) >= deadline, "wait_until never resolves before the deadline" ) ;
3746}
3847
3948fn sleep_0ms ( ) {
You can’t perform that action at this time.
0 commit comments