• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright JS Foundation and other contributors, http://js.foundation
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15var r = /[��-����]/u;
16
17var m = r.exec("��");
18assert(m !== null);
19assert(m[0] === "��");
20
21r = /[��E]/ug;
22assert (r.exec("E��E")[0] === 'E');
23assert (r.exec("E��E")[0] === '��');
24assert (r.exec("E��E")[0] === 'E');
25
26try {
27  eval("/[��-����]/");
28  assert (false);
29} catch (e) {
30  assert (e instanceof SyntaxError);
31}
32
33assert (/\udc96/.exec("\ud803\udc96")[0] === '\udc96');
34assert (/\udc96/u.exec("\ud803\udc96") === null);
35assert (/\udc96/u.exec("\udc96")[0] === '\udc96');
36
37assert (/\ud803/.exec("\ud803\udc96")[0] === '\ud803');
38assert (/\ud803/u.exec("\ud803\udc96") === null);
39assert (/\ud803/u.exec("\ud803")[0] === '\ud803');
40
41assert (/./u.exec("\ud803\udc96")[0] === '��');
42assert (/./.exec("\ud803\udc96")[0] === '\ud803');
43assert (/./u.exec("\ud803\ud803")[0] === '\ud803');
44assert (/./u.exec("\udc96\udc96")[0] === '\udc96');
45assert (/./u.exec("\ud803")[0] === '\ud803');
46
47var r = /abc/y;
48m = r.exec ("strabcstr");
49assert (m === null);
50
51r.lastIndex = 3;
52m = r.exec ("strabcstr");
53assert (m[0] === "abc");
54assert (r.lastIndex === 6);
55
56m = r.exec ("strabcstr");
57assert (m === null);
58assert (r.lastIndex === 0);
59
60var r = /abc/yg;
61m = r.exec ("strabcstr");
62assert (m === null);
63
64try {
65  RegExp.prototype.flags;
66  assert (false);
67} catch (e) {
68  assert (e instanceof TypeError);
69}
70
71var flagsProp = Object.getOwnPropertyDescriptor (RegExp.prototype, "flags");
72assert(flagsProp.get.call({}) === '');
73