File tree Expand file tree Collapse file tree 2 files changed +11
-10
lines changed
Plugins/BridgeJS/Sources/BridgeJSLink
Tests/BridgeJSRuntimeTests Expand file tree Collapse file tree 2 files changed +11
-10
lines changed Original file line number Diff line number Diff line change @@ -491,7 +491,9 @@ struct BridgeJSLink {
491491 // Always add __construct and constructor methods for all classes
492492 var constructorLines : [ String ] = [ ]
493493 constructorLines. append ( " static __construct(ptr) { " )
494- constructorLines. append ( " return new \( klass. name) (ptr, instance.exports.bjs_ \( klass. name) _deinit); " . indent ( count: 4 ) )
494+ constructorLines. append (
495+ " return new \( klass. name) (ptr, instance.exports.bjs_ \( klass. name) _deinit); " . indent ( count: 4 )
496+ )
495497 constructorLines. append ( " } " )
496498 constructorLines. append ( " " )
497499 constructorLines. append ( " constructor(pointer, deinit) { " )
Original file line number Diff line number Diff line change @@ -74,18 +74,18 @@ struct TestError: Error {
7474 g. changeName ( name: name)
7575}
7676
77- // Test class without @JS init constructor
77+ // Test class without @JS init constructor
7878@JS class Calculator {
7979 nonisolated ( unsafe) static var onDeinit : ( ) -> Void = { }
80-
80+
8181 @JS func square( value: Int ) -> Int {
8282 return value * value
8383 }
84-
84+
8585 @JS func add( a: Int , b: Int ) -> Int {
8686 return a + b
8787 }
88-
88+
8989 deinit {
9090 Self . onDeinit ( )
9191 }
@@ -99,22 +99,21 @@ struct TestError: Error {
9999 return calc. add ( a: calc. square ( value: x) , b: y)
100100}
101101
102-
103102class ExportAPITests : XCTestCase {
104103 func testAll( ) {
105104 var hasDeinitGreeter = false
106105 var hasDeinitCalculator = false
107-
106+
108107 Greeter . onDeinit = {
109108 hasDeinitGreeter = true
110109 }
111-
110+
112111 Calculator . onDeinit = {
113112 hasDeinitCalculator = true
114113 }
115-
114+
116115 runJsWorks ( )
117-
116+
118117 XCTAssertTrue ( hasDeinitGreeter, " Greeter (with @JS init) should have been deinitialized " )
119118 XCTAssertTrue ( hasDeinitCalculator, " Calculator (without @JS init) should have been deinitialized " )
120119 }
You can’t perform that action at this time.
0 commit comments