nashorn/test/script/basic/JDK-8022731.js
author attila
Thu, 04 Sep 2014 18:57:14 +0200
changeset 26378 ca7093bd5fd1
parent 24778 2ff5d7041566
permissions -rw-r--r--
8056129: AtomicInteger is treated as primitive number with optimistic compilation Reviewed-by: jlaskey, lagergren
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
19463
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
     1
/*
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
     2
 * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 19463
diff changeset
     4
 *
19463
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
     7
 * published by the Free Software Foundation.
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 19463
diff changeset
     8
 *
19463
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    13
 * accompanied this code).
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 19463
diff changeset
    14
 *
19463
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 19463
diff changeset
    18
 *
19463
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    21
 * questions.
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    22
 */
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    23
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    24
/**
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    25
 * JDK-8022731: NativeArguments has wrong implementation of isMapped()
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    26
 *
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    27
 * @test
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    28
 * @run
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    29
 */
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    30
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    31
Object.defineProperty(Object.prototype, "0", {value: "proto"});
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    32
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    33
function test0(a, b) {
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    34
    Object.defineProperty(arguments, "1", {get: function() { return "get" }});
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    35
    return arguments[0];
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    36
}
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    37
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    38
function test1(a, b) {
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    39
    Object.defineProperty(arguments, "0", {get: function() { return "get" }});
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    40
    return a;
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    41
}
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    42
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    43
function test2(a, b) {
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    44
    Object.defineProperty(arguments, "0", {value: "value"});
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    45
    delete arguments[0];
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    46
    return a;
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    47
}
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    48
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    49
function test3(a, b) {
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    50
    arguments[1] = "arg1";
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    51
    return b;
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    52
}
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    53
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    54
function test4(a, b) {
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    55
    b = "b";
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    56
    return arguments[1];
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    57
}
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    58
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    59
function test5(a, b) {
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    60
    Object.defineProperty(arguments, "0", {value: "value"});
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    61
    arguments[0] = "new";
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    62
    return a;
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    63
}
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    64
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    65
function test6(a, b) {
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    66
    Object.defineProperty(arguments, "0", {value: "value"});
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    67
    arguments[0] = "new";
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    68
    delete arguments[0];
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    69
    return a;
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    70
}
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    71
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    72
function test7(a, b) {
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    73
    Object.defineProperty(arguments, "0", {value: "value", writable: false});
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    74
    arguments[0] = "new";
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    75
    return a;
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    76
}
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    77
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    78
print(test0());
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    79
print(test0("p1", "p2"));
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    80
print(test1());
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    81
print(test1("p1"));
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    82
print(test2());
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    83
print(test2("p1"));
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    84
print(test3());
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    85
print(test3(1, 2));
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    86
print(test4());
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    87
print(test4("p1", "p2"));
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    88
print(test5());
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    89
print(test5("p1"));
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    90
print(test6());
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    91
print(test6("p1"));
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    92
print(test7());
d97df8f5945d 8022731: NativeArguments has wrong implementation of isMapped()
hannesw
parents:
diff changeset
    93
print(test7("p1"));