]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/js1_2/regexp/question_mark.js
1 /* The contents of this file are subject to the Netscape Public
2 * License Version 1.1 (the "License"); you may not use this file
3 * except in compliance with the License. You may obtain a copy of
4 * the License at http://www.mozilla.org/NPL/
6 * Software distributed under the License is distributed on an "AS
7 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
8 * implied. See the License for the specific language governing
9 * rights and limitations under the License.
11 * The Original Code is Mozilla Communicator client code, released March
14 * The Initial Developer of the Original Code is Netscape Communications
15 * Corporation. Portions created by Netscape are
16 * Copyright (C) 1998 Netscape Communications Corporation. All
23 Filename: question_mark.js
24 Description: 'Tests regular expressions containing ?'
30 var SECTION
= 'As described in Netscape doc "Whats new in JavaScript 1.2"';
31 var VERSION
= 'no version';
33 var TITLE
= 'RegExp: ?';
35 writeHeaderToLog('Executing script: question_mark.js');
36 writeHeaderToLog( SECTION
+ " "+ TITLE
);
39 var testcases
= new Array();
41 // 'abcdef'.match(new RegExp('cd?e'))
42 testcases
[count
++] = new TestCase ( SECTION
, "'abcdef'.match(new RegExp('cd?e'))",
43 String(["cde"]), String('abcdef'.match(new RegExp('cd?e'))));
45 // 'abcdef'.match(new RegExp('cdx?e'))
46 testcases
[count
++] = new TestCase ( SECTION
, "'abcdef'.match(new RegExp('cdx?e'))",
47 String(["cde"]), String('abcdef'.match(new RegExp('cdx?e'))));
49 // 'pqrstuvw'.match(new RegExp('o?pqrst'))
50 testcases
[count
++] = new TestCase ( SECTION
, "'pqrstuvw'.match(new RegExp('o?pqrst'))",
51 String(["pqrst"]), String('pqrstuvw'.match(new RegExp('o?pqrst'))));
53 // 'abcd'.match(new RegExp('x?y?z?'))
54 testcases
[count
++] = new TestCase ( SECTION
, "'abcd'.match(new RegExp('x?y?z?'))",
55 String([""]), String('abcd'.match(new RegExp('x?y?z?'))));
57 // 'abcd'.match(new RegExp('x?ay?bz?c'))
58 testcases
[count
++] = new TestCase ( SECTION
, "'abcd'.match(new RegExp('x?ay?bz?c'))",
59 String(["abc"]), String('abcd'.match(new RegExp('x?ay?bz?c'))));
61 // 'abcd'.match(/x?ay?bz?c/)
62 testcases
[count
++] = new TestCase ( SECTION
, "'abcd'.match(/x?ay?bz?c/)",
63 String(["abc"]), String('abcd'.match(/x?ay?bz?c/)));
65 // 'abbbbc'.match(new RegExp('b?b?b?b'))
66 testcases
[count
++] = new TestCase ( SECTION
, "'abbbbc'.match(new RegExp('b?b?b?b'))",
67 String(["bbbb"]), String('abbbbc'.match(new RegExp('b?b?b?b'))));
69 // '123az789'.match(new RegExp('ab?c?d?x?y?z'))
70 testcases
[count
++] = new TestCase ( SECTION
, "'123az789'.match(new RegExp('ab?c?d?x?y?z'))",
71 String(["az"]), String('123az789'.match(new RegExp('ab?c?d?x?y?z'))));
73 // '123az789'.match(/ab?c?d?x?y?z/)
74 testcases
[count
++] = new TestCase ( SECTION
, "'123az789'.match(/ab?c?d?x?y?z/)",
75 String(["az"]), String('123az789'.match(/ab?c?d?x?y?z/)));
77 // '?????'.match(new RegExp('\\??\\??\\??\\??\\??'))
78 testcases
[count
++] = new TestCase ( SECTION
, "'?????'.match(new RegExp('\\??\\??\\??\\??\\??'))",
79 String(["?????"]), String('?????'.match(new RegExp('\\??\\??\\??\\??\\??'))));
81 // 'test'.match(new RegExp('.?.?.?.?.?.?.?'))
82 testcases
[count
++] = new TestCase ( SECTION
, "'test'.match(new RegExp('.?.?.?.?.?.?.?'))",
83 String(["test"]), String('test'.match(new RegExp('.?.?.?.?.?.?.?'))));
87 for ( tc
=0; tc
< testcases
.length
; tc
++ ) {
88 testcases
[tc
].passed
= writeTestCaseResult(
91 testcases
[tc
].description
+" = "+
92 testcases
[tc
].actual
);
93 testcases
[tc
].reason
+= ( testcases
[tc
].passed
) ? "" : "wrong value ";