Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions IntegrationTests/TestSuites/Sources/PrimaryTests/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,6 @@ Host_Function_Registration: do {
try expectEqual(call_host_1Func(), .number(1))
try expectEqual(isHostFunc1Called, true)

hostFunc1.release()

let hostFunc2 = JSClosure { (arguments) -> JSValue in
do {
let input = try expectNumber(arguments[0])
Expand All @@ -220,7 +218,6 @@ Host_Function_Registration: do {

try expectEqual(hostFunc2(3), .number(6))
_ = try expectString(hostFunc2(true))
hostFunc2.release()
} catch {
print(error)
}
Expand Down Expand Up @@ -334,3 +331,16 @@ ObjectRef_Lifetime: do {
} catch {
print(error)
}

func closureScope() -> ObjectIdentifier {
let closure = JSClosure { _ in .undefined }
return ObjectIdentifier(closure)
}

Closure_Identifiers: do {
let oid1 = closureScope()
let oid2 = closureScope()
try expectEqual(oid1, oid2)
} catch {
print(error)
}
2 changes: 1 addition & 1 deletion Sources/JavaScriptKit/JSFunction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public class JSClosure: JSFunctionRef {
id = objectRef
}

public func release() {
deinit {
Self.sharedFunctions[hostFuncRef] = nil
}
}
Expand Down