Debian Codegraph @

js/src/tests/test262/built-ins/RegExp/escape/escaped-solidus-character-simple.js

raw
1 // |reftest| shell-option(--enable-regexp-escape) skip-if(!RegExp.escape||!xulRuntime.shell) -- RegExp.escape is not enabled unconditionally, requires shell-options
2 // Copyright (C) 2024 Leo Balter. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4
5 /*---
6 esid: sec-regexp.escape
7 description: Escaped U+002F (SOLIDUS) character (simple assertions)
8 info: |
9 EncodeForRegExpEscape ( c )
10
11 1. If c is matched by SyntaxCharacter or c is U+002F (SOLIDUS), then
12 a. Return the string-concatenation of 0x005C (REVERSE SOLIDUS) and UTF16EncodeCodePoint(c).
13 features: [RegExp.escape]
14 ---*/
15
16 assert.sameValue(RegExp.escape('/'), '\\/', 'solidus character is escaped correctly');
17 assert.sameValue(RegExp.escape('//'), '\\/\\/', 'solidus character is escaped correctly - multiple occurrences 1');
18 assert.sameValue(RegExp.escape('///'), '\\/\\/\\/', 'solidus character is escaped correctly - multiple occurrences 2');
19 assert.sameValue(RegExp.escape('////'), '\\/\\/\\/\\/', 'solidus character is escaped correctly - multiple occurrences 3');
20
21 reportCompare(0, 0);