Debian Codegraph @

rhino/testsrc/tests/js1_2/regexp/question_mark.js

raw symbols SCIP
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 gTestfile = 'question_mark.js';
7
8 /**
9 Filename: question_mark.js
10 Description: 'Tests regular expressions containing ?'
11
12 Author: Nick Lerissa
13 Date: March 10, 1998
14 */
15
16 var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
17 var VERSION = 'no version';
18 startTest();
19 var TITLE = 'RegExp: ?';
20
21 writeHeaderToLog('Executing script: question_mark.js');
22 writeHeaderToLog( SECTION + " "+ TITLE);
23
24 // 'abcdef'.match(new RegExp('cd?e'))
25 new TestCase ( SECTION, "'abcdef'.match(new RegExp('cd?e'))",
26 String(["cde"]), String('abcdef'.match(new RegExp('cd?e'))));
27
28 // 'abcdef'.match(new RegExp('cdx?e'))
29 new TestCase ( SECTION, "'abcdef'.match(new RegExp('cdx?e'))",
30 String(["cde"]), String('abcdef'.match(new RegExp('cdx?e'))));
31
32 // 'pqrstuvw'.match(new RegExp('o?pqrst'))
33 new TestCase ( SECTION, "'pqrstuvw'.match(new RegExp('o?pqrst'))",
34 String(["pqrst"]), String('pqrstuvw'.match(new RegExp('o?pqrst'))));
35
36 // 'abcd'.match(new RegExp('x?y?z?'))
37 new TestCase ( SECTION, "'abcd'.match(new RegExp('x?y?z?'))",
38 String([""]), String('abcd'.match(new RegExp('x?y?z?'))));
39
40 // 'abcd'.match(new RegExp('x?ay?bz?c'))
41 new TestCase ( SECTION, "'abcd'.match(new RegExp('x?ay?bz?c'))",
42 String(["abc"]), String('abcd'.match(new RegExp('x?ay?bz?c'))));
43
44 // 'abcd'.match(/x?ay?bz?c/)
45 new TestCase ( SECTION, "'abcd'.match(/x?ay?bz?c/)",
46 String(["abc"]), String('abcd'.match(/x?ay?bz?c/)));
47
48 // 'abbbbc'.match(new RegExp('b?b?b?b'))
49 new TestCase ( SECTION, "'abbbbc'.match(new RegExp('b?b?b?b'))",
50 String(["bbbb"]), String('abbbbc'.match(new RegExp('b?b?b?b'))));
51
52 // '123az789'.match(new RegExp('ab?c?d?x?y?z'))
53 new TestCase ( SECTION, "'123az789'.match(new RegExp('ab?c?d?x?y?z'))",
54 String(["az"]), String('123az789'.match(new RegExp('ab?c?d?x?y?z'))));
55
56 // '123az789'.match(/ab?c?d?x?y?z/)
57 new TestCase ( SECTION, "'123az789'.match(/ab?c?d?x?y?z/)",
58 String(["az"]), String('123az789'.match(/ab?c?d?x?y?z/)));
59
60 // '?????'.match(new RegExp('\\??\\??\\??\\??\\??'))
61 new TestCase ( SECTION, "'?????'.match(new RegExp('\\??\\??\\??\\??\\??'))",
62 String(["?????"]), String('?????'.match(new RegExp('\\??\\??\\??\\??\\??'))));
63
64 // 'test'.match(new RegExp('.?.?.?.?.?.?.?'))
65 new TestCase ( SECTION, "'test'.match(new RegExp('.?.?.?.?.?.?.?'))",
66 String(["test"]), String('test'.match(new RegExp('.?.?.?.?.?.?.?'))));
67
68 test();