16147
|
1 |
/*
|
16151
|
2 |
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
|
16147
|
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 |
*/
|
|
23 |
|
|
24 |
/**
|
|
25 |
* NASHORN-81: RHS of "in" operator should be of Object type, TypeError should be thrown otherwise
|
|
26 |
*
|
|
27 |
* @test
|
|
28 |
* @run
|
|
29 |
*/
|
|
30 |
|
|
31 |
try {
|
|
32 |
print("foo" in false);
|
|
33 |
} catch (e) {
|
|
34 |
if (! (e instanceof TypeError)) {
|
|
35 |
fail("#1: TypeError expected");
|
|
36 |
}
|
|
37 |
}
|
|
38 |
|
|
39 |
try {
|
|
40 |
print("foo" in 3.14);
|
|
41 |
} catch (e) {
|
|
42 |
if (! (e instanceof TypeError)) {
|
|
43 |
fail("#2: TypeError expected");
|
|
44 |
}
|
|
45 |
}
|
|
46 |
|
|
47 |
try {
|
|
48 |
print("foo" in "bar");
|
|
49 |
} catch (e) {
|
|
50 |
if (! (e instanceof TypeError)) {
|
|
51 |
fail("#3: TypeError expected");
|
|
52 |
}
|
|
53 |
}
|
|
54 |
|
|
55 |
try {
|
|
56 |
print("foo" in "bar");
|
|
57 |
} catch (e) {
|
|
58 |
if (! (e instanceof TypeError)) {
|
|
59 |
fail("#4: TypeError expected");
|
|
60 |
}
|
|
61 |
}
|
|
62 |
|
|
63 |
try {
|
|
64 |
print("foo" in null);
|
|
65 |
} catch (e) {
|
|
66 |
if (! (e instanceof TypeError)) {
|
|
67 |
fail("#5: TypeError expected");
|
|
68 |
}
|
|
69 |
}
|
|
70 |
|
|
71 |
try {
|
|
72 |
print("foo" in undefined);
|
|
73 |
} catch (e) {
|
|
74 |
if (! (e instanceof TypeError)) {
|
|
75 |
fail("#6: TypeError expected");
|
|
76 |
}
|
|
77 |
}
|