forked from chakra-core/ChakraCore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
17.formal_sm.js
40 lines (33 loc) · 1.25 KB
/
17.formal_sm.js
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.
//-------------------------------------------------------------------------------------------------------
"use strict";
function write(v) { WScript.Echo(v ""); }
function exceptToString(ee) {
if (ee instanceof TypeError) return "TypeError";
if (ee instanceof ReferenceError) return "ReferenceError";
if (ee instanceof EvalError) return "EvalError";
if (ee instanceof SyntaxError) return "SyntaxError";
return "Unknown Error";
}
(function Test1() {
var str = "'arguments' as formal parameter";
try {
eval("function f(arguments) {}");
} catch (e) {
write("Exception: " str " " exceptToString(e));
return;
}
write("Return: " str);
})();
(function Test2() {
var str = "'eval' as formal parameter";
try {
eval("function f(eval) {}");
} catch (e) {
write("Exception: " str " " exceptToString(e));
return;
}
write("Return: " str);
})();