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
36
37
38
39
40
41
42
|
load("test-common.js");
try {
assert(Reflect.has.length === 2);
[null, undefined, "foo", 123, NaN, Infinity].forEach(value => {
assertThrowsError(() => {
Reflect.has(value);
}, {
error: TypeError,
message: "First argument of Reflect.has() must be an object"
});
});
assert(Reflect.has({}) === false);
assert(Reflect.has({ undefined }) === true);
assert(Reflect.has({ 0: "1" }, "0") === true);
assert(Reflect.has({ foo: "bar" }, "foo") === true);
assert(Reflect.has({ bar: "baz" }, "foo") === false);
assert(Reflect.has({}, "toString") === true);
assert(Reflect.has([]) === false);
assert(Reflect.has([], 0) === false);
assert(Reflect.has([1, 2, 3], "0") === true);
assert(Reflect.has([1, 2, 3], 0) === true);
assert(Reflect.has([1, 2, 3], 1) === true);
assert(Reflect.has([1, 2, 3], 2) === true);
assert(Reflect.has([1, 2, 3], 3) === false);
assert(Reflect.has([], "pop") === true);
assert(Reflect.has(new String()) === false);
assert(Reflect.has(new String("foo"), "0") === true);
assert(Reflect.has(new String("foo"), 0) === true);
assert(Reflect.has(new String("foo"), 1) === true);
assert(Reflect.has(new String("foo"), 2) === true);
assert(Reflect.has(new String("foo"), 3) === false);
assert(Reflect.has(new String("foo"), "charAt") === true);
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
|