character-class-word-class-escape-flags-u.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // Copyright (C) 2018 Leo Balter. All rights reserved.
  2. // This code is governed by the BSD license found in the LICENSE file.
  3. /*---
  4. esid: prod-CharacterClassEscape
  5. description: >
  6. Compare range for word class escape \w with flags ug
  7. info: |
  8. This is a generated test. Please check out
  9. https://github.com/bocoup/test262-regexp-generator
  10. for any changes.
  11. CharacterClassEscape[U] ::
  12. d
  13. D
  14. s
  15. S
  16. w
  17. W
  18. 21.2.2.12 CharacterClassEscape
  19. The production CharacterClassEscape :: d evaluates as follows:
  20. Return the ten-element set of characters containing the characters 0 through 9 inclusive.
  21. The production CharacterClassEscape :: D evaluates as follows:
  22. Return the set of all characters not included in the set returned by CharacterClassEscape :: d.
  23. The production CharacterClassEscape :: s evaluates as follows:
  24. Return the set of characters containing the characters that are on the right-hand side of
  25. the WhiteSpace or LineTerminator productions.
  26. The production CharacterClassEscape :: S evaluates as follows:
  27. Return the set of all characters not included in the set returned by CharacterClassEscape :: s.
  28. The production CharacterClassEscape :: w evaluates as follows:
  29. Return the set of all characters returned by WordCharacters().
  30. The production CharacterClassEscape :: W evaluates as follows:
  31. Return the set of all characters not included in the set returned by CharacterClassEscape :: w.
  32. features: [String.fromCodePoint]
  33. includes: [regExpUtils.js]
  34. ---*/
  35. const str = buildString({
  36. loneCodePoints: [0x00005F],
  37. ranges: [
  38. [0x000030, 0x000039],
  39. [0x000041, 0x00005A],
  40. [0x000061, 0x00007A],
  41. ],
  42. });
  43. const re = /\w/ug;
  44. const errors = [];
  45. if (!re.test(str)) {
  46. // Error, let's find out where
  47. for (const char of str) {
  48. if (!re.test(char)) {
  49. errors.push('0x' + char.codePointAt(0).toString(16));
  50. }
  51. }
  52. }
  53. assert.sameValue(
  54. errors.length,
  55. 0,
  56. 'Expected matching code points, but received: ' + errors.join(',')
  57. );