@@ -268,14 +268,26 @@ try test("Call Function With This") {
268268 // ```
269269 let objectConstructor = try expectFunction ( getJSValue ( this: . global, name: " Animal " ) )
270270 let cat1 = objectConstructor. new ( " Tama " , 3 , true )
271+ let cat1Value = JSValue . object ( cat1)
271272 let getIsCat = try expectFunction ( getJSValue ( this: cat1, name: " getIsCat " ) )
273+ let setName = try expectFunction ( getJSValue ( this: cat1, name: " setName " ) )
272274
273275 // Direct call without this
274276 try expectEqual ( getIsCat ( ) , . undefined)
275277
276278 // Call with this
277279 let gotIsCat = getIsCat ( this: cat1)
278280 try expectEqual ( gotIsCat, . boolean( true ) )
281+ try expectEqual ( cat1. getIsCat!( ) , . boolean( true ) )
282+ try expectEqual ( cat1Value. getIsCat ( ) , . boolean( true ) )
283+
284+ // Call with this and argument
285+ setName ( this: cat1, JSValue . string ( " Shiro " ) )
286+ try expectEqual ( getJSValue ( this: cat1, name: " name " ) , . string( " Shiro " ) )
287+ _ = cat1. setName!( " Tora " )
288+ try expectEqual ( getJSValue ( this: cat1, name: " name " ) , . string( " Tora " ) )
289+ _ = cat1Value. setName ( " Chibi " )
290+ try expectEqual ( getJSValue ( this: cat1, name: " name " ) , . string( " Chibi " ) )
279291}
280292
281293try test ( " Object Conversion " ) {
@@ -496,3 +508,12 @@ try test("Error") {
496508 try expectEqual ( JSError ( from: . string( " error " ) ) ? . description, nil )
497509 try expectEqual ( JSError ( from: . object( error. jsObject) ) ? . description, expectedDescription)
498510}
511+
512+ try test ( " JSValue accessor " ) {
513+ let globalObject1 = JSObject . global. globalObject1
514+ try expectEqual ( globalObject1. prop_1. nested_prop, . number( 1 ) )
515+ try expectEqual ( globalObject1. object!. prop_1. object!. nested_prop, . number( 1 ) )
516+
517+ try expectEqual ( globalObject1. prop_4 [ 0 ] , . number( 3 ) )
518+ try expectEqual ( globalObject1. prop_4 [ 1 ] , . number( 4 ) )
519+ }
0 commit comments