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

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

mercurial