19258b6bc66e09368ada54001f619d53b4fc976d5ager@chromium.org// Copyright 2008 the V8 project authors. All rights reserved. 29a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// Redistribution and use in source and binary forms, with or without 39a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// modification, are permitted provided that the following conditions are 49a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// met: 59a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// 69a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// * Redistributions of source code must retain the above copyright 79a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// notice, this list of conditions and the following disclaimer. 89a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// * Redistributions in binary form must reproduce the above 99a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// copyright notice, this list of conditions and the following 109a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// disclaimer in the documentation and/or other materials provided 119a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// with the distribution. 129a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// * Neither the name of Google Inc. nor the names of its 139a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// contributors may be used to endorse or promote products derived 149a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// from this software without specific prior written permission. 159a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// 169a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 179a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 189a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 199a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 209a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 219a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 229a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 239a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 249a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 259a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 269a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 279a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 289a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comvar a = [0,1,2,3]; 29ce5e87bd905d592a8bd612b3dedf7a994177c13aager@chromium.orgassertEquals(0, a.length = 0); 309a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 319a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals('undefined', typeof a[0]); 329a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals('undefined', typeof a[1]); 339a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals('undefined', typeof a[2]); 349a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals('undefined', typeof a[3]); 359a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 369a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 379a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comvar a = [0,1,2,3]; 38ce5e87bd905d592a8bd612b3dedf7a994177c13aager@chromium.orgassertEquals(2, a.length = 2); 399a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 409a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(0, a[0]); 419a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(1, a[1]); 429a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals('undefined', typeof a[2]); 439a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals('undefined', typeof a[3]); 449a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 459a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 469a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comvar a = new Array(); 479a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.coma[0] = 0; 489a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.coma[1000] = 1000; 499a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.coma[1000000] = 1000000; 509a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.coma[2000000] = 2000000; 519a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 529a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(2000001, a.length); 53ce5e87bd905d592a8bd612b3dedf7a994177c13aager@chromium.orgassertEquals(0, a.length = 0); 549a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(0, a.length); 559a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals('undefined', typeof a[0]); 569a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals('undefined', typeof a[1000]); 579a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals('undefined', typeof a[1000000]); 589a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals('undefined', typeof a[2000000]); 599a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 609a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 619a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comvar a = new Array(); 629a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.coma[0] = 0; 639a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.coma[1000] = 1000; 649a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.coma[1000000] = 1000000; 659a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.coma[2000000] = 2000000; 669a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 679a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(2000001, a.length); 68ce5e87bd905d592a8bd612b3dedf7a994177c13aager@chromium.orgassertEquals(2000, a.length = 2000); 699a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(2000, a.length); 709a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(0, a[0]); 719a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(1000, a[1000]); 729a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals('undefined', typeof a[1000000]); 739a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals('undefined', typeof a[2000000]); 749a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 759a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 769a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comvar a = new Array(); 779a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.coma[Math.pow(2,31)-1] = 0; 789a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.coma[Math.pow(2,30)-1] = 0; 799a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(Math.pow(2,31), a.length); 809a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 819a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 829a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comvar a = new Array(); 839a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.coma[0] = 0; 849a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.coma[1000] = 1000; 859a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.coma[Math.pow(2,30)-1] = Math.pow(2,30)-1; 869a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.coma[Math.pow(2,31)-1] = Math.pow(2,31)-1; 879a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.coma[Math.pow(2,32)-2] = Math.pow(2,32)-2; 889a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 899a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(Math.pow(2,30)-1, a[Math.pow(2,30)-1]); 909a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(Math.pow(2,31)-1, a[Math.pow(2,31)-1]); 919a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(Math.pow(2,32)-2, a[Math.pow(2,32)-2]); 929a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 939a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(Math.pow(2,32)-1, a.length); 94ce5e87bd905d592a8bd612b3dedf7a994177c13aager@chromium.orgassertEquals(Math.pow(2,30) + 1, a.length = Math.pow(2,30)+1); // not a smi! 959a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(Math.pow(2,30)+1, a.length); 969a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 979a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(0, a[0]); 989a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(1000, a[1000]); 999a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(Math.pow(2,30)-1, a[Math.pow(2,30)-1]); 1009a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals('undefined', typeof a[Math.pow(2,31)-1]); 1019a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals('undefined', typeof a[Math.pow(2,32)-2], "top"); 1029a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1039a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1049a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comvar a = new Array(); 105160a7b0747492f3f735353d9582521f3314bf4dfdanno@chromium.orgassertEquals(Object(12), a.length = new Number(12)); 1069a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(12, a.length); 1079a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1089a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1099a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comvar o = { length: -23 }; 1109a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comArray.prototype.pop.apply(o); 1119a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(4294967272, o.length); 112ce5e87bd905d592a8bd612b3dedf7a994177c13aager@chromium.org 113ce5e87bd905d592a8bd612b3dedf7a994177c13aager@chromium.org// Check case of compiled stubs. 114ce5e87bd905d592a8bd612b3dedf7a994177c13aager@chromium.orgvar a = []; 115ce5e87bd905d592a8bd612b3dedf7a994177c13aager@chromium.orgfor (var i = 0; i < 7; i++) { 116ce5e87bd905d592a8bd612b3dedf7a994177c13aager@chromium.org assertEquals(3, a.length = 3); 117ce5e87bd905d592a8bd612b3dedf7a994177c13aager@chromium.org 118ce5e87bd905d592a8bd612b3dedf7a994177c13aager@chromium.org var t = 239; 119ce5e87bd905d592a8bd612b3dedf7a994177c13aager@chromium.org t = a.length = 7; 120ce5e87bd905d592a8bd612b3dedf7a994177c13aager@chromium.org assertEquals(7, t); 121ce5e87bd905d592a8bd612b3dedf7a994177c13aager@chromium.org} 122