duplicate-flags.js 1.2 KB

1234567891011121314151617181920212223242526272829
  1. // Copyright 2017 the V8 project authors. All rights reserved.
  2. // This code is governed by the BSD license found in the LICENSE file.
  3. /*---
  4. info: |
  5. RegExpInitialize ( obj, pattern, flags )
  6. 5. If F contains any code unit other than "g", "i", "m", "s", "u", or "y" or if it contains the same code unit more than once, throw a SyntaxError exception.
  7. esid: sec-regexpinitialize
  8. description: Check that duplicate RegExp flags are disallowed
  9. features: [regexp-dotall]
  10. ---*/
  11. new RegExp("", "mig"); // single g will not throw SyntaxError
  12. assert.throws(SyntaxError, () => new RegExp("", "migg"), "duplicate g");
  13. new RegExp("", "i"); // single i will not throw SyntaxError
  14. assert.throws(SyntaxError, () => new RegExp("", "ii"), "duplicate i");
  15. new RegExp("", "m"); // single m will not throw SyntaxError
  16. assert.throws(SyntaxError, () => new RegExp("", "mm"), "duplicate m");
  17. new RegExp("", "s"); // single s will not throw SyntaxError
  18. assert.throws(SyntaxError, () => new RegExp("", "ss"), "duplicate s");
  19. new RegExp("", "u"); // single u will not throw SyntaxError
  20. assert.throws(SyntaxError, () => new RegExp("", "uu"), "duplicate u");
  21. new RegExp("", "y"); // single y will not throw SyntaxError
  22. assert.throws(SyntaxError, () => new RegExp("", "yy"), "duplicate y");