Skip to content

Commit 0edc92a

Browse files
committed
[tests] Update sync binding fixtures to typed closure params
The macro now emits sync `@JS` bindings with a fully-typed closure parameter list (`(this: borrowing JavaScriptUnownedValue, arguments: consuming JavaScriptValuesBuffer) in`) to select the unowned-`this` `setProperty` overload. The fixture expectations still carried the old `this, arguments in` shorthand, so every sync-binding expansion test was failing. Update them to match. Async fixtures keep the shorthand and the owning-`this` overload, so they are left untouched.
1 parent c403548 commit 0edc92a

2 files changed

Lines changed: 17 additions & 17 deletions

File tree

apple/Tests/ExpoModulesMacrosTests/ExpoModuleMacroTests.swift

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ struct ExpoModuleMacroTests {
104104
105105
@JavaScriptActor
106106
public func _decorateModule(object: borrowing JavaScriptObject, in runtime: JavaScriptRuntime, appContext: AppContext) throws {
107-
object.setProperty("greet") { [self] this, arguments in
107+
object.setProperty("greet") { [self] (this: borrowing JavaScriptUnownedValue, arguments: consuming JavaScriptValuesBuffer) in
108108
guard arguments.count == 1 else {
109109
throw Exceptions.ArgumentsRangeMismatch((functionName: "greet", received: arguments.count, required: 1, maximum: 1))
110110
}
@@ -141,7 +141,7 @@ struct ExpoModuleMacroTests {
141141
142142
@JavaScriptActor
143143
public func _decorateModule(object: borrowing JavaScriptObject, in runtime: JavaScriptRuntime, appContext: AppContext) throws {
144-
object.setProperty("add") { [self] this, arguments in
144+
object.setProperty("add") { [self] (this: borrowing JavaScriptUnownedValue, arguments: consuming JavaScriptValuesBuffer) in
145145
guard arguments.count == 2 else {
146146
throw Exceptions.ArgumentsRangeMismatch((functionName: "add", received: arguments.count, required: 2, maximum: 2))
147147
}
@@ -179,7 +179,7 @@ struct ExpoModuleMacroTests {
179179
180180
@JavaScriptActor
181181
public func _decorateModule(object: borrowing JavaScriptObject, in runtime: JavaScriptRuntime, appContext: AppContext) throws {
182-
object.setProperty("resize") { [self] this, arguments in
182+
object.setProperty("resize") { [self] (this: borrowing JavaScriptUnownedValue, arguments: consuming JavaScriptValuesBuffer) in
183183
guard arguments.count >= 1 && arguments.count <= 2 else {
184184
throw Exceptions.ArgumentsRangeMismatch((functionName: "resize", received: arguments.count, required: 1, maximum: 2))
185185
}
@@ -222,7 +222,7 @@ struct ExpoModuleMacroTests {
222222
223223
@JavaScriptActor
224224
public func _decorateModule(object: borrowing JavaScriptObject, in runtime: JavaScriptRuntime, appContext: AppContext) throws {
225-
object.setProperty("tag") { [weak appContext, self] this, arguments in
225+
object.setProperty("tag") { [weak appContext, self] (this: borrowing JavaScriptUnownedValue, arguments: consuming JavaScriptValuesBuffer) in
226226
guard let appContext else {
227227
throw Exceptions.AppContextLost()
228228
}
@@ -268,7 +268,7 @@ struct ExpoModuleMacroTests {
268268
269269
@JavaScriptActor
270270
public func _decorateModule(object: borrowing JavaScriptObject, in runtime: JavaScriptRuntime, appContext: AppContext) throws {
271-
object.setProperty("ping") { [self] this, arguments in
271+
object.setProperty("ping") { [self] (this: borrowing JavaScriptUnownedValue, arguments: consuming JavaScriptValuesBuffer) in
272272
guard arguments.count >= 0 && arguments.count <= 1 else {
273273
throw Exceptions.ArgumentsRangeMismatch((functionName: "ping", received: arguments.count, required: 0, maximum: 1))
274274
}
@@ -317,7 +317,7 @@ struct ExpoModuleMacroTests {
317317
318318
@JavaScriptActor
319319
public func _decorateModule(object: borrowing JavaScriptObject, in runtime: JavaScriptRuntime, appContext: AppContext) throws {
320-
object.setProperty("transform") { [weak appContext, self] this, arguments in
320+
object.setProperty("transform") { [weak appContext, self] (this: borrowing JavaScriptUnownedValue, arguments: consuming JavaScriptValuesBuffer) in
321321
guard let appContext else {
322322
throw Exceptions.AppContextLost()
323323
}
@@ -364,7 +364,7 @@ struct ExpoModuleMacroTests {
364364
365365
@JavaScriptActor
366366
public func _decorateModule(object: borrowing JavaScriptObject, in runtime: JavaScriptRuntime, appContext: AppContext) throws {
367-
object.setProperty("describe") { [weak appContext, self] this, arguments in
367+
object.setProperty("describe") { [weak appContext, self] (this: borrowing JavaScriptUnownedValue, arguments: consuming JavaScriptValuesBuffer) in
368368
guard let appContext else {
369369
throw Exceptions.AppContextLost()
370370
}
@@ -404,7 +404,7 @@ struct ExpoModuleMacroTests {
404404

405405
@JavaScriptActor
406406
public func _decorateModule(object: borrowing JavaScriptObject, in runtime: JavaScriptRuntime, appContext: AppContext) throws {
407-
object.setProperty("doReset") { [self] this, arguments in
407+
object.setProperty("doReset") { [self] (this: borrowing JavaScriptUnownedValue, arguments: consuming JavaScriptValuesBuffer) in
408408
guard arguments.count == 0 else {
409409
throw Exceptions.ArgumentsRangeMismatch((functionName: "doReset", received: arguments.count, required: 0, maximum: 0))
410410
}
@@ -513,7 +513,7 @@ struct ExpoModuleMacroTests {
513513
public func _decorateModule(object: borrowing JavaScriptObject, in runtime: JavaScriptRuntime, appContext: AppContext) throws {
514514
let statusDescriptor = runtime.createObject()
515515
statusDescriptor.setProperty("enumerable", value: true)
516-
statusDescriptor.setProperty("get") { [self] this, arguments in
516+
statusDescriptor.setProperty("get") { [self] (this: borrowing JavaScriptUnownedValue, arguments: consuming JavaScriptValuesBuffer) in
517517
return self.status.toJavaScriptValue(in: runtime)
518518
}
519519
object.defineProperty("status", descriptor: statusDescriptor)
@@ -548,10 +548,10 @@ struct ExpoModuleMacroTests {
548548
public func _decorateModule(object: borrowing JavaScriptObject, in runtime: JavaScriptRuntime, appContext: AppContext) throws {
549549
let readyDescriptor = runtime.createObject()
550550
readyDescriptor.setProperty("enumerable", value: true)
551-
readyDescriptor.setProperty("get") { [self] this, arguments in
551+
readyDescriptor.setProperty("get") { [self] (this: borrowing JavaScriptUnownedValue, arguments: consuming JavaScriptValuesBuffer) in
552552
return self.ready.toJavaScriptValue(in: runtime)
553553
}
554-
readyDescriptor.setProperty("set") { [self] this, arguments in
554+
readyDescriptor.setProperty("set") { [self] (this: borrowing JavaScriptUnownedValue, arguments: consuming JavaScriptValuesBuffer) in
555555
self.ready = try arguments.unownedValue(at: 0).asBool()
556556
return .undefined
557557
}
@@ -593,13 +593,13 @@ struct ExpoModuleMacroTests {
593593
public func _decorateModule(object: borrowing JavaScriptObject, in runtime: JavaScriptRuntime, appContext: AppContext) throws {
594594
let configDescriptor = runtime.createObject()
595595
configDescriptor.setProperty("enumerable", value: true)
596-
configDescriptor.setProperty("get") { [weak appContext, self] this, arguments in
596+
configDescriptor.setProperty("get") { [weak appContext, self] (this: borrowing JavaScriptUnownedValue, arguments: consuming JavaScriptValuesBuffer) in
597597
guard let appContext else {
598598
throw Exceptions.AppContextLost()
599599
}
600600
return try MyRecord.getDynamicType().castToJS(self.config, appContext: appContext, in: runtime)
601601
}
602-
configDescriptor.setProperty("set") { [weak appContext, self] this, arguments in
602+
configDescriptor.setProperty("set") { [weak appContext, self] (this: borrowing JavaScriptUnownedValue, arguments: consuming JavaScriptValuesBuffer) in
603603
guard let appContext else {
604604
throw Exceptions.AppContextLost()
605605
}
@@ -645,7 +645,7 @@ struct ExpoModuleMacroTests {
645645

646646
@JavaScriptActor
647647
public func _decorateModule(object: borrowing JavaScriptObject, in runtime: JavaScriptRuntime, appContext: AppContext) throws {
648-
object.setProperty("greet") { [self] this, arguments in
648+
object.setProperty("greet") { [self] (this: borrowing JavaScriptUnownedValue, arguments: consuming JavaScriptValuesBuffer) in
649649
guard arguments.count == 1 else {
650650
throw Exceptions.ArgumentsRangeMismatch((functionName: "greet", received: arguments.count, required: 1, maximum: 1))
651651
}
@@ -655,7 +655,7 @@ struct ExpoModuleMacroTests {
655655
}
656656
let statusDescriptor = runtime.createObject()
657657
statusDescriptor.setProperty("enumerable", value: true)
658-
statusDescriptor.setProperty("get") { [self] this, arguments in
658+
statusDescriptor.setProperty("get") { [self] (this: borrowing JavaScriptUnownedValue, arguments: consuming JavaScriptValuesBuffer) in
659659
return self.status.toJavaScriptValue(in: runtime)
660660
}
661661
object.defineProperty("status", descriptor: statusDescriptor)
@@ -687,7 +687,7 @@ struct ExpoModuleMacroTests {
687687

688688
@JavaScriptActor
689689
public func _decorateModule(object: borrowing JavaScriptObject, in runtime: JavaScriptRuntime, appContext: AppContext) throws {
690-
object.setProperty("compute") { [self] this, arguments in
690+
object.setProperty("compute") { [self] (this: borrowing JavaScriptUnownedValue, arguments: consuming JavaScriptValuesBuffer) in
691691
guard arguments.count == 0 else {
692692
throw Exceptions.ArgumentsRangeMismatch((functionName: "compute", received: arguments.count, required: 0, maximum: 0))
693693
}

apple/Tests/ExpoModulesMacrosTests/SharedObjectMacroTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ struct ExpoModuleClassesTests {
336336

337337
@JavaScriptActor
338338
public func _decorateModule(object: borrowing JavaScriptObject, in runtime: JavaScriptRuntime, appContext: AppContext) throws {
339-
object.setProperty("ping") { [self] this, arguments in
339+
object.setProperty("ping") { [self] (this: borrowing JavaScriptUnownedValue, arguments: consuming JavaScriptValuesBuffer) in
340340
guard arguments.count == 0 else {
341341
throw Exceptions.ArgumentsRangeMismatch((functionName: "ping", received: arguments.count, required: 0, maximum: 0))
342342
}

0 commit comments

Comments
 (0)