@@ -8,8 +8,8 @@ import _CJavaScriptKit // For swjs_get_worker_thread_id
88func isMainThread( ) -> Bool
99
1010final class WebWorkerTaskExecutorTests : XCTestCase {
11- override func setUp( ) {
12- WebWorkerTaskExecutor . installGlobalExecutor ( )
11+ override func setUp( ) async {
12+ await WebWorkerTaskExecutor . installGlobalExecutor ( )
1313 }
1414
1515 func testTaskRunOnMainThread( ) async throws {
@@ -152,48 +152,46 @@ final class WebWorkerTaskExecutorTests: XCTestCase {
152152
153153 func testThreadLocalPerThreadValues( ) async throws {
154154 struct Check {
155- @ThreadLocal ( boxing: ( ) )
156- static var value : Int ?
155+ static let value = ThreadLocal < Int > ( boxing: ( ) )
157156 }
158157 let executor = try await WebWorkerTaskExecutor ( numberOfThreads: 1 )
159- XCTAssertNil ( Check . value)
160- Check . value = 42
161- XCTAssertEqual ( Check . value, 42 )
158+ XCTAssertNil ( Check . value. wrappedValue )
159+ Check . value. wrappedValue = 42
160+ XCTAssertEqual ( Check . value. wrappedValue , 42 )
162161
163162 let task = Task ( executorPreference: executor) {
164- XCTAssertEqual ( Check . value, nil )
165- Check . value = 100
166- XCTAssertEqual ( Check . value, 100 )
167- return Check . value
163+ XCTAssertNil ( Check . value. wrappedValue )
164+ Check . value. wrappedValue = 100
165+ XCTAssertEqual ( Check . value. wrappedValue , 100 )
166+ return Check . value. wrappedValue
168167 }
169168 let result = await task. value
170169 XCTAssertEqual ( result, 100 )
171- XCTAssertEqual ( Check . value, 42 )
170+ XCTAssertEqual ( Check . value. wrappedValue , 42 )
172171 executor. terminate ( )
173172 }
174173
175174 func testLazyThreadLocalPerThreadInitialization( ) async throws {
176175 struct Check {
177- static var valueToInitialize = 42
178- static var countOfInitialization = 0
179- @ LazyThreadLocal ( initialize: {
176+ nonisolated ( unsafe ) static var valueToInitialize = 42
177+ nonisolated ( unsafe ) static var countOfInitialization = 0
178+ static let value = LazyThreadLocal < Int > ( initialize: {
180179 countOfInitialization += 1
181180 return valueToInitialize
182181 } )
183- static var value : Int
184182 }
185183 let executor = try await WebWorkerTaskExecutor ( numberOfThreads: 1 )
186184 XCTAssertEqual ( Check . countOfInitialization, 0 )
187- XCTAssertEqual ( Check . value, 42 )
185+ XCTAssertEqual ( Check . value. wrappedValue , 42 )
188186 XCTAssertEqual ( Check . countOfInitialization, 1 )
189187
190188 Check . valueToInitialize = 100
191189
192190 let task = Task ( executorPreference: executor) {
193191 XCTAssertEqual ( Check . countOfInitialization, 1 )
194- XCTAssertEqual ( Check . value, 100 )
192+ XCTAssertEqual ( Check . value. wrappedValue , 100 )
195193 XCTAssertEqual ( Check . countOfInitialization, 2 )
196- return Check . value
194+ return Check . value. wrappedValue
197195 }
198196 let result = await task. value
199197 XCTAssertEqual ( result, 100 )
0 commit comments