nashorn/test/script/basic/JDK-8020223.js
author sundar
Thu, 06 Aug 2015 21:50:42 +0530
changeset 32049 af8f6292d54d
parent 24778 2ff5d7041566
permissions -rw-r--r--
8133119: Error message associated with TypeError for call and new should include stringified Node Reviewed-by: attila, mhaupt
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
18871
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
     1
/*
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
     2
 * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
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: 18871
diff changeset
     4
 *
18871
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
     7
 * published by the Free Software Foundation.
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 18871
diff changeset
     8
 *
18871
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
    13
 * accompanied this code).
24778
2ff5d7041566 8044638: Tidy up Nashorn codebase for code standards
attila
parents: 18871
diff changeset
    14
 *
18871
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
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: 18871
diff changeset
    18
 *
18871
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
    21
 * questions.
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
    22
 */
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
    23
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
    24
/**
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
    25
 * JDK-8020223: ClassCastException: String can not be casted to ScriptFunction
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
    26
 *
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
    27
 * @test
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
    28
 * @run
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
    29
 */
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
    30
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
    31
__noSuchMethod__ = "";
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
    32
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
    33
try {
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
    34
    foo();
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
    35
    fail("Must have thrown exception");
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
    36
} catch (e) {
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
    37
    if (! (e instanceof TypeError)) {
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
    38
        fail("TypeError expected, got " + e);
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
    39
    }
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
    40
}
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
    41
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
    42
__noSuchProperty__ = 23;
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
    43
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
    44
try {
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
    45
    foo;
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
    46
    fail("Must have thrown exception");
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
    47
} catch (e) {
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
    48
    if (! (e instanceof ReferenceError)) {
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
    49
        fail("ReferenceError expected, got " + e);
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
    50
    }
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
    51
}
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
    52
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
    53
var obj = new JSAdapter() {
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
    54
    __get__: 332,
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
    55
    __call__: "hello"
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
    56
}
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
    57
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
    58
try {
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
    59
    obj.foo; // should just be undefined
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
    60
} catch (e) {
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
    61
    fail("unexpected error : " + e);
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
    62
}
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
    63
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
    64
try {
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
    65
    obj.foo();
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
    66
    fail("Must have thrown exception");
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
    67
} catch(e) {
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
    68
    if (! (e instanceof TypeError)) {
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
    69
        fail("TypeError expected, got " + e);
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
    70
    }
a27c6a5b999c 8020223: ClassCastException: String can not be casted to ScriptFunction
sundar
parents:
diff changeset
    71
}