RegExpStrictDelete.js 967 B

12345678910111213141516171819202122232425262728
  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. "use strict";
  6. var props = Object.getOwnPropertyNames(RegExp);
  7. props.sort();
  8. for (var i = 0, len = props.length; i < len; i++)
  9. {
  10. var prop = props[i];
  11. if (prop === 'prototype')
  12. continue;
  13. try
  14. {
  15. WScript.Echo("Testing: delete RegExp[" + prop + "]");
  16. var result = delete RegExp[prop];
  17. if (result === false)
  18. WScript.Echo("Error: strict delete returned false");
  19. }
  20. catch (err)
  21. {
  22. if (!err instanceof TypeError)
  23. WScript.Echo("Error: strict delete threw a non-TypeError: " + err);
  24. }
  25. }