|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 |
|
7 /** |
|
8 Filename: question_mark.js |
|
9 Description: 'Tests regular expressions containing ?' |
|
10 |
|
11 Author: Nick Lerissa |
|
12 Date: March 10, 1998 |
|
13 */ |
|
14 |
|
15 var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; |
|
16 var VERSION = 'no version'; |
|
17 startTest(); |
|
18 var TITLE = 'RegExp: ?'; |
|
19 |
|
20 writeHeaderToLog('Executing script: question_mark.js'); |
|
21 writeHeaderToLog( SECTION + " "+ TITLE); |
|
22 |
|
23 // 'abcdef'.match(new RegExp('cd?e')) |
|
24 new TestCase ( SECTION, "'abcdef'.match(new RegExp('cd?e'))", |
|
25 String(["cde"]), String('abcdef'.match(new RegExp('cd?e')))); |
|
26 |
|
27 // 'abcdef'.match(new RegExp('cdx?e')) |
|
28 new TestCase ( SECTION, "'abcdef'.match(new RegExp('cdx?e'))", |
|
29 String(["cde"]), String('abcdef'.match(new RegExp('cdx?e')))); |
|
30 |
|
31 // 'pqrstuvw'.match(new RegExp('o?pqrst')) |
|
32 new TestCase ( SECTION, "'pqrstuvw'.match(new RegExp('o?pqrst'))", |
|
33 String(["pqrst"]), String('pqrstuvw'.match(new RegExp('o?pqrst')))); |
|
34 |
|
35 // 'abcd'.match(new RegExp('x?y?z?')) |
|
36 new TestCase ( SECTION, "'abcd'.match(new RegExp('x?y?z?'))", |
|
37 String([""]), String('abcd'.match(new RegExp('x?y?z?')))); |
|
38 |
|
39 // 'abcd'.match(new RegExp('x?ay?bz?c')) |
|
40 new TestCase ( SECTION, "'abcd'.match(new RegExp('x?ay?bz?c'))", |
|
41 String(["abc"]), String('abcd'.match(new RegExp('x?ay?bz?c')))); |
|
42 |
|
43 // 'abcd'.match(/x?ay?bz?c/) |
|
44 new TestCase ( SECTION, "'abcd'.match(/x?ay?bz?c/)", |
|
45 String(["abc"]), String('abcd'.match(/x?ay?bz?c/))); |
|
46 |
|
47 // 'abbbbc'.match(new RegExp('b?b?b?b')) |
|
48 new TestCase ( SECTION, "'abbbbc'.match(new RegExp('b?b?b?b'))", |
|
49 String(["bbbb"]), String('abbbbc'.match(new RegExp('b?b?b?b')))); |
|
50 |
|
51 // '123az789'.match(new RegExp('ab?c?d?x?y?z')) |
|
52 new TestCase ( SECTION, "'123az789'.match(new RegExp('ab?c?d?x?y?z'))", |
|
53 String(["az"]), String('123az789'.match(new RegExp('ab?c?d?x?y?z')))); |
|
54 |
|
55 // '123az789'.match(/ab?c?d?x?y?z/) |
|
56 new TestCase ( SECTION, "'123az789'.match(/ab?c?d?x?y?z/)", |
|
57 String(["az"]), String('123az789'.match(/ab?c?d?x?y?z/))); |
|
58 |
|
59 // '?????'.match(new RegExp('\\??\\??\\??\\??\\??')) |
|
60 new TestCase ( SECTION, "'?????'.match(new RegExp('\\??\\??\\??\\??\\??'))", |
|
61 String(["?????"]), String('?????'.match(new RegExp('\\??\\??\\??\\??\\??')))); |
|
62 |
|
63 // 'test'.match(new RegExp('.?.?.?.?.?.?.?')) |
|
64 new TestCase ( SECTION, "'test'.match(new RegExp('.?.?.?.?.?.?.?'))", |
|
65 String(["test"]), String('test'.match(new RegExp('.?.?.?.?.?.?.?')))); |
|
66 |
|
67 test(); |