array_literal.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 DumpArray(array)
  6. {
  7. WScript.Echo("[" + array.join(",") + "]");
  8. }
  9. function literalOfInts()
  10. {
  11. var array = [3, 4, 5, 6, 7, 8];
  12. DumpArray(array);
  13. var array_large = [3, 4, 5, 6, 7, 8, 3, 4, 5, 6, 7, 8, 3, 4, 5, 6, 7, 8, 3, 4, 5, 6, 7, 8, 3, 4, 5, 6, 7, 8,
  14. 3, 4, 5, 6, 7, 8, 3, 4, 5, 6, 7, 8, 3, 4, 5, 6, 7, 8, 3, 4, 5, 6, 7, 8, 3, 4, 5, 6, 7, 8,
  15. 3, 4, 5, 6, 7, 8, 3, 4, 5, 6, 7, 8, 3, 4, 5, 6, 7, 8, 3, 4, 5, 6, 7, 8, 3, 4, 5, 6, 7, 8,
  16. 3, 4, 5, 6, 7, 8, 3, 4, 5, 6, 7, 8, 3, 4, 5, 6, 7, 8, 3, 4, 5, 6, 7, 8, 3, 4, 5, 6, 7, 8,
  17. 3, 4, 5, 6, 7, 8, 3, 4, 5, 6, 7, 8, 3, 4, 5, 6, 7, 8, 3, 4, 5, 6, 7, 8, 3, 4, 5, 6, 7, 8,
  18. 3, 4, 5, 6, 7, 8, 3, 4, 5, 6, 7, 8, 3, 4, 5, 6, 7, 8, 3, 4, 5, 6, 7, 8, 3, 4, 5, 6, 7, 8,
  19. 3, 4, 5, 6, 7, 8, 3, 4, 5, 6, 7, 8, 3, 4, 5, 6, 7, 8, 3, 4, 5, 6, 7, 8, 3, 4, 5, 6, 7, 8,
  20. 3, 4, 5, 6, 7, 8, 3, 4, 5, 6, 7, 8, 3, 4, 5, 6, 7, 8, 3, 4, 5, 6, 7, 8, 3, 4, 5, 6, 7, 8,
  21. 3, 4, 5, 6, 7, 8, 3, 4, 5, 6, 7, 8, 3, 4, 5, 6, 7, 8, 3, 4, 5, 6, 7, 8, 3, 4, 5, 6, 7, 8,
  22. 3, 4, 5, 6, 7, 8, 3, 4, 5, 6, 7, 8, 3, 4, 5, 6, 7, 8, 3, 4, 5, 6, 7, 8, 3, 4, 5, 6, 7, 8,
  23. 3, 4, 5, 6, 7, 8, 3, 4, 5, 6, 7, 8, 3, 4, 5, 6, 7, 8, 3, 4, 5, 6, 7, 8, 3, 4, 5, 6, 7, 8];
  24. DumpArray(array_large);
  25. }
  26. function literalOfFloats()
  27. {
  28. var array = [3.5, 4, 5, 6, 7, 23.23];
  29. DumpArray(array);
  30. // more than 64 elements
  31. var array_large = [3.5, 4, 5, 6, 7, 23.23, 3.5, 4, 5, 6, 7, 23.23, 3.5, 4, 5, 6, 7, 23.23, 3.5, 4, 5, 6, 7, 23.23, 3.5, 4, 5, 6, 7, 23.23,
  32. 3.5, 4, 5, 6, 7, 23.23, 3.5, 4, 5, 6, 7, 23.23, 3.5, 4, 5, 6, 7, 23.23, 3.5, 4, 5, 6, 7, 23.23, 3.5, 4, 5, 6, 7, 23.23,
  33. 3.5, 4, 5, 6, 7, 23.23, 3.5, 4, 5, 6, 7, 23.23, 3.5, 4, 5, 6, 7, 23.23, 3.5, 4, 5, 6, 7, 23.23, 3.5, 4, 5, 6, 7, 23.23,
  34. 3.5, 4, 5, 6, 7, 23.23, 3.5, 4, 5, 6, 7, 23.23, 3.5, 4, 5, 6, 7, 23.23, 3.5, 4, 5, 6, 7, 23.23, 3.5, 4, 5, 6, 7, 23.23,
  35. 3.5, 4, 5, 6, 7, 23.23, 3.5, 4, 5, 6, 7, 23.23, 3.5, 4, 5, 6, 7, 23.23, 3.5, 4, 5, 6, 7, 23.23, 3.5, 4, 5, 6, 7, 23.23,
  36. 3.5, 4, 5, 6, 7, 23.23, 3.5, 4, 5, 6, 7, 23.23, 3.5, 4, 5, 6, 7, 23.23, 3.5, 4, 5, 6, 7, 23.23, 3.5, 4, 5, 6, 7, 23.23,
  37. 3.5, 4, 5, 6, 7, 23.23, 3.5, 4, 5, 6, 7, 23.23, 3.5, 4, 5, 6, 7, 23.23, 3.5, 4, 5, 6, 7, 23.23, 3.5, 4, 5, 6, 7, 23.23,
  38. 3.5, 4, 5, 6, 7, 23.23, 3.5, 4, 5, 6, 7, 23.23, 3.5, 4, 5, 6, 7, 23.23, 3.5, 4, 5, 6, 7, 23.23, 3.5, 4, 5, 6, 7, 23.23,
  39. 3.5, 4, 5, 6, 7, 23.23, 3.5, 4, 5, 6, 7, 23.23, 3.5, 4, 5, 6, 7, 23.23, 3.5, 4, 5, 6, 7, 23.23, 3.5, 4, 5, 6, 7, 23.23,
  40. 3.5, 4, 5, 6, 7, 23.23, 3.5, 4, 5, 6, 7, 23.23, 3.5, 4, 5, 6, 7, 23.23, 3.5, 4, 5, 6, 7, 23.23, 3.5, 4, 5, 6, 7, 23.23,
  41. 3.5, 4, 5, 6, 7, 23.23, 3.5, 4, 5, 6, 7, 23.23, 3.5, 4, 5, 6, 7, 23.23, 3.5, 4, 5, 6, 7, 23.23, 3.5, 4, 5, 6, 7, 23.23];
  42. DumpArray(array_large);
  43. }
  44. function otherLiteral()
  45. {
  46. var array = [];
  47. DumpArray(array);
  48. array[3] = 32;
  49. DumpArray(array);
  50. var array1 = [new Object()];
  51. var array1 = [new Object()];
  52. }
  53. function complexLiteral()
  54. {
  55. var array = [new Object(), 4, function() {}, 6, 7, 23.23];
  56. DumpArray(array);
  57. // Make the array1 itself dead and ensure that the code still works correctly with -recyclerstress
  58. var array1 = [new Object(), 4, function() {}, 6, 7, 23.23];
  59. var array1 = [new Object(), 4, function() {}, 6, 7, 23.23];
  60. }
  61. literalOfInts();
  62. literalOfFloats();
  63. otherLiteral();
  64. complexLiteral();