parseWithGc.js 1.2 KB

1234567891011121314151617181920212223242526272829303132
  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. // Test case for Blue bug 379253
  6. // Construct a json object string with the given number of properties
  7. function GetJSONString(prefix, count)
  8. {
  9. var buffer = [];
  10. for (var i = 0; i < count; i++) {
  11. buffer.push('"' + prefix + i + '": true');
  12. }
  13. return "{ " + buffer.join(',') + " }";
  14. }
  15. var string1 = GetJSONString("prop", 100);
  16. var string2 = GetJSONString("drop", 550);
  17. // Create a JSON object with a 100 properties
  18. var object1 = JSON.parse(string1);
  19. // Clear reference to that object to make its properties eligible for collection
  20. object1 = null;
  21. // Parse a second JSON object, this time with a large number of properties
  22. // This parse has a reviver passed in too to cause an enumeration to occur after parse
  23. var k = 0;
  24. var object2 = JSON.parse(string2, function(key, value) { return k++; });
  25. WScript.Echo("pass");