1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.htmlunit.javascript.regexp.mozilla.js1_2;
16
17 import org.htmlunit.WebDriverTestCase;
18 import org.htmlunit.junit.annotation.Alerts;
19 import org.junit.jupiter.api.Test;
20
21
22
23
24
25
26 public class TestTest extends WebDriverTestCase {
27
28
29
30
31
32 @Test
33 @Alerts("true")
34 public void test1() throws Exception {
35 test("/[0-9]{3}/.test('23 2 34 678 9 09')");
36 }
37
38
39
40
41
42 @Test
43 @Alerts("false")
44 public void test2() throws Exception {
45 test("/[0-9]{3}/.test('23 2 34 78 9 09')");
46 }
47
48
49
50
51
52 @Test
53 @Alerts("true")
54 public void test3() throws Exception {
55 test("/\\w+ \\w+ \\w+/.test(\"do a test\")");
56 }
57
58
59
60
61
62 @Test
63 @Alerts("false")
64 public void test4() throws Exception {
65 test("/\\w+ \\w+ \\w+/.test(\"a test\")");
66 }
67
68
69
70
71
72 @Test
73 @Alerts("true")
74 public void test5() throws Exception {
75 test("(new RegExp('[0-9]{3}')).test('23 2 34 678 9 09')");
76 }
77
78
79
80
81
82 @Test
83 @Alerts("false")
84 public void test6() throws Exception {
85 test("(new RegExp('[0-9]{3}')).test('23 2 34 78 9 09')");
86 }
87
88
89
90
91
92 @Test
93 @Alerts("true")
94 public void test7() throws Exception {
95 test("(new RegExp('\\\\w+ \\\\w+ \\\\w+')).test(\"do a test\")");
96 }
97
98
99
100
101
102 @Test
103 @Alerts("false")
104 public void test8() throws Exception {
105 test("(new RegExp('\\\\w+ \\\\w+ \\\\w+')).test(\"a test\")");
106 }
107
108 private void test(final String script) throws Exception {
109 final String html = "<html><head><script>\n"
110 + LOG_TITLE_FUNCTION
111 + " log(" + script + ");\n"
112 + "</script></head><body>\n"
113 + "</body></html>";
114 loadPageVerifyTitle2(html);
115 }
116 }