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 {
491
491
// Always add __construct and constructor methods for all classes
492
492
var constructorLines : [ String ] = [ ]
493
493
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
+ )
495
497
constructorLines. append ( " } " )
496
498
constructorLines. append ( " " )
497
499
constructorLines. append ( " constructor(pointer, deinit) { " )
Original file line number Diff line number Diff line change @@ -74,18 +74,18 @@ struct TestError: Error {
74
74
g. changeName ( name: name)
75
75
}
76
76
77
- // Test class without @JS init constructor
77
+ // Test class without @JS init constructor
78
78
@JS class Calculator {
79
79
nonisolated ( unsafe) static var onDeinit : ( ) -> Void = { }
80
-
80
+
81
81
@JS func square( value: Int ) -> Int {
82
82
return value * value
83
83
}
84
-
84
+
85
85
@JS func add( a: Int , b: Int ) -> Int {
86
86
return a + b
87
87
}
88
-
88
+
89
89
deinit {
90
90
Self . onDeinit ( )
91
91
}
@@ -99,22 +99,21 @@ struct TestError: Error {
99
99
return calc. add ( a: calc. square ( value: x) , b: y)
100
100
}
101
101
102
-
103
102
class ExportAPITests : XCTestCase {
104
103
func testAll( ) {
105
104
var hasDeinitGreeter = false
106
105
var hasDeinitCalculator = false
107
-
106
+
108
107
Greeter . onDeinit = {
109
108
hasDeinitGreeter = true
110
109
}
111
-
110
+
112
111
Calculator . onDeinit = {
113
112
hasDeinitCalculator = true
114
113
}
115
-
114
+
116
115
runJsWorks ( )
117
-
116
+
118
117
XCTAssertTrue ( hasDeinitGreeter, " Greeter (with @JS init) should have been deinitialized " )
119
118
XCTAssertTrue ( hasDeinitCalculator, " Calculator (without @JS init) should have been deinitialized " )
120
119
}
You can’t perform that action at this time.
0 commit comments