15.with.js 959 B

1234567891011121314151617181920212223242526
  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. function write(v) { WScript.Echo(v + ""); }
  6. function exceptToString(ee) {
  7. if (ee instanceof TypeError) return "TypeError";
  8. if (ee instanceof ReferenceError) return "ReferenceError";
  9. if (ee instanceof EvalError) return "EvalError";
  10. if (ee instanceof SyntaxError) return "SyntaxError";
  11. return "Unknown Error";
  12. }
  13. (function Test1() {
  14. var str = "with stmt";
  15. try {
  16. eval("with({}) {};");
  17. } catch (e) {
  18. write("Exception: " + str + " " + exceptToString(e));
  19. return;
  20. }
  21. write("Return: " + str);
  22. })();