nashorn/test/script/basic/JDK-8160034.js
author hannesw
Fri, 03 Feb 2017 13:28:00 +0100
changeset 43555 1bb10bccf057
parent 40217 88b9823eb989
permissions -rw-r--r--
8173888: Test for JDK-8169481 causes stack overflows in parser tests Reviewed-by: jlaskey, sundar
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
39900
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
     1
/*
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
     4
 *
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
     7
 * published by the Free Software Foundation.
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
     8
 *
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
    13
 * accompanied this code).
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
    14
 *
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
    18
 *
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
    21
 * questions.
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
    22
 */
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
    23
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
    24
/**
40217
88b9823eb989 8162771: Strict equality operators should not be optimistic
hannesw
parents: 39900
diff changeset
    25
 * JDK-8160034: The `this` value in the `with` is broken by the repetition of a function call
39900
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
    26
 *
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
    27
 * @test
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
    28
 * @option --unstable-relink-threshold=4
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
    29
 * @run
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
    30
 */
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
    31
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
    32
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
    33
var bar = "BAR";
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
    34
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
    35
function Foo() {
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
    36
    this.bar = "bar";
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
    37
    this.baz = "baz";
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
    38
}
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
    39
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
    40
function foo_proto_h() {
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
    41
    print(this.bar);
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
    42
    delete Foo.prototype._h;
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
    43
}
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
    44
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
    45
function foo_proto_e() {
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
    46
    print(this.baz);
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
    47
}
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
    48
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
    49
function _h() {
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
    50
    print(this.bar);
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
    51
    Foo.prototype._h = foo_proto_h;
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
    52
}
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
    53
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
    54
Foo.prototype._e = foo_proto_e;
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
    55
Foo.prototype._h = foo_proto_h;
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
    56
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
    57
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
    58
var fn = new Function("with(this) { _h(); _e(); }");
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
    59
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
    60
for (var i = 0; i < 20; i++) {
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
    61
    fn.call(new Foo());
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
    62
}
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
    63
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
    64
for (var i = 0; i < 20; i++) {
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
    65
    foo = new Foo();
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
    66
    foo['e' + Math.random()] = 1; // force new map
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
    67
    fn.call(foo);
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
    68
}
a9ad93ab3f6d 8160034: The `this` value in the `with` is broken by the repetition of a function call
hannesw
parents:
diff changeset
    69