@@ -186,6 +186,12 @@ try test("Function Call") {
186186let evalClosure = JSObject . global. globalObject1. eval_closure. function!
187187
188188try 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+
189195 do {
190196 let c1 = JSClosure { arguments in
191197 return arguments [ 0 ]
@@ -200,7 +206,7 @@ try test("Closure Lifetime") {
200206 }
201207 c1. release ( )
202208 // Call a released closure
203- _ = try expectThrow ( try evalClosure . throws ( c1 ) )
209+ try expectCrashByCall ( ofClosure : c1 )
204210 }
205211
206212 do {
@@ -209,7 +215,7 @@ try test("Closure Lifetime") {
209215 _ = JSClosure { _ in . undefined }
210216 return . undefined
211217 }
212- _ = try expectThrow ( try evalClosure . throws ( c1 ) )
218+ try expectCrashByCall ( ofClosure : c1 )
213219 c1. release ( )
214220 }
215221
@@ -219,7 +225,7 @@ try test("Closure Lifetime") {
219225 }
220226 try expectEqual ( evalClosure ( c1) , . boolean( true ) )
221227 // 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 )
223229 // OneshotClosure won't call fatalError even if it's deallocated before `release`
224230 }
225231}
@@ -617,12 +623,25 @@ try test("Error") {
617623}
618624
619625try test ( " JSValue accessor " ) {
620- let globalObject1 = JSObject . global. globalObject1
626+ var globalObject1 = JSObject . global. globalObject1
621627 try expectEqual ( globalObject1. prop_1. nested_prop, . number( 1 ) )
622628 try expectEqual ( globalObject1. object!. prop_1. object!. nested_prop, . number( 1 ) )
623629
624630 try expectEqual ( globalObject1. prop_4 [ 0 ] , . number( 3 ) )
625631 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+ */
626645}
627646
628647try test ( " Exception " ) {
0 commit comments