map.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 three = { val: 3 };
  6. var five = 5;
  7. var six = { val: 6 };
  8. var x = new Map();
  9. var y = x;
  10. y.baz = 5;
  11. var z = new Map();
  12. z.set(1, -1);
  13. z.set(2, -2);
  14. z.set(five, 5);
  15. WScript.SetTimeout(testFunction, 50);
  16. /////////////////
  17. function testFunction()
  18. {
  19. telemetryLog(`x === y: ${x === y}`, true); //true
  20. telemetryLog(`x.baz: ${x.baz}`, true); //5
  21. telemetryLog(`z.has(five): ${z.has(five)}`, true); //true
  22. telemetryLog(`z.get(five): ${z.get(five)}`, true); //5
  23. ////
  24. x.set(three, 3);
  25. z.delete(five);
  26. ////
  27. telemetryLog(`post update 1 -- y.has(three): ${y.has(three)}`, true); //true
  28. telemetryLog(`post update 1 -- y.get(three): ${y.get(three)}`, true); //3
  29. telemetryLog(`post update 1 -- z.has(five): ${z.has(five)}`, true); //false
  30. ////
  31. z.set(six, 6);
  32. six = null;
  33. y.set(three, 4);
  34. y.set(five, 5);
  35. ////
  36. telemetryLog(`post update 2 -- x.has(five): ${x.has(five)}`, true); //true
  37. telemetryLog(`post update 2 -- x.get(five): ${x.get(five)}`, true); //5
  38. telemetryLog(`post update 2 -- x.get(three): ${x.get(three)}`, true); //4
  39. }