memop-upperbound.js 835 B

1234567891011121314151617181920212223242526272829
  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. // Reduction of live site code that exposed use of bad upper bound in a memop transformation
  6. function f(a, b) {
  7. var c, d = a.length < b.length ? a.length : b.length;
  8. for (c = 0; d > c; c++)
  9. a[c] = b[c];
  10. for (c = d; c < a.length; c++)
  11. a[c] = 0
  12. }
  13. var a = Array(3);
  14. var b = [0, 1, 2, 3];
  15. f(a, b);
  16. WScript.Echo(a);
  17. b = [0];
  18. a = [0, 1, 2, 3];
  19. f(a, b);
  20. WScript.Echo(a);
  21. a = [2, 2];
  22. b = [8, 7, 6, 5, 2, 2, 2, 2, 2];
  23. f(a, b);
  24. WScript.Echo(a);