-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
unicode_forbidden_escapes.js
33 lines (29 loc) · 1.18 KB
/
unicode_forbidden_escapes.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
WScript.LoadScriptFile("..\\UnitTestFramework\\UnitTestFramework.js");
var tests = [
{
name: "Unicode-mode RegExp Forbidden Escapes",
body: function () {
let forbidden = [
'\\p',
'\\P',
'\\a',
'\\A',
'\\e',
'\\E',
'\\y',
'\\Y',
'\\z',
'\\Z',
];
for (re of forbidden) {
assert.throws(function () { new RegExp(re, 'u') }, SyntaxError, 'Invalid regular expression: invalid escape in unicode pattern');
assert.doesNotThrow(function () { new RegExp(re) });
}
}
}
];
testRunner.runTests(tests, { verbose: WScript.Arguments[0] != "summary" });