| 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: Extensions to ClassEscape |
| 7 |
info: | |
| 8 |
ClassEscape[U] :: |
| 9 |
b |
| 10 |
[+U] - |
| 11 |
[~U] c ClassControlLetter |
| 12 |
CharacterClassEscape |
| 13 |
CharacterEscape[?U] |
| 14 |
|
| 15 |
ClassControlLetter :: |
| 16 |
DecimalDigit |
| 17 |
_ |
| 18 |
|
| 19 |
The production ClassEscape :: c ClassControlLetter evaluates as follows: |
| 20 |
|
| 21 |
1. Let ch be the character matched by ClassControlLetter. |
| 22 |
2. Let i be ch's character value. |
| 23 |
3. Let j be the remainder of dividing i by 32. |
| 24 |
4. Let d be the character whose character value is j. |
| 25 |
5. Return the CharSet containing the single character d. |
| 26 |
---*/ |
| 27 |
|
| 28 |
var match; |
| 29 |
|
| 30 |
match = /\c0/.exec('\x0f\x10\x11'); |
| 31 |
assert.sameValue(match, null, '\\c0 outside of CharacterClass'); |
| 32 |
|
| 33 |
match = /[\c0]/.exec('\x0f\x10\x11'); |
| 34 |
assert.sameValue(match[0], '\x10', '\\c0 within CharacterClass'); |
| 35 |
|
| 36 |
match = /[\c00]+/.exec('\x0f0\x10\x11'); |
| 37 |
assert.sameValue(match[0], '0\x10', '\\c00 within CharacterClass'); |
| 38 |
|
| 39 |
match = /\c1/.exec('\x10\x11\x12'); |
| 40 |
assert.sameValue(match, null, '\\c1 outside of CharacterClass'); |
| 41 |
|
| 42 |
match = /[\c1]/.exec('\x10\x11\x12'); |
| 43 |
assert.sameValue(match[0], '\x11', '\\c1 within CharacterClass'); |
| 44 |
|
| 45 |
match = /[\c10]+/.exec('\x100\x11\x12'); |
| 46 |
assert.sameValue(match[0], '0\x11', '\\c10 within CharacterClass'); |
| 47 |
|
| 48 |
match = /\c8/.exec('\x17\x18\x19'); |
| 49 |
assert.sameValue(match, null, '\\c8 outside of CharacterClass'); |
| 50 |
|
| 51 |
match = /[\c8]/.exec('\x17\x18\x19'); |
| 52 |
assert.sameValue(match[0], '\x18', '\\c8 within CharacterClass'); |
| 53 |
|
| 54 |
match = /[\c80]+/.exec('\x170\x18\x19'); |
| 55 |
assert.sameValue(match[0], '0\x18', '\\c80 within CharacterClass'); |
| 56 |
|
| 57 |
match = /\c9/.exec('\x18\x19\x1a'); |
| 58 |
assert.sameValue(match, null, '\\c9 outside of CharacterClass'); |
| 59 |
|
| 60 |
match = /[\c9]/.exec('\x18\x19\x1a'); |
| 61 |
assert.sameValue(match[0], '\x19', '\\c9 within CharacterClass'); |
| 62 |
|
| 63 |
match = /[\c90]+/.exec('\x180\x19\x1a'); |
| 64 |
assert.sameValue(match[0], '0\x19', '\\c90 within CharacterClass'); |
| 65 |
|
| 66 |
match = /\c_/.exec('\x1e\x1f\x20'); |
| 67 |
assert.sameValue(match, null, '\\c_ outside of CharacterClass'); |
| 68 |
|
| 69 |
match = /[\c_]/.exec('\x1e\x1f\x20'); |
| 70 |
assert.sameValue(match[0], '\x1f', '\\c_ within CharacterClass'); |