character-class-non-word-class-escape.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 non-word class escape \W with flags g
  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: [0x000060],
  37. ranges: [
  38. [0x00DC00, 0x00DFFF],
  39. [0x000000, 0x00002F],
  40. [0x00003A, 0x000040],
  41. [0x00005B, 0x00005E],
  42. [0x00007B, 0x00DBFF],
  43. [0x00E000, 0x00FFFF],
  44. ],
  45. });
  46. const re = /\W/g;
  47. const errors = [];
  48. if (!re.test(str)) {
  49. // Error, let's find out where
  50. for (const char of str) {
  51. if (!re.test(char)) {
  52. errors.push('0x' + char.codePointAt(0).toString(16));
  53. }
  54. }
  55. }
  56. assert.sameValue(
  57. errors.length,
  58. 0,
  59. 'Expected matching code points, but received: ' + errors.join(',')
  60. );