2
0

GlobalFunctions.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. function GetCharCodes(str) {
  22. var result = [];
  23. str.split("").forEach(function(_,i,a) {
  24. result.push(a[i].charCodeAt(0));
  25. });
  26. return result.join();
  27. }
  28. WScript.Echo("*** Test URI functions ***");
  29. var checkChar = "\u00a9";
  30. WScript.Echo("Test print wchar: \"\\u00a9\" ");
  31. WScript.Echo(GetCharCodes(checkChar) == "169");
  32. var a = encodeURI("\u00a9");
  33. WScript.Echo("Test encode : encodeURI(\"\\u00a9\");");
  34. var a = encodeURI("\u00a9");
  35. WScript.Echo(a);
  36. WScript.Echo("Test decode back: ")
  37. var b = decodeURI(encodeURI("\u00a9"));
  38. WScript.Echo(GetCharCodes(b) == "169");
  39. WScript.Echo("Test encode : encodeURI(\"http:\/\/www.isp.com\/app.cgi?arg1=1&arg2=hello world\");");
  40. a = encodeURI("http://www.isp.com/app.cgi?arg1=1&arg2=hello world");
  41. WScript.Echo(a);
  42. WScript.Echo("Test decode back: ")
  43. b = decodeURI(encodeURI("http://www.isp.com/app.cgi?arg1=1&arg2=hello world"));
  44. WScript.Echo(b);
  45. WScript.Echo("Test encode component : encodeURIComponent(\"http\");");
  46. a = encodeURIComponent("http");
  47. WScript.Echo(a);
  48. WScript.Echo("Test decode component back: ")
  49. b = decodeURIComponent(encodeURIComponent("http"));
  50. WScript.Echo(b);
  51. WScript.Echo("Test encode component : encodeURIComponent(\"\/\/www.isp.com\/app.cgi\");");
  52. a = encodeURIComponent("//www.isp.com/app.cgi");
  53. WScript.Echo(a);
  54. WScript.Echo("Test decode component back: ")
  55. b = decodeURIComponent(encodeURIComponent("//www.isp.com/app.cgi"));
  56. WScript.Echo(b);
  57. WScript.Echo("Test encode component : encodeURIComponent(\"arg1=1&arg2=hello world\");");
  58. a = encodeURIComponent("arg1=1&arg2=hello world");
  59. WScript.Echo(a);
  60. WScript.Echo("Test decode component back: ")
  61. b = decodeURIComponent(encodeURIComponent("arg1=1&arg2=hello world"));
  62. WScript.Echo(b);
  63. WScript.Echo("Test global constants: ");
  64. WScript.Echo(Infinity);
  65. WScript.Echo(undefined);
  66. WScript.Echo("Escape Unescape ");
  67. WScript.Echo(escape("Hello World"));
  68. WScript.Echo(unescape("Hello%20World"));
  69. WScript.Echo(unescape(escape("foo bar")));
  70. WScript.Echo(unescape("It%27s%20a%20test%21"));