character-class-whitespace-class-escape.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 whitespace class escape \s 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: [
  37. 0x000020,
  38. 0x0000A0,
  39. 0x001680,
  40. 0x00202F,
  41. 0x00205F,
  42. 0x003000,
  43. 0x00FEFF,
  44. ],
  45. ranges: [
  46. [0x000009, 0x00000D],
  47. [0x002000, 0x00200A],
  48. [0x002028, 0x002029],
  49. ],
  50. });
  51. const re = /\s/g;
  52. const errors = [];
  53. if (!re.test(str)) {
  54. // Error, let's find out where
  55. for (const char of str) {
  56. if (!re.test(char)) {
  57. errors.push('0x' + char.codePointAt(0).toString(16));
  58. }
  59. }
  60. }
  61. assert.sameValue(
  62. errors.length,
  63. 0,
  64. 'Expected matching code points, but received: ' + errors.join(',')
  65. );