regexp-sticky-helpers.js 604 B

1234567891011121314151617181920212223
  1. 'use strict';
  2. var fails = require('./fails');
  3. // babel-minify transpiles RegExp('a', 'y') -> /a/y and it causes SyntaxError,
  4. // so we use an intermediate function.
  5. function RE(s, f) {
  6. return RegExp(s, f);
  7. }
  8. exports.UNSUPPORTED_Y = fails(function () {
  9. // babel-minify transpiles RegExp('a', 'y') -> /a/y and it causes SyntaxError
  10. var re = RE('a', 'y');
  11. re.lastIndex = 2;
  12. return re.exec('abcd') != null;
  13. });
  14. exports.BROKEN_CARET = fails(function () {
  15. // https://bugzilla.mozilla.org/show_bug.cgi?id=773687
  16. var re = RE('^r', 'gy');
  17. re.lastIndex = 2;
  18. return re.exec('str') != null;
  19. });