test/script/basic/JDK-8134569.js

Tue, 21 Mar 2017 13:41:57 -0700

author
asaha
date
Tue, 21 Mar 2017 13:41:57 -0700
changeset 2160
1df40fe54cd6
parent 1548
898e2a08a252
permissions
-rw-r--r--

Merge

hannesw@1547 1 /*
hannesw@1547 2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
hannesw@1547 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
hannesw@1547 4 *
hannesw@1547 5 * This code is free software; you can redistribute it and/or modify it
hannesw@1547 6 * under the terms of the GNU General Public License version 2 only, as
hannesw@1547 7 * published by the Free Software Foundation.
hannesw@1547 8 *
hannesw@1547 9 * This code is distributed in the hope that it will be useful, but WITHOUT
hannesw@1547 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
hannesw@1547 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
hannesw@1547 12 * version 2 for more details (a copy is included in the LICENSE file that
hannesw@1547 13 * accompanied this code).
hannesw@1547 14 *
hannesw@1547 15 * You should have received a copy of the GNU General Public License version
hannesw@1547 16 * 2 along with this work; if not, write to the Free Software Foundation,
hannesw@1547 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
hannesw@1547 18 *
hannesw@1547 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
hannesw@1547 20 * or visit www.oracle.com if you need additional information or have any
hannesw@1547 21 * questions.
hannesw@1547 22 */
hannesw@1547 23
hannesw@1547 24 /**
hannesw@1547 25 * JDK-8134569: Add tests for prototype callsites
hannesw@1547 26 *
hannesw@1547 27 * @test
hannesw@1547 28 * @run
hannesw@1547 29 */
hannesw@1547 30
hannesw@1547 31 function create() {
hannesw@1547 32 function C() {
hannesw@1547 33 this.i1 = 1;
hannesw@1547 34 this.i2 = 2;
hannesw@1547 35 this.i3 = 3;
hannesw@1547 36 return this;
hannesw@1547 37 }
hannesw@1547 38 return new C();
hannesw@1547 39 }
hannesw@1547 40
hannesw@1547 41 function createEmpty() {
hannesw@1547 42 function C() {
hannesw@1547 43 return this;
hannesw@1547 44 }
hannesw@1547 45 return new C();
hannesw@1547 46 }
hannesw@1547 47
hannesw@1547 48 function createDeep() {
hannesw@1547 49 function C() {
hannesw@1547 50 this.i1 = 1;
hannesw@1547 51 this.i2 = 2;
hannesw@1547 52 this.i3 = 3;
hannesw@1547 53 return this;
hannesw@1547 54 }
hannesw@1547 55 function D() {
hannesw@1547 56 this.p1 = 1;
hannesw@1547 57 this.p2 = 2;
hannesw@1547 58 this.p3 = 3;
hannesw@1547 59 return this;
hannesw@1547 60 }
hannesw@1547 61 C.prototype = new D();
hannesw@1547 62 return new C();
hannesw@1547 63 }
hannesw@1547 64
hannesw@1548 65 function createDeeper() {
hannesw@1548 66 function C() {
hannesw@1548 67 this.i1 = 1;
hannesw@1548 68 this.i2 = 2;
hannesw@1548 69 this.i3 = 3;
hannesw@1548 70 return this;
hannesw@1548 71 }
hannesw@1548 72 function D() {
hannesw@1548 73 this.p1 = 1;
hannesw@1548 74 this.p2 = 2;
hannesw@1548 75 this.p3 = 3;
hannesw@1548 76 return this;
hannesw@1548 77 }
hannesw@1548 78 function E() {
hannesw@1548 79 this.e1 = 1;
hannesw@1548 80 this.e2 = 2;
hannesw@1548 81 this.e3 = 3;
hannesw@1548 82 return this;
hannesw@1548 83 }
hannesw@1548 84 D.prototype = new E();
hannesw@1548 85 C.prototype = new D();
hannesw@1548 86 return new C();
hannesw@1548 87 }
hannesw@1548 88
hannesw@1547 89 function createEval() {
hannesw@1547 90 return eval("Object.create({})");
hannesw@1547 91 }
hannesw@1547 92
hannesw@1547 93 function p(o) { print(o.x) }
hannesw@1547 94
hannesw@1548 95 function e(o) { print(o.e1) }
hannesw@1548 96
hannesw@1548 97 var a, b, c;
hannesw@1547 98
hannesw@1547 99 create();
hannesw@1547 100 a = create();
hannesw@1547 101 b = create();
hannesw@1548 102 c = create();
hannesw@1547 103 a.__proto__.x = 123;
hannesw@1547 104
hannesw@1547 105 p(a);
hannesw@1547 106 p(b);
hannesw@1548 107 p(c);
hannesw@1547 108
hannesw@1547 109 a = create();
hannesw@1547 110 b = create();
hannesw@1548 111 c = create();
hannesw@1547 112 b.__proto__.x = 123;
hannesw@1547 113
hannesw@1547 114 p(a);
hannesw@1547 115 p(b);
hannesw@1548 116 p(c);
hannesw@1547 117
hannesw@1547 118 a = createEmpty();
hannesw@1547 119 b = createEmpty();
hannesw@1548 120 c = createEmpty();
hannesw@1547 121 a.__proto__.x = 123;
hannesw@1547 122
hannesw@1547 123 p(a);
hannesw@1547 124 p(b);
hannesw@1548 125 p(c);
hannesw@1547 126
hannesw@1547 127 a = createEmpty();
hannesw@1547 128 b = createEmpty();
hannesw@1548 129 c = createEmpty();
hannesw@1547 130 b.__proto__.x = 123;
hannesw@1547 131
hannesw@1547 132 p(a);
hannesw@1547 133 p(b);
hannesw@1548 134 p(c);
hannesw@1547 135
hannesw@1547 136 a = createDeep();
hannesw@1547 137 b = createDeep();
hannesw@1548 138 c = createDeep();
hannesw@1547 139 a.__proto__.__proto__.x = 123;
hannesw@1547 140
hannesw@1547 141 p(a);
hannesw@1547 142 p(b);
hannesw@1548 143 p(c);
hannesw@1547 144
hannesw@1547 145 a = createDeep();
hannesw@1547 146 b = createDeep();
hannesw@1548 147 c = createDeep();
hannesw@1547 148 b.__proto__.__proto__.x = 123;
hannesw@1547 149
hannesw@1547 150 p(a);
hannesw@1547 151 p(b);
hannesw@1548 152 p(c);
hannesw@1548 153
hannesw@1548 154 a = createDeeper();
hannesw@1548 155 b = createDeeper();
hannesw@1548 156 c = createDeeper();
hannesw@1548 157 a.__proto__.__proto__.__proto__.x = 123;
hannesw@1548 158
hannesw@1548 159 p(a);
hannesw@1548 160 p(b);
hannesw@1548 161 p(c);
hannesw@1548 162
hannesw@1548 163 a = createDeeper();
hannesw@1548 164 b = createDeeper();
hannesw@1548 165 c = createDeeper();
hannesw@1548 166 b.__proto__.__proto__.__proto__.x = 123;
hannesw@1548 167
hannesw@1548 168 p(a);
hannesw@1548 169 p(b);
hannesw@1548 170 p(c);
hannesw@1548 171
hannesw@1548 172 a = createDeeper();
hannesw@1548 173 b = createDeeper();
hannesw@1548 174 c = createDeeper();
hannesw@1548 175 a.__proto__.__proto__ = null;
hannesw@1548 176
hannesw@1548 177 e(a);
hannesw@1548 178 e(b);
hannesw@1548 179 e(c);
hannesw@1548 180
hannesw@1548 181 a = createDeeper();
hannesw@1548 182 b = createDeeper();
hannesw@1548 183 c = createDeeper();
hannesw@1548 184 b.__proto__.__proto__ = null;
hannesw@1548 185
hannesw@1548 186 e(a);
hannesw@1548 187 e(b);
hannesw@1548 188 e(c);
hannesw@1548 189
hannesw@1547 190
hannesw@1547 191 a = createEval();
hannesw@1547 192 b = createEval();
hannesw@1548 193 c = createEval();
hannesw@1547 194 a.__proto__.x = 123;
hannesw@1547 195
hannesw@1547 196 p(a);
hannesw@1547 197 p(b);
hannesw@1548 198 p(c);
hannesw@1547 199
hannesw@1547 200 a = createEval();
hannesw@1547 201 b = createEval();
hannesw@1548 202 c = createEval();
hannesw@1547 203 b.__proto__.x = 123;
hannesw@1547 204
hannesw@1547 205 p(a);
hannesw@1547 206 p(b);
hannesw@1548 207 p(c);

mercurial