File tree Expand file tree Collapse file tree 2 files changed +31
-1
lines changed
Examples/EmbeddedConcurrency
Sources/EmbeddedConcurrencyApp Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -121,6 +121,36 @@ struct App {
121121 check ( false , " Promise chaining should succeed " )
122122 }
123123
124+ // Test 7: JSPromise.value await (with async resolution)
125+ let promise2 = JSPromise ( resolver: { resolve in
126+ _ = JSObject . global. setTimeout!(
127+ JSOneshotClosure { _ in
128+ resolve ( . success( JSValue . number ( 456 ) ) )
129+ return . undefined
130+ } ,
131+ 1
132+ )
133+ } )
134+ let awaitedValue = try await promise2. value
135+ check ( awaitedValue. number == 456 , " JSPromise.value await returns correct value " )
136+
137+ // Test 8: JSPromise.result await (with async resolution)
138+ let promise3 = JSPromise ( resolver: { resolve in
139+ _ = JSObject . global. setTimeout!(
140+ JSOneshotClosure { _ in
141+ resolve ( . success( JSValue . number ( 789 ) ) )
142+ return . undefined
143+ } ,
144+ 1
145+ )
146+ } )
147+ let awaitedResult = await promise3. result
148+ if case . success( let val) = awaitedResult {
149+ check ( val. number == 789 , " JSPromise.result await resolves correctly " )
150+ } else {
151+ check ( false , " JSPromise.result await should succeed " )
152+ }
153+
124154 // Summary
125155 let console = JSObject . global. console
126156 let totalTests = testsPassed + testsFailed
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import { instantiate } from
33import { defaultNodeSetup } from
44 "./.build/plugins/PackageToJS/outputs/Package/platforms/node.js"
55
6- const EXPECTED_TESTS = 6 ;
6+ const EXPECTED_TESTS = 8 ;
77const TIMEOUT_MS = 30_000 ;
88
99// Intercept console.log to capture test output
You can’t perform that action at this time.
0 commit comments