property.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. //
  6. // Ensure that large numbers of properties are processed correctly.
  7. //
  8. var obj=new Object();
  9. for(x=0;x<5000;x++)
  10. {
  11. if(x<1000)
  12. {
  13. // Example: "var y15=15"
  14. eval("var y"+x+"=" + x );
  15. if(!(eval("y"+x)===x))
  16. WScript.Echo("FAIL: y"+x+" == " + eval("y"+x) + ". Expected: " + x);
  17. }
  18. else
  19. {
  20. // Example: "obj['o57']=57"
  21. eval("obj['o"+x+"']="+x );
  22. }
  23. }
  24. // Here it is assumed that the enumeration of properties are accessed in the sequence they were created
  25. // An example error message would look like:
  26. // FAIL: obj[p1] == 23. Expected: 47
  27. var y=1000;
  28. for(p1 in obj)
  29. {
  30. if(obj[p1]!==y)
  31. WScript.Echo("FAIL: obj["+p1+"] == " + (obj[p1]) + ". Expected: " + y);
  32. y++;
  33. }
  34. WScript.Echo("done");