15c838251403b0be9a882540f1922577abba4c872ager@chromium.org// Copyright 2010 the V8 project authors. All rights reserved. 25c838251403b0be9a882540f1922577abba4c872ager@chromium.org// Redistribution and use in source and binary forms, with or without 35c838251403b0be9a882540f1922577abba4c872ager@chromium.org// modification, are permitted provided that the following conditions are 45c838251403b0be9a882540f1922577abba4c872ager@chromium.org// met: 55c838251403b0be9a882540f1922577abba4c872ager@chromium.org// 65c838251403b0be9a882540f1922577abba4c872ager@chromium.org// * Redistributions of source code must retain the above copyright 75c838251403b0be9a882540f1922577abba4c872ager@chromium.org// notice, this list of conditions and the following disclaimer. 85c838251403b0be9a882540f1922577abba4c872ager@chromium.org// * Redistributions in binary form must reproduce the above 95c838251403b0be9a882540f1922577abba4c872ager@chromium.org// copyright notice, this list of conditions and the following 105c838251403b0be9a882540f1922577abba4c872ager@chromium.org// disclaimer in the documentation and/or other materials provided 115c838251403b0be9a882540f1922577abba4c872ager@chromium.org// with the distribution. 125c838251403b0be9a882540f1922577abba4c872ager@chromium.org// * Neither the name of Google Inc. nor the names of its 135c838251403b0be9a882540f1922577abba4c872ager@chromium.org// contributors may be used to endorse or promote products derived 145c838251403b0be9a882540f1922577abba4c872ager@chromium.org// from this software without specific prior written permission. 155c838251403b0be9a882540f1922577abba4c872ager@chromium.org// 165c838251403b0be9a882540f1922577abba4c872ager@chromium.org// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 175c838251403b0be9a882540f1922577abba4c872ager@chromium.org// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 185c838251403b0be9a882540f1922577abba4c872ager@chromium.org// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 195c838251403b0be9a882540f1922577abba4c872ager@chromium.org// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 205c838251403b0be9a882540f1922577abba4c872ager@chromium.org// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 215c838251403b0be9a882540f1922577abba4c872ager@chromium.org// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 225c838251403b0be9a882540f1922577abba4c872ager@chromium.org// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 235c838251403b0be9a882540f1922577abba4c872ager@chromium.org// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 245c838251403b0be9a882540f1922577abba4c872ager@chromium.org// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 255c838251403b0be9a882540f1922577abba4c872ager@chromium.org// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 265c838251403b0be9a882540f1922577abba4c872ager@chromium.org// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 275c838251403b0be9a882540f1922577abba4c872ager@chromium.org 285c838251403b0be9a882540f1922577abba4c872ager@chromium.org// Simple class using inline constructor. 295c838251403b0be9a882540f1922577abba4c872ager@chromium.orgfunction C1() { 305c838251403b0be9a882540f1922577abba4c872ager@chromium.org this.x = 23; 315c838251403b0be9a882540f1922577abba4c872ager@chromium.org}; 325c838251403b0be9a882540f1922577abba4c872ager@chromium.orgvar c1 = new C1(); 335c838251403b0be9a882540f1922577abba4c872ager@chromium.orgassertEquals(23, c1.x); 345c838251403b0be9a882540f1922577abba4c872ager@chromium.orgassertEquals("undefined", typeof c1.y); 351805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.org 365c838251403b0be9a882540f1922577abba4c872ager@chromium.org// Add setter somewhere on the prototype chain after having constructed the 375c838251403b0be9a882540f1922577abba4c872ager@chromium.org// first instance. 385c838251403b0be9a882540f1922577abba4c872ager@chromium.orgC1.prototype = { set x(value) { this.y = 23; } }; 395c838251403b0be9a882540f1922577abba4c872ager@chromium.orgvar c1 = new C1(); 405c838251403b0be9a882540f1922577abba4c872ager@chromium.orgassertEquals("undefined", typeof c1.x); 415c838251403b0be9a882540f1922577abba4c872ager@chromium.orgassertEquals(23, c1.y); 421805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.org 435c838251403b0be9a882540f1922577abba4c872ager@chromium.org// Simple class using inline constructor. 445c838251403b0be9a882540f1922577abba4c872ager@chromium.orgfunction C2() { 455c838251403b0be9a882540f1922577abba4c872ager@chromium.org this.x = 23; 465c838251403b0be9a882540f1922577abba4c872ager@chromium.org}; 475c838251403b0be9a882540f1922577abba4c872ager@chromium.orgvar c2 = new C2(); 485c838251403b0be9a882540f1922577abba4c872ager@chromium.orgassertEquals(23, c2.x); 495c838251403b0be9a882540f1922577abba4c872ager@chromium.orgassertEquals("undefined", typeof c2.y); 505c838251403b0be9a882540f1922577abba4c872ager@chromium.org 515c838251403b0be9a882540f1922577abba4c872ager@chromium.org// Add setter somewhere on the prototype chain after having constructed the 525c838251403b0be9a882540f1922577abba4c872ager@chromium.org// first instance. 535c838251403b0be9a882540f1922577abba4c872ager@chromium.orgC2.prototype.__proto__ = { set x(value) { this.y = 23; } }; 545c838251403b0be9a882540f1922577abba4c872ager@chromium.orgvar c2 = new C2(); 555c838251403b0be9a882540f1922577abba4c872ager@chromium.orgassertEquals("undefined", typeof c2.x); 565c838251403b0be9a882540f1922577abba4c872ager@chromium.orgassertEquals(23, c2.y); 575c838251403b0be9a882540f1922577abba4c872ager@chromium.org 585c838251403b0be9a882540f1922577abba4c872ager@chromium.org// Simple class using inline constructor. 595c838251403b0be9a882540f1922577abba4c872ager@chromium.orgfunction C3() { 605c838251403b0be9a882540f1922577abba4c872ager@chromium.org this.x = 23; 615c838251403b0be9a882540f1922577abba4c872ager@chromium.org}; 625c838251403b0be9a882540f1922577abba4c872ager@chromium.orgvar c3 = new C3(); 635c838251403b0be9a882540f1922577abba4c872ager@chromium.orgassertEquals(23, c3.x); 645c838251403b0be9a882540f1922577abba4c872ager@chromium.orgassertEquals("undefined", typeof c3.y); 655c838251403b0be9a882540f1922577abba4c872ager@chromium.org 665c838251403b0be9a882540f1922577abba4c872ager@chromium.org// Add setter somewhere on the prototype chain after having constructed the 675c838251403b0be9a882540f1922577abba4c872ager@chromium.org// first instance. 685c838251403b0be9a882540f1922577abba4c872ager@chromium.orgC3.prototype.__defineSetter__('x', function(value) { this.y = 23; }); 695c838251403b0be9a882540f1922577abba4c872ager@chromium.orgvar c3 = new C3(); 705c838251403b0be9a882540f1922577abba4c872ager@chromium.orgassertEquals("undefined", typeof c3.x); 715c838251403b0be9a882540f1922577abba4c872ager@chromium.orgassertEquals(23, c3.y); 725c838251403b0be9a882540f1922577abba4c872ager@chromium.org 735c838251403b0be9a882540f1922577abba4c872ager@chromium.org// Simple class using inline constructor. 745c838251403b0be9a882540f1922577abba4c872ager@chromium.orgfunction C4() { 755c838251403b0be9a882540f1922577abba4c872ager@chromium.org this.x = 23; 765c838251403b0be9a882540f1922577abba4c872ager@chromium.org}; 775c838251403b0be9a882540f1922577abba4c872ager@chromium.orgvar c4 = new C4(); 785c838251403b0be9a882540f1922577abba4c872ager@chromium.orgassertEquals(23, c4.x); 795c838251403b0be9a882540f1922577abba4c872ager@chromium.orgassertEquals("undefined", typeof c4.y); 805c838251403b0be9a882540f1922577abba4c872ager@chromium.org 815c838251403b0be9a882540f1922577abba4c872ager@chromium.org// Add setter somewhere on the prototype chain after having constructed the 825c838251403b0be9a882540f1922577abba4c872ager@chromium.org// first instance. 835c838251403b0be9a882540f1922577abba4c872ager@chromium.orgC4.prototype.__proto__.__defineSetter__('x', function(value) { this.y = 23; }); 845c838251403b0be9a882540f1922577abba4c872ager@chromium.orgvar c4 = new C4(); 855c838251403b0be9a882540f1922577abba4c872ager@chromium.orgassertEquals("undefined", typeof c4.x); 865c838251403b0be9a882540f1922577abba4c872ager@chromium.orgassertEquals(23, c4.y); 87