10.eval.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. var x = "global";
  7. (function Test1() {
  8. write(x);
  9. eval("var x = 'Test1.eval'; write(x);");
  10. write(x);
  11. })();
  12. (function Test2() {
  13. var x = "Test2.local";
  14. write(x);
  15. eval("var x = 'Test2.eval'; write(x);");
  16. write(x);
  17. })();
  18. (function Test3() {
  19. var str = "'Test3.para'";
  20. eval("var x = eval; write(x(str));");
  21. })();
  22. (function Test4() {
  23. var str = "'Test4'";
  24. eval("function Test4_Inner() { write('inside Test4_inner');} ");
  25. try {
  26. Test4_Inner();
  27. } catch (e) {
  28. write("Exception : " + e);
  29. }
  30. })();
  31. eval("'use strict'; function foo(a){eval('');return String(a)}; foo('hello');");