| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- //-------------------------------------------------------------------------------------------------------
- // 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";
- }
- (function Test1() {
- var str = "Property named eval";
- try {
- eval("var o = { set x(eval) { this.value = eval;}, get x() { return this.value;} };");
- o.x = 10;
- write("o.x : " + o.x);
- write("o.value : " + o.value);
- } catch (e) {
- write("Exception: " + str + " " + exceptToString(e));
- return;
- }
- write("Return: " + str);
- }) ();
- (function Test2() {
- var str = "Property named arguments";
- try {
- eval("var o = { set x(arguments) { this.value = arguments;}, get x() { return this.value;} };");
- o.x = 10;
- write("o.x : " + o.x);
- write("o.value : " + o.value);
- } catch (e) {
- write("Exception: " + str + " " + exceptToString(e));
- return;
- }
- write("Return: " + str);
- }) ();
|