forked from chakra-core/ChakraCore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvariousErrors.js
More file actions
40 lines (35 loc) · 1.07 KB
/
variousErrors.js
File metadata and controls
40 lines (35 loc) · 1.07 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.
//-------------------------------------------------------------------------------------------------------
function write(v) { WScript.Echo(v + ""); }
function getErrorType(e)
{
if (e instanceof EvalError) return "EvalError";
if (e instanceof SyntaxError) return "SyntaxError";
if (e instanceof ReferenceError) return "ReferenceError";
if (e instanceof TypeError) return "TypeError";
return "unknown";
}
var scen = [
"42 = 42",
"'x' = 42",
"true = 42",
"null = 42",
"delete this",
"delete true",
"delete 10",
"delete null"
];
for (var i=0;i<scen.length;i++)
{
try
{
var result = eval(scen[i]);
write(scen[i] + " .. " + result);
}
catch (e)
{
write(scen[i] + " :: " + getErrorType(e));
}
}