From 8dd16259287f58f9273002717ec4d27e97127719 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 12 Jun 2024 07:43:14 +0200 Subject: Merging upstream version 127.0. Signed-off-by: Daniel Baumann --- .../built-ins/RegExp/Symbol.species/length.js | 11 ++- .../RegExp/Symbol.species/symbol-species-name.js | 14 ++- .../early-err-modifiers-code-point-repeat-i-1.js | 19 ++++ .../early-err-modifiers-code-point-repeat-i-2.js | 19 ++++ ...rly-err-modifiers-other-code-point-arbitrary.js | 19 ++++ ...y-err-modifiers-other-code-point-combining-i.js | 19 ++++ ...y-err-modifiers-other-code-point-combining-m.js | 19 ++++ ...y-err-modifiers-other-code-point-combining-s.js | 19 ++++ .../early-err-modifiers-other-code-point-d.js | 19 ++++ .../early-err-modifiers-other-code-point-g.js | 19 ++++ ...err-modifiers-other-code-point-non-display-1.js | Bin 0 -> 855 bytes ...err-modifiers-other-code-point-non-display-2.js | 19 ++++ ...arly-err-modifiers-other-code-point-non-flag.js | 19 ++++ .../early-err-modifiers-other-code-point-u.js | 19 ++++ ...y-err-modifiers-other-code-point-uppercase-I.js | 19 ++++ .../early-err-modifiers-other-code-point-y.js | 19 ++++ .../early-err-modifiers-other-code-point-zwj.js | 19 ++++ .../early-err-modifiers-other-code-point-zwnbsp.js | 19 ++++ .../early-err-modifiers-other-code-point-zwnj.js | 19 ++++ .../early-err-modifiers-should-not-case-fold-i.js | 19 ++++ .../early-err-modifiers-should-not-case-fold-m.js | 19 ++++ .../early-err-modifiers-should-not-case-fold-s.js | 19 ++++ ...err-modifiers-should-not-unicode-case-fold-i.js | 19 ++++ ...err-modifiers-should-not-unicode-case-fold-s.js | 19 ++++ .../RegExp/prototype/Symbol.match/length.js | 11 ++- .../RegExp/prototype/Symbol.match/name.js | 11 ++- .../prototype/Symbol.match/not-a-constructor.js | 2 +- .../RegExp/prototype/Symbol.matchAll/length.js | 11 ++- .../RegExp/prototype/Symbol.matchAll/name.js | 11 ++- .../prototype/Symbol.matchAll/not-a-constructor.js | 2 +- .../RegExp/prototype/Symbol.replace/length.js | 11 ++- .../RegExp/prototype/Symbol.replace/name.js | 11 ++- .../prototype/Symbol.replace/not-a-constructor.js | 2 +- .../RegExp/prototype/Symbol.search/length.js | 11 ++- .../RegExp/prototype/Symbol.search/name.js | 11 ++- .../prototype/Symbol.search/not-a-constructor.js | 2 +- .../RegExp/prototype/Symbol.split/length.js | 11 ++- .../RegExp/prototype/Symbol.split/name.js | 11 ++- .../prototype/Symbol.split/not-a-constructor.js | 2 +- .../built-ins/RegExp/prototype/exec/name.js | 11 ++- .../RegExp/prototype/exec/not-a-constructor.js | 2 +- .../built-ins/RegExp/prototype/global/length.js | 11 ++- .../built-ins/RegExp/prototype/global/name.js | 14 ++- .../RegExp/prototype/ignoreCase/length.js | 11 ++- .../built-ins/RegExp/prototype/ignoreCase/name.js | 14 ++- .../built-ins/RegExp/prototype/multiline/length.js | 11 ++- .../built-ins/RegExp/prototype/multiline/name.js | 14 ++- .../built-ins/RegExp/prototype/sticky/length.js | 11 ++- .../built-ins/RegExp/prototype/sticky/name.js | 14 ++- .../built-ins/RegExp/prototype/test/name.js | 11 ++- .../RegExp/prototype/test/not-a-constructor.js | 2 +- .../built-ins/RegExp/prototype/toString/name.js | 11 ++- .../RegExp/prototype/toString/not-a-constructor.js | 2 +- .../built-ins/RegExp/prototype/unicode/length.js | 11 ++- .../built-ins/RegExp/prototype/unicode/name.js | 11 ++- .../add-dotAll-does-not-affect-dotAll-property.js | 49 ++++++++++ .../add-dotAll-does-not-affect-ignoreCase-flag.js | 67 +++++++++++++ .../add-dotAll-does-not-affect-multiline-flag.js | 59 ++++++++++++ .../RegExp/regexp-modifiers/add-dotAll.js | 105 +++++++++++++++++++++ .../add-ignoreCase-affects-backreferences.js | 55 +++++++++++ .../add-ignoreCase-affects-characterClasses.js | 67 +++++++++++++ .../add-ignoreCase-affects-characterEscapes.js | 67 +++++++++++++ .../add-ignoreCase-affects-slash-lower-b.js | 77 +++++++++++++++ .../add-ignoreCase-affects-slash-lower-p.js | 61 ++++++++++++ .../add-ignoreCase-affects-slash-lower-w.js | 77 +++++++++++++++ .../add-ignoreCase-affects-slash-upper-b.js | 57 +++++++++++ .../add-ignoreCase-affects-slash-upper-p.js | 63 +++++++++++++ .../add-ignoreCase-affects-slash-upper-w.js | 57 +++++++++++ .../add-ignoreCase-does-not-affect-dotAll-flag.js | 67 +++++++++++++ ...noreCase-does-not-affect-ignoreCase-property.js | 55 +++++++++++ ...dd-ignoreCase-does-not-affect-multiline-flag.js | 67 +++++++++++++ .../RegExp/regexp-modifiers/add-ignoreCase.js | 47 +++++++++ .../add-multiline-does-not-affect-dotAll-flag.js | 59 ++++++++++++ ...dd-multiline-does-not-affect-ignoreCase-flag.js | 67 +++++++++++++ ...multiline-does-not-affect-multiline-property.js | 49 ++++++++++ .../RegExp/regexp-modifiers/add-multiline.js | 49 ++++++++++ .../regexp-modifiers/add-remove-modifiers.js | 45 +++++++++ .../built-ins/RegExp/regexp-modifiers/browser.js | 0 ...-dotAll-flag-does-not-affect-dotAll-modifier.js | 77 +++++++++++++++ ...ase-flag-does-not-affect-ignoreCase-modifier.js | 55 +++++++++++ ...line-flag-does-not-affect-multiline-modifier.js | 51 ++++++++++ .../nested-add-remove-modifiers.js | 45 +++++++++ .../nesting-add-dotAll-within-remove-dotAll.js | 71 ++++++++++++++ ...ting-add-ignoreCase-within-remove-ignoreCase.js | 45 +++++++++ ...esting-add-multiline-within-remove-multiline.js | 47 +++++++++ .../nesting-remove-dotAll-within-add-dotAll.js | 71 ++++++++++++++ ...ting-remove-ignoreCase-within-add-ignoreCase.js | 45 +++++++++ ...esting-remove-multiline-within-add-multiline.js | 47 +++++++++ ...emove-dotAll-does-not-affect-dotAll-property.js | 43 +++++++++ ...emove-dotAll-does-not-affect-ignoreCase-flag.js | 49 ++++++++++ ...remove-dotAll-does-not-affect-multiline-flag.js | 49 ++++++++++ .../RegExp/regexp-modifiers/remove-dotAll.js | 71 ++++++++++++++ .../remove-ignoreCase-affects-backreferences.js | 43 +++++++++ .../remove-ignoreCase-affects-characterClasses.js | 55 +++++++++++ .../remove-ignoreCase-affects-characterEscapes.js | 52 ++++++++++ .../remove-ignoreCase-affects-slash-lower-b.js | 53 +++++++++++ .../remove-ignoreCase-affects-slash-lower-p.js | 55 +++++++++++ .../remove-ignoreCase-affects-slash-lower-w.js | 53 +++++++++++ .../remove-ignoreCase-affects-slash-upper-b.js | 53 +++++++++++ .../remove-ignoreCase-affects-slash-upper-p.js | 56 +++++++++++ .../remove-ignoreCase-affects-slash-upper-w.js | 53 +++++++++++ ...emove-ignoreCase-does-not-affect-dotAll-flag.js | 49 ++++++++++ ...noreCase-does-not-affect-ignoreCase-property.js | 49 ++++++++++ ...ve-ignoreCase-does-not-affect-multiline-flag.js | 49 ++++++++++ .../RegExp/regexp-modifiers/remove-ignoreCase.js | 49 ++++++++++ ...remove-multiline-does-not-affect-dotAll-flag.js | 49 ++++++++++ ...ve-multiline-does-not-affect-ignoreCase-flag.js | 49 ++++++++++ ...multiline-does-not-affect-multiline-property.js | 43 +++++++++ .../RegExp/regexp-modifiers/remove-multiline.js | 45 +++++++++ .../built-ins/RegExp/regexp-modifiers/shell.js | 0 .../RegExp/regexp-modifiers/syntax/browser.js | 0 .../RegExp/regexp-modifiers/syntax/shell.js | 0 ...ve-modifiers-can-have-empty-remove-modifiers.js | 68 +++++++++++++ .../syntax/valid/add-and-remove-modifiers.js | 74 +++++++++++++++ .../syntax/valid/add-modifiers-when-nested.js | 44 +++++++++ .../valid/add-modifiers-when-not-set-as-flags.js | 68 +++++++++++++ .../valid/add-modifiers-when-set-as-flags.js | 46 +++++++++ .../regexp-modifiers/syntax/valid/browser.js | 0 .../syntax/valid/remove-modifiers-when-nested.js | 44 +++++++++ .../remove-modifiers-when-not-set-as-flags.js | 68 +++++++++++++ .../valid/remove-modifiers-when-set-as-flags.js | 68 +++++++++++++ .../RegExp/regexp-modifiers/syntax/valid/shell.js | 0 ...syntax-err-arithmetic-modifiers-add-remove-i.js | 19 ++++ ...syntax-err-arithmetic-modifiers-add-remove-m.js | 19 ++++ ...thmetic-modifiers-add-remove-multi-duplicate.js | 19 ++++ ...err-arithmetic-modifiers-add-remove-s-escape.js | 19 ++++ ...syntax-err-arithmetic-modifiers-add-remove-s.js | 19 ++++ .../syntax-err-arithmetic-modifiers-both-empty.js | 19 ++++ ...r-arithmetic-modifiers-code-point-repeat-i-1.js | 19 ++++ ...r-arithmetic-modifiers-code-point-repeat-i-2.js | 19 ++++ ...thmetic-modifiers-other-code-point-arbitrary.js | 19 ++++ ...metic-modifiers-other-code-point-combining-i.js | 19 ++++ ...metic-modifiers-other-code-point-combining-m.js | 19 ++++ ...metic-modifiers-other-code-point-combining-s.js | 19 ++++ ...-err-arithmetic-modifiers-other-code-point-d.js | 19 ++++ ...-err-arithmetic-modifiers-other-code-point-g.js | 19 ++++ ...tic-modifiers-other-code-point-non-display-1.js | Bin 0 -> 718 bytes ...tic-modifiers-other-code-point-non-display-2.js | 19 ++++ ...ithmetic-modifiers-other-code-point-non-flag.js | 19 ++++ ...-err-arithmetic-modifiers-other-code-point-u.js | 19 ++++ ...metic-modifiers-other-code-point-uppercase-I.js | 19 ++++ ...-err-arithmetic-modifiers-other-code-point-y.js | 19 ++++ ...rr-arithmetic-modifiers-other-code-point-zwj.js | 19 ++++ ...arithmetic-modifiers-other-code-point-zwnbsp.js | 19 ++++ ...r-arithmetic-modifiers-other-code-point-zwnj.js | 19 ++++ ...rr-arithmetic-modifiers-reverse-add-remove-i.js | 19 ++++ ...rr-arithmetic-modifiers-reverse-add-remove-m.js | 19 ++++ ...modifiers-reverse-add-remove-multi-duplicate.js | 19 ++++ ...hmetic-modifiers-reverse-add-remove-s-escape.js | 19 ++++ ...rr-arithmetic-modifiers-reverse-add-remove-s.js | 19 ++++ ...etic-modifiers-reverse-code-point-repeat-i-1.js | 19 ++++ ...etic-modifiers-reverse-code-point-repeat-i-2.js | 19 ++++ ...modifiers-reverse-other-code-point-arbitrary.js | 19 ++++ ...difiers-reverse-other-code-point-combining-i.js | 19 ++++ ...difiers-reverse-other-code-point-combining-m.js | 19 ++++ ...difiers-reverse-other-code-point-combining-s.js | 19 ++++ ...thmetic-modifiers-reverse-other-code-point-d.js | 19 ++++ ...thmetic-modifiers-reverse-other-code-point-g.js | 19 ++++ ...fiers-reverse-other-code-point-non-display-1.js | Bin 0 -> 718 bytes ...fiers-reverse-other-code-point-non-display-2.js | 19 ++++ ...-modifiers-reverse-other-code-point-non-flag.js | 19 ++++ ...thmetic-modifiers-reverse-other-code-point-u.js | 19 ++++ ...difiers-reverse-other-code-point-uppercase-I.js | 19 ++++ ...thmetic-modifiers-reverse-other-code-point-y.js | 19 ++++ ...metic-modifiers-reverse-other-code-point-zwj.js | 19 ++++ ...ic-modifiers-reverse-other-code-point-zwnbsp.js | 19 ++++ ...etic-modifiers-reverse-other-code-point-zwnj.js | 19 ++++ ...tic-modifiers-reverse-should-not-case-fold-i.js | 19 ++++ ...tic-modifiers-reverse-should-not-case-fold-m.js | 19 ++++ ...tic-modifiers-reverse-should-not-case-fold-s.js | 19 ++++ ...fiers-reverse-should-not-unicode-case-fold-i.js | 19 ++++ ...fiers-reverse-should-not-unicode-case-fold-s.js | 19 ++++ ...-arithmetic-modifiers-should-not-case-fold-i.js | 19 ++++ ...-arithmetic-modifiers-should-not-case-fold-m.js | 19 ++++ ...-arithmetic-modifiers-should-not-case-fold-s.js | 19 ++++ ...tic-modifiers-should-not-unicode-case-fold-i.js | 19 ++++ ...tic-modifiers-should-not-unicode-case-fold-s.js | 19 ++++ 177 files changed, 5031 insertions(+), 148 deletions(-) create mode 100644 js/src/tests/test262/built-ins/RegExp/early-err-modifiers-code-point-repeat-i-1.js create mode 100644 js/src/tests/test262/built-ins/RegExp/early-err-modifiers-code-point-repeat-i-2.js create mode 100644 js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-arbitrary.js create mode 100644 js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-combining-i.js create mode 100644 js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-combining-m.js create mode 100644 js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-combining-s.js create mode 100644 js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-d.js create mode 100644 js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-g.js create mode 100644 js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-non-display-1.js create mode 100644 js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-non-display-2.js create mode 100644 js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-non-flag.js create mode 100644 js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-u.js create mode 100644 js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-uppercase-I.js create mode 100644 js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-y.js create mode 100644 js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-zwj.js create mode 100644 js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-zwnbsp.js create mode 100644 js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-zwnj.js create mode 100644 js/src/tests/test262/built-ins/RegExp/early-err-modifiers-should-not-case-fold-i.js create mode 100644 js/src/tests/test262/built-ins/RegExp/early-err-modifiers-should-not-case-fold-m.js create mode 100644 js/src/tests/test262/built-ins/RegExp/early-err-modifiers-should-not-case-fold-s.js create mode 100644 js/src/tests/test262/built-ins/RegExp/early-err-modifiers-should-not-unicode-case-fold-i.js create mode 100644 js/src/tests/test262/built-ins/RegExp/early-err-modifiers-should-not-unicode-case-fold-s.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-dotAll-does-not-affect-dotAll-property.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-dotAll-does-not-affect-ignoreCase-flag.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-dotAll-does-not-affect-multiline-flag.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-dotAll.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-backreferences.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-characterClasses.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-characterEscapes.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-slash-lower-b.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-slash-lower-p.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-slash-lower-w.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-slash-upper-b.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-slash-upper-p.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-slash-upper-w.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-does-not-affect-dotAll-flag.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-does-not-affect-ignoreCase-property.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-does-not-affect-multiline-flag.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-multiline-does-not-affect-dotAll-flag.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-multiline-does-not-affect-ignoreCase-flag.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-multiline-does-not-affect-multiline-property.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-multiline.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-remove-modifiers.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/browser.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/changing-dotAll-flag-does-not-affect-dotAll-modifier.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/changing-ignoreCase-flag-does-not-affect-ignoreCase-modifier.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/changing-multiline-flag-does-not-affect-multiline-modifier.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/nested-add-remove-modifiers.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/nesting-add-dotAll-within-remove-dotAll.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/nesting-add-ignoreCase-within-remove-ignoreCase.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/nesting-add-multiline-within-remove-multiline.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/nesting-remove-dotAll-within-add-dotAll.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/nesting-remove-ignoreCase-within-add-ignoreCase.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/nesting-remove-multiline-within-add-multiline.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-dotAll-does-not-affect-dotAll-property.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-dotAll-does-not-affect-ignoreCase-flag.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-dotAll-does-not-affect-multiline-flag.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-dotAll.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-backreferences.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-characterClasses.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-characterEscapes.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-slash-lower-b.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-slash-lower-p.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-slash-lower-w.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-slash-upper-b.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-slash-upper-p.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-slash-upper-w.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-does-not-affect-dotAll-flag.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-does-not-affect-ignoreCase-property.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-does-not-affect-multiline-flag.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-multiline-does-not-affect-dotAll-flag.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-multiline-does-not-affect-ignoreCase-flag.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-multiline-does-not-affect-multiline-property.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-multiline.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/shell.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/browser.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/shell.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/add-and-remove-modifiers-can-have-empty-remove-modifiers.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/add-and-remove-modifiers.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/add-modifiers-when-nested.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/add-modifiers-when-not-set-as-flags.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/add-modifiers-when-set-as-flags.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/browser.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/remove-modifiers-when-nested.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/remove-modifiers-when-not-set-as-flags.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/remove-modifiers-when-set-as-flags.js create mode 100644 js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/shell.js create mode 100644 js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-add-remove-i.js create mode 100644 js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-add-remove-m.js create mode 100644 js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-add-remove-multi-duplicate.js create mode 100644 js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-add-remove-s-escape.js create mode 100644 js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-add-remove-s.js create mode 100644 js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-both-empty.js create mode 100644 js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-code-point-repeat-i-1.js create mode 100644 js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-code-point-repeat-i-2.js create mode 100644 js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-arbitrary.js create mode 100644 js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-combining-i.js create mode 100644 js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-combining-m.js create mode 100644 js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-combining-s.js create mode 100644 js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-d.js create mode 100644 js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-g.js create mode 100644 js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-non-display-1.js create mode 100644 js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-non-display-2.js create mode 100644 js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-non-flag.js create mode 100644 js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-u.js create mode 100644 js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-uppercase-I.js create mode 100644 js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-y.js create mode 100644 js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-zwj.js create mode 100644 js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-zwnbsp.js create mode 100644 js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-zwnj.js create mode 100644 js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-add-remove-i.js create mode 100644 js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-add-remove-m.js create mode 100644 js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-add-remove-multi-duplicate.js create mode 100644 js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-add-remove-s-escape.js create mode 100644 js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-add-remove-s.js create mode 100644 js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-code-point-repeat-i-1.js create mode 100644 js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-code-point-repeat-i-2.js create mode 100644 js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-arbitrary.js create mode 100644 js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-combining-i.js create mode 100644 js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-combining-m.js create mode 100644 js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-combining-s.js create mode 100644 js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-d.js create mode 100644 js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-g.js create mode 100644 js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-non-display-1.js create mode 100644 js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-non-display-2.js create mode 100644 js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-non-flag.js create mode 100644 js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-u.js create mode 100644 js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-uppercase-I.js create mode 100644 js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-y.js create mode 100644 js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-zwj.js create mode 100644 js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-zwnbsp.js create mode 100644 js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-zwnj.js create mode 100644 js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-should-not-case-fold-i.js create mode 100644 js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-should-not-case-fold-m.js create mode 100644 js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-should-not-case-fold-s.js create mode 100644 js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-should-not-unicode-case-fold-i.js create mode 100644 js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-should-not-unicode-case-fold-s.js create mode 100644 js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-should-not-case-fold-i.js create mode 100644 js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-should-not-case-fold-m.js create mode 100644 js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-should-not-case-fold-s.js create mode 100644 js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-should-not-unicode-case-fold-i.js create mode 100644 js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-should-not-unicode-case-fold-s.js (limited to 'js/src/tests/test262/built-ins/RegExp') diff --git a/js/src/tests/test262/built-ins/RegExp/Symbol.species/length.js b/js/src/tests/test262/built-ins/RegExp/Symbol.species/length.js index c38cb495a3..5330173b20 100644 --- a/js/src/tests/test262/built-ins/RegExp/Symbol.species/length.js +++ b/js/src/tests/test262/built-ins/RegExp/Symbol.species/length.js @@ -25,10 +25,11 @@ features: [Symbol.species] var desc = Object.getOwnPropertyDescriptor(RegExp, Symbol.species); -assert.sameValue(desc.get.length, 0); - -verifyNotEnumerable(desc.get, "length"); -verifyNotWritable(desc.get, "length"); -verifyConfigurable(desc.get, "length"); +verifyProperty(desc.get, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/Symbol.species/symbol-species-name.js b/js/src/tests/test262/built-ins/RegExp/Symbol.species/symbol-species-name.js index c7069365a6..5502462c6e 100644 --- a/js/src/tests/test262/built-ins/RegExp/Symbol.species/symbol-species-name.js +++ b/js/src/tests/test262/built-ins/RegExp/Symbol.species/symbol-species-name.js @@ -15,13 +15,11 @@ includes: [propertyHelper.js] var descriptor = Object.getOwnPropertyDescriptor(RegExp, Symbol.species); -assert.sameValue( - descriptor.get.name, - 'get [Symbol.species]' -); - -verifyNotEnumerable(descriptor.get, 'name'); -verifyNotWritable(descriptor.get, 'name'); -verifyConfigurable(descriptor.get, 'name'); +verifyProperty(descriptor.get, "name", { + value: "get [Symbol.species]", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-code-point-repeat-i-1.js b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-code-point-repeat-i-1.js new file mode 100644 index 0000000000..cc4d99e0cd --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-code-point-repeat-i-1.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?ii:a)", ""); +}, 'RegExp("(?ii:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-code-point-repeat-i-2.js b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-code-point-repeat-i-2.js new file mode 100644 index 0000000000..24a85269ad --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-code-point-repeat-i-2.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?imsi:a)", ""); +}, 'RegExp("(?imsi:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-arbitrary.js b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-arbitrary.js new file mode 100644 index 0000000000..d67bb46e14 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-arbitrary.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?1:a)", ""); +}, 'RegExp("(?1:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-combining-i.js b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-combining-i.js new file mode 100644 index 0000000000..d309c29c20 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-combining-i.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?iͥ:a)", ""); +}, 'RegExp("(?iͥ:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-combining-m.js b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-combining-m.js new file mode 100644 index 0000000000..38d57aca09 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-combining-m.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?mͫ:a)", ""); +}, 'RegExp("(?mͫ:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-combining-s.js b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-combining-s.js new file mode 100644 index 0000000000..325d6cce13 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-combining-s.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?s̀:a)", ""); +}, 'RegExp("(?s̀:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-d.js b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-d.js new file mode 100644 index 0000000000..27d3dcc71a --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-d.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?d:a)", ""); +}, 'RegExp("(?d:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-g.js b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-g.js new file mode 100644 index 0000000000..e2805673f2 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-g.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?g:a)", ""); +}, 'RegExp("(?g:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-non-display-1.js b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-non-display-1.js new file mode 100644 index 0000000000..d2d2223eb2 Binary files /dev/null and b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-non-display-1.js differ diff --git a/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-non-display-2.js b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-non-display-2.js new file mode 100644 index 0000000000..9e05cb67f3 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-non-display-2.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?s‎:a)", ""); +}, 'RegExp("(?s‎:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-non-flag.js b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-non-flag.js new file mode 100644 index 0000000000..87ee26e9ca --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-non-flag.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?Q:a)", ""); +}, 'RegExp("(?Q:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-u.js b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-u.js new file mode 100644 index 0000000000..82c45b61f2 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-u.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?u:a)", ""); +}, 'RegExp("(?u:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-uppercase-I.js b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-uppercase-I.js new file mode 100644 index 0000000000..17e23af60b --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-uppercase-I.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?I:a)", ""); +}, 'RegExp("(?I:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-y.js b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-y.js new file mode 100644 index 0000000000..829ec8a69f --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-y.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?y:a)", ""); +}, 'RegExp("(?y:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-zwj.js b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-zwj.js new file mode 100644 index 0000000000..e7877d64c1 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-zwj.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?s‍:a)", ""); +}, 'RegExp("(?s‍:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-zwnbsp.js b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-zwnbsp.js new file mode 100644 index 0000000000..0a44ee1551 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-zwnbsp.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?s:a)", ""); +}, 'RegExp("(?s:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-zwnj.js b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-zwnj.js new file mode 100644 index 0000000000..233c5aa9dd --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-other-code-point-zwnj.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?s‌:a)", ""); +}, 'RegExp("(?s‌:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-should-not-case-fold-i.js b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-should-not-case-fold-i.js new file mode 100644 index 0000000000..bbe8e845e2 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-should-not-case-fold-i.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Code points other than "i", "m", "s" should not be case folded to "i", "m", or "s" (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?I:a)", "i"); +}, 'RegExp("(?I:a)", "i"): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-should-not-case-fold-m.js b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-should-not-case-fold-m.js new file mode 100644 index 0000000000..61068122a5 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-should-not-case-fold-m.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Code points other than "i", "m", "s" should not be case folded to "i", "m", or "s" (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?M:a)", "i"); +}, 'RegExp("(?M:a)", "i"): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-should-not-case-fold-s.js b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-should-not-case-fold-s.js new file mode 100644 index 0000000000..464666a010 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-should-not-case-fold-s.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Code points other than "i", "m", "s" should not be case folded to "i", "m", or "s" (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?S:a)", "i"); +}, 'RegExp("(?S:a)", "i"): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-should-not-unicode-case-fold-i.js b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-should-not-unicode-case-fold-i.js new file mode 100644 index 0000000000..3140f4e4de --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-should-not-unicode-case-fold-i.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Code points other than "i", "m", "s" should not be case-folded to "i", "m", or "s" (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?İ:a)", "iu"); +}, 'RegExp("(?İ:a)", "iu"): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-should-not-unicode-case-fold-s.js b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-should-not-unicode-case-fold-s.js new file mode 100644 index 0000000000..939793f5ed --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/early-err-modifiers-should-not-unicode-case-fold-s.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Code points other than "i", "m", "s" should not be case-folded to "i", "m", or "s" (regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpresisonFlags : Disjunction ) + It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code points other than "i", "m", "s", or if it contains the same code point more than once. + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?ſ:a)", "u"); +}, 'RegExp("(?ſ:a)", "u"): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.match/length.js b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.match/length.js index ea84d3ce40..b8c3c34a02 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.match/length.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.match/length.js @@ -19,10 +19,11 @@ includes: [propertyHelper.js] features: [Symbol.match] ---*/ -assert.sameValue(RegExp.prototype[Symbol.match].length, 1); - -verifyNotEnumerable(RegExp.prototype[Symbol.match], 'length'); -verifyNotWritable(RegExp.prototype[Symbol.match], 'length'); -verifyConfigurable(RegExp.prototype[Symbol.match], 'length'); +verifyProperty(RegExp.prototype[Symbol.match], "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.match/name.js b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.match/name.js index 2c676dba2f..a0629a0c73 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.match/name.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.match/name.js @@ -17,10 +17,11 @@ includes: [propertyHelper.js] features: [Symbol.match] ---*/ -assert.sameValue(RegExp.prototype[Symbol.match].name, '[Symbol.match]'); - -verifyNotEnumerable(RegExp.prototype[Symbol.match], 'name'); -verifyNotWritable(RegExp.prototype[Symbol.match], 'name'); -verifyConfigurable(RegExp.prototype[Symbol.match], 'name'); +verifyProperty(RegExp.prototype[Symbol.match], "name", { + value: "[Symbol.match]", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.match/not-a-constructor.js b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.match/not-a-constructor.js index f56be3391f..727add9892 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.match/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.match/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let re = new RegExp(''); new re[Symbol.match](); -}, '`let re = new RegExp(\'\'); new re[Symbol.match]()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.matchAll/length.js b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.matchAll/length.js index ec522ab2f5..70284e43e6 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.matchAll/length.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.matchAll/length.js @@ -23,10 +23,11 @@ includes: [propertyHelper.js] features: [Symbol.matchAll] ---*/ -assert.sameValue(RegExp.prototype[Symbol.matchAll].length, 1); - -verifyNotEnumerable(RegExp.prototype[Symbol.matchAll], 'length'); -verifyNotWritable(RegExp.prototype[Symbol.matchAll], 'length'); -verifyConfigurable(RegExp.prototype[Symbol.matchAll], 'length'); +verifyProperty(RegExp.prototype[Symbol.matchAll], "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.matchAll/name.js b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.matchAll/name.js index f9a1e9bf87..4ce81b923f 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.matchAll/name.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.matchAll/name.js @@ -21,10 +21,11 @@ includes: [propertyHelper.js] features: [Symbol.matchAll] ---*/ -assert.sameValue(RegExp.prototype[Symbol.matchAll].name, '[Symbol.matchAll]'); - -verifyNotEnumerable(RegExp.prototype[Symbol.matchAll], 'name'); -verifyNotWritable(RegExp.prototype[Symbol.matchAll], 'name'); -verifyConfigurable(RegExp.prototype[Symbol.matchAll], 'name'); +verifyProperty(RegExp.prototype[Symbol.matchAll], "name", { + value: "[Symbol.matchAll]", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.matchAll/not-a-constructor.js b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.matchAll/not-a-constructor.js index 03009bf3de..956881d1c6 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.matchAll/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.matchAll/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let re = new RegExp(''); new re[Symbol.matchAll](); -}, '`let re = new RegExp(\'\'); new re[Symbol.matchAll]()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.replace/length.js b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.replace/length.js index fe89e2265b..7dce30b819 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.replace/length.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.replace/length.js @@ -19,10 +19,11 @@ includes: [propertyHelper.js] features: [Symbol.replace] ---*/ -assert.sameValue(RegExp.prototype[Symbol.replace].length, 2); - -verifyNotEnumerable(RegExp.prototype[Symbol.replace], 'length'); -verifyNotWritable(RegExp.prototype[Symbol.replace], 'length'); -verifyConfigurable(RegExp.prototype[Symbol.replace], 'length'); +verifyProperty(RegExp.prototype[Symbol.replace], "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.replace/name.js b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.replace/name.js index 5d6dbb13e7..512c11a769 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.replace/name.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.replace/name.js @@ -17,10 +17,11 @@ includes: [propertyHelper.js] features: [Symbol.replace] ---*/ -assert.sameValue(RegExp.prototype[Symbol.replace].name, '[Symbol.replace]'); - -verifyNotEnumerable(RegExp.prototype[Symbol.replace], 'name'); -verifyNotWritable(RegExp.prototype[Symbol.replace], 'name'); -verifyConfigurable(RegExp.prototype[Symbol.replace], 'name'); +verifyProperty(RegExp.prototype[Symbol.replace], "name", { + value: "[Symbol.replace]", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.replace/not-a-constructor.js b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.replace/not-a-constructor.js index 8fe7bd03bb..07c7a0b7a1 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.replace/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.replace/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let re = new RegExp(''); new re[Symbol.replace](); -}, '`let re = new RegExp(\'\'); new re[Symbol.replace]()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.search/length.js b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.search/length.js index 86a0b3051c..5be85a3bf4 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.search/length.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.search/length.js @@ -20,10 +20,11 @@ features: [Symbol.search] includes: [propertyHelper.js] ---*/ -assert.sameValue(RegExp.prototype[Symbol.search].length, 1); - -verifyNotEnumerable(RegExp.prototype[Symbol.search], 'length'); -verifyNotWritable(RegExp.prototype[Symbol.search], 'length'); -verifyConfigurable(RegExp.prototype[Symbol.search], 'length'); +verifyProperty(RegExp.prototype[Symbol.search], "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.search/name.js b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.search/name.js index 08a4452f48..4f3861d650 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.search/name.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.search/name.js @@ -17,10 +17,11 @@ features: [Symbol.search] includes: [propertyHelper.js] ---*/ -assert.sameValue(RegExp.prototype[Symbol.search].name, '[Symbol.search]'); - -verifyNotEnumerable(RegExp.prototype[Symbol.search], 'name'); -verifyNotWritable(RegExp.prototype[Symbol.search], 'name'); -verifyConfigurable(RegExp.prototype[Symbol.search], 'name'); +verifyProperty(RegExp.prototype[Symbol.search], "name", { + value: "[Symbol.search]", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.search/not-a-constructor.js b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.search/not-a-constructor.js index 0403b2e6da..8d13663998 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.search/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.search/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let re = new RegExp(''); new re[Symbol.search](); -}, '`let re = new RegExp(\'\'); new re[Symbol.search]()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.split/length.js b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.split/length.js index 546f056ca0..5fe2ff49c4 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.split/length.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.split/length.js @@ -17,10 +17,11 @@ includes: [propertyHelper.js] features: [Symbol.split] ---*/ -assert.sameValue(RegExp.prototype[Symbol.split].length, 2); - -verifyNotEnumerable(RegExp.prototype[Symbol.split], 'length'); -verifyNotWritable(RegExp.prototype[Symbol.split], 'length'); -verifyConfigurable(RegExp.prototype[Symbol.split], 'length'); +verifyProperty(RegExp.prototype[Symbol.split], "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.split/name.js b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.split/name.js index aac4f253a1..5284f94f57 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.split/name.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.split/name.js @@ -17,10 +17,11 @@ includes: [propertyHelper.js] features: [Symbol.split] ---*/ -assert.sameValue(RegExp.prototype[Symbol.split].name, '[Symbol.split]'); - -verifyNotEnumerable(RegExp.prototype[Symbol.split], 'name'); -verifyNotWritable(RegExp.prototype[Symbol.split], 'name'); -verifyConfigurable(RegExp.prototype[Symbol.split], 'name'); +verifyProperty(RegExp.prototype[Symbol.split], "name", { + value: "[Symbol.split]", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.split/not-a-constructor.js b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.split/not-a-constructor.js index 4623db96ba..88094c421a 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.split/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/Symbol.split/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let re = new RegExp(''); new re[Symbol.split](); -}, '`let re = new RegExp(\'\'); new re[Symbol.split]()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/exec/name.js b/js/src/tests/test262/built-ins/RegExp/prototype/exec/name.js index 89d0243a20..ef865729a9 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/exec/name.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/exec/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(RegExp.prototype.exec.name, "exec"); - -verifyNotEnumerable(RegExp.prototype.exec, "name"); -verifyNotWritable(RegExp.prototype.exec, "name"); -verifyConfigurable(RegExp.prototype.exec, "name"); +verifyProperty(RegExp.prototype.exec, "name", { + value: "exec", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/exec/not-a-constructor.js b/js/src/tests/test262/built-ins/RegExp/prototype/exec/not-a-constructor.js index c4492952dd..9578cd6777 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/exec/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/exec/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let re = new RegExp(''); new re.exec(); -}, '`let re = new RegExp(\'\'); new re.exec()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/global/length.js b/js/src/tests/test262/built-ins/RegExp/prototype/global/length.js index d2802441f3..181dc3f2c4 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/global/length.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/global/length.js @@ -24,10 +24,11 @@ includes: [propertyHelper.js] var desc = Object.getOwnPropertyDescriptor(RegExp.prototype, "global"); -assert.sameValue(desc.get.length, 0); - -verifyNotEnumerable(desc.get, "length"); -verifyNotWritable(desc.get, "length"); -verifyConfigurable(desc.get, "length"); +verifyProperty(desc.get, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/global/name.js b/js/src/tests/test262/built-ins/RegExp/prototype/global/name.js index ba8ace9def..fb76ce7121 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/global/name.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/global/name.js @@ -14,13 +14,11 @@ includes: [propertyHelper.js] var descriptor = Object.getOwnPropertyDescriptor(RegExp.prototype, 'global'); -assert.sameValue( - descriptor.get.name, - 'get global' -); - -verifyNotEnumerable(descriptor.get, 'name'); -verifyNotWritable(descriptor.get, 'name'); -verifyConfigurable(descriptor.get, 'name'); +verifyProperty(descriptor.get, "name", { + value: "get global", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/ignoreCase/length.js b/js/src/tests/test262/built-ins/RegExp/prototype/ignoreCase/length.js index 3707ec5ad1..fcb51bc8d7 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/ignoreCase/length.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/ignoreCase/length.js @@ -24,10 +24,11 @@ includes: [propertyHelper.js] var desc = Object.getOwnPropertyDescriptor(RegExp.prototype, "ignoreCase"); -assert.sameValue(desc.get.length, 0); - -verifyNotEnumerable(desc.get, "length"); -verifyNotWritable(desc.get, "length"); -verifyConfigurable(desc.get, "length"); +verifyProperty(desc.get, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/ignoreCase/name.js b/js/src/tests/test262/built-ins/RegExp/prototype/ignoreCase/name.js index 1f3894cbbe..4f7dc92846 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/ignoreCase/name.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/ignoreCase/name.js @@ -14,13 +14,11 @@ includes: [propertyHelper.js] var descriptor = Object.getOwnPropertyDescriptor(RegExp.prototype, 'ignoreCase'); -assert.sameValue( - descriptor.get.name, - 'get ignoreCase' -); - -verifyNotEnumerable(descriptor.get, 'name'); -verifyNotWritable(descriptor.get, 'name'); -verifyConfigurable(descriptor.get, 'name'); +verifyProperty(descriptor.get, "name", { + value: "get ignoreCase", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/multiline/length.js b/js/src/tests/test262/built-ins/RegExp/prototype/multiline/length.js index 08105090e0..c79cb88c99 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/multiline/length.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/multiline/length.js @@ -24,10 +24,11 @@ includes: [propertyHelper.js] var desc = Object.getOwnPropertyDescriptor(RegExp.prototype, "multiline"); -assert.sameValue(desc.get.length, 0); - -verifyNotEnumerable(desc.get, "length"); -verifyNotWritable(desc.get, "length"); -verifyConfigurable(desc.get, "length"); +verifyProperty(desc.get, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/multiline/name.js b/js/src/tests/test262/built-ins/RegExp/prototype/multiline/name.js index 674dec6f70..3fd0e3bce7 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/multiline/name.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/multiline/name.js @@ -14,13 +14,11 @@ includes: [propertyHelper.js] var descriptor = Object.getOwnPropertyDescriptor(RegExp.prototype, 'multiline'); -assert.sameValue( - descriptor.get.name, - 'get multiline' -); - -verifyNotEnumerable(descriptor.get, 'name'); -verifyNotWritable(descriptor.get, 'name'); -verifyConfigurable(descriptor.get, 'name'); +verifyProperty(descriptor.get, "name", { + value: "get multiline", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/sticky/length.js b/js/src/tests/test262/built-ins/RegExp/prototype/sticky/length.js index 220cf0a901..178f62270b 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/sticky/length.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/sticky/length.js @@ -24,10 +24,11 @@ includes: [propertyHelper.js] var desc = Object.getOwnPropertyDescriptor(RegExp.prototype, "sticky"); -assert.sameValue(desc.get.length, 0); - -verifyNotEnumerable(desc.get, "length"); -verifyNotWritable(desc.get, "length"); -verifyConfigurable(desc.get, "length"); +verifyProperty(desc.get, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/sticky/name.js b/js/src/tests/test262/built-ins/RegExp/prototype/sticky/name.js index 8fa5b1ac0f..b1c2120e47 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/sticky/name.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/sticky/name.js @@ -14,13 +14,11 @@ includes: [propertyHelper.js] var descriptor = Object.getOwnPropertyDescriptor(RegExp.prototype, 'sticky'); -assert.sameValue( - descriptor.get.name, - 'get sticky' -); - -verifyNotEnumerable(descriptor.get, 'name'); -verifyNotWritable(descriptor.get, 'name'); -verifyConfigurable(descriptor.get, 'name'); +verifyProperty(descriptor.get, "name", { + value: "get sticky", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/test/name.js b/js/src/tests/test262/built-ins/RegExp/prototype/test/name.js index 7ee8a9a2e7..dcfb6f1e1a 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/test/name.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/test/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(RegExp.prototype.test.name, "test"); - -verifyNotEnumerable(RegExp.prototype.test, "name"); -verifyNotWritable(RegExp.prototype.test, "name"); -verifyConfigurable(RegExp.prototype.test, "name"); +verifyProperty(RegExp.prototype.test, "name", { + value: "test", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/test/not-a-constructor.js b/js/src/tests/test262/built-ins/RegExp/prototype/test/not-a-constructor.js index ee6ce0aeaf..60422aca55 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/test/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/test/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let re = new RegExp(''); new re.test(); -}, '`let re = new RegExp(\'\'); new re.test()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/toString/name.js b/js/src/tests/test262/built-ins/RegExp/prototype/toString/name.js index 91fe5a8809..46da2536c2 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/toString/name.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/toString/name.js @@ -19,10 +19,11 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(RegExp.prototype.toString.name, "toString"); - -verifyNotEnumerable(RegExp.prototype.toString, "name"); -verifyNotWritable(RegExp.prototype.toString, "name"); -verifyConfigurable(RegExp.prototype.toString, "name"); +verifyProperty(RegExp.prototype.toString, "name", { + value: "toString", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/toString/not-a-constructor.js b/js/src/tests/test262/built-ins/RegExp/prototype/toString/not-a-constructor.js index f064aaf64d..76b48034ed 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/toString/not-a-constructor.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/toString/not-a-constructor.js @@ -29,7 +29,7 @@ assert.sameValue( assert.throws(TypeError, () => { let re = new RegExp(''); new re.toString(); -}, '`let re = new RegExp(\'\'); new re.toString()` throws TypeError'); +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/unicode/length.js b/js/src/tests/test262/built-ins/RegExp/prototype/unicode/length.js index 127e2d0428..c661157d48 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/unicode/length.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/unicode/length.js @@ -21,10 +21,11 @@ includes: [propertyHelper.js] var getter = Object.getOwnPropertyDescriptor(RegExp.prototype, 'unicode').get; -assert.sameValue(getter.length, 0); - -verifyNotEnumerable(getter, 'length'); -verifyNotWritable(getter, 'length'); -verifyConfigurable(getter, 'length'); +verifyProperty(getter, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/prototype/unicode/name.js b/js/src/tests/test262/built-ins/RegExp/prototype/unicode/name.js index 1e1858b46d..a152d919b5 100644 --- a/js/src/tests/test262/built-ins/RegExp/prototype/unicode/name.js +++ b/js/src/tests/test262/built-ins/RegExp/prototype/unicode/name.js @@ -28,10 +28,11 @@ includes: [propertyHelper.js] var getter = Object.getOwnPropertyDescriptor(RegExp.prototype, 'unicode').get; -assert.sameValue(getter.name, 'get unicode'); - -verifyNotEnumerable(getter, 'name'); -verifyNotWritable(getter, 'name'); -verifyConfigurable(getter, 'name'); +verifyProperty(getter, "name", { + value: "get unicode", + writable: false, + enumerable: false, + configurable: true +}); reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-dotAll-does-not-affect-dotAll-property.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-dotAll-does-not-affect-dotAll-property.js new file mode 100644 index 0000000000..7edf9b90a4 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-dotAll-does-not-affect-dotAll-property.js @@ -0,0 +1,49 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Adding dotAll (`s`) modifier does not affect RegExp instance `dotAll` property. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?s:)/; +assert(!re1.dotAll, "RegExp instance dotAll flag should not be set"); + +var re2 = new RegExp("(?s:)"); +assert(!re2.dotAll, "RegExp instance dotAll flag should not be set"); + +var re3 = /(?s-:)/; +assert(!re3.dotAll, "RegExp instance dotAll flag should not be set"); + +var re4 = new RegExp("(?s-:)"); +assert(!re4.dotAll, "RegExp instance dotAll flag should not be set"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-dotAll-does-not-affect-ignoreCase-flag.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-dotAll-does-not-affect-ignoreCase-flag.js new file mode 100644 index 0000000000..1ebb730625 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-dotAll-does-not-affect-ignoreCase-flag.js @@ -0,0 +1,67 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Adding dotAll (`s`) modifier in group should not affect ignoreCase (`i`) flag. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?s:.es)/; +assert(re1.test("aes"), "s should match s in modified group"); +assert(re1.test("\nes"), "s should match s in modified group"); +assert(!re1.test("aeS"), "s should not match S in modified group"); +assert(!re1.test("\neS"), "s should not match S in modified group"); + +var re2 = /(?s:.es)/i; +assert(re2.test("aes"), "s should match s in modified group"); +assert(re2.test("aeS"), "s should match S in modified group"); +assert(re2.test("\nes"), "s should match s in modified group"); +assert(re2.test("\neS"), "s should match S in modified group"); + +var re3 = /(?s-:.es)/; +assert(re3.test("aes"), "s should match s in modified group"); +assert(re3.test("\nes"), "s should match s in modified group"); +assert(!re3.test("aeS"), "s should not match S in modified group"); +assert(!re3.test("\neS"), "s should not match S in modified group"); + +var re4 = /(?s-:.es)/i; +assert(re4.test("aes"), "s should match s in modified group"); +assert(re4.test("aeS"), "s should match S in modified group"); +assert(re4.test("\nes"), "s should match s in modified group"); +assert(re4.test("\neS"), "s should match S in modified group"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-dotAll-does-not-affect-multiline-flag.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-dotAll-does-not-affect-multiline-flag.js new file mode 100644 index 0000000000..2f9adf75e3 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-dotAll-does-not-affect-multiline-flag.js @@ -0,0 +1,59 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Adding dotAll (`s`) modifier in group should not affect multiline (`m`) flag. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?s:.es$)/; +assert(re1.test("\nes"), ". should match newline in modified group"); +assert(!re1.test("\nes\nz"), "$ should not match newline in modified group"); + +var re2 = /(?s:.es$)/m; +assert(re2.test("\nes"), ". should match newline in modified group"); +assert(re2.test("\nes\nz"), "$ should match newline in modified group"); + +var re3 = /(?s-:.es$)/; +assert(re3.test("\nes"), ". should match newline in modified group"); +assert(!re3.test("\nes\nz"), "$ should not match newline in modified group"); + +var re4 = /(?s-:.es$)/m; +assert(re4.test("\nes"), ". should match newline in modified group"); +assert(re4.test("\nes\nz"), "$ should match newline in modified group"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-dotAll.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-dotAll.js new file mode 100644 index 0000000000..8c163adf54 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-dotAll.js @@ -0,0 +1,105 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + dotAll (`s`) modifier can be added via `(?s:)` or `(?s-:)`. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?s:^.$)/; +assert(re1.test("a"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re1.test("3"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re1.test("π"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re1.test("\u2027"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re1.test("\u0085"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re1.test("\v"), "Pattern character '.' should match mon-line terminators in modified group"); +assert(re1.test("\f"), "Pattern character '.' should match mon-line terminators in modified group"); +assert(re1.test("\u180E"), "Pattern character '.' should match non-line terminators in modified group"); +assert(!re1.test("\u{10300}"), "Supplementary plane not matched by a single ."); +assert(re1.test("\n"), "Pattern character '.' should match line terminators in modified group"); +assert(re1.test("\r"), "Pattern character '.' should match line terminators in modified group"); +assert(re1.test("\u2028"), "Pattern character '.' should match line terminators in modified group"); +assert(re1.test("\u2029"), "Pattern character '.' should match line terminators in modified group"); +assert(re1.test("\uD800"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re1.test("\uDFFF"), "Pattern character '.' should match non-line terminators in modified group"); + +var re2 = new RegExp("(?s:^.$)"); +assert(re2.test("a"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re2.test("3"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re2.test("π"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re2.test("\u2027"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re2.test("\u0085"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re2.test("\v"), "Pattern character '.' should match mon-line terminators in modified group"); +assert(re2.test("\f"), "Pattern character '.' should match mon-line terminators in modified group"); +assert(re2.test("\u180E"), "Pattern character '.' should match non-line terminators in modified group"); +assert(!re2.test("\u{10300}"), "Supplementary plane not matched by a single ."); +assert(re2.test("\n"), "Pattern character '.' should match line terminators in modified group"); +assert(re2.test("\r"), "Pattern character '.' should match line terminators in modified group"); +assert(re2.test("\u2028"), "Pattern character '.' should match line terminators in modified group"); +assert(re2.test("\u2029"), "Pattern character '.' should match line terminators in modified group"); +assert(re2.test("\uD800"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re2.test("\uDFFF"), "Pattern character '.' should match non-line terminators in modified group"); + +var re3 = /(?s-:^.$)/; +assert(re3.test("a"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re3.test("3"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re3.test("π"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re3.test("\u2027"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re3.test("\u0085"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re3.test("\v"), "Pattern character '.' should match mon-line terminators in modified group"); +assert(re3.test("\f"), "Pattern character '.' should match mon-line terminators in modified group"); +assert(re3.test("\u180E"), "Pattern character '.' should match non-line terminators in modified group"); +assert(!re3.test("\u{10300}"), "Supplementary plane not matched by a single ."); +assert(re3.test("\n"), "Pattern character '.' should match line terminators in modified group"); +assert(re3.test("\r"), "Pattern character '.' should match line terminators in modified group"); +assert(re3.test("\u2028"), "Pattern character '.' should match line terminators in modified group"); +assert(re3.test("\u2029"), "Pattern character '.' should match line terminators in modified group"); +assert(re3.test("\uD800"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re3.test("\uDFFF"), "Pattern character '.' should match non-line terminators in modified group"); + +var re4 = new RegExp("(?s-:^.$)"); +assert(re4.test("a"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re4.test("3"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re4.test("π"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re4.test("\u2027"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re4.test("\u0085"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re4.test("\v"), "Pattern character '.' should match mon-line terminators in modified group"); +assert(re4.test("\f"), "Pattern character '.' should match mon-line terminators in modified group"); +assert(re4.test("\u180E"), "Pattern character '.' should match non-line terminators in modified group"); +assert(!re4.test("\u{10300}"), "Supplementary plane not matched by a single ."); +assert(re4.test("\n"), "Pattern character '.' should match line terminators in modified group"); +assert(re4.test("\r"), "Pattern character '.' should match line terminators in modified group"); +assert(re4.test("\u2028"), "Pattern character '.' should match line terminators in modified group"); +assert(re4.test("\u2029"), "Pattern character '.' should match line terminators in modified group"); +assert(re4.test("\uD800"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re4.test("\uDFFF"), "Pattern character '.' should match non-line terminators in modified group"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-backreferences.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-backreferences.js new file mode 100644 index 0000000000..53e9ecb991 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-backreferences.js @@ -0,0 +1,55 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Adding ignoreCase (`i`) modifier in group affects backreferences in group. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(a)(?i:\1)/; +assert(!re1.test("AA"), "a should not match first A"); +assert(!re1.test("Aa"), "a should not match A"); +assert(re1.test("aa"), "a matches first a, so \\1 should match second a"); +assert(re1.test("aA"), "a matches a, so \\1 should match A (ignores case)"); + +var re2 = /(a)(?i-:\1)/; +assert(!re2.test("AA"), "a should not match first A"); +assert(!re2.test("Aa"), "a should not match A"); +assert(re2.test("aa"), "a matches first a, so \\1 should match second a"); +assert(re2.test("aA"), "a matches a, so \\1 should match A (ignores case)"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-characterClasses.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-characterClasses.js new file mode 100644 index 0000000000..75c50a97fa --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-characterClasses.js @@ -0,0 +1,67 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Adding ignoreCase (`i`) modifier in group affects character classes in group. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?i:[ab])c/; +assert(re1.test("ac"), "[ab] should match a"); +assert(re1.test("Ac"), "[ab] should match A"); +assert(re1.test("bc"), "[ab] should match b"); +assert(re1.test("Bc"), "[ab] should match B"); + +var re2 = /(?i-:[ab])c/; +assert(re2.test("ac"), "[ab] should match a"); +assert(re2.test("Ac"), "[ab] should match A"); +assert(re2.test("bc"), "[ab] should match b"); +assert(re2.test("Bc"), "[ab] should match B"); + +var re3 = /(?i:[^ab])c/; +assert(!re3.test("ac"), "[^ab] should not match a"); +assert(!re3.test("Ac"), "[^ab] should not match A"); +assert(!re3.test("bc"), "[^ab] should not match b"); +assert(!re3.test("Bc"), "[^ab] should not match B"); + +var re4 = /(?i-:[^ab])c/; +assert(!re4.test("ac"), "[^ab] should not match a"); +assert(!re4.test("Ac"), "[^ab] should not match A"); +assert(!re4.test("bc"), "[^ab] should not match b"); +assert(!re4.test("Bc"), "[^ab] should not match B"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-characterEscapes.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-characterEscapes.js new file mode 100644 index 0000000000..98fa435027 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-characterEscapes.js @@ -0,0 +1,67 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Adding ignoreCase (`i`) modifier in group affects character escapes in group. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?i:\x61)b/; +assert(re1.test("ab"), "\\x61 should match a"); +assert(re1.test("Ab"), "\\x61 should match A"); + +var re2 = /(?i:\u0061)b/; +assert(re2.test("ab"), "\\u0061 should match a"); +assert(re2.test("Ab"), "\\u0061 should match A"); + +var re3 = /(?i:\u{0061})b/u; +assert(re3.test("ab"), "\\u0061 should match a"); +assert(re3.test("Ab"), "\\u0061 should match A"); + +var re4 = /(?i-:\x61)b/; +assert(re4.test("ab"), "\\x61 should match a"); +assert(re4.test("Ab"), "\\x61 should match A"); + +var re5 = /(?i-:\u0061)b/; +assert(re5.test("ab"), "\\u0061 should match a"); +assert(re5.test("Ab"), "\\u0061 should match A"); + +var re6 = /(?i-:\u{0061})b/u; +assert(re6.test("ab"), "\\u0061 should match a"); +assert(re6.test("Ab"), "\\u0061 should match A"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-slash-lower-b.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-slash-lower-b.js new file mode 100644 index 0000000000..a3f5b9f009 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-slash-lower-b.js @@ -0,0 +1,77 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Adding ignoreCase (`i`) modifier affects matching for `\b`. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + + GetWordCharacters ( modifiers ) + The abstract operation GetWordCharacters takes argument modifiers (a Modifiers Record) and returns a CharSet. It performs the following steps when called: + + 1. Let wordCharacters be the mathematical set that is the union of all sixty-three characters in "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_" (letters, numbers, and U+005F (LOW LINE) in the Unicode Basic Latin block) and all characters c for which c is not in that set but Canonicalize(c, modifiers) is. + 2. Return wordCharacters. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?i:\b)/; +assert(re1.test("A"), "\\b should match after A"); +assert(re1.test("a"), "\\b should match after a"); +assert(re1.test("z"), "\\b should match after z"); +assert(re1.test("Z"), "\\b should match after Z"); + +var re2 = /(?i:\b)/u; +assert(re2.test("A"), "\\b should match after A"); +assert(re2.test("a"), "\\b should match after a"); +assert(re2.test("z"), "\\b should match after z"); +assert(re2.test("Z"), "\\b should match after Z"); +assert(re2.test("\u017f"), "\\b should match after \u017f"); +assert(re2.test("\u212a"), "\\b should match after \u212a"); + +var re3 = /(?i-:\b)/; +assert(re3.test("A"), "\\b should match after A"); +assert(re3.test("a"), "\\b should match after a"); +assert(re3.test("z"), "\\b should match after z"); +assert(re3.test("Z"), "\\b should match after Z"); + +var re4 = /(?i-:\b)/u; +assert(re4.test("A"), "\\b should match after A"); +assert(re4.test("a"), "\\b should match after a"); +assert(re4.test("z"), "\\b should match after z"); +assert(re4.test("Z"), "\\b should match after Z"); +assert(re4.test("\u017f"), "\\b should match after \u017f"); +assert(re4.test("\u212a"), "\\b should match after \u212a"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-slash-lower-p.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-slash-lower-p.js new file mode 100644 index 0000000000..41788082ee --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-slash-lower-p.js @@ -0,0 +1,61 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Adding ignoreCase (`i`) modifier affects matching for `\p{}`. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + + GetWordCharacters ( modifiers ) + The abstract operation GetWordCharacters takes argument modifiers (a Modifiers Record) and returns a CharSet. It performs the following steps when called: + + 1. Let wordCharacters be the mathematical set that is the union of all sixty-three characters in "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_" (letters, numbers, and U+005F (LOW LINE) in the Unicode Basic Latin block) and all characters c for which c is not in that set but Canonicalize(c, modifiers) is. + 2. Return wordCharacters. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?i:\p{Lu})/u; +assert(re1.test("A"), "\\p{Lu} should match A"); +assert(re1.test("a"), "\\p{Lu} should match a (ignores case)"); +assert(re1.test("Z"), "\\p{Lu} should match Z"); +assert(re1.test("z"), "\\p{Lu} should match z (ignores case)"); + +var re2 = /(?i-:\p{Lu})/u; +assert(re2.test("A"), "\\p{Lu} should match A"); +assert(re2.test("a"), "\\p{Lu} should match a (ignores case)"); +assert(re2.test("Z"), "\\p{Lu} should match Z"); +assert(re2.test("z"), "\\p{Lu} should match z (ignores case)"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-slash-lower-w.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-slash-lower-w.js new file mode 100644 index 0000000000..324961d782 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-slash-lower-w.js @@ -0,0 +1,77 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Adding ignoreCase (`i`) modifier affects matching for `\w`. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + + GetWordCharacters ( modifiers ) + The abstract operation GetWordCharacters takes argument modifiers (a Modifiers Record) and returns a CharSet. It performs the following steps when called: + + 1. Let wordCharacters be the mathematical set that is the union of all sixty-three characters in "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_" (letters, numbers, and U+005F (LOW LINE) in the Unicode Basic Latin block) and all characters c for which c is not in that set but Canonicalize(c, modifiers) is. + 2. Return wordCharacters. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?i:\w)/; +assert(re1.test("A"), "\\w should match A"); +assert(re1.test("a"), "\\w should match a"); +assert(re1.test("z"), "\\w should match z"); +assert(re1.test("Z"), "\\w should match Z"); + +var re2 = /(?i:\w)/u; +assert(re2.test("A"), "\\w should match A"); +assert(re2.test("a"), "\\w should match a"); +assert(re2.test("z"), "\\w should match z"); +assert(re2.test("Z"), "\\w should match Z"); +assert(re2.test("\u017f"), "\\w should match \u017f"); +assert(re2.test("\u212a"), "\\w should match \u212a"); + +var re3 = /(?i-:\w)/; +assert(re3.test("A"), "\\w should match A"); +assert(re3.test("a"), "\\w should match a"); +assert(re3.test("z"), "\\w should match z"); +assert(re3.test("Z"), "\\w should match Z"); + +var re4 = /(?i-:\w)/u; +assert(re4.test("A"), "\\w should match A"); +assert(re4.test("a"), "\\w should match a"); +assert(re4.test("z"), "\\w should match z"); +assert(re4.test("Z"), "\\w should match Z"); +assert(re4.test("\u017f"), "\\w should match \u017f"); +assert(re4.test("\u212a"), "\\w should match \u212a"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-slash-upper-b.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-slash-upper-b.js new file mode 100644 index 0000000000..ffb346277f --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-slash-upper-b.js @@ -0,0 +1,57 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Adding ignoreCase (`i`) modifier affects matching for `\B`. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + + GetWordCharacters ( modifiers ) + The abstract operation GetWordCharacters takes argument modifiers (a Modifiers Record) and returns a CharSet. It performs the following steps when called: + + 1. Let wordCharacters be the mathematical set that is the union of all sixty-three characters in "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_" (letters, numbers, and U+005F (LOW LINE) in the Unicode Basic Latin block) and all characters c for which c is not in that set but Canonicalize(c, modifiers) is. + 2. Return wordCharacters. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?i:Z\B)/u; +assert(re1.test("Z\u017f"), "\\B should match between Z and \u017f"); +assert(re1.test("Z\u212a"), "\\B should match between Z and \u212a"); + +var re2 = /(?i-:Z\B)/u; +assert(re2.test("Z\u017f"), "\\B should match between Z and \u017f"); +assert(re2.test("Z\u212a"), "\\B should match between Z and \u212a"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-slash-upper-p.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-slash-upper-p.js new file mode 100644 index 0000000000..d5f30655cb --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-slash-upper-p.js @@ -0,0 +1,63 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Adding ignoreCase (`i`) modifier affects matching for `\P{}`. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + + GetWordCharacters ( modifiers ) + The abstract operation GetWordCharacters takes argument modifiers (a Modifiers Record) and returns a CharSet. It performs the following steps when called: + + 1. Let wordCharacters be the mathematical set that is the union of all sixty-three characters in "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_" (letters, numbers, and U+005F (LOW LINE) in the Unicode Basic Latin block) and all characters c for which c is not in that set but Canonicalize(c, modifiers) is. + 2. Return wordCharacters. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?i:\P{Lu})/u; +assert(re1.test("A"), "\\P{Lu} should match A (ignores case)"); +assert(re1.test("a"), "\\P{Lu} should match a"); +assert(re1.test("Z"), "\\P{Lu} should match Z (ignores case)"); +assert(re1.test("z"), "\\P{Lu} should match z"); +assert(re1.test("0"), "\\P{Lu} should match 0"); + +var re2 = /(?i-:\P{Lu})/u; +assert(re2.test("A"), "\\P{Lu} should match A (ignores case)"); +assert(re2.test("a"), "\\P{Lu} should match a"); +assert(re2.test("Z"), "\\P{Lu} should match Z (ignores case)"); +assert(re2.test("z"), "\\P{Lu} should match z"); +assert(re2.test("0"), "\\P{Lu} should match 0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-slash-upper-w.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-slash-upper-w.js new file mode 100644 index 0000000000..a0c527efa2 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-affects-slash-upper-w.js @@ -0,0 +1,57 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Adding ignoreCase (`i`) modifier affects matching for `\W`. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + + GetWordCharacters ( modifiers ) + The abstract operation GetWordCharacters takes argument modifiers (a Modifiers Record) and returns a CharSet. It performs the following steps when called: + + 1. Let wordCharacters be the mathematical set that is the union of all sixty-three characters in "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_" (letters, numbers, and U+005F (LOW LINE) in the Unicode Basic Latin block) and all characters c for which c is not in that set but Canonicalize(c, modifiers) is. + 2. Return wordCharacters. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?i:\W)/u; +assert(!re1.test("\u017f"), "\\W should not match \u017f"); +assert(!re1.test("\u212a"), "\\W should not match \u212a"); + +var re2 = /(?i-:\W)/u; +assert(!re2.test("\u017f"), "\\W should not match \u017f"); +assert(!re2.test("\u212a"), "\\W should not match \u212a"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-does-not-affect-dotAll-flag.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-does-not-affect-dotAll-flag.js new file mode 100644 index 0000000000..999598c492 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-does-not-affect-dotAll-flag.js @@ -0,0 +1,67 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Adding ignoreCase (`i`) modifier in group should not affect dotAll (`s`) flag. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?i:.es)/; +assert(re1.test("aes"), ". should match a in modified group"); +assert(re1.test("aeS"), ". should match a in modified group"); +assert(!re1.test("\nes"), ". should not match newline in modified group"); +assert(!re1.test("\neS"), ". should not match newline in modified group"); + +var re2 = /(?i:.es)/s; +assert(re2.test("aes"), ". should match a in modified group"); +assert(re2.test("aeS"), ". should match a in modified group"); +assert(re2.test("\nes"), ". should match newline in modified group"); +assert(re2.test("\neS"), ". should match newline in modified group"); + +var re3 = /(?i-:.es)/; +assert(re3.test("aes"), ". should match a in modified group"); +assert(re3.test("aeS"), ". should match a in modified group"); +assert(!re3.test("\nes"), ". should not match newline in modified group"); +assert(!re3.test("\neS"), ". should not match newline in modified group"); + +var re4 = /(?i-:.es)/s; +assert(re4.test("aes"), ". should match a in modified group"); +assert(re4.test("aeS"), ". should match a in modified group"); +assert(re4.test("\nes"), ". should match newline in modified group"); +assert(re4.test("\neS"), ". should match newline in modified group"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-does-not-affect-ignoreCase-property.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-does-not-affect-ignoreCase-property.js new file mode 100644 index 0000000000..24da245c46 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-does-not-affect-ignoreCase-property.js @@ -0,0 +1,55 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Adding ignoreCase (`i`) modifier does not affect RegExp instance `ignoreCase` property. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?i:)/; +assert(!re1.ignoreCase, "RegExp instance ignoreCase property should not be set"); + +var re2 = new RegExp("(?i:)"); +assert(!re2.ignoreCase, "RegExp instance ignoreCase property should not be set"); + +var re3 = /(?i-:)/; +assert(!re3.ignoreCase, "RegExp instance ignoreCase property should not be set"); + +var re4 = new RegExp("(?i-:)"); +assert(!re4.ignoreCase, "RegExp instance ignoreCase property should not be set"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-does-not-affect-multiline-flag.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-does-not-affect-multiline-flag.js new file mode 100644 index 0000000000..692cfd9f2f --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase-does-not-affect-multiline-flag.js @@ -0,0 +1,67 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Adding ignoreCase (`i`) modifier in group should not affect multiline (`m`) flag. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?i:es$)/; +assert(re1.test("es"), "s should match s in modified group"); +assert(re1.test("eS"), "s should match S in modified group"); +assert(!re1.test("es\nz"), "$ should not match newline in modified group"); +assert(!re1.test("eS\nz"), "$ should not match newline in modified group"); + +var re2 = /(?i:es$)/m; +assert(re2.test("es"), "s should match s in modified group"); +assert(re2.test("eS"), "s should match S in modified group"); +assert(re2.test("es\nz"), "$ should match newline in modified group"); +assert(re2.test("eS\nz"), "$ should match newline in modified group"); + +var re3 = /(?i-:es$)/; +assert(re3.test("es"), "s should match s in modified group"); +assert(re3.test("eS"), "s should match S in modified group"); +assert(!re3.test("es\nz"), "$ should not match newline in modified group"); +assert(!re3.test("eS\nz"), "$ should not match newline in modified group"); + +var re4 = /(?i-:es$)/m; +assert(re4.test("es"), "s should match s in modified group"); +assert(re4.test("eS"), "s should match S in modified group"); +assert(re4.test("es\nz"), "$ should match newline in modified group"); +assert(re4.test("eS\nz"), "$ should match newline in modified group"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase.js new file mode 100644 index 0000000000..bd07e7aa22 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-ignoreCase.js @@ -0,0 +1,47 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + ignoreCase (`i`) modifier can be added via `(?i:)` or `(?i-:)`. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?i:a)b/; +assert(!re1.test("AB"), "b should not match B in AB"); +assert(re1.test("Ab"), "a should match A in AB"); +assert(re1.test("ab"), "should match AB"); + +var re2 = new RegExp("(?i:a)b"); +assert(!re2.test("AB"), "b should not match B in AB"); +assert(re2.test("Ab"), "a should match A in AB"); +assert(re2.test("ab"), "should match AB"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-multiline-does-not-affect-dotAll-flag.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-multiline-does-not-affect-dotAll-flag.js new file mode 100644 index 0000000000..c065d293ac --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-multiline-does-not-affect-dotAll-flag.js @@ -0,0 +1,59 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Adding multiline (`m`) modifier in group should not affect dotAll (`s`) flag. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?m:es.$)/; +assert(re1.test("esz\n"), "$ should match newline in modified group"); +assert(!re1.test("es\n\n"), ". should not match newline in modified group"); + +var re2 = /(?m:es.$)/s; +assert(re2.test("esz\n"), "$ should match newline in modified group"); +assert(re2.test("es\n\n"), ". should match newline in modified group"); + +var re3 = /(?m-:es.$)/; +assert(re3.test("esz\n"), "$ should match newline in modified group"); +assert(!re3.test("es\n\n"), ". should not match newline in modified group"); + +var re4 = /(?m-:es.$)/s; +assert(re4.test("esz\n"), "$ should match newline in modified group"); +assert(re4.test("es\n\n"), ". should match newline in modified group"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-multiline-does-not-affect-ignoreCase-flag.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-multiline-does-not-affect-ignoreCase-flag.js new file mode 100644 index 0000000000..b8b33e9c22 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-multiline-does-not-affect-ignoreCase-flag.js @@ -0,0 +1,67 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Adding multiline (`m`) modifier in group should not affect ignoreCase (`i`) flag. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?m:es$)/; +assert(re1.test("es"), "s should match s in modified group"); +assert(!re1.test("eS"), "s should not match S in modified group"); +assert(re1.test("es\nz"), "$ should match newline in modified group"); +assert(!re1.test("eS\nz"), "s should not match S in modified group"); + +var re2 = /(?m:es$)/i; +assert(re2.test("es"), "s should match s in modified group"); +assert(re2.test("eS"), "s should match S in modified group"); +assert(re2.test("es\nz"), "$ should match newline in modified group"); +assert(re2.test("eS\nz"), "$ should match newline in modified group"); + +var re3 = /(?m-:es$)/; +assert(re3.test("es"), "s should match s in modified group"); +assert(!re3.test("eS"), "s should not match S in modified group"); +assert(re3.test("es\nz"), "$ should match newline in modified group"); +assert(!re3.test("eS\nz"), "s should not match S in modified group"); + +var re4 = /(?m-:es$)/i; +assert(re4.test("es"), "s should match s in modified group"); +assert(re4.test("eS"), "s should match S in modified group"); +assert(re4.test("es\nz"), "$ should match newline in modified group"); +assert(re4.test("eS\nz"), "$ should match newline in modified group"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-multiline-does-not-affect-multiline-property.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-multiline-does-not-affect-multiline-property.js new file mode 100644 index 0000000000..3b960f5a6c --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-multiline-does-not-affect-multiline-property.js @@ -0,0 +1,49 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Adding multiline (`m`) modifier does not affect RegExp instance `multiline` property. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?m:)/; +assert(!re1.multiline, "RegExp instance multiline flag should not be set"); + +var re2 = new RegExp("(?m:)"); +assert(!re2.multiline, "RegExp instance multiline flag should not be set"); + +var re3 = /(?m-:)/; +assert(!re3.multiline, "RegExp instance multiline flag should not be set"); + +var re4 = new RegExp("(?m-:)"); +assert(!re4.multiline, "RegExp instance multiline flag should not be set"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-multiline.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-multiline.js new file mode 100644 index 0000000000..ee1d0a65cc --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-multiline.js @@ -0,0 +1,49 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + multiline (`m`) modifier can be added via `(?m:)` or `(?m-:)`. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?m:es$)/; +assert(re1.test("es\ns"), "$ should match newline in modified group"); + +var re2 = new RegExp("(?m:es$)"); +assert(re2.test("es\ns"), "$ should match newline in modified group"); + +var re3 = /(?m-:es$)/; +assert(re3.test("es\ns"), "$ should match newline in modified group"); + +var re4 = new RegExp("(?m-:es$)"); +assert(re4.test("es\ns"), "$ should match newline in modified group"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-remove-modifiers.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-remove-modifiers.js new file mode 100644 index 0000000000..68e4761cfc --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/add-remove-modifiers.js @@ -0,0 +1,45 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Modifiers can be both added and removed via `(?ims-ims:)`. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?m-i:^a$)/i; +assert(!re1.test("A\n"), "Should not match 'A\\n'"); +assert(re1.test("a\n"), "Should match 'a\\n'"); + +var re2 = new RegExp("(?m-i:^a$)", "i"); +assert(!re2.test("A\n"), "Should not match 'A\\n'"); +assert(re2.test("a\n"), "Should match 'a\\n'"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/browser.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/changing-dotAll-flag-does-not-affect-dotAll-modifier.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/changing-dotAll-flag-does-not-affect-dotAll-modifier.js new file mode 100644 index 0000000000..b275621155 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/changing-dotAll-flag-does-not-affect-dotAll-modifier.js @@ -0,0 +1,77 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + New dotAll (`s`) flag from RegExp constructor does not affect dotAll modifier in group. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = new RegExp(/(?s:^.$)/s, ""); +assert(re1.test("a"), "Pattern character '.' still should match non-line terminators in modified group"); +assert(re1.test("3"), "Pattern character '.' still should match non-line terminators in modified group"); +assert(re1.test("π"), "Pattern character '.' still should match non-line terminators in modified group"); +assert(re1.test("\u2027"), "Pattern character '.' still should match non-line terminators in modified group"); +assert(re1.test("\u0085"), "Pattern character '.' still should match non-line terminators in modified group"); +assert(re1.test("\v"), "Pattern character '.' still should match mon-line terminators in modified group"); +assert(re1.test("\f"), "Pattern character '.' still should match mon-line terminators in modified group"); +assert(re1.test("\u180E"), "Pattern character '.' still should match non-line terminators in modified group"); +assert(!re1.test("\u{10300}"), "Supplementary plane still not matched by a single ."); +assert(re1.test("\n"), "Pattern character '.' still should match line terminators in modified group"); +assert(re1.test("\r"), "Pattern character '.' still should match line terminators in modified group"); +assert(re1.test("\u2028"), "Pattern character '.' still should match line terminators in modified group"); +assert(re1.test("\u2029"), "Pattern character '.' still should match line terminators in modified group"); +assert(re1.test("\uD800"), "Pattern character '.' still should match non-line terminators in modified group"); +assert(re1.test("\uDFFF"), "Pattern character '.' still should match non-line terminators in modified group"); + +var re2 = new RegExp(/(?-s:^.$)/, "s"); +assert(re2.test("a"), "Pattern character '.' still should match non-line terminators in modified group"); +assert(re2.test("3"), "Pattern character '.' still should match non-line terminators in modified group"); +assert(re2.test("π"), "Pattern character '.' still should match non-line terminators in modified group"); +assert(re2.test("\u2027"), "Pattern character '.' still should match non-line terminators in modified group"); +assert(re2.test("\u0085"), "Pattern character '.' still should match non-line terminators in modified group"); +assert(re2.test("\v"), "Pattern character '.' still should match mon-line terminators in modified group"); +assert(re2.test("\f"), "Pattern character '.' still should match mon-line terminators in modified group"); +assert(re2.test("\u180E"), "Pattern character '.' still should match non-line terminators in modified group"); +assert(!re2.test("\u{10300}"), "Supplementary plane still not matched by a single ."); +assert(!re2.test("\n"), "Pattern character '.' still should not match '\\n' in modified group"); +assert(!re2.test("\r"), "Pattern character '.' still should not match '\\r' in modified group"); +assert(!re2.test("\u2028"), "Pattern character '.' still should not match '\\u2028' in modified group"); +assert(!re2.test("\u2029"), "Pattern character '.' still should not match '\\u2029' in modified group"); +assert(re2.test("\uD800"), "Pattern character '.' still should match non-line terminators in modified group"); +assert(re2.test("\uDFFF"), "Pattern character '.' still should match non-line terminators in modified group"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/changing-ignoreCase-flag-does-not-affect-ignoreCase-modifier.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/changing-ignoreCase-flag-does-not-affect-ignoreCase-modifier.js new file mode 100644 index 0000000000..8db72f0742 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/changing-ignoreCase-flag-does-not-affect-ignoreCase-modifier.js @@ -0,0 +1,55 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + New ignoreCase (`i`) flag from RegExp constructor does not affect ignoreCase modifier in group. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = new RegExp(/(?i:aB)/i, ""); +assert(re1.test("AB"), "still should ignore case in modified group"); +assert(re1.test("Ab"), "still should ignore case in modified group"); +assert(re1.test("aB"), "still should ignore case in modified group"); +assert(re1.test("ab"), "still should ignore case in modified group"); + +var re2 = new RegExp(/(?-i:aB)/, "i"); +assert(!re2.test("AB"), "still should preserve case in modified group"); +assert(!re2.test("Ab"), "still should preserve case in modified group"); +assert(!re2.test("ab"), "still should preserve case in modified group"); +assert(re2.test("aB"), "still should preserve case in modified group"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/changing-multiline-flag-does-not-affect-multiline-modifier.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/changing-multiline-flag-does-not-affect-multiline-modifier.js new file mode 100644 index 0000000000..b890200b21 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/changing-multiline-flag-does-not-affect-multiline-modifier.js @@ -0,0 +1,51 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + New multiline (`m`) flag from RegExp constructor does not affect multiline modifier in group. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = new RegExp(/(?m:es$)/m, ""); +assert(re1.test("es"), "$ still should match end of input in modified group"); +assert(re1.test("es\ns"), "$ still should match newline in modified group"); + +var re2 = new RegExp(/^(?-m:es$)/, "m"); +assert(re2.test("es"), "$ still should match end of input in modified group"); +assert(!re2.test("es\ns"), "$ still should not match newline in modified group"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/nested-add-remove-modifiers.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/nested-add-remove-modifiers.js new file mode 100644 index 0000000000..f2e1052643 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/nested-add-remove-modifiers.js @@ -0,0 +1,45 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Modifiers can be nested. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?m:^(?-i:a)$)/i; +assert(!re1.test("A\n"), "Should not match 'A\\n'"); +assert(re1.test("a\n"), "Should match 'a\\n'"); + +var re2 = new RegExp("(?m:^(?-i:a)$)", "i"); +assert(!re2.test("A\n"), "Should not match 'A\\n'"); +assert(re2.test("a\n"), "Should match 'a\\n'"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/nesting-add-dotAll-within-remove-dotAll.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/nesting-add-dotAll-within-remove-dotAll.js new file mode 100644 index 0000000000..26b7d760b4 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/nesting-add-dotAll-within-remove-dotAll.js @@ -0,0 +1,71 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Can add multiline (`m`) modifier for group nested within a group that removes multiline modifier. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?-s:(?s:^.$))/s; +assert(re1.test("a"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re1.test("3"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re1.test("π"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re1.test("\u2027"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re1.test("\u0085"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re1.test("\v"), "Pattern character '.' should match mon-line terminators in modified group"); +assert(re1.test("\f"), "Pattern character '.' should match mon-line terminators in modified group"); +assert(re1.test("\u180E"), "Pattern character '.' should match non-line terminators in modified group"); +assert(!re1.test("\u{10300}"), "Supplementary plane not matched by a single ."); +assert(re1.test("\n"), "Pattern character '.' should match line terminators in modified group"); +assert(re1.test("\r"), "Pattern character '.' should match line terminators in modified group"); +assert(re1.test("\u2028"), "Pattern character '.' should match line terminators in modified group"); +assert(re1.test("\u2029"), "Pattern character '.' should match line terminators in modified group"); +assert(re1.test("\uD800"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re1.test("\uDFFF"), "Pattern character '.' should match non-line terminators in modified group"); + +var re2 = /(?-s:(?s-:^.$))/s; +assert(re2.test("a"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re2.test("3"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re2.test("π"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re2.test("\u2027"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re2.test("\u0085"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re2.test("\v"), "Pattern character '.' should match mon-line terminators in modified group"); +assert(re2.test("\f"), "Pattern character '.' should match mon-line terminators in modified group"); +assert(re2.test("\u180E"), "Pattern character '.' should match non-line terminators in modified group"); +assert(!re2.test("\u{10300}"), "Supplementary plane not matched by a single ."); +assert(re2.test("\n"), "Pattern character '.' should match line terminators in modified group"); +assert(re2.test("\r"), "Pattern character '.' should match line terminators in modified group"); +assert(re2.test("\u2028"), "Pattern character '.' should match line terminators in modified group"); +assert(re2.test("\u2029"), "Pattern character '.' should match line terminators in modified group"); +assert(re2.test("\uD800"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re2.test("\uDFFF"), "Pattern character '.' should match non-line terminators in modified group"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/nesting-add-ignoreCase-within-remove-ignoreCase.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/nesting-add-ignoreCase-within-remove-ignoreCase.js new file mode 100644 index 0000000000..04103802c6 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/nesting-add-ignoreCase-within-remove-ignoreCase.js @@ -0,0 +1,45 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Can add ignoreCase (`i`) modifier for group nested within a group that removes ignoreCase modifier. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?-i:a(?i:b))c/i; +assert(!re1.test("ABC"), "a should not match A in ABC"); +assert(!re1.test("ABc"), "a should not match A in ABc"); +assert(!re1.test("Abc"), "a should not match A in Abc"); +assert(re1.test("aBc"), "b should match B in aBc"); +assert(re1.test("abC"), "c should match C in abC"); +assert(re1.test("abc"), "should match abc"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/nesting-add-multiline-within-remove-multiline.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/nesting-add-multiline-within-remove-multiline.js new file mode 100644 index 0000000000..dcf7504067 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/nesting-add-multiline-within-remove-multiline.js @@ -0,0 +1,47 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Can add multiline (`m`) modifier for group nested within a group that removes multiline modifier. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?-m:es(?m:$)|js$)/m; +assert(re1.test("es\ns"), "$ should match newline in modified group"); +assert(re1.test("js"), "$ should match end of input in nested modified group"); +assert(!re1.test("js\ns"), "$ should not match newline in nested modified group"); + +var re2 = /(?-m:es(?m-:$)|js$)/m; +assert(re2.test("es\ns"), "$ should match newline in modified group"); +assert(re2.test("js"), "$ should match end of input in nested modified group"); +assert(!re2.test("js\ns"), "$ should not match newline in nested modified group"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/nesting-remove-dotAll-within-add-dotAll.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/nesting-remove-dotAll-within-add-dotAll.js new file mode 100644 index 0000000000..e62290bedd --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/nesting-remove-dotAll-within-add-dotAll.js @@ -0,0 +1,71 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Can remove multiline (`m`) modifier for group nested within a group that adds multiline modifier. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?s:(?-s:^.$))/; +assert(re1.test("a"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re1.test("3"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re1.test("π"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re1.test("\u2027"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re1.test("\u0085"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re1.test("\v"), "Pattern character '.' should match mon-line terminators in modified group"); +assert(re1.test("\f"), "Pattern character '.' should match mon-line terminators in modified group"); +assert(re1.test("\u180E"), "Pattern character '.' should match non-line terminators in modified group"); +assert(!re1.test("\u{10300}"), "Supplementary plane not matched by a single ."); +assert(!re1.test("\n"), "Pattern character '.' should not match '\\n' in modified group"); +assert(!re1.test("\r"), "Pattern character '.' should not match '\\r' in modified group"); +assert(!re1.test("\u2028"), "Pattern character '.' should not match '\\u2028' in modified group"); +assert(!re1.test("\u2029"), "Pattern character '.' should not match '\\u2029' in modified group"); +assert(re1.test("\uD800"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re1.test("\uDFFF"), "Pattern character '.' should match non-line terminators in modified group"); + +var re2 = /(?s-:(?-s:^.$))/; +assert(re2.test("a"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re2.test("3"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re2.test("π"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re2.test("\u2027"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re2.test("\u0085"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re2.test("\v"), "Pattern character '.' should match mon-line terminators in modified group"); +assert(re2.test("\f"), "Pattern character '.' should match mon-line terminators in modified group"); +assert(re2.test("\u180E"), "Pattern character '.' should match non-line terminators in modified group"); +assert(!re2.test("\u{10300}"), "Supplementary plane not matched by a single ."); +assert(!re2.test("\n"), "Pattern character '.' should not match '\\n' in modified group"); +assert(!re2.test("\r"), "Pattern character '.' should not match '\\r' in modified group"); +assert(!re2.test("\u2028"), "Pattern character '.' should not match '\\u2028' in modified group"); +assert(!re2.test("\u2029"), "Pattern character '.' should not match '\\u2029' in modified group"); +assert(re2.test("\uD800"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re2.test("\uDFFF"), "Pattern character '.' should match non-line terminators in modified group"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/nesting-remove-ignoreCase-within-add-ignoreCase.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/nesting-remove-ignoreCase-within-add-ignoreCase.js new file mode 100644 index 0000000000..6b260ab2cc --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/nesting-remove-ignoreCase-within-add-ignoreCase.js @@ -0,0 +1,45 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Can remove ignoreCase (`i`) modifier for group nested within a group that adds ignoreCase modifier. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?-i:a(?i:b))c/i; +assert(!re1.test("ABC"), "a should not match A in ABC"); +assert(!re1.test("ABc"), "a should not match A in ABc"); +assert(!re1.test("Abc"), "a should not match A in Abc"); +assert(re1.test("aBc"), "b should match B in aBc"); +assert(re1.test("abC"), "c should match C in abC"); +assert(re1.test("abc"), "should match abc"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/nesting-remove-multiline-within-add-multiline.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/nesting-remove-multiline-within-add-multiline.js new file mode 100644 index 0000000000..b7aa1b9895 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/nesting-remove-multiline-within-add-multiline.js @@ -0,0 +1,47 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Can remove multiline (`m`) modifier for group nested within a group that adds multiline modifier. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?m:es$|(?-m:js$))/; +assert(re1.test("es\ns"), "first $ should match newline in modified group"); +assert(re1.test("js"), "second $ should match end of input in nested modified group"); +assert(!re1.test("js\ns"), "second $ should not match newline in nested modified group"); + +var re2 = /(?m-:es$|(?-m:js$))/; +assert(re2.test("es\ns"), "first $ should match newline in modified group"); +assert(re2.test("js"), "second $ should match end of input in nested modified group"); +assert(!re2.test("js\ns"), "second $ should not match newline in nested modified group"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-dotAll-does-not-affect-dotAll-property.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-dotAll-does-not-affect-dotAll-property.js new file mode 100644 index 0000000000..23e607be8d --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-dotAll-does-not-affect-dotAll-property.js @@ -0,0 +1,43 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Removing dotAll (`s`) modifier does not affect RegExp instance `dotAll` property. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?-s:^.$)/s; +assert(re1.dotAll, "RegExp instance dotAll flag should still be set"); + +var re2 = new RegExp("(?-s:^.$)", "s"); +assert(re2.dotAll, "RegExp instance dotAll flag should still be set"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-dotAll-does-not-affect-ignoreCase-flag.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-dotAll-does-not-affect-ignoreCase-flag.js new file mode 100644 index 0000000000..2ccd21b4e2 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-dotAll-does-not-affect-ignoreCase-flag.js @@ -0,0 +1,49 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Removing dotAll (`s`) modifier in group should not affect ignoreCase (`i`) flag. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?-s:.es)/s; +assert(re1.test("aes"), "s should match s in modified group"); +assert(!re1.test("aeS"), "s should not match S in modified group"); +assert(!re1.test("\nes"), ". should not match newline in modified group"); +assert(!re1.test("\neS"), ". should not match newline in modified group"); + +var re2 = /(?-s:.es)/si; +assert(re2.test("aes"), "s should match s in modified group"); +assert(re2.test("aeS"), "s should match S in modified group"); +assert(!re2.test("\nes"), ". should not match newline in modified group"); +assert(!re2.test("\neS"), ". should not match newline in modified group"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-dotAll-does-not-affect-multiline-flag.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-dotAll-does-not-affect-multiline-flag.js new file mode 100644 index 0000000000..1f73afc52c --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-dotAll-does-not-affect-multiline-flag.js @@ -0,0 +1,49 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Removing dotAll (`s`) modifier in group should not affect multiline (`m`) flag. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?-s:.es$)/s; +assert(re1.test("aes"), ". should match a in modified group"); +assert(!re1.test("aes\nz"), "$ should not match newline in modified group"); +assert(!re1.test("\nes"), ". should not match newline in modified group"); +assert(!re1.test("\nes\nz"), "$ should not match newline in modified group"); + +var re2 = /(?-s:.es$)/sm; +assert(re2.test("aes"), ". should match a in modified group"); +assert(re2.test("aes\nz"), "$ should match newline in modified group"); +assert(!re2.test("\nes"), ". should not match newline in modified group"); +assert(!re2.test("\nes\nz"), ". should not match newline in modified group"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-dotAll.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-dotAll.js new file mode 100644 index 0000000000..8abed77808 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-dotAll.js @@ -0,0 +1,71 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + dotAll (`s`) modifier can be added via `(?s:)` or `(?s-:)`. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?-s:^.$)/s; +assert(re1.test("a"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re1.test("3"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re1.test("π"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re1.test("\u2027"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re1.test("\u0085"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re1.test("\v"), "Pattern character '.' should match mon-line terminators in modified group"); +assert(re1.test("\f"), "Pattern character '.' should match mon-line terminators in modified group"); +assert(re1.test("\u180E"), "Pattern character '.' should match non-line terminators in modified group"); +assert(!re1.test("\u{10300}"), "Supplementary plane not matched by a single ."); +assert(!re1.test("\n"), "Pattern character '.' should not match '\\n' in modified group"); +assert(!re1.test("\r"), "Pattern character '.' should not match '\\r' in modified group"); +assert(!re1.test("\u2028"), "Pattern character '.' should not match '\\u2028' in modified group"); +assert(!re1.test("\u2029"), "Pattern character '.' should not match '\\u2029' in modified group"); +assert(re1.test("\uD800"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re1.test("\uDFFF"), "Pattern character '.' should match non-line terminators in modified group"); + +var re2 = new RegExp("(?-s:^.$)", "s"); +assert(re2.test("a"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re2.test("3"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re2.test("π"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re2.test("\u2027"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re2.test("\u0085"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re2.test("\v"), "Pattern character '.' should match mon-line terminators in modified group"); +assert(re2.test("\f"), "Pattern character '.' should match mon-line terminators in modified group"); +assert(re2.test("\u180E"), "Pattern character '.' should match non-line terminators in modified group"); +assert(!re2.test("\u{10300}"), "Supplementary plane not matched by a single ."); +assert(!re2.test("\n"), "Pattern character '.' should not match '\\n' in modified group"); +assert(!re2.test("\r"), "Pattern character '.' should not match '\\r' in modified group"); +assert(!re2.test("\u2028"), "Pattern character '.' should not match '\\u2028' in modified group"); +assert(!re2.test("\u2029"), "Pattern character '.' should not match '\\u2029' in modified group"); +assert(re2.test("\uD800"), "Pattern character '.' should match non-line terminators in modified group"); +assert(re2.test("\uDFFF"), "Pattern character '.' should match non-line terminators in modified group"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-backreferences.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-backreferences.js new file mode 100644 index 0000000000..1d1767651b --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-backreferences.js @@ -0,0 +1,43 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Removing ignoreCase (`i`) modifier in group affects backreferences in group. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(a)(?-i:\1)/i; +assert(re1.test("AA"), "a matches first A, so \\1 should match second A"); +assert(!re1.test("aA"), "a matches a, so \\1 should not match A (preserves case)"); +assert(!re1.test("Aa"), "a matches A, so \\1 should not match a (preserves case)"); +assert(re1.test("aa"), "a matches first a, so \\1 should match second a"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-characterClasses.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-characterClasses.js new file mode 100644 index 0000000000..fbe2d16256 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-characterClasses.js @@ -0,0 +1,55 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Removing ignoreCase (`i`) modifier in group affects character classes in group. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?-i:[ab])c/i; +assert(re1.test("ac"), "[ab] should match a"); +assert(!re1.test("Ac"), "[ab] should not match A"); +assert(re1.test("bc"), "[ab] should match b"); +assert(!re1.test("Bc"), "[ab] should not match B"); + +var re2 = /(?-i:[^ab])c/i; +assert(!re2.test("ac"), "[^ab] should not match a"); +assert(re2.test("Ac"), "[^ab] should match A"); +assert(!re2.test("bc"), "[^ab] should not match b"); +assert(re2.test("Bc"), "[^ab] should match B"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-characterEscapes.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-characterEscapes.js new file mode 100644 index 0000000000..1edb2d2124 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-characterEscapes.js @@ -0,0 +1,52 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Removing ignoreCase (`i`) modifier in group affects character escapes in group. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?-i:\x61)b/i; +assert(re1.test("ab"), "\\x61 should match a"); +assert(re1.test("aB"), "b should match B"); +assert(!re1.test("Ab"), "\\x61 should not match A"); + +var re2 = /(?-i:\u0061)b/i; +assert(re2.test("ab"), "\\u0061 should match a"); +assert(re2.test("aB"), "b should match B"); +assert(!re2.test("Ab"), "\\u0061 should not match A"); + +var re3 = /(?-i:\u{0061})b/iu; +assert(re3.test("ab"), "\\u0061 should match a"); +assert(re3.test("aB"), "b should match B"); +assert(!re3.test("Ab"), "\\u0061 should not match A"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-slash-lower-b.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-slash-lower-b.js new file mode 100644 index 0000000000..b8b51d794b --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-slash-lower-b.js @@ -0,0 +1,53 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Removing ignoreCase (`i`) modifier affects matching for `\b`. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + + GetWordCharacters ( modifiers ) + The abstract operation GetWordCharacters takes argument modifiers (a Modifiers Record) and returns a CharSet. It performs the following steps when called: + + 1. Let wordCharacters be the mathematical set that is the union of all sixty-three characters in "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_" (letters, numbers, and U+005F (LOW LINE) in the Unicode Basic Latin block) and all characters c for which c is not in that set but Canonicalize(c, modifiers) is. + 2. Return wordCharacters. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?-i:\b)/ui; +assert(!re1.test("\u017f"), "\\b should not match after \u017f"); +assert(!re1.test("\u212a"), "\\b should not match after \u212a"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-slash-lower-p.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-slash-lower-p.js new file mode 100644 index 0000000000..2a0167b689 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-slash-lower-p.js @@ -0,0 +1,55 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Removing ignoreCase (`i`) modifier affects matching for `\p{}`. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + + GetWordCharacters ( modifiers ) + The abstract operation GetWordCharacters takes argument modifiers (a Modifiers Record) and returns a CharSet. It performs the following steps when called: + + 1. Let wordCharacters be the mathematical set that is the union of all sixty-three characters in "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_" (letters, numbers, and U+005F (LOW LINE) in the Unicode Basic Latin block) and all characters c for which c is not in that set but Canonicalize(c, modifiers) is. + 2. Return wordCharacters. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?-i:\p{Lu})/ui; +assert(re1.test("A"), "\\p{Lu} should match A"); +assert(!re1.test("a"), "\\p{Lu} should not match a"); +assert(re1.test("Z"), "\\p{Lu} should match Z"); +assert(!re1.test("z"), "\\p{Lu} should not match z"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-slash-lower-w.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-slash-lower-w.js new file mode 100644 index 0000000000..e8686f2e9d --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-slash-lower-w.js @@ -0,0 +1,53 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Removing ignoreCase (`i`) modifier affects matching for `\w`. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + + GetWordCharacters ( modifiers ) + The abstract operation GetWordCharacters takes argument modifiers (a Modifiers Record) and returns a CharSet. It performs the following steps when called: + + 1. Let wordCharacters be the mathematical set that is the union of all sixty-three characters in "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_" (letters, numbers, and U+005F (LOW LINE) in the Unicode Basic Latin block) and all characters c for which c is not in that set but Canonicalize(c, modifiers) is. + 2. Return wordCharacters. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?-i:\w)/ui; +assert(!re1.test("\u017f"), "\\w should not match \u017f"); +assert(!re1.test("\u212a"), "\\w should not match \u212a"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-slash-upper-b.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-slash-upper-b.js new file mode 100644 index 0000000000..9ed611bbe9 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-slash-upper-b.js @@ -0,0 +1,53 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Removing ignoreCase (`i`) modifier affects matching for `\B`. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + + GetWordCharacters ( modifiers ) + The abstract operation GetWordCharacters takes argument modifiers (a Modifiers Record) and returns a CharSet. It performs the following steps when called: + + 1. Let wordCharacters be the mathematical set that is the union of all sixty-three characters in "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_" (letters, numbers, and U+005F (LOW LINE) in the Unicode Basic Latin block) and all characters c for which c is not in that set but Canonicalize(c, modifiers) is. + 2. Return wordCharacters. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?-i:Z\B)/ui; +assert(!re1.test("Z\u017f"), "\\B should not match between Z and \u017f"); +assert(!re1.test("Z\u212a"), "\\B should not match between Z and \u212a"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-slash-upper-p.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-slash-upper-p.js new file mode 100644 index 0000000000..c764e66610 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-slash-upper-p.js @@ -0,0 +1,56 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Removing ignoreCase (`i`) modifier affects matching for `\P{}`. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + + GetWordCharacters ( modifiers ) + The abstract operation GetWordCharacters takes argument modifiers (a Modifiers Record) and returns a CharSet. It performs the following steps when called: + + 1. Let wordCharacters be the mathematical set that is the union of all sixty-three characters in "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_" (letters, numbers, and U+005F (LOW LINE) in the Unicode Basic Latin block) and all characters c for which c is not in that set but Canonicalize(c, modifiers) is. + 2. Return wordCharacters. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?-i:\P{Lu})/ui; +assert(!re1.test("A"), "\\P{Lu} should not match A"); +assert(re1.test("a"), "\\P{Lu} should match a"); +assert(!re1.test("Z"), "\\P{Lu} should not match Z"); +assert(re1.test("z"), "\\P{Lu} should match z"); +assert(re1.test("0"), "\\P{Lu} should match 0"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-slash-upper-w.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-slash-upper-w.js new file mode 100644 index 0000000000..fe2a24a2a2 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-affects-slash-upper-w.js @@ -0,0 +1,53 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Removing ignoreCase (`i`) modifier affects matching for `\W`. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + + GetWordCharacters ( modifiers ) + The abstract operation GetWordCharacters takes argument modifiers (a Modifiers Record) and returns a CharSet. It performs the following steps when called: + + 1. Let wordCharacters be the mathematical set that is the union of all sixty-three characters in "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_" (letters, numbers, and U+005F (LOW LINE) in the Unicode Basic Latin block) and all characters c for which c is not in that set but Canonicalize(c, modifiers) is. + 2. Return wordCharacters. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?-i:\W)/ui; +assert(re1.test("\u017f"), "\\W should match \u017f"); +assert(re1.test("\u212a"), "\\W should match \u212a"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-does-not-affect-dotAll-flag.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-does-not-affect-dotAll-flag.js new file mode 100644 index 0000000000..f66c8f0857 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-does-not-affect-dotAll-flag.js @@ -0,0 +1,49 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Removing ignoreCase (`i`) modifier in group should not affect dotAll (`s`) flag. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?-i:.es)/i; +assert(re1.test("aes"), "s should match s in modified group"); +assert(!re1.test("aeS"), "s should not match S in modified group"); +assert(!re1.test("\nes"), ". should not match newline in modified group"); +assert(!re1.test("\neS"), ". should not match newline in modified group"); + +var re2 = /(?-i:.es)/is; +assert(re2.test("aes"), "s should match s in modified group"); +assert(!re2.test("aeS"), "s should not match S in modified group"); +assert(re2.test("\nes"), ". should match newline in modified group"); +assert(!re2.test("\neS"), "s should not match S in modified group"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-does-not-affect-ignoreCase-property.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-does-not-affect-ignoreCase-property.js new file mode 100644 index 0000000000..4b68807d35 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-does-not-affect-ignoreCase-property.js @@ -0,0 +1,49 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Removing ignoreCase (`i`) modifier does not affect RegExp instance `ignoreCase` property. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?-i:)/i; +assert(re1.ignoreCase, "RegExp instance ignoreCase property should still be set"); + +var re2 = new RegExp("(?-i:)", "i"); +assert(re2.ignoreCase, "RegExp instance ignoreCase property should still be set"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-does-not-affect-multiline-flag.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-does-not-affect-multiline-flag.js new file mode 100644 index 0000000000..26bc3278b1 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase-does-not-affect-multiline-flag.js @@ -0,0 +1,49 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Removing ignoreCase (`i`) modifier in group should not affect multiline (`m`) flag. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?-i:es$)/i; +assert(re1.test("es"), "s should match s in modified group"); +assert(!re1.test("eS"), "s should not match S in modified group"); +assert(!re1.test("es\nz"), "$ should not match newline in modified group"); +assert(!re1.test("eS\nz"), "s should not match S in modified group"); + +var re2 = /(?-i:es$)/im; +assert(re2.test("es"), "s should match s in modified group"); +assert(!re2.test("eS"), "s should not match S in modified group"); +assert(re2.test("es\nz"), "$ should match newline in modified group"); +assert(!re2.test("eS\nz"), "s should not match S in modified group"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase.js new file mode 100644 index 0000000000..87fa013049 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-ignoreCase.js @@ -0,0 +1,49 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + ignoreCase (`i`) modifier can be removed via `(?i:)` or `(?i-:)`. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?-i:fo)o/i; +assert(!re1.test("FOO"), "Pattern should not match as modified group does not ignore case"); +assert(!re1.test("FOo"), "Pattern should not match as modified group does not ignore case"); +assert(re1.test("foo"), "Pattern should not ignore case in modified group"); +assert(re1.test("foO"), "Pattern should not ignore case in modified group"); + +var re2 = new RegExp("(?-i:fo)o", "i"); +assert(!re2.test("FOO"), "Pattern should not match as modified group does not ignore case"); +assert(!re2.test("FOo"), "Pattern should not match as modified group does not ignore case"); +assert(re2.test("foo"), "Pattern should not ignore case in modified group"); +assert(re2.test("foO"), "Pattern should not ignore case in modified group"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-multiline-does-not-affect-dotAll-flag.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-multiline-does-not-affect-dotAll-flag.js new file mode 100644 index 0000000000..b28b545cc0 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-multiline-does-not-affect-dotAll-flag.js @@ -0,0 +1,49 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Removing multiline (`m`) modifier in group should not affect dotAll (`s`) flag. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?-m:es.$)/m; +assert(re1.test("esz"), ". should match z in modified group"); +assert(!re1.test("es\n"), ". should not match newline in modified group"); +assert(!re1.test("esz\n"), "$ should not match newline in modified group"); +assert(!re1.test("es\n\n"), "$ should not match newline in modified group"); + +var re2 = /(?-m:es.$)/ms; +assert(re2.test("esz"), ". should match z in modified group"); +assert(re2.test("es\n"), ". should match newline in modified group"); +assert(!re2.test("esz\n"), "$ should not match newline in modified group"); +assert(!re2.test("es\n\n"), "$ should not match newline in modified group"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-multiline-does-not-affect-ignoreCase-flag.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-multiline-does-not-affect-ignoreCase-flag.js new file mode 100644 index 0000000000..a482105dee --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-multiline-does-not-affect-ignoreCase-flag.js @@ -0,0 +1,49 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Removing multiline (`m`) modifier in group should not affect ignoreCase (`i`) flag. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?-m:es$)/m; +assert(re1.test("es"), "s should match s in modified group"); +assert(!re1.test("eS"), "s should not match S in modified group"); +assert(!re1.test("es\nz"), "$ should not match newline in modified group"); +assert(!re1.test("eS\nz"), "s should not match S in modified group"); + +var re2 = /(?-m:es$)/mi; +assert(re2.test("es"), "s should match s in modified group"); +assert(re2.test("eS"), "s should match S in modified group"); +assert(!re2.test("es\nz"), "$ should not match newline in modified group"); +assert(!re2.test("eS\nz"), "$ should not match newline in modified group"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-multiline-does-not-affect-multiline-property.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-multiline-does-not-affect-multiline-property.js new file mode 100644 index 0000000000..885ae9b242 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-multiline-does-not-affect-multiline-property.js @@ -0,0 +1,43 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Removing multiline (`m`) modifier does not affect RegExp instance `multiline` property. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /(?-m:)/m; +assert(re1.multiline, "RegExp instance multiline flag should still be set"); + +var re2 = new RegExp("(?-m:)", "m"); +assert(re2.multiline, "RegExp instance multiline flag should still be set"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-multiline.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-multiline.js new file mode 100644 index 0000000000..730888a662 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/remove-multiline.js @@ -0,0 +1,45 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + multiline (`m`) modifier can be removed via `(?-m:)`. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +var re1 = /^(?-m:es$)/m; +assert(!re1.test("\nes\ns"), "$ should not match newline in modified group"); +assert(re1.test("\nes"), "$ should match end of input in modified group"); + +var re2 = new RegExp("^(?-m:es$)", "m"); +assert(!re2.test("\nes\ns"), "$ should not match newline in modified group"); +assert(re2.test("\nes"), "$ should match end of input in modified group"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/shell.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/browser.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/shell.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/add-and-remove-modifiers-can-have-empty-remove-modifiers.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/add-and-remove-modifiers-can-have-empty-remove-modifiers.js new file mode 100644 index 0000000000..9d5fd6c879 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/add-and-remove-modifiers-can-have-empty-remove-modifiers.js @@ -0,0 +1,68 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Modifiers syntax `(?ims-:)` is legal. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +/(?i-:)/; +/(?is-:)/; +/(?im-:)/; +/(?s-:)/; +/(?si-:)/; +/(?sm-:)/; +/(?m-:)/; +/(?mi-:)/; +/(?ms-:)/; +/(?ims-:)/; +/(?ism-:)/; +/(?sim-:)/; +/(?smi-:)/; +/(?mis-:)/; +/(?msi-:)/; +new RegExp("(?i-:)"); +new RegExp("(?is-:)"); +new RegExp("(?im-:)"); +new RegExp("(?s-:)"); +new RegExp("(?si-:)"); +new RegExp("(?sm-:)"); +new RegExp("(?m-:)"); +new RegExp("(?mi-:)"); +new RegExp("(?ms-:)"); +new RegExp("(?ims-:)"); +new RegExp("(?ism-:)"); +new RegExp("(?sim-:)"); +new RegExp("(?smi-:)"); +new RegExp("(?mis-:)"); +new RegExp("(?msi-:)"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/add-and-remove-modifiers.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/add-and-remove-modifiers.js new file mode 100644 index 0000000000..728d47d3a0 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/add-and-remove-modifiers.js @@ -0,0 +1,74 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Modifiers syntax `(?im-s:)` (and similar) is legal, as long as they do not overlap. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +/(?i-s:)/; +/(?i-sm:)/; +/(?i-m:)/; +/(?i-ms:)/; +/(?s-i:)/; +/(?s-im:)/; +/(?s-m:)/; +/(?s-mi:)/; +/(?m-i:)/; +/(?m-is:)/; +/(?m-s:)/; +/(?m-si:)/; +/(?is-m:)/; +/(?im-s:)/; +/(?si-m:)/; +/(?sm-i:)/; +/(?mi-s:)/; +/(?ms-i:)/; +new RegExp("(?i-s:)"); +new RegExp("(?i-sm:)"); +new RegExp("(?i-m:)"); +new RegExp("(?i-ms:)"); +new RegExp("(?s-i:)"); +new RegExp("(?s-im:)"); +new RegExp("(?s-m:)"); +new RegExp("(?s-mi:)"); +new RegExp("(?m-i:)"); +new RegExp("(?m-is:)"); +new RegExp("(?m-s:)"); +new RegExp("(?m-si:)"); +new RegExp("(?is-m:)"); +new RegExp("(?im-s:)"); +new RegExp("(?si-m:)"); +new RegExp("(?sm-i:)"); +new RegExp("(?mi-s:)"); +new RegExp("(?ms-i:)"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/add-modifiers-when-nested.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/add-modifiers-when-nested.js new file mode 100644 index 0000000000..278633d304 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/add-modifiers-when-nested.js @@ -0,0 +1,44 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Modifiers syntax `(?ims:)` is legal, even when modifiers are already set via an outer non-capturing group. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +/(?i:(?i:))/; +/(?s:(?s:))/; +/(?m:(?m:))/; +new RegExp("(?i:(?i:))"); +new RegExp("(?s:(?s:))"); +new RegExp("(?m:(?m:))"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/add-modifiers-when-not-set-as-flags.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/add-modifiers-when-not-set-as-flags.js new file mode 100644 index 0000000000..e288c833c6 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/add-modifiers-when-not-set-as-flags.js @@ -0,0 +1,68 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Modifiers syntax `(?ims:)` is legal. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +/(?i:)/; +/(?is:)/; +/(?im:)/; +/(?s:)/; +/(?si:)/; +/(?sm:)/; +/(?m:)/; +/(?mi:)/; +/(?ms:)/; +/(?ims:)/; +/(?ism:)/; +/(?sim:)/; +/(?smi:)/; +/(?mis:)/; +/(?msi:)/; +new RegExp("(?i:)"); +new RegExp("(?is:)"); +new RegExp("(?im:)"); +new RegExp("(?s:)"); +new RegExp("(?si:)"); +new RegExp("(?sm:)"); +new RegExp("(?m:)"); +new RegExp("(?mi:)"); +new RegExp("(?ms:)"); +new RegExp("(?ims:)"); +new RegExp("(?ism:)"); +new RegExp("(?sim:)"); +new RegExp("(?smi:)"); +new RegExp("(?mis:)"); +new RegExp("(?msi:)"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/add-modifiers-when-set-as-flags.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/add-modifiers-when-set-as-flags.js new file mode 100644 index 0000000000..f1d5cedc83 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/add-modifiers-when-set-as-flags.js @@ -0,0 +1,46 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Modifiers syntax `(?ims:)` is legal, even when modifiers are already set via flags. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by RegularExpressionFlags. + 2. Let removeModifiers be the empty String. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), removeModifiers). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +/(?i:)/i; +/(?s:)/s; +/(?m:)/m; +/(?ims:)/ims; +new RegExp("(?i:)", "i"); +new RegExp("(?s:)", "s"); +new RegExp("(?m:)", "m"); +new RegExp("(?ims:)", "ims"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/browser.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/remove-modifiers-when-nested.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/remove-modifiers-when-nested.js new file mode 100644 index 0000000000..90d5e5e606 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/remove-modifiers-when-nested.js @@ -0,0 +1,44 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Modifiers syntax `(?-ims:)` is legal, even when modifiers are already cleared via an outer non-capturing group. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +/(?-i:(?-i:))/; +/(?-s:(?-s:))/; +/(?-m:(?-m:))/; +new RegExp("(?-i:(?-i:))"); +new RegExp("(?-s:(?-s:))"); +new RegExp("(?-m:(?-m:))"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/remove-modifiers-when-not-set-as-flags.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/remove-modifiers-when-not-set-as-flags.js new file mode 100644 index 0000000000..397e94ce6b --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/remove-modifiers-when-not-set-as-flags.js @@ -0,0 +1,68 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Modifiers syntax `(?-ims:)` is legal, even when not set as flags. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +/(?-i:)/; +/(?-is:)/; +/(?-im:)/; +/(?-s:)/; +/(?-si:)/; +/(?-sm:)/; +/(?-m:)/; +/(?-mi:)/; +/(?-ms:)/; +/(?-ims:)/; +/(?-ism:)/; +/(?-smi:)/; +/(?-sim:)/; +/(?-mis:)/; +/(?-msi:)/; +new RegExp("(?-i:)"); +new RegExp("(?-is:)"); +new RegExp("(?-im:)"); +new RegExp("(?-s:)"); +new RegExp("(?-si:)"); +new RegExp("(?-sm:)"); +new RegExp("(?-m:)"); +new RegExp("(?-mi:)"); +new RegExp("(?-ms:)"); +new RegExp("(?-ims:)"); +new RegExp("(?-ism:)"); +new RegExp("(?-smi:)"); +new RegExp("(?-sim:)"); +new RegExp("(?-mis:)"); +new RegExp("(?-msi:)"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/remove-modifiers-when-set-as-flags.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/remove-modifiers-when-set-as-flags.js new file mode 100644 index 0000000000..1b96c747a8 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/remove-modifiers-when-set-as-flags.js @@ -0,0 +1,68 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright 2023 Ron Buckton. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +author: Ron Buckton +description: > + Modifiers syntax `(?-ims:)` is legal. +info: | + Runtime Semantics: CompileAtom + The syntax-directed operation CompileAtom takes arguments direction (forward or backward) and modifiers (a Modifiers Record) and returns a Matcher. + + Atom :: `(` `?` RegularExpressionFlags `-` RegularExpressionFlags `:` Disjunction `)` + 1. Let addModifiers be the source text matched by the first RegularExpressionFlags. + 2. Let removeModifiers be the source text matched by the second RegularExpressionFlags. + 3. Let newModifiers be UpdateModifiers(modifiers, CodePointsToString(addModifiers), CodePointsToString(removeModifiers)). + 4. Return CompileSubpattern of Disjunction with arguments direction and newModifiers. + + UpdateModifiers ( modifiers, add, remove ) + The abstract operation UpdateModifiers takes arguments modifiers (a Modifiers Record), add (a String), and remove (a String) and returns a Modifiers. It performs the following steps when called: + + 1. Let dotAll be modifiers.[[DotAll]]. + 2. Let ignoreCase be modifiers.[[IgnoreCase]]. + 3. Let multiline be modifiers.[[Multiline]]. + 4. If add contains "s", set dotAll to true. + 5. If add contains "i", set ignoreCase to true. + 6. If add contains "m", set multiline to true. + 7. If remove contains "s", set dotAll to false. + 8. If remove contains "i", set ignoreCase to false. + 9. If remove contains "m", set multiline to false. + 10. Return the Modifiers Record { [[DotAll]]: dotAll, [[IgnoreCase]]: ignoreCase, [[Multiline]]: multiline }. + +esid: sec-compileatom +features: [regexp-modifiers] +---*/ + +/(?-i:)/i; +/(?-is:)/is; +/(?-im:)/im; +/(?-s:)/s; +/(?-si:)/si; +/(?-sm:)/sm; +/(?-m:)/m; +/(?-mi:)/mi; +/(?-ms:)/ms; +/(?-ims:)/ims; +/(?-ism:)/ism; +/(?-sim:)/sim; +/(?-smi:)/smi; +/(?-mis:)/mis; +/(?-msi:)/msi; +new RegExp("(?-i:)", "i"); +new RegExp("(?-is:)", "is"); +new RegExp("(?-im:)", "im"); +new RegExp("(?-s:)", "s"); +new RegExp("(?-si:)", "si"); +new RegExp("(?-sm:)", "sm"); +new RegExp("(?-m:)", "m"); +new RegExp("(?-mi:)", "mi"); +new RegExp("(?-ms:)", "ms"); +new RegExp("(?-ims:)", "ims"); +new RegExp("(?-ism:)", "ism"); +new RegExp("(?-sim:)", "sim"); +new RegExp("(?-smi:)", "smi"); +new RegExp("(?-mis:)", "mis"); +new RegExp("(?-msi:)", "msi"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/shell.js b/js/src/tests/test262/built-ins/RegExp/regexp-modifiers/syntax/valid/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-add-remove-i.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-add-remove-i.js new file mode 100644 index 0000000000..36e5757c2c --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-add-remove-i.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the any code point in the source text matched by the first RegularExpressionFlags is also contained in the source text matched by the second RegularExpressionFlags. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?i-i:a)", ""); +}, 'RegExp("(?i-i:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-add-remove-m.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-add-remove-m.js new file mode 100644 index 0000000000..96df538289 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-add-remove-m.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the any code point in the source text matched by the first RegularExpressionFlags is also contained in the source text matched by the second RegularExpressionFlags. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?m-m:a)", ""); +}, 'RegExp("(?m-m:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-add-remove-multi-duplicate.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-add-remove-multi-duplicate.js new file mode 100644 index 0000000000..c566dd7a84 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-add-remove-multi-duplicate.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the any code point in the source text matched by the first RegularExpressionFlags is also contained in the source text matched by the second RegularExpressionFlags. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?ims-m:a)", ""); +}, 'RegExp("(?ims-m:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-add-remove-s-escape.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-add-remove-s-escape.js new file mode 100644 index 0000000000..3efc2308c1 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-add-remove-s-escape.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the any code point in the source text matched by the first RegularExpressionFlags is also contained in the source text matched by the second RegularExpressionFlags. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?\u{0073}-s:a)", ""); +}, 'RegExp("(?\u{0073}-s:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-add-remove-s.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-add-remove-s.js new file mode 100644 index 0000000000..b745f7f6aa --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-add-remove-s.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the any code point in the source text matched by the first RegularExpressionFlags is also contained in the source text matched by the second RegularExpressionFlags. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?s-s:a)", ""); +}, 'RegExp("(?s-s:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-both-empty.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-both-empty.js new file mode 100644 index 0000000000..5ce55095fc --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-both-empty.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by the first RegularExpressionFlags and the source text matched by the second RegularExpressionFlags are both empty. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?-:a)", ""); +}, 'RegExp("(?-:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-code-point-repeat-i-1.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-code-point-repeat-i-1.js new file mode 100644 index 0000000000..3aa6a30d89 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-code-point-repeat-i-1.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?-ii:a)", ""); +}, 'RegExp("(?-ii:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-code-point-repeat-i-2.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-code-point-repeat-i-2.js new file mode 100644 index 0000000000..d494df0113 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-code-point-repeat-i-2.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?-imsi:a)", ""); +}, 'RegExp("(?-imsi:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-arbitrary.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-arbitrary.js new file mode 100644 index 0000000000..f5e3b26dd1 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-arbitrary.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?-1:a)", ""); +}, 'RegExp("(?-1:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-combining-i.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-combining-i.js new file mode 100644 index 0000000000..8a2eb982b4 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-combining-i.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?-iͥ:a)", ""); +}, 'RegExp("(?-iͥ:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-combining-m.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-combining-m.js new file mode 100644 index 0000000000..086271affb --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-combining-m.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?-mͫ:a)", ""); +}, 'RegExp("(?-mͫ:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-combining-s.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-combining-s.js new file mode 100644 index 0000000000..ccf4152844 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-combining-s.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?-s̀:a)", ""); +}, 'RegExp("(?-s̀:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-d.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-d.js new file mode 100644 index 0000000000..c8ee295463 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-d.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?-d:a)", ""); +}, 'RegExp("(?-d:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-g.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-g.js new file mode 100644 index 0000000000..9e52eb067f --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-g.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?-g:a)", ""); +}, 'RegExp("(?-g:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-non-display-1.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-non-display-1.js new file mode 100644 index 0000000000..8ae9398003 Binary files /dev/null and b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-non-display-1.js differ diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-non-display-2.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-non-display-2.js new file mode 100644 index 0000000000..888fd17adc --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-non-display-2.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?-s‎:a)", ""); +}, 'RegExp("(?-s‎:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-non-flag.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-non-flag.js new file mode 100644 index 0000000000..fa899733ff --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-non-flag.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?-Q:a)", ""); +}, 'RegExp("(?-Q:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-u.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-u.js new file mode 100644 index 0000000000..9174df4eaa --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-u.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?-u:a)", ""); +}, 'RegExp("(?-u:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-uppercase-I.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-uppercase-I.js new file mode 100644 index 0000000000..f51bdcd561 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-uppercase-I.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?-I:a)", ""); +}, 'RegExp("(?-I:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-y.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-y.js new file mode 100644 index 0000000000..c5f981ef7b --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-y.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?-y:a)", ""); +}, 'RegExp("(?-y:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-zwj.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-zwj.js new file mode 100644 index 0000000000..6dc54400f7 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-zwj.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?-s‍:a)", ""); +}, 'RegExp("(?-s‍:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-zwnbsp.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-zwnbsp.js new file mode 100644 index 0000000000..626fcead1b --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-zwnbsp.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?-s:a)", ""); +}, 'RegExp("(?-s:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-zwnj.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-zwnj.js new file mode 100644 index 0000000000..eac16a0439 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-other-code-point-zwnj.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?-s‌:a)", ""); +}, 'RegExp("(?-s‌:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-add-remove-i.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-add-remove-i.js new file mode 100644 index 0000000000..36e5757c2c --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-add-remove-i.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the any code point in the source text matched by the first RegularExpressionFlags is also contained in the source text matched by the second RegularExpressionFlags. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?i-i:a)", ""); +}, 'RegExp("(?i-i:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-add-remove-m.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-add-remove-m.js new file mode 100644 index 0000000000..96df538289 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-add-remove-m.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the any code point in the source text matched by the first RegularExpressionFlags is also contained in the source text matched by the second RegularExpressionFlags. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?m-m:a)", ""); +}, 'RegExp("(?m-m:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-add-remove-multi-duplicate.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-add-remove-multi-duplicate.js new file mode 100644 index 0000000000..8e9c608e4a --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-add-remove-multi-duplicate.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the any code point in the source text matched by the first RegularExpressionFlags is also contained in the source text matched by the second RegularExpressionFlags. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?m-ims:a)", ""); +}, 'RegExp("(?m-ims:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-add-remove-s-escape.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-add-remove-s-escape.js new file mode 100644 index 0000000000..3bb3e4a89f --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-add-remove-s-escape.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the any code point in the source text matched by the first RegularExpressionFlags is also contained in the source text matched by the second RegularExpressionFlags. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?s-\u{0073}:a)", ""); +}, 'RegExp("(?s-\u{0073}:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-add-remove-s.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-add-remove-s.js new file mode 100644 index 0000000000..b745f7f6aa --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-add-remove-s.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the any code point in the source text matched by the first RegularExpressionFlags is also contained in the source text matched by the second RegularExpressionFlags. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?s-s:a)", ""); +}, 'RegExp("(?s-s:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-code-point-repeat-i-1.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-code-point-repeat-i-1.js new file mode 100644 index 0000000000..1aee0a56f2 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-code-point-repeat-i-1.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?ii-:a)", ""); +}, 'RegExp("(?ii-:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-code-point-repeat-i-2.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-code-point-repeat-i-2.js new file mode 100644 index 0000000000..8ae4960441 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-code-point-repeat-i-2.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?imsi-:a)", ""); +}, 'RegExp("(?imsi-:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-arbitrary.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-arbitrary.js new file mode 100644 index 0000000000..70e24b4e22 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-arbitrary.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?1-:a)", ""); +}, 'RegExp("(?1-:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-combining-i.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-combining-i.js new file mode 100644 index 0000000000..7cf8d11d2c --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-combining-i.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?iͥ-:a)", ""); +}, 'RegExp("(?iͥ-:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-combining-m.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-combining-m.js new file mode 100644 index 0000000000..5023bcb573 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-combining-m.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?mͫ-:a)", ""); +}, 'RegExp("(?mͫ-:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-combining-s.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-combining-s.js new file mode 100644 index 0000000000..f2edc9f211 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-combining-s.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?s̀-:a)", ""); +}, 'RegExp("(?s̀-:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-d.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-d.js new file mode 100644 index 0000000000..ccbda94c89 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-d.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?d-:a)", ""); +}, 'RegExp("(?d-:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-g.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-g.js new file mode 100644 index 0000000000..f89699072b --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-g.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?g-:a)", ""); +}, 'RegExp("(?g-:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-non-display-1.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-non-display-1.js new file mode 100644 index 0000000000..16c0162a9a Binary files /dev/null and b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-non-display-1.js differ diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-non-display-2.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-non-display-2.js new file mode 100644 index 0000000000..9b8d348b31 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-non-display-2.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?s‎-:a)", ""); +}, 'RegExp("(?s‎-:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-non-flag.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-non-flag.js new file mode 100644 index 0000000000..d52249217c --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-non-flag.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?Q-:a)", ""); +}, 'RegExp("(?Q-:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-u.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-u.js new file mode 100644 index 0000000000..1f7d261897 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-u.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?u-:a)", ""); +}, 'RegExp("(?u-:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-uppercase-I.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-uppercase-I.js new file mode 100644 index 0000000000..a9d284f5c2 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-uppercase-I.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?I-:a)", ""); +}, 'RegExp("(?I-:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-y.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-y.js new file mode 100644 index 0000000000..bc13bdfb1c --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-y.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?y-:a)", ""); +}, 'RegExp("(?y-:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-zwj.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-zwj.js new file mode 100644 index 0000000000..4b16df3743 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-zwj.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?s‍-:a)", ""); +}, 'RegExp("(?s‍-:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-zwnbsp.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-zwnbsp.js new file mode 100644 index 0000000000..f1a4373aef --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-zwnbsp.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?s-:a)", ""); +}, 'RegExp("(?s-:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-zwnj.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-zwnj.js new file mode 100644 index 0000000000..11c119eae4 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-other-code-point-zwnj.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: It is a Syntax Error if the source text matched by RegularExpressionFlags contains any code point other than i, m, or s, or if it contains the same code point more than once. (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?s‌-:a)", ""); +}, 'RegExp("(?s‌-:a)", ""): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-should-not-case-fold-i.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-should-not-case-fold-i.js new file mode 100644 index 0000000000..667d2408bb --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-should-not-case-fold-i.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Code points other than "i", "m", "s" should not be case folded to "i", "m", or "s" (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?I-:a)", "i"); +}, 'RegExp("(?I-:a)", "i"): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-should-not-case-fold-m.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-should-not-case-fold-m.js new file mode 100644 index 0000000000..4fb69935ed --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-should-not-case-fold-m.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Code points other than "i", "m", "s" should not be case folded to "i", "m", or "s" (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?M-:a)", "i"); +}, 'RegExp("(?M-:a)", "i"): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-should-not-case-fold-s.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-should-not-case-fold-s.js new file mode 100644 index 0000000000..f678b0c532 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-should-not-case-fold-s.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Code points other than "i", "m", "s" should not be case folded to "i", "m", or "s" (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?S-:a)", "i"); +}, 'RegExp("(?S-:a)", "i"): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-should-not-unicode-case-fold-i.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-should-not-unicode-case-fold-i.js new file mode 100644 index 0000000000..fedb79a4f2 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-should-not-unicode-case-fold-i.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Code points other than "i", "m", "s" should not be case-folded to "i", "m", or "s" (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?İ-:a)", "iu"); +}, 'RegExp("(?İ-:a)", "iu"): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-should-not-unicode-case-fold-s.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-should-not-unicode-case-fold-s.js new file mode 100644 index 0000000000..0cd8418bae --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-reverse-should-not-unicode-case-fold-s.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Code points other than "i", "m", "s" should not be case-folded to "i", "m", or "s" (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?ſ-:a)", "u"); +}, 'RegExp("(?ſ-:a)", "u"): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-should-not-case-fold-i.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-should-not-case-fold-i.js new file mode 100644 index 0000000000..4021cd675e --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-should-not-case-fold-i.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Code points other than "i", "m", "s" should not be case folded to "i", "m", or "s" (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?-I:a)", "i"); +}, 'RegExp("(?-I:a)", "i"): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-should-not-case-fold-m.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-should-not-case-fold-m.js new file mode 100644 index 0000000000..9dff9ce51a --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-should-not-case-fold-m.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Code points other than "i", "m", "s" should not be case folded to "i", "m", or "s" (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?-M:a)", "i"); +}, 'RegExp("(?-M:a)", "i"): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-should-not-case-fold-s.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-should-not-case-fold-s.js new file mode 100644 index 0000000000..0a78e61909 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-should-not-case-fold-s.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Code points other than "i", "m", "s" should not be case folded to "i", "m", or "s" (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?-S:a)", "i"); +}, 'RegExp("(?-S:a)", "i"): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-should-not-unicode-case-fold-i.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-should-not-unicode-case-fold-i.js new file mode 100644 index 0000000000..7f38b553f2 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-should-not-unicode-case-fold-i.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Code points other than "i", "m", "s" should not be case-folded to "i", "m", or "s" (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?-İ:a)", "iu"); +}, 'RegExp("(?-İ:a)", "iu"): '); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-should-not-unicode-case-fold-s.js b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-should-not-unicode-case-fold-s.js new file mode 100644 index 0000000000..f826ffe544 --- /dev/null +++ b/js/src/tests/test262/built-ins/RegExp/syntax-err-arithmetic-modifiers-should-not-unicode-case-fold-s.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-modifiers is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Code points other than "i", "m", "s" should not be case-folded to "i", "m", or "s" (arithmetic regular expression flags) +esid: sec-patterns-static-semantics-early-errors +features: [regexp-modifiers] +info: | + Atom :: ( ? RegularExpressionFlags - RegularExpressionFlags : Disjunction ) + ... + +---*/ + +assert.throws(SyntaxError, function () { + RegExp("(?-ſ:a)", "u"); +}, 'RegExp("(?-ſ:a)", "u"): '); + +reportCompare(0, 0); -- cgit v1.2.3