Debian Codegraph @

js/src/tests/test262/language/literals/regexp/u-null-character-escape.js

raw
1 // Copyright (C) 2020 Alexey Shvayka. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 esid: prod-CharacterEscape
6 description: >
7 Null character escape is permitted in Unicode patterns.
8 info: |
9 CharacterEscape[U] ::
10 ControlEscape
11 c ControlLetter
12 0 [lookahead ∉ DecimalDigit]
13 HexEscapeSequence
14 RegExpUnicodeEscapeSequence[?U]
15 IdentityEscape[?U]
16
17 DecimalDigit :: one of
18 0 1 2 3 4 5 6 7 8 9
19 ---*/
20
21 var nullChar = String.fromCharCode(0);
22 assert.sameValue(/\0/u.exec(nullChar)[0], nullChar);
23 assert(/^\0a$/u.test('\0a'));
24 assert.sameValue('\x00②'.match(/\0②/u)[0], '\x00②');
25 assert.sameValue('\u0000፬'.search(/\0፬$/u), 0);
26
27 reportCompare(0, 0);