test/script/basic/JDK-8071928.js

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

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

Merge

hannesw@1368 1 /*
hannesw@1368 2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
hannesw@1368 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
hannesw@1368 4 *
hannesw@1368 5 * This code is free software; you can redistribute it and/or modify it
hannesw@1368 6 * under the terms of the GNU General Public License version 2 only, as
hannesw@1368 7 * published by the Free Software Foundation.
hannesw@1368 8 *
hannesw@1368 9 * This code is distributed in the hope that it will be useful, but WITHOUT
hannesw@1368 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
hannesw@1368 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
hannesw@1368 12 * version 2 for more details (a copy is included in the LICENSE file that
hannesw@1368 13 * accompanied this code).
hannesw@1368 14 *
hannesw@1368 15 * You should have received a copy of the GNU General Public License version
hannesw@1368 16 * 2 along with this work; if not, write to the Free Software Foundation,
hannesw@1368 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
hannesw@1368 18 *
hannesw@1368 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
hannesw@1368 20 * or visit www.oracle.com if you need additional information or have any
hannesw@1368 21 * questions.
hannesw@1368 22 */
hannesw@1368 23
hannesw@1368 24 /**
hannesw@1368 25 * JDK-8071928: Instance properties with getters returning wrong values
hannesw@1368 26 *
hannesw@1368 27 * @test
hannesw@1368 28 * @run
hannesw@1368 29 */
hannesw@1368 30
hannesw@1368 31
hannesw@1368 32 var types = {};
hannesw@1368 33
hannesw@1368 34 function Type() {}
hannesw@1368 35
hannesw@1368 36 Type.prototype.getName = function() {
hannesw@1368 37 return this._name;
hannesw@1368 38 };
hannesw@1368 39
hannesw@1368 40 function defineType(init) {
hannesw@1368 41 return Object.create(Type.prototype, {
hannesw@1368 42 _name: { get: function() { return init.name; } }
hannesw@1368 43 });
hannesw@1368 44 }
hannesw@1368 45
hannesw@1368 46 types.A = defineType({ name: 'A' });
hannesw@1368 47 types.B = defineType({ name: 'B' });
hannesw@1368 48 types.C = defineType({ name: 'C' });
hannesw@1368 49 types.D = defineType({ name: 'D' });
hannesw@1368 50
hannesw@1368 51 var keys = Object.keys(types);
hannesw@1368 52 for (var i = 0; i < keys.length; i++) {
hannesw@1368 53 var t = types[keys[i]];
hannesw@1368 54 if (t.getName() != keys[i]) {
hannesw@1368 55 throw 'wrong name for ' + keys[i] + ': ' + t.getName();
hannesw@1368 56 }
hannesw@1368 57 }

mercurial