• 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;
16
17r = new RegExp ("a|b");
18assert (r.exec("a") == "a");
19
20r = new RegExp ("a|b");
21assert (r.exec("b") == "b");
22
23r = new RegExp ("a|b|c");
24assert (r.exec("b") == "b");
25
26r = new RegExp ("a|b|c");
27assert (r.exec("c") == "c");
28
29r = new RegExp ("a|b|c|d");
30assert (r.exec("") == undefined);
31
32r = new RegExp ("a|b|c|d");
33assert (r.exec("a") == "a");
34
35r = new RegExp ("a|b|c|d");
36assert (r.exec("b") == "b");
37
38r = new RegExp ("a|b|c|d");
39assert (r.exec("c") == "c");
40
41r = new RegExp ("a|b|c|d");
42assert (r.exec("d") == "d");
43
44r = new RegExp ("a|bb|c|d");
45assert (r.exec("e") == undefined);
46
47r = new RegExp ("a|bb|c|d");
48assert (r.exec("bb") == "bb");
49
50r = new RegExp ("a|bb|c|d");
51assert (r.exec("bba") == "bb");
52
53r = new RegExp ("a|bb|c|d");
54assert (r.exec("bbbb") == "bb");
55
56r = new RegExp ("a|bb|c|d");
57assert (r.exec("a") == "a");
58
59r = new RegExp ("a|bb|c|d");
60assert (r.exec("b") == undefined);
61
62r = new RegExp("(?:a|b)\\b|\\.\\w+", "g");
63assert (r.exec("name.lower()")[0] === ".lower")
64