non-unicode-property-names.js 948 B

1234567891011121314151617181920212223
  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. description: Exotic named group names in non-Unicode RegExps
  5. esid: prod-GroupSpecifier
  6. features: [regexp-named-groups]
  7. ---*/
  8. assert.sameValue("a", /(?<π>a)/.exec("bab").groups.π);
  9. assert.sameValue("a", /(?<π>a)/.exec("bab").groups.\u03C0);
  10. assert.sameValue("a", /(?<$>a)/.exec("bab").groups.$);
  11. assert.sameValue("a", /(?<_>a)/.exec("bab").groups._);
  12. assert.sameValue("a", /(?<_\u200C>a)/.exec("bab").groups._\u200C);
  13. assert.sameValue("a", /(?<_\u200D>a)/.exec("bab").groups._\u200D);
  14. assert.sameValue("a", /(?<ಠ_ಠ>a)/.exec("bab").groups.ಠ_ಠ);
  15. // Unicode escapes in capture names.
  16. assert(/(?<\u0041>.)/.test("a"));
  17. assert(RegExp("(?<\u{0041}>.)").test("a"), "Non-surrogate");
  18. // 4-char escapes must be the proper ID_Start/ID_Continue
  19. assert(RegExp("(?<\\u0041>.)").test("a"), "Non-surrogate");