1402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu// Copyright 2008 the V8 project authors. All rights reserved.
2402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu// Redistribution and use in source and binary forms, with or without
3402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu// modification, are permitted provided that the following conditions are
4402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu// met:
5402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu//
6402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu//     * Redistributions of source code must retain the above copyright
7402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu//       notice, this list of conditions and the following disclaimer.
8402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu//     * Redistributions in binary form must reproduce the above
9402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu//       copyright notice, this list of conditions and the following
10402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu//       disclaimer in the documentation and/or other materials provided
11402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu//       with the distribution.
12402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu//     * Neither the name of Google Inc. nor the names of its
13402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu//       contributors may be used to endorse or promote products derived
14402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu//       from this software without specific prior written permission.
15402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu//
16402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu
28402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu// Flags: --allow-natives-syntax
29402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu
30402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescufunction RunTest(ensure_fast_case) {
31402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu  function C1() {
32402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu    this.x = 23;
33402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu  };
34402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu  C1.prototype = { set x(value) { this.y = 23; } };
35402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu  if (ensure_fast_case) {
36402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu    %ToFastProperties(C1.prototype);
37402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu  }
38589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch
39402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu  for (var i = 0; i < 10; i++) {
40402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu    var c1 = new C1();
41402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu    assertEquals("undefined", typeof c1.x);
42402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu    assertEquals(23, c1.y);
43402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu  }
44589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch
45589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch
46402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu  function C2() {
47402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu    this.x = 23;
48402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu  };
49402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu  C2.prototype = { };
50402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu  C2.prototype.__proto__ = { set x(value) { this.y = 23; } };
51402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu  if (ensure_fast_case) {
52402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu    %ToFastProperties(C2.prototype.__proto__)
53402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu  }
54589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch
55402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu  for (var i = 0; i < 10; i++) {
56402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu    var c2 = new C2();
57402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu    assertEquals("undefined", typeof c2.x);
58402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu    assertEquals(23, c2.y);
59402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu  }
60589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch
61589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch
62402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu  function C3() {
63402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu    this.x = 23;
64402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu  };
65402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu  C3.prototype = { };
66402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu  C3.prototype.__defineSetter__('x', function(value) { this.y = 23; });
67402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu  if (ensure_fast_case) {
68402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu    %ToFastProperties(C3.prototype);
69402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu  }
70589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch
71402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu  for (var i = 0; i < 10; i++) {
72402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu    var c3 = new C3();
73402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu    assertEquals("undefined", typeof c3.x);
74402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu    assertEquals(23, c3.y);
75402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu  }
76589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch
77589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch
78402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu  function C4() {
79402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu    this.x = 23;
80402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu  };
81402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu  C4.prototype = { };
82402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu  C4.prototype.__proto__ = {  };
83402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu  C4.prototype.__proto__.__defineSetter__('x', function(value) { this.y = 23; });
84402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu  if (ensure_fast_case) {
85402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu    %ToFastProperties(C4.prototype.__proto__);
86402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu  }
87589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch
88402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu  for (var i = 0; i < 10; i++) {
89402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu    var c4 = new C4();
90402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu    assertEquals("undefined", typeof c4.x);
91402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu    assertEquals(23, c4.y);
92402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu  }
93589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch
94589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch
95402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu  function D() {
96402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu    this.x = 23;
97402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu  };
98402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu  D.prototype = 1;
99402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu  if (ensure_fast_case) {
100402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu    %ToFastProperties(D.prototype);
101402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu  }
102589d6979ff2ef66fca2d8fa51404c369ca5e9250Ben Murdoch
103402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu  for (var i = 0; i < 10; i++) {
104402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu    var d = new D();
105402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu    assertEquals(23, d.x);
106402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu    assertEquals("undefined", typeof d.y);
107402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu  }
108402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu}
109402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu
110402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei PopescuRunTest(false);
111402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei PopescuRunTest(true);
112