test/mjsunit/object-seal.js
// Verify flat, map, slice, flatMap, join, reduce, reduceRight for sealed packed array
Verify flat, map, slice, flatMap, join, reduce, reduceRight for sealed packed array
Verify flat map slice flatMap join reduce reduceRight for sealed packed array
function testPackedSealedArray2(arr) {
  assertTrue(Object.isSealed(arr));
  assertFalse(Object.isFrozen(arr));
  assertEquals(arr.map(x => [x]), [['a'], ['b'], ['c']]);
  assertEquals(arr.flatMap(x => [x]), arr);
  assertEquals(arr.flat(), arr);
  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), ['a']);
  arr.sort();
  assertEquals(arr.join(''), "abc");
  arr.reverse();
  assertEquals(arr.join(''), "cba");
  arr.copyWithin(0, 1, 2);
  assertEquals(arr.join(''),"bba");
  arr.fill('d');
  assertEquals(arr.join(''), "ddd");
}
function testPackedSealedArray2 ( arr ) { assertTrue ( Object . isSealed ( arr ) ) ; assertFalse ( Object . isFrozen ( arr ) ) ; assertEquals ( arr . map ( x => [ x ] ) , [ [ 'a' ] , [ 'b' ] , [ 'c' ] ] ) ; assertEquals ( arr . flatMap ( x => [ x ] ) , arr ) ; assertEquals ( arr . flat ( ) , arr ) ; 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 ) , [ 'a' ] ) ; arr . sort ( ) ; assertEquals ( arr . join ( '' ) , "abc" ) ; arr . reverse ( ) ; assertEquals ( arr . join ( '' ) , "cba" ) ; arr . copyWithin ( 0 , 1 , 2 ) ; assertEquals ( arr . join ( '' ) , "bba" ) ; arr . fill ( 'd' ) ; assertEquals ( arr . join ( '' ) , "ddd" ) ; }
Verify flat, map, slice, flatMap, join, reduce, reduceRight for sealed packed array
Verify flat map slice flatMap join reduce reduceRight for sealed packed array
// Verify change content of sealed packed array