forked from chakra-core/ChakraCore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathErrorCtorProps.js
More file actions
40 lines (35 loc) · 1.31 KB
/
ErrorCtorProps.js
File metadata and controls
40 lines (35 loc) · 1.31 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
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
var ctors = [Error, EvalError, RangeError, ReferenceError, SyntaxError, TypeError, URIError];
safeCall(eval, "ctors.push(RegExpError);");
safeCall(eval, "ctors.push(ConversionError);");
var props = ["message", "name", "description", "call", "apply"];
for (var i in ctors)
{
Test(ctors[i]);
}
function Test(ctor)
{
WScript.Echo("---------------------------------");
WScript.Echo("toString(): " + ctor.toString());
for (var j in props)
{
var prop = props[j];
WScript.Echo("Property: '" + prop + "'");
WScript.Echo("Value: '" + ctor[prop] + "'");
WScript.Echo("hasOwnProperty: " + ctor.hasOwnProperty(prop));
}
WScript.Echo();
}
function safeCall(f) {
var args = [];
for (var a = 1; a < arguments.length; ++a)
args.push(arguments[a]);
try {
return f.apply(this, args);
} catch (ex) {
WScript.Echo(ex.name + ": " + ex.message);
}
}