| 1 |
// Copyright (C) 2016 the V8 project authors. All rights reserved. |
| 2 |
// This code is governed by the BSD license found in the LICENSE file. |
| 3 |
/*--- |
| 4 |
esid: sec-regular-expressions-patterns |
| 5 |
es6id: B.1.4 |
| 6 |
description: Legacy Octal Escape Sequence |
| 7 |
info: | |
| 8 |
CharacterEscape[U]:: |
| 9 |
ControlEscape |
| 10 |
c ControlLetter |
| 11 |
0 [lookahead ∉ DecimalDigit] |
| 12 |
HexEscapeSequence |
| 13 |
RegExpUnicodeEscapeSequence[?U] |
| 14 |
[~U] LegacyOctalEscapeSequence |
| 15 |
IdentityEscape[?U] |
| 16 |
|
| 17 |
The production CharacterEscape::LegacyOctalEscapeSequence evaluates by |
| 18 |
evaluating the SV of the LegacyOctalEscapeSequence (see B.1.2) and |
| 19 |
returning its character result. |
| 20 |
---*/ |
| 21 |
|
| 22 |
var match; |
| 23 |
|
| 24 |
assert.sameValue(/\1/.exec('\x01')[0], '\x01', '\\1'); |
| 25 |
assert.sameValue(/\2/.exec('\x02')[0], '\x02', '\\2'); |
| 26 |
assert.sameValue(/\3/.exec('\x03')[0], '\x03', '\\3'); |
| 27 |
assert.sameValue(/\4/.exec('\x04')[0], '\x04', '\\4'); |
| 28 |
assert.sameValue(/\5/.exec('\x05')[0], '\x05', '\\5'); |
| 29 |
assert.sameValue(/\6/.exec('\x06')[0], '\x06', '\\6'); |
| 30 |
assert.sameValue(/\7/.exec('\x07')[0], '\x07', '\\7'); |
| 31 |
|
| 32 |
assert.sameValue(/\00/.exec('\x00')[0], '\x00', '\\00'); |
| 33 |
assert.sameValue(/\07/.exec('\x07')[0], '\x07', '\\07'); |
| 34 |
|
| 35 |
assert.sameValue(/\30/.exec('\x18')[0], '\x18', '\\30'); |
| 36 |
assert.sameValue(/\37/.exec('\x1f')[0], '\x1f', '\\37'); |
| 37 |
|
| 38 |
assert.sameValue(/\40/.exec('\x20')[0], '\x20', '\\40'); |
| 39 |
assert.sameValue(/\47/.exec('\x27')[0], '\x27', '\\47'); |
| 40 |
|
| 41 |
assert.sameValue(/\70/.exec('\x38')[0], '\x38', '\\70'); |
| 42 |
assert.sameValue(/\77/.exec('\x3f')[0], '\x3f', '\\77'); |
| 43 |
|
| 44 |
// Sequence is bounded according to the String Value (not number of characters) |
| 45 |
assert.sameValue(/\400/.exec('\x200')[0], '\x200', '\\400'); |
| 46 |
assert.sameValue(/\470/.exec('\x270')[0], '\x270', '\\470'); |
| 47 |
assert.sameValue(/\700/.exec('\x380')[0], '\x380', '\\700'); |
| 48 |
assert.sameValue(/\770/.exec('\x3f0')[0], '\x3f0', '\\770'); |
| 49 |
|
| 50 |
assert.sameValue(/\000/.exec('\x00')[0], '\x00', '\\000'); |
| 51 |
assert.sameValue(/\007/.exec('\x07')[0], '\x07', '\\007'); |
| 52 |
assert.sameValue(/\070/.exec('\x38')[0], '\x38', '\\070'); |
| 53 |
|
| 54 |
assert.sameValue(/\300/.exec('\xc0')[0], '\xc0', '\\300'); |
| 55 |
assert.sameValue(/\307/.exec('\xc7')[0], '\xc7', '\\307'); |
| 56 |
assert.sameValue(/\370/.exec('\xf8')[0], '\xf8', '\\370'); |
| 57 |
|
| 58 |
match = /(.)\1/.exec('a\x01 aa'); |
| 59 |
assert.sameValue( |
| 60 |
match[0], 'aa', 'DecimalEscape takes precedence over LegacyOctalEscapeSequence' |
| 61 |
); |