blob: f6c90a823af25984ea630f9fd638f5b2802b3118 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
load("test-common.js");
try {
["foo", 123, null, undefined].forEach(value => {
assertThrowsError(() => {
"prop" in value;
}, {
error: TypeError,
message: "'in' operator must be used on an object"
});
});
var o = {foo: "bar", bar: undefined};
assert("" in o === false);
assert("foo" in o === true);
assert("bar" in o === true);
assert("baz" in o === false);
assert("toString" in o === true);
var a = ["hello", "friends"];
assert(0 in a === true);
assert(1 in a === true);
assert(2 in a === false);
assert("0" in a === true);
assert("hello" in a === false);
assert("friends" in a === false);
assert("length" in a === true);
var s = new String("foo");
assert("length" in s);
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
|