summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/RegExp/named-groups/unicode-property-names-invalid.js
blob: 9b0ef33496abf0a3285bee6cb9cd171a83928b36 (plain)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright (C) 2020 Apple Inc. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
author: Michael Saboff
description: Invalid exotic named group names in Unicode RegExps
esid: prod-GroupSpecifier
features: [regexp-named-groups]
---*/

/*
 Valid ID_Continue Unicode characters (Can't be first identifier character.)

 𝟚  \u{1d7da}  \ud835 \udfda

 Invalid ID_Start / ID_Continue

 (fox face emoji) 🦊  \u{1f98a}  \ud83e \udd8a
 (dog emoji)  🐕  \u{1f415}  \ud83d \udc15
*/

assert.throws(SyntaxError, function() {
    return new RegExp("(?<🦊>fox)", "u");
});

assert.throws(SyntaxError, function() {
    return new RegExp("(?<\u{1f98a}>fox)", "u");
});

assert.throws(SyntaxError, function() {
    return new RegExp("(?<\ud83e\udd8a>fox)", "u");
});

assert.throws(SyntaxError, function() {
    return new RegExp("(?<🐕>dog)", "u");
});

assert.throws(SyntaxError, function() {
    return new RegExp("(?<\u{1f415}>dog)", "u");
});

assert.throws(SyntaxError, function() {
    return new RegExp("(?<\ud83d \udc15>dog)", "u");
});

assert.throws(SyntaxError, function() {
    return new RegExp("(?<𝟚the>the)", "u");
});

assert.throws(SyntaxError, function() {
    return new RegExp("(?<\u{1d7da}the>the)", "u");
});

assert.throws(SyntaxError, function() {
    return new RegExp("(?<\ud835\udfdathe>the)", "u");
});

reportCompare(0, 0);