tizen beta release
[profile/ivi/webkit-efl.git] / LayoutTests / fast / js / script-tests / regexp-compile.js
1 description(
2 'Test RegExp.compile method.'
3 );
4
5 re = new RegExp("a", "i");
6 shouldBe("re.toString()", "'/a/i'");
7
8 re.compile("a");
9 shouldBe("re.multiline", "false");
10 shouldBe("re.ignoreCase", "false");
11 shouldBe("re.global", "false");
12 shouldBe("re.test('A')", "false");
13 shouldBe("re.toString()", "'/a/'");
14
15 re.compile("b", "g");
16 shouldBe("re.toString()", "'/b/g'");
17
18 re.compile(new RegExp("c"));
19 shouldBe("re.toString()", "'/c/'");
20
21 re.compile(new RegExp("c", "i"));
22 shouldBe("re.ignoreCase", "true");
23 shouldBe("re.test('C')", "true");
24 shouldBe("re.toString()", "'/c/i'");
25
26 shouldThrow("re.compile(new RegExp('c'), 'i');");
27
28 // It's OK to supply a second argument, as long as the argument is "undefined".
29 re.compile(re, undefined);
30 shouldBe("re.toString()", "'/c/i'");
31
32 shouldThrow("re.compile(new RegExp('+'));");
33
34 re.compile(undefined);
35 shouldBe("re.toString()", "'/undefined/'");
36
37 re.compile(null);
38 shouldBe("re.toString()", "'/null/'");
39
40 re.compile();
41 shouldBe("re.toString()", "'/(?:)/'");
42
43 re.compile("z", undefined);
44 shouldBe("re.toString()", "'/z/'");
45
46 // Compiling should reset lastIndex.
47 re.lastIndex = 100;
48 re.compile(/a/g);
49 shouldBe("re.lastIndex", "0");
50 re.exec("aaa");
51 shouldBe("re.lastIndex", "1");