@@ -268,14 +268,26 @@ try test("Call Function With This") {
268
268
// ```
269
269
let objectConstructor = try expectFunction ( getJSValue ( this: . global, name: " Animal " ) )
270
270
let cat1 = objectConstructor. new ( " Tama " , 3 , true )
271
+ let cat1Value = JSValue . object ( cat1)
271
272
let getIsCat = try expectFunction ( getJSValue ( this: cat1, name: " getIsCat " ) )
273
+ let setName = try expectFunction ( getJSValue ( this: cat1, name: " setName " ) )
272
274
273
275
// Direct call without this
274
276
try expectEqual ( getIsCat ( ) , . undefined)
275
277
276
278
// Call with this
277
279
let gotIsCat = getIsCat ( this: cat1)
278
280
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 " ) )
279
291
}
280
292
281
293
try test ( " Object Conversion " ) {
@@ -496,3 +508,12 @@ try test("Error") {
496
508
try expectEqual ( JSError ( from: . string( " error " ) ) ? . description, nil )
497
509
try expectEqual ( JSError ( from: . object( error. jsObject) ) ? . description, expectedDescription)
498
510
}
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