| //------------------------------------------------------------------------------------------------------- |
| // 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 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"; |
| } |
| |
| var _eval = eval; |
| |
| (function Test1() { |
| var str = "var named eval"; |
| |
| try { |
| _eval("var eval;"); |
| } catch (e) { |
| write("Exception: " + str + " " + exceptToString(e)); |
| return; |
| } |
| write("Return: " + str); |
| })(); |
| |
| (function Test2() { |
| var str = "var named eval inital value"; |
| |
| try { |
| _eval("var eval = 10;"); |
| } catch (e) { |
| write("Exception: " + str + " " + exceptToString(e)); |
| return; |
| } |
| write("Return: " + str); |
| })(); |
| |
| (function Test3() { |
| var str = "var named arguments"; |
| |
| try { |
| _eval("var arguments;"); |
| } catch (e) { |
| write("Exception: " + str + " " + exceptToString(e)); |
| return; |
| } |
| write("Return: " + str); |
| })(); |
| |
| (function Test4() { |
| var str = "var named arguments inital value"; |
| |
| try { |
| _eval("var arguments = 10;"); |
| } catch (e) { |
| write("Exception: " + str + " " + exceptToString(e)); |
| return; |
| } |
| write("Return: " + str); |
| })(); |