GlobalFunctions.js 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. var a = eval("1+1");
  6. eval("a");
  7. eval.foo = "Expando_In_Eval_Ok";
  8. WScript.Echo(eval.foo);
  9. var nn = isNaN(Number.NaN);
  10. WScript.Echo("test: isNaN(Number.NaN) : " + nn);
  11. nn = isNaN(123);
  12. WScript.Echo("test: isNaN(123) : " + nn);
  13. isNaN.foo = "Expando_In_IsNaN_Ok";
  14. WScript.Echo(isNaN.foo);
  15. nn = isFinite(Number.POSITIVE_INFINITY);
  16. WScript.Echo("test: isFinite(Number.POSITIVE_INFINITY) : " + nn);
  17. nn = isFinite(123);
  18. WScript.Echo("test: isFinite(123) : " + nn);
  19. isFinite.foo = "Expando_In_IsFinite_Ok";
  20. WScript.Echo(isNaN.foo);
  21. WScript.Echo("*** Test URI functions ***");
  22. var checkChar = "\u00a9";
  23. WScript.Echo("Test print wchar: \"\\u00a9\" ");
  24. WScript.Echo(checkChar);
  25. var a = encodeURI("\u00a9");
  26. WScript.Echo("Test encode : encodeURI(\"\\u00a9\");");
  27. var a = encodeURI("\u00a9");
  28. WScript.Echo(a);
  29. WScript.Echo("Test decode back: ")
  30. var b = decodeURI(encodeURI("\u00a9"));
  31. WScript.Echo(b);
  32. WScript.Echo("Test encode : encodeURI(\"http:\/\/www.isp.com\/app.cgi?arg1=1&arg2=hello world\");");
  33. a = encodeURI("http://www.isp.com/app.cgi?arg1=1&arg2=hello world");
  34. WScript.Echo(a);
  35. WScript.Echo("Test decode back: ")
  36. b = decodeURI(encodeURI("http://www.isp.com/app.cgi?arg1=1&arg2=hello world"));
  37. WScript.Echo(b);
  38. WScript.Echo("Test encode component : encodeURIComponent(\"http\");");
  39. a = encodeURIComponent("http");
  40. WScript.Echo(a);
  41. WScript.Echo("Test decode component back: ")
  42. b = decodeURIComponent(encodeURIComponent("http"));
  43. WScript.Echo(b);
  44. WScript.Echo("Test encode component : encodeURIComponent(\"\/\/www.isp.com\/app.cgi\");");
  45. a = encodeURIComponent("//www.isp.com/app.cgi");
  46. WScript.Echo(a);
  47. WScript.Echo("Test decode component back: ")
  48. b = decodeURIComponent(encodeURIComponent("//www.isp.com/app.cgi"));
  49. WScript.Echo(b);
  50. WScript.Echo("Test encode component : encodeURIComponent(\"arg1=1&arg2=hello world\");");
  51. a = encodeURIComponent("arg1=1&arg2=hello world");
  52. WScript.Echo(a);
  53. WScript.Echo("Test decode component back: ")
  54. b = decodeURIComponent(encodeURIComponent("arg1=1&arg2=hello world"));
  55. WScript.Echo(b);
  56. WScript.Echo("Test global constants: ");
  57. WScript.Echo(Infinity);
  58. WScript.Echo(undefined);
  59. WScript.Echo("Escape Unescape ");
  60. WScript.Echo(escape("Hello World"));
  61. WScript.Echo(unescape("Hello%20World"));
  62. WScript.Echo(unescape(escape("foo bar")));
  63. WScript.Echo(unescape("It%27s%20a%20test%21"));