@@ -86,22 +86,36 @@ try test("Array Iterator") {
8686 let globalObject1 = getJSValue ( this: . global, name: " globalObject1 " )
8787 let globalObject1Ref = try expectObject ( globalObject1)
8888 let prop_4 = getJSValue ( this: globalObject1Ref, name: " prop_4 " )
89- let array = try expectArray ( prop_4)
89+ let array1 = try expectArray ( prop_4)
9090 let expectedProp_4 : [ JSValue ] = [
9191 . number( 3 ) , . number( 4 ) , . string( " str_elm_1 " ) , . null, . undefined, . number( 5 ) ,
9292 ]
93- try expectEqual ( Array ( array) , expectedProp_4)
93+ try expectEqual ( Array ( array1) , expectedProp_4)
94+
95+ // Ensure that iterator skips empty hole as JavaScript does.
96+ let prop_8 = getJSValue ( this: globalObject1Ref, name: " prop_8 " )
97+ let array2 = try expectArray ( prop_8)
98+ let expectedProp_8 : [ JSValue ] = [ 0 , 2 , 3 , 6 ]
99+ try expectEqual ( Array ( array2) , expectedProp_8)
94100}
95101
96102try test ( " Array RandomAccessCollection " ) {
97103 let globalObject1 = getJSValue ( this: . global, name: " globalObject1 " )
98104 let globalObject1Ref = try expectObject ( globalObject1)
99105 let prop_4 = getJSValue ( this: globalObject1Ref, name: " prop_4 " )
100- let array = try expectArray ( prop_4)
106+ let array1 = try expectArray ( prop_4)
101107 let expectedProp_4 : [ JSValue ] = [
102108 . number( 3 ) , . number( 4 ) , . string( " str_elm_1 " ) , . null, . undefined, . number( 5 ) ,
103109 ]
104- try expectEqual ( [ array [ 0 ] , array [ 1 ] , array [ 2 ] , array [ 3 ] , array [ 4 ] , array [ 5 ] ] , expectedProp_4)
110+ try expectEqual ( [ array1 [ 0 ] , array1 [ 1 ] , array1 [ 2 ] , array1 [ 3 ] , array1 [ 4 ] , array1 [ 5 ] ] , expectedProp_4)
111+
112+ // Ensure that subscript can access empty hole
113+ let prop_8 = getJSValue ( this: globalObject1Ref, name: " prop_8 " )
114+ let array2 = try expectArray ( prop_8)
115+ let expectedProp_8 : [ JSValue ] = [
116+ 0 , . undefined, 2 , 3 , . undefined, . undefined, 6
117+ ]
118+ try expectEqual ( [ array2 [ 0 ] , array2 [ 1 ] , array2 [ 2 ] , array2 [ 3 ] , array2 [ 4 ] , array2 [ 5 ] , array2 [ 6 ] ] , expectedProp_8)
105119}
106120
107121try test ( " Value Decoder " ) {
0 commit comments