@@ -397,6 +397,62 @@ describe(module.id, function () {
397397 interop . free ( ptr ) ;
398398 } ) ;
399399
400+ it ( "Reference access indexed values from pointer array property" , function ( ) {
401+ const structs = [
402+ new TNSPoint ( { x : 1 , y : 2 } ) ,
403+ new TNSPoint ( { x : 3 , y : 4 } ) ,
404+ new TNSPoint ( { x : 5 , y : 6 } )
405+ ] ;
406+ const length = structs . length ;
407+ const ptr = interop . alloc ( interop . sizeof ( TNSPoint ) * length ) ;
408+
409+ const ref = new interop . Reference ( TNSPoint , ptr ) ;
410+ for ( let i = 0 ; i < length ; i ++ ) {
411+ ref [ i ] = structs [ i ] ;
412+ }
413+
414+ const pointCollection = TNSPointCollection . alloc ( ) . initWithPointsCount ( ptr , length ) ;
415+
416+ // Runtime converts pointers into references for cases with type so use handleof to get pointer
417+ const pointsPtr = interop . handleof ( pointCollection . points ) ;
418+
419+ // Check if values were retrieved from pointer
420+ const resultRef = new interop . Reference ( TNSPoint , pointsPtr ) ;
421+ for ( let i = 0 ; i < length ; i ++ ) {
422+ expect ( TNSPoint . equals ( resultRef [ i ] , structs [ i ] ) ) . toBe ( true ) ;
423+ }
424+
425+ interop . free ( ptr ) ;
426+ interop . free ( pointsPtr ) ;
427+ } ) ;
428+
429+ it ( "Reference access value from pointer array property" , function ( ) {
430+ const structs = [
431+ new TNSPoint ( { x : 1 , y : 2 } ) ,
432+ new TNSPoint ( { x : 3 , y : 4 } ) ,
433+ new TNSPoint ( { x : 5 , y : 6 } )
434+ ] ;
435+ const length = structs . length ;
436+ const ptr = interop . alloc ( interop . sizeof ( TNSPoint ) * length ) ;
437+
438+ const ref = new interop . Reference ( TNSPoint , ptr ) ;
439+ for ( let i = 0 ; i < length ; i ++ ) {
440+ ref [ i ] = structs [ i ] ;
441+ }
442+
443+ const pointCollection = TNSPointCollection . alloc ( ) . initWithPointsCount ( ptr , length ) ;
444+
445+ // Runtime converts pointers into references for cases with type so use handleof to get pointer
446+ const pointsPtr = interop . handleof ( pointCollection . points ) ;
447+
448+ // Check if values were retrieved from pointer
449+ const resultRef = new interop . Reference ( TNSPoint , pointsPtr ) ;
450+ expect ( TNSPoint . equals ( resultRef . value , structs [ 0 ] ) ) . toBe ( true ) ;
451+
452+ interop . free ( ptr ) ;
453+ interop . free ( pointsPtr ) ;
454+ } ) ;
455+
400456 it ( "interops string from CString with fixed length" , function ( ) {
401457 const str = "te\0st" ;
402458 const ptr = interop . alloc ( ( str . length + 1 ) * interop . sizeof ( interop . types . uint8 ) ) ;
0 commit comments