forked from chakra-core/ChakraCore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstanceof.js
More file actions
47 lines (38 loc) · 1.45 KB
/
instanceof.js
File metadata and controls
47 lines (38 loc) · 1.45 KB
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
43
44
45
46
47
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
function write(v) { WScript.Echo(v + ""); }
function foo() {}
function bar() {} ;
var fncs = [ "Object", "Function", "Array", "String", "Number", "Boolean", "Date", "RegExp", "foo", "bar"] ;
var f = new foo();
var b = new bar();
var objs = [ "new Object()",
"f", "b", "foo", "String.fromCharCode", "Array.prototype.concat",
"[1,2,3]", "new Array()", "fncs",
"'hello'", "new String('world')",
"10", "10.2", "NaN", "new Number(3)",
"true", "false", "new Boolean(true)", "new Boolean(false)",
"new Date()",
"/a+/"
];
function check(str)
{
try {
write(str + " : " + eval(str));
} catch (e) {
write(" Exception: " + str + ". " + e.message);
}
}
for (var i=0; i<objs.length ; i++) {
for (var j=0; j<fncs.length; j++) {
check(objs[i] + " instanceof " + fncs[j]);
}
}
var count = 0;
for (var i=0; i<objs.length ; i++) {
for (var j=0; j<objs.length; j++) {
check(objs[i] + " instanceof " + objs[j]);
}
}