Skip to content

Commit c008ee0

Browse files
Tests: Cover a test case to kill JSObject? double-release
1 parent 9de77fc commit c008ee0

File tree

4 files changed

+44
-0
lines changed

4 files changed

+44
-0
lines changed

Tests/BridgeJSRuntimeTests/Generated/BridgeJS.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5843,6 +5843,16 @@ public func _bjs_roundTripOptionalTypedPayloadResult(_ resultIsSome: Int32, _ re
58435843
#endif
58445844
}
58455845

5846+
@_expose(wasm, "bjs_takeOptionalJSObject")
5847+
@_cdecl("bjs_takeOptionalJSObject")
5848+
public func _bjs_takeOptionalJSObject(_ valueIsSome: Int32, _ valueValue: Int32) -> Void {
5849+
#if arch(wasm32)
5850+
takeOptionalJSObject(_: Optional<JSObject>.bridgeJSLiftParameter(valueIsSome, valueValue))
5851+
#else
5852+
fatalError("Only available on WebAssembly")
5853+
#endif
5854+
}
5855+
58465856
@_expose(wasm, "bjs_compareAPIResults")
58475857
@_cdecl("bjs_compareAPIResults")
58485858
public func _bjs_compareAPIResults(_ r1IsSome: Int32, _ r1CaseId: Int32, _ r2IsSome: Int32, _ r2CaseId: Int32) -> Void {

Tests/BridgeJSRuntimeTests/Generated/JavaScript/BridgeJS.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10564,6 +10564,36 @@
1056410564
}
1056510565
}
1056610566
},
10567+
{
10568+
"abiName" : "bjs_takeOptionalJSObject",
10569+
"effects" : {
10570+
"isAsync" : false,
10571+
"isStatic" : false,
10572+
"isThrows" : false
10573+
},
10574+
"name" : "takeOptionalJSObject",
10575+
"parameters" : [
10576+
{
10577+
"label" : "_",
10578+
"name" : "value",
10579+
"type" : {
10580+
"nullable" : {
10581+
"_0" : {
10582+
"jsObject" : {
10583+
10584+
}
10585+
},
10586+
"_1" : "null"
10587+
}
10588+
}
10589+
}
10590+
],
10591+
"returnType" : {
10592+
"void" : {
10593+
10594+
}
10595+
}
10596+
},
1056710597
{
1056810598
"abiName" : "bjs_compareAPIResults",
1056910599
"effects" : {

Tests/BridgeJSRuntimeTests/JavaScript/OptionalSupportTests.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,4 +241,6 @@ export function runJsOptionalSupportTests(exports) {
241241
assert.deepEqual(exports.roundTripOptionalPayloadResultOpt(oatr_empty), oatr_empty);
242242
assert.equal(exports.roundTripOptionalPayloadResultOpt(null), null);
243243

244+
exports.takeOptionalJSObject(null);
245+
assert.doesNotThrow(() => exports.takeOptionalJSObject({ key: "value" }));
244246
}

Tests/BridgeJSRuntimeTests/OptionalSupportTests.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ typealias OptionalAge = Int?
127127
result
128128
}
129129

130+
@JS func takeOptionalJSObject(_ value: JSObject?) {}
131+
130132
@JS func compareAPIResults(_ r1: APIResult?, _ r2: APIResult?) -> String {
131133
let r1Str: String
132134
switch r1 {

0 commit comments

Comments
 (0)