1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/test/script/basic/JDK-8134569.js Thu Sep 10 13:50:04 2015 +0200 1.3 @@ -0,0 +1,128 @@ 1.4 +/* 1.5 + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.23 + * or visit www.oracle.com if you need additional information or have any 1.24 + * questions. 1.25 + */ 1.26 + 1.27 +/** 1.28 + * JDK-8134569: Add tests for prototype callsites 1.29 + * 1.30 + * @test 1.31 + * @run 1.32 + */ 1.33 + 1.34 +function create() { 1.35 + function C() { 1.36 + this.i1 = 1; 1.37 + this.i2 = 2; 1.38 + this.i3 = 3; 1.39 + return this; 1.40 + } 1.41 + return new C(); 1.42 +} 1.43 + 1.44 +function createEmpty() { 1.45 + function C() { 1.46 + return this; 1.47 + } 1.48 + return new C(); 1.49 +} 1.50 + 1.51 +function createDeep() { 1.52 + function C() { 1.53 + this.i1 = 1; 1.54 + this.i2 = 2; 1.55 + this.i3 = 3; 1.56 + return this; 1.57 + } 1.58 + function D() { 1.59 + this.p1 = 1; 1.60 + this.p2 = 2; 1.61 + this.p3 = 3; 1.62 + return this; 1.63 + } 1.64 + C.prototype = new D(); 1.65 + return new C(); 1.66 +} 1.67 + 1.68 +function createEval() { 1.69 + return eval("Object.create({})"); 1.70 +} 1.71 + 1.72 +function p(o) { print(o.x) } 1.73 + 1.74 +var a, b; 1.75 + 1.76 +create(); 1.77 +a = create(); 1.78 +b = create(); 1.79 +a.__proto__.x = 123; 1.80 + 1.81 +p(a); 1.82 +p(b); 1.83 + 1.84 +a = create(); 1.85 +b = create(); 1.86 +b.__proto__.x = 123; 1.87 + 1.88 +p(a); 1.89 +p(b); 1.90 + 1.91 +a = createEmpty(); 1.92 +b = createEmpty(); 1.93 +a.__proto__.x = 123; 1.94 + 1.95 +p(a); 1.96 +p(b); 1.97 + 1.98 +a = createEmpty(); 1.99 +b = createEmpty(); 1.100 +b.__proto__.x = 123; 1.101 + 1.102 +p(a); 1.103 +p(b); 1.104 + 1.105 +a = createDeep(); 1.106 +b = createDeep(); 1.107 +a.__proto__.__proto__.x = 123; 1.108 + 1.109 +p(a); 1.110 +p(b); 1.111 + 1.112 +a = createDeep(); 1.113 +b = createDeep(); 1.114 +b.__proto__.__proto__.x = 123; 1.115 + 1.116 +p(a); 1.117 +p(b); 1.118 + 1.119 +a = createEval(); 1.120 +b = createEval(); 1.121 +a.__proto__.x = 123; 1.122 + 1.123 +p(a); 1.124 +p(b); 1.125 + 1.126 +a = createEval(); 1.127 +b = createEval(); 1.128 +b.__proto__.x = 123; 1.129 + 1.130 +p(a); 1.131 +p(b);