test/mjsunit/object-seal.js
// Verify flat, map, slice, flatMap, join, reduce, reduceRight for sealed holey array
Verify flat, map, slice, flatMap, join, reduce, reduceRight for sealed holey array
Verify flat map slice flatMap join reduce reduceRight for sealed holey array
function testHoleySealedArray2(arr) {
  assertTrue(Object.isSealed(arr));
  assertFalse(Object.isFrozen(arr));
  assertEquals(arr.map(x => [x]), [, ['a'], ['b'], ['c']]);
  assertEquals(arr.flatMap(x => [x]), ["a", "b", "c"]);
  assertEquals(arr.flat(), ["a", "b", "c"]);
  assertEquals(arr.join('-'), "-a-b-c");
  const reducer = (accumulator, currentValue) => accumulator + currentValue;
  assertEquals(arr.reduce(reducer), "abc");
  assertEquals(arr.reduceRight(reducer), "cba");
  assertEquals(arr.slice(0, 1), [,]);
  assertEquals(arr.slice(1, 2), ["a"]);
  assertThrows(function(){arr.sort();}, TypeError);
  assertEquals(arr.join(''), "abc");
  assertThrows(function(){arr.reverse();}, TypeError);
  assertEquals(arr.join(''), "abc");
  assertThrows(function(){arr.copyWithin(0, 1, 2);}, TypeError);
  assertEquals(arr.join(''),"abc");
  arr.copyWithin(1, 2, 3);
  assertEquals(arr.join(''),"bbc");
  assertThrows(function(){arr.fill('d');}, TypeError);
  assertEquals(arr.join(''), "bbc");
}
function testHoleySealedArray2 ( arr ) { assertTrue ( Object . isSealed ( arr ) ) ; assertFalse ( Object . isFrozen ( arr ) ) ; assertEquals ( arr . map ( x => [ x ] ) , [ , [ 'a' ] , [ 'b' ] , [ 'c' ] ] ) ; assertEquals ( arr . flatMap ( x => [ x ] ) , [ "a" , "b" , "c" ] ) ; assertEquals ( arr . flat ( ) , [ "a" , "b" , "c" ] ) ; assertEquals ( arr . join ( '-' ) , "-a-b-c" ) ; const reducer = ( accumulator , currentValue ) => accumulator + currentValue ; assertEquals ( arr . reduce ( reducer ) , "abc" ) ; assertEquals ( arr . reduceRight ( reducer ) , "cba" ) ; assertEquals ( arr . slice ( 0 , 1 ) , [ , ] ) ; assertEquals ( arr . slice ( 1 , 2 ) , [ "a" ] ) ; assertThrows ( function ( ) { arr . sort ( ) ; } , TypeError ) ; assertEquals ( arr . join ( '' ) , "abc" ) ; assertThrows ( function ( ) { arr . reverse ( ) ; } , TypeError ) ; assertEquals ( arr . join ( '' ) , "abc" ) ; assertThrows ( function ( ) { arr . copyWithin ( 0 , 1 , 2 ) ; } , TypeError ) ; assertEquals ( arr . join ( '' ) , "abc" ) ; arr . copyWithin ( 1 , 2 , 3 ) ; assertEquals ( arr . join ( '' ) , "bbc" ) ; assertThrows ( function ( ) { arr . fill ( 'd' ) ; } , TypeError ) ; assertEquals ( arr . join ( '' ) , "bbc" ) ; }
Verify flat, map, slice, flatMap, join, reduce, reduceRight for sealed holey array
Verify flat map slice flatMap join reduce reduceRight for sealed holey array
// Verify change content of sealed holey array