Skip to content
Snippets Groups Projects
Commit d5e11503 authored by Mathias Bynens's avatar Mathias Bynens Committed by Leo Balter
Browse files

Add regular RegExp Unicode property escape tests (#1014)

parent 09f01de8
No related branches found
No related tags found
No related merge requests found
Showing
with 46 additions and 0 deletions
// Copyright 2017 Mathias Bynens. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
author: Mathias Bynens
description: >
Binary properties with an explicit value must throw in Unicode property
escapes (even if the value is valid).
esid: sec-static-semantics-unicodematchproperty-p
features: [regexp-unicode-property-escapes]
---*/
assert.throws.early(SyntaxError, "/\\p{ASCII=Yes}/u");
assert.throws.early(SyntaxError, "/\\p{ASCII=Y}/u");
assert.throws.early(SyntaxError, "/\\p{ASCII=T}/u");
assert.throws.early(SyntaxError, "/\\P{ASCII=No}/u");
assert.throws.early(SyntaxError, "/\\P{ASCII=N}/u");
assert.throws.early(SyntaxError, "/\\P{ASCII=F}/u");
assert.throws.early(SyntaxError, "/\\p{ASCII=Invalid}/u");
// Copyright 2017 Mathias Bynens. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
author: Mathias Bynens
description: >
Unicode property escapes must be supported in character classes.
esid: sec-static-semantics-unicodematchproperty-p
features: [regexp-unicode-property-escapes]
---*/
/[\p{Hex}]/u;
assert(
/[\p{Hex}-\uFFFF]/u.test('-'),
'property escape in character class should not be parsed as the start of a range'
);
assert.throws.early(SyntaxError, "/[\\p{}]/u");
assert.throws.early(SyntaxError, "/[\\p{invalid}]/u");
assert.throws.early(SyntaxError, "/[\\p{]/u");
assert.throws.early(SyntaxError, "/[\\p{]}/u");
assert.throws.early(SyntaxError, "/[\\p}]/u");
assert(
/[\p{Hex}\P{Hex}]/u.test('\u{1D306}'),
'multiple property escapes in a single character class should be supported'
);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment