summaryrefslogtreecommitdiffstats
path: root/js/src/tests/js1_2/regexp/question_mark.js
blob: e159be8bb8011adb179848fb3b1cc193a8282960 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */


/**
   Filename:     question_mark.js
   Description:  'Tests regular expressions containing ?'

   Author:       Nick Lerissa
   Date:         March 10, 1998
*/

var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
var VERSION = 'no version';
startTest();
var TITLE   = 'RegExp: ?';

writeHeaderToLog('Executing script: question_mark.js');
writeHeaderToLog( SECTION + " "+ TITLE);

// 'abcdef'.match(new RegExp('cd?e'))
new TestCase ( SECTION, "'abcdef'.match(new RegExp('cd?e'))",
	       String(["cde"]), String('abcdef'.match(new RegExp('cd?e'))));

// 'abcdef'.match(new RegExp('cdx?e'))
new TestCase ( SECTION, "'abcdef'.match(new RegExp('cdx?e'))",
	       String(["cde"]), String('abcdef'.match(new RegExp('cdx?e'))));

// 'pqrstuvw'.match(new RegExp('o?pqrst'))
new TestCase ( SECTION, "'pqrstuvw'.match(new RegExp('o?pqrst'))",
	       String(["pqrst"]), String('pqrstuvw'.match(new RegExp('o?pqrst'))));

// 'abcd'.match(new RegExp('x?y?z?'))
new TestCase ( SECTION, "'abcd'.match(new RegExp('x?y?z?'))",
	       String([""]), String('abcd'.match(new RegExp('x?y?z?'))));

// 'abcd'.match(new RegExp('x?ay?bz?c'))
new TestCase ( SECTION, "'abcd'.match(new RegExp('x?ay?bz?c'))",
	       String(["abc"]), String('abcd'.match(new RegExp('x?ay?bz?c'))));

// 'abcd'.match(/x?ay?bz?c/)
new TestCase ( SECTION, "'abcd'.match(/x?ay?bz?c/)",
	       String(["abc"]), String('abcd'.match(/x?ay?bz?c/)));

// 'abbbbc'.match(new RegExp('b?b?b?b'))
new TestCase ( SECTION, "'abbbbc'.match(new RegExp('b?b?b?b'))",
	       String(["bbbb"]), String('abbbbc'.match(new RegExp('b?b?b?b'))));

// '123az789'.match(new RegExp('ab?c?d?x?y?z'))
new TestCase ( SECTION, "'123az789'.match(new RegExp('ab?c?d?x?y?z'))",
	       String(["az"]), String('123az789'.match(new RegExp('ab?c?d?x?y?z'))));

// '123az789'.match(/ab?c?d?x?y?z/)
new TestCase ( SECTION, "'123az789'.match(/ab?c?d?x?y?z/)",
	       String(["az"]), String('123az789'.match(/ab?c?d?x?y?z/)));

// '?????'.match(new RegExp('\\??\\??\\??\\??\\??'))
new TestCase ( SECTION, "'?????'.match(new RegExp('\\??\\??\\??\\??\\??'))",
	       String(["?????"]), String('?????'.match(new RegExp('\\??\\??\\??\\??\\??'))));

// 'test'.match(new RegExp('.?.?.?.?.?.?.?'))
new TestCase ( SECTION, "'test'.match(new RegExp('.?.?.?.?.?.?.?'))",
	       String(["test"]), String('test'.match(new RegExp('.?.?.?.?.?.?.?'))));

test();