18.formal_sm.js 994 B

12345678910111213141516171819202122232425262728
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. "use strict";
  6. function write(v) { WScript.Echo(v + ""); }
  7. function exceptToString(ee) {
  8. if (ee instanceof TypeError) return "TypeError";
  9. if (ee instanceof ReferenceError) return "ReferenceError";
  10. if (ee instanceof EvalError) return "EvalError";
  11. if (ee instanceof SyntaxError) return "SyntaxError";
  12. return "Unknown Error";
  13. }
  14. (function Test1() {
  15. var str = "same named parameters";
  16. try {
  17. eval("function f(x,x) {}");
  18. } catch (e) {
  19. write("Exception: " + str + " " + exceptToString(e));
  20. return;
  21. }
  22. write("Return: " + str);
  23. })();