character-class-digit-class-escape-flags-u.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 digit class escape \d 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: [],
  37. ranges: [
  38. [0x0030, 0x0039],
  39. ],
  40. });
  41. const re = /\d/ug;
  42. const errors = [];
  43. if (!re.test(str)) {
  44. // Error, let's find out where
  45. for (const char of str) {
  46. if (!re.test(char)) {
  47. errors.push('0x' + char.codePointAt(0).toString(16));
  48. }
  49. }
  50. }
  51. assert.sameValue(
  52. errors.length,
  53. 0,
  54. 'Expected matching code points, but received: ' + errors.join(',')
  55. );