@@ -186,6 +186,12 @@ try test("Function Call") {
186
186
let evalClosure = JSObject . global. globalObject1. eval_closure. function!
187
187
188
188
try test ( " Closure Lifetime " ) {
189
+ func expectCrashByCall( ofClosure c: JSClosureProtocol ) throws {
190
+ print ( " ======= BEGIN OF EXPECTED FATAL ERROR ===== " )
191
+ _ = try expectThrow ( try evalClosure. throws ( c) )
192
+ print ( " ======= END OF EXPECTED FATAL ERROR ======= " )
193
+ }
194
+
189
195
do {
190
196
let c1 = JSClosure { arguments in
191
197
return arguments [ 0 ]
@@ -200,7 +206,7 @@ try test("Closure Lifetime") {
200
206
}
201
207
c1. release ( )
202
208
// Call a released closure
203
- _ = try expectThrow ( try evalClosure . throws ( c1 ) )
209
+ try expectCrashByCall ( ofClosure : c1 )
204
210
}
205
211
206
212
do {
@@ -209,7 +215,7 @@ try test("Closure Lifetime") {
209
215
_ = JSClosure { _ in . undefined }
210
216
return . undefined
211
217
}
212
- _ = try expectThrow ( try evalClosure . throws ( c1 ) )
218
+ try expectCrashByCall ( ofClosure : c1 )
213
219
c1. release ( )
214
220
}
215
221
@@ -219,7 +225,7 @@ try test("Closure Lifetime") {
219
225
}
220
226
try expectEqual ( evalClosure ( c1) , . boolean( true ) )
221
227
// second call will cause `fatalError` that can be caught as a JavaScript exception
222
- _ = try expectThrow ( try evalClosure . throws ( c1 ) )
228
+ try expectCrashByCall ( ofClosure : c1 )
223
229
// OneshotClosure won't call fatalError even if it's deallocated before `release`
224
230
}
225
231
}
@@ -617,12 +623,25 @@ try test("Error") {
617
623
}
618
624
619
625
try test ( " JSValue accessor " ) {
620
- let globalObject1 = JSObject . global. globalObject1
626
+ var globalObject1 = JSObject . global. globalObject1
621
627
try expectEqual ( globalObject1. prop_1. nested_prop, . number( 1 ) )
622
628
try expectEqual ( globalObject1. object!. prop_1. object!. nested_prop, . number( 1 ) )
623
629
624
630
try expectEqual ( globalObject1. prop_4 [ 0 ] , . number( 3 ) )
625
631
try expectEqual ( globalObject1. prop_4 [ 1 ] , . number( 4 ) )
632
+
633
+ globalObject1. prop_1. nested_prop = " bar "
634
+ try expectEqual ( globalObject1. prop_1. nested_prop, . string( " bar " ) )
635
+
636
+ /* TODO: Fix https://github.com/swiftwasm/JavaScriptKit/issues/132 and un-comment this test
637
+ `nested` should not be set again to `target.nested` by `target.nested.prop = .number(1)`
638
+
639
+ let observableObj = globalObject1.observable_obj.object!
640
+ observableObj.set_called = .boolean(false)
641
+ observableObj.target.nested.prop = .number(1)
642
+ try expectEqual(observableObj.set_called, .boolean(false))
643
+
644
+ */
626
645
}
627
646
628
647
try test ( " Exception " ) {
0 commit comments