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.com// Flags: --allow-natives-syntax 299a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 309a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comfunction L0() { 319a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com return %_ArgumentsLength(); 329a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 339a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 349a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comfunction L1(a) { 359a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com return %_ArgumentsLength(); 369a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 379a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 389a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comfunction L5(a,b,c,d,e) { 399a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com return %_ArgumentsLength(); 409a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 419a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 429a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 439a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(0, L0()); 449a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(1, L0(1)); 459a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(2, L0(1,2)); 469a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(5, L0(1,2,3,4,5)); 479a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 489a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(0, L1()); 499a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(1, L1(1)); 509a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(2, L1(1,2)); 519a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(5, L1(1,2,3,4,5)); 529a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 539a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(0, L5()); 549a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(1, L5(1)); 559a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(2, L5(1,2)); 569a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(5, L5(1,2,3,4,5)); 579a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 589a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 599a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comfunction A(key) { 609a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com return %_Arguments(key); 619a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 629a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 639a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// Integer access. 649a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(0, A(0)); 659a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(0, A(0,1)); 669a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(2, A(1,2)); 679a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(2, A(1,2,3,4,5)); 689a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(5, A(4,2,3,4,5)); 699a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertTrue(typeof A(1) == 'undefined'); 709a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertTrue(typeof A(3,2,1) == 'undefined'); 719a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 729a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// Out-of-bounds integer access with and without argument 739a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// adaptor frames. 749a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertTrue(typeof(A(-10000)) == 'undefined'); 759a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertTrue(typeof(A(-10000, 0)) == 'undefined'); 769a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertTrue(typeof(A(-1)) == 'undefined'); 779a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertTrue(typeof(A(-1, 0)) == 'undefined'); 789a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertTrue(typeof(A(10000)) == 'undefined'); 799a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertTrue(typeof(A(10000, 0)) == 'undefined'); 809a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 819a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// String access. 82160a7b0747492f3f735353d9582521f3314bf4dfdanno@chromium.orgassertEquals('0', A('0')); 83160a7b0747492f3f735353d9582521f3314bf4dfdanno@chromium.orgassertEquals('0', A('0',1)); 849a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(2, A('1',2)); 859a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(2, A('1',2,3,4,5)); 869a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(5, A('4',2,3,4,5)); 87160a7b0747492f3f735353d9582521f3314bf4dfdanno@chromium.orgassertEquals('undefined', typeof A('1')); 88160a7b0747492f3f735353d9582521f3314bf4dfdanno@chromium.orgassertEquals('undefined', typeof A('3',2,1)); 899a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(A, A('callee')); 909a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(1, A('length')); 919a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(2, A('length',2)); 929a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(5, A('length',2,3,4,5)); 939a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals({}.toString, A('toString')); 949a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals({}.isPrototypeOf, A('isPrototypeOf')); 95160a7b0747492f3f735353d9582521f3314bf4dfdanno@chromium.orgassertEquals('undefined', typeof A('xxx')); 969a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 979a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// Object access. 989a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comfunction O(key) { 999a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com return { toString: function() { return key; } }; 1009a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com} 1019a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 102160a7b0747492f3f735353d9582521f3314bf4dfdanno@chromium.orgvar O0 = O(0); 103160a7b0747492f3f735353d9582521f3314bf4dfdanno@chromium.orgassertSame(O0, A(O0)); 104160a7b0747492f3f735353d9582521f3314bf4dfdanno@chromium.orgassertSame(O0, A(O0,1)); 1059a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(2, A(O(1),2)); 1069a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(2, A(O(1),2,3,4,5)); 1079a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(5, A(O(4),2,3,4,5)); 1089a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertTrue(typeof A(O(1)) == 'undefined'); 1099a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertTrue(typeof A(O(3),2,1) == 'undefined'); 1109a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 111160a7b0747492f3f735353d9582521f3314bf4dfdanno@chromium.orgO0 = O('0'); 112160a7b0747492f3f735353d9582521f3314bf4dfdanno@chromium.orgassertSame(O0, A(O0)); 113160a7b0747492f3f735353d9582521f3314bf4dfdanno@chromium.orgassertSame(O0, A(O0,1)); 1149a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(2, A(O('1'),2)); 1159a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(2, A(O('1'),2,3,4,5)); 1169a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(5, A(O('4'),2,3,4,5)); 1179a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertTrue(typeof A(O('1')) == 'undefined'); 1189a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertTrue(typeof A(O('3'),2,1) == 'undefined'); 1199a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(A, A(O('callee'))); 1209a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(1, A(O('length'))); 1219a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(2, A(O('length'),2)); 1229a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(5, A(O('length'),2,3,4,5)); 1239a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals({}.toString, A(O('toString'))); 1249a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals({}.isPrototypeOf, A(O('isPrototypeOf'))); 1259a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertTrue(typeof A(O('xxx')) == 'undefined'); 1269a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 1279a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// Make sure that out-of-bounds access do lookups in the 1289a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// prototype chain. 1299a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comObject.prototype[5] = 42; 1309a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(42, A(5)); 1319a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comObject.prototype[-5] = 87; 1329a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(87, A(-5)); 133