2
0

10.eval_sm.js 1023 B

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