js/src/tests/test262/ch08/8.7/S8.7_A2.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/test262/ch08/8.7/S8.7_A2.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,42 @@
     1.4 +// Copyright 2009 the Sputnik authors.  All rights reserved.
     1.5 +// This code is governed by the BSD license found in the LICENSE file.
     1.6 +
     1.7 +/**
     1.8 + * Reference to Self-Modifying Object remain the integrity
     1.9 + *
    1.10 + * @path ch08/8.7/S8.7_A2.js
    1.11 + * @description Create a reference to the array, and change original array
    1.12 + */
    1.13 +
    1.14 +//////////////////////////////////////////////////////////////////////////////
    1.15 +//CHECK#1
    1.16 +// Create an array of items
    1.17 +var items = new Array( "one", "two", "three" );
    1.18 +// Create a reference to the array of items
    1.19 +var itemsRef = items;
    1.20 +// Add an item to the original array
    1.21 +items.push( "four" );var itemsRef = items;
    1.22 +// The length of each array should be the same,
    1.23 +// since they both point to the same array object
    1.24 +if( itemsRef.length !== 4){
    1.25 +  $ERROR('#1: var items = new Array( "one", "two", "three" ); var itemsRef = items; items.push( "four" );var itemsRef = items; itemsRef.length !== 4');
    1.26 +};
    1.27 +//
    1.28 +//////////////////////////////////////////////////////////////////////////////
    1.29 +
    1.30 +//////////////////////////////////////////////////////////////////////////////
    1.31 +//CHECK#
    1.32 +// Create an array of items
    1.33 +var items = new Array( "one", "two", "three" );
    1.34 +// Create a reference to the array of items
    1.35 +var itemsRef = items;
    1.36 +// Add an item to the original array
    1.37 +items[1]="duo";
    1.38 +// The length of each array should be the same,
    1.39 +// since they both point to the same array object
    1.40 +if( itemsRef[1] !== "duo"){
    1.41 +  $ERROR('#2: var items = new Array( "one", "two", "three" ); var itemsRef = items; items[1]="duo"; itemsRef[1] === "duo". Actual: ' + (itemsRef[1]));
    1.42 +};
    1.43 +//
    1.44 +//////////////////////////////////////////////////////////////////////////////
    1.45 +

mercurial