File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ import Dispatch
19
19
// CHECK: Starting!
20
20
print ( " Starting! " )
21
21
await testSleepFinished ( )
22
+ await testSleepMomentary ( )
22
23
await testSleepCancelledBeforeStarted ( )
23
24
await testSleepCancelled ( )
24
25
}
@@ -40,6 +41,17 @@ import Dispatch
40
41
print ( " Wakey wakey! " )
41
42
}
42
43
44
+ static func testSleepMomentary( ) async {
45
+ // CHECK-NEXT: Testing sleep that completes instantly
46
+ print ( " Testing sleep that completes instantly " )
47
+
48
+ // try! will fail if the task got cancelled (which shouldn't happen).
49
+ try ! await Task . sleep ( nanoseconds: 0 )
50
+
51
+ // CHECK-NEXT: Wakey wakey!
52
+ print ( " Wakey wakey! " )
53
+ }
54
+
43
55
static func testSleepCancelledBeforeStarted( ) async {
44
56
// CHECK-NEXT: Testing sleep that gets cancelled before it starts
45
57
print ( " Testing sleep that gets cancelled before it starts " )
You can’t perform that action at this time.
0 commit comments