File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
IntegrationTests/TestSuites/Sources/ConcurrencyTests Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -97,6 +97,24 @@ func entrypoint() async throws {
97
97
_ = await ( t3. value, t4. value, t5. value)
98
98
try expectEqual ( context. completed, [ " t4 " , " t3 " , " t5 " ] )
99
99
}
100
+
101
+ try await asyncTest ( " Async JSClosure " ) {
102
+ let delayClosure = JSClosure . async { _ -> JSValue in
103
+ try await Task . sleep ( nanoseconds: 2_000_000_000 )
104
+ return JSValue . number ( 3 )
105
+ }
106
+ let delayObject = JSObject . global. Object. function!. new ( )
107
+ delayObject. closure = delayClosure. jsValue ( )
108
+
109
+ let start = time ( nil )
110
+ let promise = JSPromise ( from: delayObject. closure!( ) )
111
+ try expectNotNil ( promise)
112
+ let result = try await promise!. value
113
+ let diff = difftime ( time ( nil ) , start)
114
+ try expectEqual ( diff >= 2 , true )
115
+ try expectEqual ( result, . number( 3 ) )
116
+ }
117
+
100
118
// FIXME(katei): Somehow it doesn't work due to a mysterious unreachable inst
101
119
// at the end of thunk.
102
120
// This issue is not only on JS host environment, but also on standalone coop executor.
You can’t perform that action at this time.
0 commit comments